I'm also implementing a tool something along the lines discussed in this
thread.  Essentially, I am passed the JNDI lookup reference for the Home
object of an EJB whose Remote interface I know extends "MyInterface" (that
is, the Remote interface of the EJB extends both EJBObject and MyInterface).
My problem is that -- in order to invoke "create" on the Home interface -- I
need to have access to the .class file of the Home interface in order to
perform the create() (using reflection).  As mentioned in this thread, one
can not assume a remote object narrowed to EJBHome (in this case, a Stub)
responds to create(), since create() is not defined in EJBHome.  Once I call
create(), I can narrow the resulting object to "MyInterface" -- I don't need
access to the EJBs Remote interface.  Thus, my tool can be independent of
the Remote interface of any EJB I need to converse with (my tool is slightly
less generic than the component discussed elsewhere in this thread, since I
am speaking to the resulting EJB using a known interface -- "MyInterface" --
rather than using reflection to invoke arbitary methods on the EJB).

My problem is that I don't want my tool, while being independent of EJB
Remtoe interfaces, is _not_ independent of EJB Home interfaces.  The leve of
independence I am seeking is one which will allow my tool to be deployed
without requiring the Home interfaces of every EJB Home it will ever talk to
being visible on its classpath.

My original idea for solving this problem was to require the Home interfaces
of all the EJBs to extend an interface "MyInterfaceHome," that would look
like the following:

    public interface MyInterfaceHome extends java.rmi.Remote {
       MyInterface create() throws RemoteException,CreateException
    }

Then, the Home interfaces for any EJB which I want to talk to would look
like the following:

   public interface AnEJBHome extends javax.ejb.EJBHome,MyInterfaceHome {
   }

However, this doesn't work for the following reasons
   1.  the EJB spec requires that any create() methods in Home interfaces
return the precise type of the EJBs remote interface.  Thus, returning a
supertype (e.g. an interface which the EJB Remote interface itself extends)
is not allowed.
   2.  Even if AnEJBHome  already has a no-arg constructor, and, moreover,
the EJB's Remote Interface extends "MyInterface" (implying that the return
value of the no-arg constructor is assignable to "MyInterface") Java itself
does not allow AnEJBHome to extend "MyInterfaceHome" because the return
types are different (even though, in this case, the actual return type is
assignable to the return type defined in the interface).

So, I'm stuck.  I'd prefer to have a solution (i.e. be able to have
Home-interface-independent code) rather than simply moving the problem to
some other component (e.g. forwarding invocations on to some Delegate, which
must itself have access to the class file).

Sorry for the verbosity.  Any ideas?

Sam Schapmann
Bank of America, Global Derivates Trading
[EMAIL PROTECTED]

===========================================================================
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