views:

20

answers:

1

Hi!

How can I configure a schedule intervals

(@Schedule(persistent=true, minute="", second="/5", hour="*") )

outside from application:

  1. How can I configure it in ejb-jar.xml?
  2. Can I configure it outside from application (kind of properties file)?

Thanks!

+1  A: 

According to the EJB 3.1 specification, automatic timers can be configured through annotations or through the ejb-jar.xml deployment descriptor.

18.2.2 Automatic Timer Creation

The Timer Service supports the automatic creation of a timer based on metadata in the bean class or deployment descriptor. This allows the bean developer to schedule a timer without relying on a bean invocation to programmatically invoke one of the Timer Service timer creation methods. Automatically created timers are created by the container as a result of application deployment.

And my understanding of the deployment descriptor XLM schema is that you define it using a <timer> element inside a <session> element.

<xsd:element name="timer"
             type="javaee:timerType"
             minOccurs="0"
             maxOccurs="unbounded"/>

See the definition of the timerType complex type for the details (in particular the schedule and timeout-method elements).

References

  • EJB 3.1 Specification
    • Section 18.2.2 "Automatic Timer Creation"
    • Section 19.5 "Deployment Descriptor XML Schema" (p. 580, p583-p584)
Pascal Thivent