• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Specific risks of using java.util.Timer in a SessionBean?

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I know that java.util.Timer is not supposed to be used in the servlet or
EJB containers (is the recommendation as strong for the servlet
container?). But I'd really like to understand what the specific risks are.

We are using OAS 9i (which supports EJB 2.0 - not 2.1 - and hence we cannot take advantage of EJB TimerService feature offered in EJB 2.1). I am not sure if the details of what I am trying to do will be of any use. All I want to know "what are the specific risks if I use "java.util.Timer"? Or what risk(s) do I face if I do this:

public class MyBean extends TimerTask implements SessionBean

Thanks in advance!
Saeed
[ May 04, 2007: Message edited by: Saeed Amer ]
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you spawn new threads(creating a timer is spawning a new thread) from inside an EJB instance, the container will not be able to manage the lifecycle of the bean instance, as, it would not be able to determine when a particular method has finished execution.
Just a question, why, do you want to make your ejb a timer task? Can't you have a timer task seperately and call the session bean from inside the timer task, using local interface? That was just a thought, may be not relevant in the problem you have.
 
Saeed Amer
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much for your response Nitesh!

I just wanted to get some clarification (which I have got now - Thanks!)

Just a question, why, do you want to make your ejb a timer task? Can't you have a timer task seperately and call the session bean from inside the timer task, using local interface? That was just a thought, may be not relevant in the problem you have.



That is precisely what I am going to do.

Thanks again, friend!

Saeed
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic