users@glassfish.java.net

Spec-compliant way to obtain a list of EJBs?

From: <glassfish_at_javadesktop.org>
Date: Fri, 26 Mar 2010 14:13:17 PDT

What is the best specification-compliant (Java EE 6) way for a given EJB to investigate its environment and discover other EJBs at runtime?

I am not sure if I can count on a javax.naming.Context.lookup() of the "java:module" namespace to do this for me (at least that's what comes to mind).

The back story:
I have various DAOs, each of which is a stateless session bean.

When I need to find all instances of a given type, in the abstract I'd just ask its DAO for them. But if that type can be extended, then various DAOs might be able to return such instances.

So I'd like to ask all the DAOs that are capable of returning instances of a given type to do so.

In order to do this, I need to be able to find all the DAOs.

I'd like to do this at runtime so I don't effectively have to maintain two lists of EJBs, but can instead simply deploy the EJBs I wish and then have them discovered.

I can think of all kinds of non-specification-compliant ways to do this, including scanning the classpath and looking for @Stateless annotations and various other hacks in much the same way as I'm sure the container does at startup. I really really really really really don't want to do this.

Lastly I should say I'm not at all familiar with JSR-299; perhaps that has something in it that would help in this regard?

Thanks for any help and pointers,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=393942