Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invocation of a TimerService

 
Padma Priya
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Antonov
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic