2010-04-22 21 views
0
@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; 
     } 
    } 
} 

JSF页面对于@Stateless豆拦截工作,但对于BeanWeb拦截不起作用。而我们从未进入过“拦截”的方式。@Intertceptors不适用于网络豆连续工作

  1. 这是怎么发生的?
  2. 如何拦截BeanWeb中的方法调用?

P.S .:所有这些都在Glassfish 3.x下旋转。

回答

0

它的工作:

@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; 
     } 
    } 
} 

我希望这是正确的。