startstudentbean.java

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

JAVA
44
字号
package sessionEntity;

import java.math.*;
import java.util.*;
//import java.rmi.*;
import javax.ejb.*;
//import javax.naming.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

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();
  	Collection collection = null;
		try {
			Context ctx = new InitialContext();
			Object ref = ctx.lookup("StudentEJB");
			StudentHome studentHome = (StudentHome)
			PortableRemoteObject.narrow(ref,StudentHome.class);
			collection = studentHome.findStudentsInGrade(grade);
		} catch(Exception e) {
			System.out.println("Failed get All Students");			
		}
		return collection;
  }  
  
  public StartStudentBean() {}
  public void ejbCreate() {}
  public void ejbRemove() {}
  public void ejbActivate() {}
  public void ejbPassivate() {}  
}

⌨️ 快捷键说明

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