File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes few queries regarding injection and InitialContext? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "few queries regarding injection and InitialContext?" Watch "few queries regarding injection and InitialContext?" New topic
Author

few queries regarding injection and InitialContext?

gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

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 ?

thanks and regards
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Hi gurpreet,

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.

Thanks.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

waiting for other ranchers to comment on this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: few queries regarding injection and InitialContext?