Win a copy of High Performance Python for Data Analytics this week in the Python 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
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

EJBContext

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the diffrence between java:comp/ and java:comp/env/

ref:--http://javahowto.blogspot.in/2006/06/4-ways-to-get-ejbcontext-in-ejb-3.html

may I know the diffrence between
1>java:comp/EJBContext
2>java:comp/env/com.foo.ejb.HelloBean/sctx
3>java:comp/env/sessionContext


 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is the diffrence between java:comp/ and java:comp/env/



Imagine both as directories on your file system. You might have files (environment entries) in both directories (contexts).

The java:comp namespace exists per component (like the "My Documents" folder exists for each user on Microsoft Windows). By default, environment entries declared by the components are created in java:comp/env. The Java EE 6 specification recommends (but not requires) that environment entries be created in the env subcontext to avoid potential conflicts with current or future versions of the specification. I.e. the future versions of the spec may require that certain entries be created in the java:comp context - as EJBContext already is.

ref:--http://javahowto.blogspot.in/2006/06/4-ways-to-get-ejbcontext-in-ejb-3.html

may I know the diffrence between
1>java:comp/EJBContext
2>java:comp/env/com.foo.ejb.HelloBean/sctx
3>java:comp/env/sessionContext



In this case, if you imagine the contexts again as directories on your file system, you can imagine the entries 2 and 3 as symbolic links to java:comp/EJBContext.

Symbolic link 2 java:comp/env/com.foo.ejb.HelloBean/sctx is created because that is the default: full qualified class name (com.foo.ejb.HelloBean) + "/" + name of member variable (sctx):



Symbolic link 3 java:comp/env/sessionContext is created because the code explicitly says so in the name attribute of the Resource annotation:



Sidenote:
Even though the 4 ways to get the EJBContext in EJB 3.1 are correct, I do not see why I should use JNDI lookup if I already have access via the member variable. Nevertheless, it demonstrates nicely under which entry an object is made available.

 
Christian Ludt
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW: casting the EJBContext to a SessionContext only works because the EJBContext is accessed in an EJB session bean. If you accessed the EJBContext in a MessageDrivenBean, it would be a MessageDrivenContext; in an Entity bean it would be an EntityContext.
 
this is supposed to be a surprise, but it smells like a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic