• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Few EJB questions [newbie]

 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy Ranchers!

I've just started entering the EJB world and few questions raised in my head. Excuse me if these are obvious ones :-)

As I understand the ENC is a private scope for a concrete EJB.
So, can you say it's like the init-param's in the servlets world?

Can a EJB A access the EJB's B ENC?

What is the relation between the ENC and JNDI? Is ENC a JNDI, is it a part of the JNDI or are these two entities unrelated with each other?

If I would like to have a scope where one EJB could take something from the other EJB - what should I use? Directly bind some entity in the JNDI and pass the location to another EJB or something else? Should the new EJB Singleton be used for such all EJB's common-space?

As I understand, every part of the application server can access some entry in the JNDI, so it's somewhat similar to the context-param (in contrast to the similarity of EJB's ENC <-> servlet's init-param)? By the way: is there a way to 'restrict' access to some resource in the JNDI? For example: EJB A and EJB B can access a resource in this JNDI location, but EJB C cannot access it.

Are the ENC parameters read only during deployment and CAN'T be changed at all after the deploy? I just was wandering that if it WOULD be possible to change the ENC value, you might end in an inconsistent EJB state.
I mean: I have a property marked with @Resource annotation which I inject with a value of "10". Container creates i.e. 5 instances of the EJB and put them in the pool. Then, somehow, I change the value of the ENC parameter to "20".
After this, container might decide to create few new EJB instances and add them to the pool. These new instances would have different property value injected ("20") and therefore I would end up with x instances with property value of "10" and y instances with property value of "20". As the container can choose which instance will be used to serve user's request, I would end in an inconsistent state of the EJB's.
Is this scenario even possible?

Thanks in advance for your time!

Cheers!
 
Greenhorn
Posts: 18
Mac Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pedro Kowalski wrote:
What is the relation between the ENC and JNDI? Is ENC a JNDI, is it a part of the JNDI or are these two entities unrelated with each other?


The ENC is the component's individual space in the JNDI. It's just a name space in the JNDI.
The ENC is managed by the container.
You can access the resources defined in the ENC via JNDI lookup or via EJBContext methods.

Pedro Kowalski wrote:
Are the ENC parameters read only during deployment and CAN'T be changed at all after the deploy? I just was wandering that if it WOULD be possible to change the ENC value, you might end in an inconsistent EJB state.


EJB have read only access to the ENC/JNDI. You'll get a javax.naming.OperationNotSupported if you try to rebind variables. (this is on the exam)
 
Piotr Nowicki
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Logan!

Logan Lee wrote:EJB have read only access to the ENC/JNDI. You'll get a javax.naming.OperationNotSupported if you try to rebind variables. (this is on the exam)


Ok, this solves some problems but does it mean that the EJB cannot bind some object to the JNDI? Or maybe it just can't bind some object to the ENC?

 
Logan Lee
Greenhorn
Posts: 18
Mac Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use @EJB or @resource in a ejb those resources are automaticallly made available in the ENC/jndi
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic