Dieter Quickfend wrote:But the 'name' attribute also does injection of resources bound in the EJB's environment, right? Like if you specify in ejb-jar.xml an env-entry "myString" for some EJB, the following:
will inject the resource
and for, let's say a datasource, which is specified as "java:comp/env/jdbc/Muppets" in the JNDI context, the 'name' property is not binding it when it injects this value using:
Dieter Quickfend wrote:So, if I'm understanding you correctly, specifying "@Resource(name='thisResource') String myString;" behaves exactly the same as "@Resource String myString;" except that the former will also bind the value injected into this component (without knowing where it got it from) as 'thisResource' in the ENC (assuming 'thisResource' doesn't exist)? What happens if 'thisResource' already exists?
What happens if 'thisResource' already exists?
That clears it up for me. So @Resource(name="") is actually a code-level declaration of an env-entry rather than a JNDI lookup of an env-entry.
And yes, I've been using your notes intensively, after reading the specification, to prepare for the EJB certification (which will be in a few weeks). Thanks a lot, both for this explanation and for your awesome notes! They've been a big help!
Frits Walraven wrote:
(I still find the description in the EJB specs is lacking some important aspects)
Jaikiran Pai wrote:
From what I remember the explanation of @Resource is probably done more in the Java EE spec rather than in EJB spec.