tags:

views:

34

answers:

1
@Named
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
    public String methodThrowException throws Exception() {
        throws new Exception();
    }
}

public class MyInterceptor {
    @AroundInvoke
    public Object intercept(InvocationContext ic) throws Exception {
        try {
            return ic.proceed();
        } catch (Exception e) {
            return null;
        }
    }
}

For @Stateless beans interceptor works, but for the BeanWeb interceptor does not work. And we have never entered into "intercept" method.

  1. Why is this happening?
  2. How could intercept method calls in BeanWeb?

P.S.: All this spin under Glassfish 3.x.

A: 

It's work:

@Named
@Stateful
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
    public String methodThrowException throws Exception() {
        throws new Exception();
    }
}

public class MyInterceptor implements Serializable {
    @AroundInvoke
    public Object intercept(InvocationContext ic) throws Exception {
        try {
            return ic.proceed();
        } catch (Exception e) {
            return null;
        }
    }
}

I hope this is correct.

Drevlyanin