RosterBean.java
资源名称:某公司的java培训教材 [点击查看]
上传用户:dinglihq
上传日期:2013-02-04
资源大小:99958k
文件大小:3k
源码类别:
Java编程
开发平台:
Java
- package cmpsample;
- import javax.ejb.*;
- import javax.naming.*;
- abstract public class RosterBean implements EntityBean {
- EntityContext entityContext;
- public java.lang.String ejbCreate(java.lang.String rosterID) throws CreateException {
- setRosterID(rosterID);
- return null;
- }
- //business methods
- public String fetchRosterID()
- {
- return getRosterID();
- }
- public String fetchStudentID()
- {
- return getStudentID();
- }
- public String fetchScheduleID()
- {
- return getScheduleID();
- }
- public java.lang.String ejbCreate(String rosterID, String scheduleID, String studentID) throws CreateException {
- System.out.println(" -- RsoterEJB - ejbCreate...");
- setRosterID(rosterID);
- setScheduleID(scheduleID);
- //setStudentID(studentID); u00B2u00BBu00C4u00DCu00D4u00DAu00B4u00CBu00D6±u00BDu00D3setXXX().see ejbPostCreate()
- return rosterID;
- }
- public void ejbPostCreate(java.lang.String rosterID) throws CreateException {
- /**@todo Complete this method*/
- }
- public void ejbPostCreate(String rosterID, String scheduleID, String studentID) throws CreateException {
- System.out.println(" -- RosterEJB -ejbPostCreate...rosterID = "+rosterID);
- try {
- Context ic = new InitialContext();
- StudentHome home = (StudentHome)
- ic.lookup("Student");
- Student student = home.findByPrimaryKey(studentID);
- student.addRoster((Roster)entityContext.getEJBLocalObject());
- } catch (Exception ex) {
- entityContext.setRollbackOnly();
- ex.printStackTrace();
- }
- }
- public void ejbRemove() throws RemoveException {
- /**@todo Complete this method*/
- }
- public abstract void setRosterID(java.lang.String rosterID);
- public abstract void setStudentID(java.lang.String studentID);
- public abstract void setScheduleID(java.lang.String scheduleID);
- public abstract java.lang.String getRosterID();
- public abstract java.lang.String getStudentID();
- public abstract java.lang.String getScheduleID();
- public void ejbLoad() {
- /**@todo Complete this method*/
- }
- public void ejbStore() {
- /**@todo Complete this method*/
- }
- public void ejbActivate() {
- /**@todo Complete this method*/
- }
- public void ejbPassivate() {
- /**@todo Complete this method*/
- }
- public void unsetEntityContext() {
- this.entityContext = null;
- }
- public void setEntityContext(EntityContext entityContext) {
- this.entityContext = entityContext;
- }
- }