开发者

Add @Schedule annotation using AOP in Java EE

I am trying to create schedule event using EJB 3.1 @Schedule annotation. Everything works fine as long as I have the annotation inside my bean. Because I want to be able to change schedule in deploy time开发者_Python百科 without repacking ear I want to add this annotation using AOP. But this does not work.

Here is my sample bean:

@AspectDomain(value = "TimerBeanDomain")
@Singleton
public class TimerBean {

    public void timerMethod() {
        System.out.println("Timer method activated");
    }

}

Here is my aop.xml file (packed outside -ejb.jar):

<?xml version="1.0" encoding="UTF-8"?>

<aop xmlns="urn:jboss:aop-beans:1.0">
    <domain name="TimerBeanDomain">
        <annotation expr="method(void *->timerMethod(..))">
            @javax.ejb.Schedule(second = "*/30", minute = "*", hour = "*")
        </annotation>
    </domain>
</aop>

Bean is packed inside -ejb.jar and aop file is outside this -ejb.jar.

There are no errors in console. It just does not work.

I tried it with stateless bean as well. But it does not help. In this case aop.xml looked like

<domain name="TimerBeanDomain" extends="Stateless Bean" inheritBindings="true">

I am using Jboss 6.0.1 and 6.1.0. At least is there some way how to debug the AOP process of adding annotation?

Any help will be appreciate.

Regards, Eman


You can still configure the schedule outside of the code with EJB3.1, without using AOP, see:

Can the EJB 3.1 @Schedule be configured outside of the application code?


Probably it's a known bug: https://issues.jboss.org/browse/EJBTHREE-1632

I shall look into the matter in a bit more detail during forthcoming weekends & let you know if I find any work-around.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜