• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Invoking Timer methods from stateful/stateless session bean

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i see that javax.ejb.Timer methods can be called from business methods, afterBegin and beforeCompletion. why it cannot be called from other methods such as setSessionContext, ejbCreate/ejbRemove/ejbActivate/ejbPassivate and afterCompletion in stateful session bean. The specification does not specify the exact condition from where the Timer methods could be invoked from the methods of stateful or stateless session bean.

Could someone please clarify the above?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As par my understading EJB timer service is only applicable to Stateless session beans and MDB's. If you try to invoke getTimerService() for Stateful session bean container will throw an IllegalStateException.

As par specs
"ejb-3_0-fr-spec-ejbcore
Timers cannot be created for stateful session beans[94] or EJB 3.0 entities."
[94] This functionality may be added in a future release of this specification."
 
Vijay Ramalingam
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gaurav,

But my question is invoking methods on Timer API and not calling getTimerService().

For example we could get the javax.ejb.Timer object from the serialized TimerHandle, and then invoke methods on it. As per the spec, the javax.ejb.Timer method invocation is allowed from businessmethod, afterCompletion and beforeCompletion.
My question is why it is restricted in other methods of stateful session bean.
 
Vijay Ramalingam
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Gaurav,

But my question is invoking methods on Timer API and not calling getTimerService().

For example we could get the javax.ejb.Timer object from the serialized TimerHandle, and then invoke methods on it. As per the spec, the javax.ejb.Timer method invocation is allowed from businessmethod, afterCompletion and beforeCompletion.
My question is why it is restricted in other methods of stateful session bean.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As per my understanding,

Timer is an active object which allows you to perform
operations like cancel/getNextTimeout/getTimeRemaining etc.


To operate on these methods, it must be in active transaction.

"setSessionContext/ejbCreate/ejbRemove" are executed in unspecified transaction.
And for stateless session beans and MDBs "ejbActivate/ejbPassivate" does not make
any sense which also are executed in unspecified transaction.

So Timer methods can not be called from these methods.

In case of "afterCompletion", it is related to stateful session bean and also
this method is the last possible method for stateful session bean transaction
hence can not be used for Timer methods.

Hope this is useful to you.

Regards
 
Live a little! The night is young! And we have umbrellas in our drinks! This umbrella has a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic