• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

What does the JNDI lookup return?

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
when we perform a JNDI lookup, does it return a reference to the Home interface or the reference to the class which implements the home interface which is created by the container during deployment?

Regards,
Sathya
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JNDI lookup returns a stub to the remote home object. This stub might not implement the home interface (as it might be an IIOP stub), so you must first narrow it and then cast it to the home interface. When we sometimes say that the home interface is returned, we actually mean that the stub returned from the lookup has been narrowed and cast to the home interface.
 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
the below is my understanding of the whole EJB functionality.Correct me if iam wrong.

Initially to start with, we define home interface,remote interface and a bean class.

First , we have to get a reference to Home interface.During deployment,the server automatically generates a class which implements this home interface(Let this class be denoted by A).During JNDI lookup,the object to this class is returned.

CustomerHome cust = Context.lookup("Customer");

Customer remote = cust.create();

Like above,during deployment,the server generates a class which implements the remote interface(let this class be denoted by B).When the create method is called,an object to this class is created and its reference is returned.Also an instance to the bean class is created either by calling the beans constructor or by taking the instance from the pool.So the remote variable contains the reference to the class generated by the server.

Now when a method is called,

remote.<method_name>

the control goes to the stub which performs marshalling.The stub transfers the data through network and the skeleton unmarshalls the arguements and calls the method in the class B.This inturn calls the actual bean implementation method.

This is my overall understanding of the working of EJB.Kindly correct me if iam wrong.

Regards,
Sathya
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Also an instance to the bean class is created either by calling the beans constructor or by taking the instance from the pool.


For a stateless session bean or entity bean, the instantiation is typically done on server startup when a pool of instances is created for each bean type. In other words, bean creation is not related to what the client does. However, if client requests require more instances than are available, the container may create more instances up to the maximimum limit specified for the bean type.

For a stateful session bean, it's different in that the bean instance creation is done upon invocation of the client's create() method. In other words, stateful session beans are not pooled but created on client requests.
 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for your reply.

In other words, stateful session beans are not pooled but created on client requests.



Can you kindly explain me why the instance creation for a stateful session bean happens only on the request and not pooled?

Regards,
Sathya
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sathya Narayanan:
Hi,
thanks for your reply.



Can you kindly explain me why the instance creation for a stateful session bean happens only on the request and not pooled?

Regards,
Sathya



This is beacause the client could pass in some data during creation and so ejbCreate can have arguments.
 
reply
    Bookmark Topic Watch Topic
  • New Topic