• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pls help clear my doubts

 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I have just started on EJB's and have few ?s to ask. I have just gone on to finish Session Beans.
So some of them may be foolish enough, but I wanna get my concepts cleared

Q1. When a client calls create() methd after getting the Home stub, the stub calls on the Home object...so isn't it at this junction that Authentication and Authorization wud be done?...If so why setSessionContext() doesn't get client Security Info frm Container using SessionContext obj?

Regd Stateless Beans..
Q1. When is ejbCreate() calld in stateless bean lifecycle?..Is it after setSessionContext() in bean construction or after client calls create() on Home stub?

Q2. Also, In Stateful beans we can access resource mgr or other bean methods from ejbCreate(), why can't we do the same for Stateless?

Thanks to all in advance!!
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Pandey:

Q1. When a client calls create() methd after getting the Home stub, the stub calls on the Home object...so isn't it at this junction that Authentication and Authorization wud be done?...If so why setSessionContext() doesn't get client Security Info frm Container using SessionContext obj?


The sequence of bean creation is constructor(newInstance)->setSessionContext->ejbCreate, in the method setSessionContext it's just to bind the context to the bean, therefore it's cannot use the context at that time.

Originally posted by Mike Pandey:

Regd Stateless Beans..
Q1. When is ejbCreate() calld in stateless bean lifecycle?..Is it after setSessionContext() in bean construction or after client calls create() on Home stub?

Q2. Also, In Stateful beans we can access resource mgr or other bean methods from ejbCreate(), why can't we do the same for Stateless?

Thanks to all in advance!!

Q1. It was called after setSessionContext and it was created by the container, not by create() call from client.

Q2. Don't know
 
Raja Sagar Panamgipalli
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The purpose of Stateful session bean is to serve the client,i.e maintain a history of Client's wish list, right when the client enters the application,it cannot drop off in the middle (unless the server goes down).

So,resources can be accessed by the bean because he(client) is initiating the process of bean creation(i.e.. HE wants to interact with the app,a state for himself), which again based on the business logic will trigger call to resource mgrs and other beans.

So its because the creation is triggered by the client,(again impl dependent), we give him "exclusively made for U" bean.

Where as in case of stateless session bean we are leaving creation at the container's will n wish, so that bean doesn't hang around with connection to resource mgr open and gossipping around with other beans in the pool.

Correct me if i'm wrong.....
 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I don't agree with this

The sequence of bean creation is constructor(newInstance)->setSessionContext->ejbCreate, in the method setSessionContext it's just to bind the context to the bean, therefore it's cannot use the context at that time.

As in setSessionContext we can use the Context object to get hold of Home interface reference which means this method is calld after the binding.
Pls advice!!


Neways..thanks a tonne Kengkaj!!
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Pandey:
Hi ,

I don't agree with this

The sequence of bean creation is constructor(newInstance)->setSessionContext->ejbCreate, in the method setSessionContext it's just to bind the context to the bean, therefore it's cannot use the context at that time.

As in setSessionContext we can use the Context object to get hold of Home interface reference which means this method is calld after the binding.
Pls advice!!


Neways..thanks a tonne Kengkaj!!


Yes, I am wrong.
when create method was called the sequence is constructor->setSessionContext->ejbCreate

The actual is before ejbCreate is called the context is not bind to EJBObject yet, but in the setSessionContext the context is already bind to EJBHome (home is already exist because create method was called from home but EJBObject is not exist until the creation complete and when creation was complete the ejbCreate callback is called).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic