employeeservice.java
来自「《精通JSP编程 》源代码(赵强那本) 很有用的源代码」· Java 代码 · 共 34 行
JAVA
34 行
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 + =
减小字号Ctrl + -
显示快捷键?