Hi Marina,
It doesn't seem to work either.
Here is the ejb-jar.xml I used.
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="
http://java.sun.com/xml/ns/javaee"
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" version="3.1">
<enterprise-beans>
<session>
<ejb-name>TEST</ejb-name>
<ejb-class>javaee6.tools.Test</ejb-class>
<session-type>Singleton</session-type>
<timer>
<schedule>
<second>0/10</second>
<minute>*</minute>
<hour>*</hour>
</schedule>
<timeout-method>
<method-name>schedule</method-name>
</timeout-method>
</timer>
<around-timeout>
<class>javaee6.tools.MetrologyBean</class>
<method-name>metrology</method-name>
</around-timeout>
</session>
</enterprise-beans>
</ejb-jar>
Thanks,
Sergio
Le 22/03/2011 01:37, Marina Vatkina a écrit :
> Looks like a bug. Does it work if you use ejb-jar.xml for the binding?
>
> thanks,
> -marina
>
> DOS SANTOS Sergio wrote:
>> Hi everyone,
>>
>> I'm trying to use interceptor bindings with @Schedule methods but it
>> does not seem to work.
>>
>> It works with the classic @Interceptor(SomeInterceptor.class) but not
>> with @SomeInterceptorBinding.
>>
>> The interceptor bean is declared in the beans.xml and the interceptor
>> binding works fine with @Timeout methods but not around @Schedule
>> methods (aroundTimeout).
>>
>> Here is the code I use:
>>
>> -------------------------------
>> @Startup
>> @Singleton
>> @Metrology
>> public class Test implements Serializable {
>>
>> private static final long serialVersionUID = -254310325908151372L;
>>
>> @Resource
>> TimerService timerService;
>>
>> @PostConstruct
>> public void init() {
>> System.out.println("startup");
>> timerService.createTimer(0, 10000, null);
>> }
>>
>> @Schedule(second = "0/5", minute = "*", hour = "*")
>> void schedule() {
>> System.out.println("schedule()");
>> }
>>
>> @Timeout
>> public void timeOut() {
>> System.out.println("timeOut()");
>> }
>> }
>> -------------------------------
>> @Inherited
>> @InterceptorBinding
>> @Retention(RetentionPolicy.RUNTIME)
>> @Target({ ElementType.METHOD, ElementType.TYPE })
>> public @interface Metrology {
>>
>> }
>> -------------------------------
>> @Metrology
>> @Interceptor
>> public class MetrologyBean implements Serializable {
>>
>> private static final long serialVersionUID = 1L;
>>
>> @AroundInvoke
>> @AroundTimeout
>> public Object metrology(InvocationContext invocationContext)
>> throws Exception {
>> System.out.println("aroundTimeout() " +
>> invocationContext.getMethod().getName());
>> return invocationContext.proceed();
>> }
>> }
>>
>>
>> Here is what is displayed in the Glassfish console :
>> -------------------------------
>> INFO: aroundTimeout() timeOut
>> INFO: timeOut()
>>
>> INFO: schedule()
>>
>> INFO: schedule()
>>
>> INFO: aroundTimeout() timeOut
>> INFO: timeOut()
>> -------------------------------
>>
>> There is no : INFO: aroundTimeout() schedule.
>>
>> Is this a bug ? Are the interceptor bindings not supported for
>> @Schedule methods ? I can't seem to find any related information
>> about this issue.
>>
>> Thanks for your help.
>>
>> Regards,
>> Sergio