|
Listing 6.3 Source Code for HelloWorldSessionImpl.ava package usingj2ee.hello;
import java.rmi.*; import java.util.*; import javax.ejb.*;
/** The implementation class for the HelloWorldSession bean */
public class HelloWorldSessionImpl implements SessionBean { /** Holds the session's greeting */ protected String greeting;
/** The session context provided by the EJB container. A session bean must hold on to the context it is given. */
private SessionContext context;
/** An EJB must have a public, parameterless constructor */
public HelloWorldSessionImpl() { }
/** Called by the EJB container to set this session's context */
public void setSessionContext(SessionContext aContext) { context = aContext; }
/** Called by the EJB container when a client calls the create() method in the Home interface */
public void ejbCreate() throws CreateException { greeting = "Hello World!"; }
/** Called by the EJB container when a client calls the create(String) method in the Home interface */
public void ejbCreate(String aGreeting) throws CreateException { greeting = aGreeting; }
/** Called by the EJB container to wake this session bean up after it has been put to sleep with the ejbPassivate method. */
public void ejbActivate() { }
/** Called by the EJB container to tell this session bean that it is being suspended from use (it's being put to sleep). */
public void ejbPassivate() { }
/** Called by the EJB container to tell this session bean that it has been removed, either because the client invoked the remove() method or the container has timed the session out. */
public void ejbRemove() { }
/** Returns the session's greeting */
public String getGreeting() { return greeting; }
/** Changes the session's greeting */
public void setGreeting(String aGreeting) { greeting = aGreeting; } }
|