This week's giveaway is in the Spring forum.
We're giving away four copies of liveProject: Protecting User Data with Spring Security and OAuth2 and have Laurentiu Spilca on-line!
See this thread for details.
Win a copy of liveProject: Protecting User Data with Spring Security and OAuth2 this week in the Spring forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

Why EJBTimer service not supporting in stateful beans

 
Ranch Hand
Posts: 109
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why EJBTimer service not supporting in stateful beans? Is that because stateful beans can passivated.
And why is that not specified in specification?
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
If you look at page 510 of the EJB 3.1 specification, then it says that the ability to create timers for stateful session beans may be added in a future version of the specification, so I suspect there are no reasons that are strong enough to stop such a feature.

I can speculate in some reasons that can make timers and stateful session beans a little difficult, but these are just my own speculations and again nothing that cannot be overcome:
- The need to associated a timer to a specific instance of a stateful session bean.
Unlike stateless session beans where a timer can invoke a timeout method on an arbitrary instance from the bean pool, a timer invoking a stateful session bean need to invoke a specific instance. This since they all have an unique state.
- Contention between timer and client.
Since stateful session beans only allow one single thread at a time executing in a bean instance, there may be contention between timer(s) and client associated with a certain bean instance.
For instance, the timer times out and want to invoke a callback method on the bean, but the client has already called the bean. The timer must thus wait until the client call has finished executing.
Best wishes!
 
Udara Amarasinghe
Ranch Hand
Posts: 109
Netbeans IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK so then there is no mechanism to implement stateful bean clients session to finish at specific time.
 
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think thats what Session timeout would help you do. Isn't it?

Regds,
Amit
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

Udara Amarasinghe wrote:OK so then there is no mechanism to implement stateful bean clients session to finish at specific time.


How about delegating processing of requests to a stateless bean?
Any state information can be enclosed, for instance, as a parameter to the stateless bean.
In the stateless bean you can then use EJB timers.
Best wishes!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic