package examples.ejb.subclass.child; import javax.ejb.*; import javax.naming.*; import java.io.Serializable; import java.rmi.RemoteException; import java.util.*; import examples.ejb.subclass.parent.*; /** * ChildBean is a stateless SessionBean. This bean illustrates: * * * @author Copyright (c) 1998 by WebLogic, Inc. All Rights Reserved. * @author Copyright (c) 1998-1999 by BEA Systems, Inc. All Rights Reserved. */ public class ChildBean extends examples.ejb.subclass.parent.ParentBean implements SessionBean { /** * Returns a message identifying the method. * This method is unique to the Child bean. * * @return String Message */ public String childSaysHello() { return "Hello from the ChildBean."; } /** * Returns a message identifying the method. * This method is inherited and overloaded by the Child bean. * * @return String Message */ public String parentSaysHello() { return "Hello from the ChildBean overload of the \"parentSaysHello()\" method."; } /** * Looks up a parent bean and calls its * parentMethodOnly(). Returns a message identifying the method. * * @return String Message * @exception RemoteException if there is * a communications or systems failure */ public String callParentBean() throws RemoteException { String message = "ChildBean calling a ParentBean method:\n"; try { Context context = new InitialContext(ctx.getEnvironment()); ParentHome parentHome = (ParentHome) context.lookup("parent.ParentHome"); Parent parent = parentHome.create(); message = message + parent.parentMethodOnly(); return message; } catch (Exception e) { throw new RemoteException(e.getMessage()); } } }