Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question on activation/passivation

 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I know the activation and passivation is bit different in entity bean and session bean. But still i have following doubts because of comparision.

1) ejbActivate/ejbPassivate method run in 'unspecified transaction context' both in entity bean as well as stateful session bean. But, it is possible to access 'other enterprise beans' and 'resource managers' in Stateful Session bean's ejbActivate/ejbPassivate method but NOT in Entity bean's ejbActivate/ejbPassivate method. Why?

2) In stateful session bean's ejbActivate/ejbPassivate method, we can access client's security info but, not in entity bean's ejbActivate/ejbPassivate method. Why?

Somebody please answer.

Thanks,
Prashant
 
Vijay Dasari
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prasanth,
Thats an interesting question. I looked in to Spec, but i did not get the clear answer to that.

As i understood..
The Basic rule for ResourceManager access and Other Enterprise Bean acess is that the method(calling method) should be called atleast in a Transactional Context or it should have availability of the Security Context.

Wording from Spec
"
Accessing resource managers and enterprise beans is disallowed in the session bean methods
for which the container does not have a meaningful transaction context or client security context.
"

The steps what a container might be doing for Enity Beans is

1. Bean(Enity) is in pooled state
2. Client calls a Business method.
3. Container picks an instance from pool
4. Container sets the PrimaryKey
5. Call ejbActivate() without any transactional context.
(At this point the bean instance is not yet identified with client.)
6. Container passes the Security context to the instance via EJBObject.
(Now the bean instance is identified with the client)
7. Call ejbLoad() with in the transactional context of the invoked business method.

Vijay.
 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay, thanks for ur time.

1) According to spec, if there is a meaningful transaction context or client security context, bean can access ResourceManager and Other Enterprise Bean.So, since session beans have security context in ejbActivate/ejbPassivate methods, it can access the ResourceManager and Other Enterprise Bean. So this is fine.

2) I still dont understand this. Why security context is passed to ejbActivate/ejbPassivate methods ONLY in stateful session bean but not in ejbActivate/ejbPassivate methods of entity beans?

Thanks,
Prashant
 
Prashant Neginahal
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
other experts please answer.
 
KasiMurugan Ramasamy
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prahant,

Good question. For stateful when you creating, you have identity(Client who calling the create method on home). So once you have security identity until the bean destory the identity has been kept by the container. So that security identity is available in ejbPassivate and ejbActivate.

But in entity bean,

As per our previous expert statement, after ejbActivate only we have security info.Because after the ejbActivate only container assigning a EJBObject, then only our business call delegate(this time only container assign a client info to this entitybean instance).

Simmilarlly,when container decided to call ejbPassivate on a entity instance means further business calls might not processed by this instance. So that client informations are removed from instance in entity bean. So that we don't have security info in ejbPassivate.

Regards
Kasimurugan R.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic