startstudentbean.java

来自「java的一系列产品中包括jsme,jmse,j2ee,本文件提供j2ee实现的」· Java 代码 · 共 38 行

JAVA
38
字号
package sessionEntity;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.math.*;

public class StartStudentBean implements SessionBean{
  private SessionContext ctx;
  public void setSessionContext(SessionContext sc){
  	ctx=sc;
  }
  
  public String HelloStudent(){
  	return "Hello StartStudent,Welcome!";
  }
  
  public Collection getAllStudents(int grade){
  	Vector vectUserInfos = new Vector();
		try {
			Context ctx = new InitialContext();
			Object ref = ctx.lookup("StudentHome");
			StudentHome studentHome = (StudentHome)
			PortableRemoteObject.narrow(ref,StudentHome.class);
			Collection collection = studentHome.findStudentsInGrade(grade);
			Return collection;
		} catch(Exception e) {
			System.out.println("failed get All Students");
			//e.printStackTrace();
		}
  }  
  
  public HelloEJBBean() {}
  public void ejbCreate() {}
  public void ejbRemove() {}
  public void ejbActivate() {}
  public void ejbPassivate() {}  
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?