Hey,

Have a remote interface "EngineEJB".

Have two beans, "ElectricEJB" and "CombustionEJB", both of which use
"EngineEJB" and their remote interface.

Deploy the two beans.

Use a proxy or facade on the client side to call either bean to get your
instance member.

hth.

Glenn.

-----Original Message-----
From: Oisin Kim [mailto:[EMAIL PROTECTED]]
Sent: 03 December 2001 15:07
To: [EMAIL PROTECTED]
Subject: How to achieve polymorphic access to EJB methods with the same
superclass


Hi All,

myself and some colleagues have been going over this EJB design question
for the last while and can't seem to get a decent solution.

To simplify my question, I'll use a trivial example with some Entity
EJBs. Imagine we have a superclass "EngineEJB" and two subclasses
"ElectricEJB" or "CombustionEJB". They all have a method "String
getPower()" which will return a String containing the power of that
particular engine. For example calling "getPower()" on an EJB of type
"ElectricEJB" would return somthing like "12 KWatts" or calling
"getPower()" on "CombustionEJB" would return "12 BHP".

Now here's the question: how can I reference these EJBs polymorphically.
As the EJB Container looks after the imlpementation of EJBs, I have to
specify at the client what sort of object I do a "findByPrimaryKey()" by
specifying what kind of EJBHome object I do the create on.

Is there a way to do a findByXXX() and then call methods polymorphically
on the Remote reference I recieve. In the case above, this would mean
getting a reference to an "EngineEJB" Remote Home reference and calling
"findByPrimaryKey()" which would return a Remote "EngineEJB" reference.
Calling "getPower()" on this Remote reference would call the correct
method depending on the type of the returned reference.

It would seem that you can't have multiple implementations of an EJB
interface. What am I missing here???

Thanks for any ideas/opinions/(even flames),
Oisin

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to