【问题标题】:@Schedule annotation deployment descriptor tag?@Schedule 注解部署描述符标签?
【发布时间】:2012-02-03 20:53:29
【问题描述】:

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

我在网上搜索了它,但每个引用 TimerServices 的页面都将 @Schedule 解释为注释。

有可能吗?有错吗?

提前致谢

【问题讨论】:

    标签: jakarta-ee schedule


    【解决方案1】:

    这是一个ejb-jar.xml sn-p 等效于@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

    【讨论】:

      猜你喜欢
      • 2012-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 2013-02-26
      相关资源
      最近更新 更多