The EJB 3.1 specification in section 16 does not really say what the
contents of name() should be.
Can it be a portable JNDI URI, like "java:app/ejb/Fred", as this (
http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#How_do_I_define_my_own_portable_global)
indicates? I did not find a similar sentiment present in the specification.
Since it is just the name of a reference, this should behave in terms of
automatic container linking just as though it were named something "normal"
like "ejb/Fred", right? That is, if there is one EJB in the deployment
unit that can satisfy the reference it will be automatically bound...?
Background: for historical reasons I have dozens if not hundreds of
@ManagedBeans that have @EJB references in them.
I want to name these references according to some convention so that I can
target them all in one shot when their enclosing @ManagedBeans are deployed
as part of an .ear file, and when that particular ear file contains several
implementations of the bean that any given @ManagedBean's @EJB-annotated
field is expecting to reference.
If these @ManagedBean resource classes should find themselves part of some
other kind of application where there is only one implementation of the EJB
in question, I don't want anyone to have to configure anything.
@ManagedBeans have no component environment, so simply saying @EJB(name =
"ejb/Fred") doesn't really do me any good. If there's only one Fred
implementation, everything works fine.
I want to make sure that it is expected and legal to have this:
@ManagedBean("FooResource")
@Path(...)
public class FooResource {
@EJB(name = "java:app/ejb/Fred") // define a non-relative ejb-ref-name
private Fred fred;
}
...so that later on in an application.xml I can do this:
<ejb-local-ref>
<ejb-ref-name>java:app/ejb/Fred</ejb-ref-name>
<local>foo.Fred</local>
<ejb-link>some-bean.jar#FredBean</ejb-link>
</ejb-local-ref>
...and all of those references will get FredBean implementations injected
into them.
Best,
Laird
--
http://about.me/lairdnelson