aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Invocation of a TimerService Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Invocation of a TimerService" Watch "Invocation of a TimerService" New topic
Author

Invocation of a TimerService

Padma Priya
Ranch Hand

Joined: Feb 01, 2007
Posts: 113
Hi all,

Can anybody explain me the exact sequence of events that should take place for the invocation of a timer service. What is a setSessionContext method. I don't find it anywhere in the api.

With Regards
Deepthi
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268
Copied from internet -
The SessionContext interface provides access to the runtime session context that the container provides for a session enterprise Bean instance. The container passes the SessionContext interface to an instance after the instance has been created. The session context remains associated with the instance for the lifetime of the instance.

Copied from internet -
The setSessionContext() method of the SessionContext interface is used by the container to pass a reference to the bean’s session context. The container calls this method after an instance of the bean is created. The bean uses the reference to interact with the container during its life.

SessionContext.html

EJBContext.html, must see.

Exmple


Prasad Kumbhare
Greenhorn

Joined: Oct 18, 2007
Posts: 26
If I understand your question correctly about Timer, you want to know how Timer works. Right ? I didn't get your question correctly I apologize.

Timer can be two types, programmatic and automatic.
For Programmatic Timer, you inject TimerService in your Bean and create Timer programmatically using one of the 4 createTimer methods of TimerService.

When Bean instantiates and come to the point where it can create timer, it creates Timer instance and Timer executes timeout callback method as specified while creating timer.

For Automatic Timer, we can use @Scheduler. You can specify when you want to run a particular task in schedule. Timer gets created automatically.
Timer doesn't die with Bean. Once it gets created and bean dies still Timer can execute in the server.

Below URL has some more good information on timer.

Timers in EJB3


Thanks.


Thanks,
Prasad Kumbhare
SCJP 5.0, SCWCD 5.0, SCBCD 5.0
Michael Antonov
Greenhorn

Joined: Nov 16, 2009
Posts: 11
Prasad Kumbhare wrote:If I understand your question correctly about Timer, you want to know how Timer works. Right ? I didn't get your question correctly I apologize.

Timer can be two types, programmatic and automatic.
For Programmatic Timer, you inject TimerService in your Bean and create Timer programmatically using one of the 4 createTimer methods of TimerService.

When Bean instantiates and come to the point where it can create timer, it creates Timer instance and Timer executes timeout callback method as specified while creating timer.

For Automatic Timer, we can use @Scheduler. You can specify when you want to run a particular task in schedule. Timer gets created automatically.
Timer doesn't die with Bean. Once it gets created and bean dies still Timer can execute in the server.

Below URL has some more good information on timer.

Timers in EJB3


Thanks.

Well,that is really interesting and useful what you did say about Schedulers, but that is part of EJB 3.1 and hence out of SCBCD 5.0 scope, do you agree?
I meant topic starter probably asked about times in 3.0 only.

JEE Developer.
SCJP 5 - 80%, SCBCD 5 - 90%.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Invocation of a TimerService