2012-02-03 206 views
1

我有@Schedule注释创建一个TimerService,但我希望能够通过在部署描述符标签覆盖分钟参数。@Schedule注释部署描述符标签?

我在网上搜索了,但每一页都指的TimerServices解释@Schedule作为注解。

可能吗?这是错的吗?

在此先感谢

回答

2

这里是一个ejb-jar.xml片段eqivalent到@Scheduled注释:

<?xml version="1.0" encoding="UTF-8"?> 
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" version="3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> 
    <enterprise-beans> 
     <session> 
      <ejb-name>DummyTimer4</ejb-name> 
      <ejb-class>org.glassfish.samples.DummyTimer4</ejb-class> 
      <session-type>Stateless</session-type> 
      <timer> 
       <schedule> 
        <second>*/10</second> 
        <minute>*</minute> 
        <hour>*</hour> 
        <month>*</month> 
        <year>*</year> 
       </schedule> 
       <timeout-method> 
        <method-name>timeout</method-name> 
        <method-params> 
         <method-param>javax.ejb.Timer</method-param> 
        </method-params> 
       </timeout-method> 
      </timer> 
     </session> 
    </enterprise-beans> 
</ejb-jar> 

参见:https://blogs.oracle.com/arungupta/entry/totd_146_understanding_the_ejb