@Schedule注释部署描述符标签?

时间:2012-02-03 20:53:29

标签: java-ee schedule

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

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

有可能吗?这不对吗?

提前致谢

1 个答案:

答案 0 :(得分:2)

以下是与ejb-jar.xml注释等效的@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