This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbActivate and EntityContext

 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mini,
Is this a cross-post? I seem to recall already answering it.
 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1646
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic