*
The moose likes EJB and other Java EE Technologies and the fly likes ejbActivate and EntityContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbActivate and EntityContext " Watch "ejbActivate and EntityContext " New topic
Author

ejbActivate and EntityContext

mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Hi
Can anybody please explain me why entity bean's ejbActivate method can't do following on EntityContext
1. get security information about client.
2. force a transaction to rollback(CMT beans)
3. find out if the transaction has already been set to rollback(CMT beans)
4. get a transaction reference, and call methods on it (BMT beans only, so entities can't use this)
I guess ejbActivate method of entity bean is called by container when the bean is picked up from the pool to serve a client when it invokes the entity beans business method. So there is a client during ejbActivate.
Regards
Mini
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Mini,
Is this a cross-post? I seem to recall already answering it.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Originally posted by Nathaniel Stoddard:
Mini,
Is this a cross-post? I seem to recall already answering it.

Hi Nathaniel
I posted it again in this forum because I didn't a satisfactory answer. Following is your answer :
" The answer to all your questions is no due to the fact that there is no client during ejbActivate. Therefore there is no transaction."

But Infact, that is not true because you can access bean's EJBObject and EJBHome from the ejbActivate method, which means that it can see the client.
Regards
mini
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Just because you can get the home or component interface doesn't mean there's a valid transactional context. They are separate things. Obviously you can get the home and component interface when you are in a valid context due to a client invoking a call. But, you do not have to be in a transaction to get home or component interface. In ejbActivate for example, there is no transactional context, but as you stated, you can still get the home and component interfaces.
Anna Madhusudhanan Natanagopalan
Greenhorn

Joined: Apr 05, 2004
Posts: 25
Hi Nathaniel,
You post that we can get the context , from the context we can get the home and component . Then when will we get the transactional context (at the time of ejbActivation).
Thanks and regards
Anna Madhusudhanan
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Anna Madhusudhanan Natanagopalan:
Then when will we get the transactional context (at the time of ejbActivation).

Well, not at the time of activation. You have a valid transactional context only during the execution of a business method. ejbActivate is not a business method. That being said, I would assume you need a transactional context during ejbLoad, but that method again is not a business method.
I've never needed to do anything in ejbActivate, and honestly I cannot think of what you'd want to do there that you couldn't do inside a business method. Can you (or the OP) give us the problem you're trying to address? Maybe there's another way to solve it.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: ejbActivate and EntityContext