Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

few queries regarding injection and InitialContext?

 
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
gurpeet singh
Ranch Hand
Posts: 924
1
Netbeans IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
waiting for other ranchers to comment on this
 
I love a woman who dresses in stainless steel ... and carries tiny ads:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic