This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
can resource injection be ONLY performed from bean classes and application client class OR it can also be performed from simple POJO class that is in my EAR or ejb-jar.jar project ?
also if I have a POJO class and I have defined a jms resource with JNDI name as jms/MyQueueFactory in glassfish service I know I can access it using no-arg InitialContext constructor but my question is how it is possible in simple POJO class. I haven't read about this in the spec also. don't we need to pass environment properties to the InitialContext constructor ? is it a vendor provided feature ?
1) POJO doesn't have access to ENC by default (it needs some properties to get that access), and hence, though the annotations are allowed in POJO, those won't inject an actual EJB in it (e.g. who will inject EJB in case of POJO? how would runtime get to know where to look for that particular EJB? etc.)
2) As mentioned above, you can access JMS queue after getting a proper context. In POJO, to get a proper context, some properties are necessary (e.g. context factory, security principle - if configured etc.). In a POJO, if no-arg InitialContext constructor is called, then a NoInitialContextException will be thrown.
I'm not expert in this area, so comments/corrections welcome.