This is more of an EJB question (obviously) than a JSP question. There's an
EJB-interest list, but I understand it's as clogged as this one is.

However, you can indeed do this; you can use the same remote interface for a
series of EJBs, and different home interfaces. The home interface will
create a bean of the correct type, and you would cast the result into the
interface type; then you'd just call your standard method name. I do the
same thing myself in forwarding messages to message-driven beans.


>From: "Xu, Li" <[EMAIL PROTECTED]>
>Reply-To: A mailing list about Java Server Pages specification and
>     reference <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: polymorphism and EJB?
>Date: Wed, 21 Feb 2001 14:53:14 -0600
>
>Can EJBs do polymorphism?
>My exact question is: I have an abstract base class called BaseClass, and a
>bunch of subclasses, let's call them SubClass1, SubClass2.... All classes
>have a method execute().
>I used to have Java code doing this:
>
>BaseClass bc;
>bc = (BaseClass)Class.forName(subClassName).newInstance();
>bc.execute();
>
>When the parameter "className" is the qualified path of any of the
>subclasses, then by calling bc.execute(), that particular subclass's
>execute() method is actually run. By doing this, I don't have to know
>exactly which subclass it is but run its execute() method. Can EJB do the
>same thing?
>The way EJB obtains a home interface doesn't seem to allow me to Cast an
>object of subclass into the base class's home interface like below. I got
>an
>java.lang.ClassCastException.
>
>Object objref = initialContext.lookup(subClassJNDIName);
>(BaseClassHome)PortableRemoteObject.narrow(objref, BaseClassHome.class);
>
>
>So Basically how can I use EJB to achieve the same thing as my old code?
>Any
>help is appreciated.
>
>Li
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST
>DIGEST".
>Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to