package examples.ejb.subclass.parent;
import javax.ejb.*;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.util.*;
/**
* ParentBean is a stateless SessionBean. This bean illustrates:
*
* - Parent class to the ChildBean subclass
*
- Contains methods that are inherited and overloaded
* in the Child bean
*
- Note the use of protected instead of private variables
* so that the Child bean can inherit them
*
*
* @author Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved.
* @author Copyright (c) 1998-1999 by BEA Systems, Inc. All Rights Reserved.
*/
public class ParentBean implements SessionBean {
static final boolean VERBOSE = true;
// -----------------------------------------------------------------
// protected variables
protected transient SessionContext ctx;
protected transient Properties props;
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbActivate() {
if (VERBOSE)
System.out.println("ejbActivate called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbRemove() {
if (VERBOSE)
System.out.println("ejbRemove called");
}
/**
* This method is required by the EJB Specification,
* but is not used by this example.
*
*/
public void ejbPassivate() {
if (VERBOSE)
System.out.println("ejbPassivate called");
}
/**
* Sets the session context.
*
* @param ctx SessionContext Context for session
*/
public void setSessionContext(SessionContext ctx) {
if (VERBOSE)
System.out.println("setSessionContext called");
this.ctx = ctx;
props = ctx.getEnvironment();
}
// Interface exposed to EJBObject
// ( a clone of the Parent interface without the RemoteException,
// and an ejbCreate without any parameters)
/**
* This method corresponds to the create method in the home interface
* "ParentHome".
* The parameter sets of the two methods are identical. When the client calls
* ParentHome.create()
, the container allocates an instance of
* the EJBean and calls ejbCreate()
.
*
* @exception javax.ejb.CreateException if there is
* a problem creating the bean
* @see examples.ejb.subclass.parent.Parent
*/
public void ejbCreate() throws CreateException {
if (VERBOSE)
System.out.println("ejbCreate called");
}
/**
* Sends back a pre-defined message identifying the method.
* This method is inherited and overloaded by the Child bean.
*
* @return String Message
*/
public String parentSaysHello() {
return "Hello from the ParentBean.";
}
/**
* Sends back a pre-defined message identifying the method.
* This method is inherited but not overloaded by the Child bean.
*
* @return String Message
*/
public String parentMethodOnly() {
return "This method is only in the ParentBean.";
}
}