Skip to main content

GlassFIsh 3.1 - Interceptor bindings with Schedule

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
5 replies [Last post]
DOS SANTOS Serg...
Offline
Joined: 2011-03-21

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:

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04

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:
>

DOS SANTOS Serg...
Offline
Joined: 2011-03-21

Hi Marina,

It doesn't seem to work either.

Here is the ejb-jar.xml I used.

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

TEST
javaee6.tools.Test
Singleton

0/10
*
*

schedule

javaee6.tools.MetrologyBean
metrology

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:
>>

mvatkina
Offline
Joined: 2005-04-04

Sergio,

Comparing it with our devtest:
http://java.net/projects/glassfish/sources/svn/content/trunk/v2/appserv-...
it looks like the portion might not be working either (or may be
there is a bug in your setup that is not reported correctly) - try
adding section as in the referenced ejb-jar.xml.

HTH,
-marina

DOS SANTOS Sergio wrote:
> Hi Marina,
>
> It doesn't seem to work either.
>
> Here is the ejb-jar.xml I used.
>
> <?xml version="1.0" encoding="UTF-8"?>
> 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">
>
>
> TEST
> javaee6.tools.Test
> Singleton
>
>
> 0/10
> *
> *
>
>
> schedule
>
>
>
> javaee6.tools.MetrologyBean
> metrology
>
>
>
>
>
> 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
>

sergiomail
Offline
Joined: 2011-03-26

Marina,
Thanks for the tip. I was using an incomplete ejb-jar.xml...
Now that interceptor and interceptor-binding are well defined the interceptor binding work just fine around @Schedule methods !
But I still wonder why it is not working with annotations.
Thanks for the help.
Sergio

mvatkina
Offline
Joined: 2005-04-04

May be we didn't test it ;). Please file a bug with a reproducible test case and we'll check what's going on...
Best,
-marina