• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • 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 Java MySQL Database
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Time flies like an arrow. Fruit flies like a banana. Steve flies like a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!