📄 employeeservice.java
字号:
package edu.reumann;import java.util.Collection;import java.util.ArrayList;public class EmployeeService { public EmployeeDTO insertEmployee( EmployeeDTO employee ) throws DatabaseException { //in real life call other business classes to do insert try { mimicInsert( employee ); } catch( DatabaseException de ) { //log error throw de; } return employee; } public EmployeeDTO updateEmployee( EmployeeDTO employee ) throws DatabaseException { //in real life call other business classes to do update try { mimicUpdate( employee ); } catch( DatabaseException de ) { //log error throw de; } return employee; } //this wouldn't be in this service class, but would be in some other business class/DAO private void mimicInsert( EmployeeDTO employee ) throws DatabaseException { //to test an Exception thrown uncomment line below //throw new DatabaseException("Error trying to insert Employee"); } //this wouldn't be in this service class, but would be in some other business class/DAO private void mimicUpdate( EmployeeDTO employee ) throws DatabaseException { //to test an Exception thrown uncomment line below //throw new DatabaseException("Error trying to update Employee"); } public Collection getDepartments() { //call business layer to return Collection of Department beans //since we aren't dealing with the model layer, we'll mimic it here ArrayList list = new ArrayList(3); list.add( new DepartmentBean( 1, "Accounting")); list.add( new DepartmentBean( 2, "IT")); list.add( new DepartmentBean( 3, "Shipping")); return list; } public Collection getFlavors() { //call business layer to return Collection of Flavors //since we aren't dealing with the model layer, we'll mimic it here ArrayList list = new ArrayList(3); list.add( new FlavorBean( "101", "Chocolate")); list.add( new FlavorBean( "201", "Vanilla")); list.add( new FlavorBean( "500", "Strawberry")); return list; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -