wood burning stoves 2.0*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on Timeout Callbacks for Programmatic Timers 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 "Question on Timeout Callbacks for Programmatic Timers" Watch "Question on Timeout Callbacks for Programmatic Timers" New topic
Author

Question on Timeout Callbacks for Programmatic Timers

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Source: EJB 3.1 Specification

18.2.5.1 Timeout Callbacks for Programmatic Timers


A.All timers created via one of the TimerService timer creation methods for a particular component use a
single timeout callback method. This method may be a
i)method annotated with the Timeoutannotation
(or a method specified as a timeout method in the deployment descriptor) or
ii) the bean may implement the javax.ejb.TimedObjectinterface.

B.If the bean implements the TimedObjectinterface, the Timeoutannotation or timeout-method
deployment descriptor element can only be used to specify the ejbTimeoutmethod


As stated in statment B,the Timeoutannotation or timeout-method deployment descriptor element can only be used to specify the ejbTimeoutmethod.
Question: Can someone provide a example explaining the same ?


OCPJP 6.0 93%
OCPJWCD 5.0 98%
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks James for the reply.
However I still have queries

As stated in Statement A,Timeoutannotation or timeout method in the deployment descriptor are used to specify single timeout callback method.
and Statement B says that If the bean implements the TimedObjectinterface, the Timeoutannotation or timeout-method deployment descriptor element can only be used to specify the ejbTimeoutmethod

ejbTimeoutmethod is also timeout callback method

The 2 statement looks similar But I see there is on text(see text in bold) that creates a difference.
Question:Can someone throw more light on the text ?
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

Mohit

My last post is not correct so apologies first for that.

What the statement in bold means is that should you implement the TimedObject interface, you can only annotate or specify in the descriptor file the ejbTimeout method as the timeout method.

So, as an example, this code would be valid:

But this code would be invalid:
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks James
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on Timeout Callbacks for Programmatic Timers
 
Similar Threads
This weeks Giveaway
Can CMP entity beans created without a Primary Key ?
HELP NEEDED in DD
Invocation of a TimerService
CreateException & FinderException?