Dynamically Access & Call An EJB From Another EJB?

Discussion in 'Java' started by Steve, Jul 14, 2003.

  1. Steve

    Steve Guest

    Is there a way to dynamically access and call an EJB from another EJB?
    For example, can a session bean read a file with information about
    another session bean without hardcoding information about the second
    bean in the first bean's .java bean class or its .xml descriptor files? Can
    some form of reflection or introspection be used?

    Thanks.

    Steve
    Steve, Jul 14, 2003
    #1
    1. Advertising

  2. Steve wrote:
    > Is there a way to dynamically access and call an EJB from another EJB?


    What, exactly, do you want to do?

    > For example, can a session bean read a file with information about
    > another session bean without hardcoding information about the second
    > bean in the first bean's .java bean class or its .xml descriptor files? Can
    > some form of reflection or introspection be used?


    It sounds like what you are trying to do might be at least partially
    solved by implementing polymorphic EJBs. (Actually, you already have
    them: every EJB home interface extends EJBHome, every remote interface
    extends EJBObject, etc. You can always access bean implementations via
    these interfaces, albeit perhaps not usefully.) You can always type a
    reference to an EJB implementation object according to any interface it
    implements, and invoke methods on it via that interface. You can also
    dynamically construct JNDI names by which to look up home interfaces,
    which can also be polymorphic. You can create a session bean that
    obtains other bean implementations for you, based on whatever criteria
    and algorithms you like.

    What you cannot do is ever use a bean that you do not, somewhere,
    declare a reference to in a deployment descriptor. You can hide the
    lookup and deployment information in a single session bean, for
    instance, but at least that one bean has to know about all the beans you
    might want to access. This is inherent in the EJB model.


    John Bollinger
    John C. Bollinger, Jul 15, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mumbai Joe
    Replies:
    0
    Views:
    589
    Mumbai Joe
    Jul 29, 2003
  2. Jeremy Haile

    To EJB or not to EJB

    Jeremy Haile, Sep 3, 2003, in forum: Java
    Replies:
    5
    Views:
    526
    Christopher Blunck
    Sep 10, 2003
  3. Rizwan
    Replies:
    2
    Views:
    4,279
    Rizwan
    May 3, 2005
  4. Andre Broers
    Replies:
    6
    Views:
    399
    Andre Broers
    Nov 21, 2007
  5. Raymond Schanks
    Replies:
    0
    Views:
    643
    Raymond Schanks
    Aug 3, 2010
Loading...

Share This Page