📄 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 { doInsert( employee ); } catch( DatabaseException de ) { //log error throw de; } return 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; } //this wouldn't be in this service class, but would be in some other business class/DAO private void doInsert( EmployeeDTO employee ) throws DatabaseException { //to test an exception thrown uncomment line below //throw new DatabaseException(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -