package ejb.demo; /** * DemoBean -- This is implemented by the EnterPrise`Bean. * This class must extend`javax.ejb.SessionBean and implement * the methods in this interface as well as providing * the implementation of the business methods. * */ import javax.ejb.*; import javax.naming.*; import java.rmi.*; public class DemoBean implements javax.ejb.SessionBean { //Instance member variables. // // Session context, can be used to obtain handles etc // javax.ejb.SessionContext ejbSessionContext = null; //Getter/setter methods // // TBD: Add implementations for any additional remote method interfaces // // The default ejbCreate method. // public void ejbCreate( ) throws javax.ejb.CreateException, java.rmi.RemoteException { } // TBD: If any other ejbCreate's are added manually to the home interface, define them. // // Other methods required in a session bean // public void setSessionContext( javax.ejb.SessionContext ejbSessionContext ) throws RemoteException { this.ejbSessionContext = ejbSessionContext; } public void unsetSessionContext() throws RemoteException { this.ejbSessionContext = null; } public void ejbRemove() throws java.rmi.RemoteException, javax.ejb.EJBException { // TBD: Do any processing here when instance is being removed } public void ejbActivate() throws java.rmi.RemoteException { // TBD: Restore any saved resources } public void ejbPassivate() throws java.rmi.RemoteException { // TBD: Save any resources here before bean is passivated } /** * **** HERE IS THE BUSINESS LOGIC ***** * Do the demoSelect() but don't even go to * the database in this eg but instead just * return a String. * The really BIG thing to notice here is that * this is the only code we have invented at all * the rest of the code has been declarations * or simply implementing methods which are * part of the EJB interfaces and in this example * are not even used. */ public String demoSelect() throws RemoteException { return("hello world"); } }