I'm very new to EJB but I have a thought.
Rather than directly implementing the interface, you could create a common
ancestor that implements the interface. This ancestor could expose a method
that returns the *name* of the class - myWidget.getClass().getName().
By inheriting from this class you save yourself the trouble of repeatedly
implementing this method, and you no longer need to explicitly state
myWidgetClass implements myWidgetInterface.
This method could be advertised in the interface and could be used on the
client side to determine the name of the class in question. The client could
then manufacture an instance of that class using dynamic class loading
*outside the ejb container* and operate on this instance with instanceOf to
assess its logical heritage. You should be able to manufacture an instance
of any ejb class since they all have nil parameter constructors, and you
don't need to do anything other than construct them to operate on the
instance with instanceOf.
Maybe you can't do this, I don't know. I have checked just now and you can
certainly determine the name of an ejb within the bean; I just did it.
Passing this name to the client as a String return value of a method is also
certainly possible.
I'm going to try it now.
----- Original Message -----
From: Kenworthy, Edward <[EMAIL PROTECTED]>
To: 'jBoss' <[EMAIL PROTECTED]>
Sent: Monday, February 05, 2001 6:25 PM
Subject: RE: [jBoss-User] IsA behaviour when inheriting beans
> Inheritance isn't supported by the EJB spec'. You can get a sort of
> fake-inheritance running BUT it will be very inconsistent (eg sometimes
the
> inheritance will work as expected sometimes it won't.) Personally I would
> avoid it.
>
> -----Original Message-----
> From: Sacha Labourey [mailto:[EMAIL PROTECTED]]
> Sent: 02 February 2001 10:50
> To: jBoss
> Subject: [jBoss-User] IsA behaviour when inheriting beans
>
>
> Hello,
>
> I've got some questions regarding inheritance in Jboss.
>
> Imagine these RI:
> - interface ABusiness ...
> - interface A extends ABusiness, EJBObject ...
>
> a son of A:
> - interface B1Business extends ABusiness ...
> - interface B1 extends B1Business, A ...
>
> another son of A, brother of B1:
> - interface B2Business extends ABusiness ...
> - interface B2 extends B2Business, A ...
>
>
> If I have a method of antoher Bean which returns a base class A, is it
> possible to use a instanceOf behavior on the client side to decide which B
> it is:
>
> A = myOtherBean.getBObject (); // return type is A
> if (A instanceof B1) ...
>
>
> In the same way, what about returned sequences?
>
> mySequence = myOtherBean.getManyObjects (); // a sequence of base
> interface
> A
> if (mySequence.elementAt(0) instance of B1)...
>
>
> Does this works automagically? Will the client side proxy knows its
accurate
> distant object type?
>
> thank you. Cheers,
>
>
>
> Sacha
>
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
>
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> List Help?: [EMAIL PROTECTED]
>
>
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
List Help?: [EMAIL PROTECTED]