I have an issue in which a 3rd party control is attempting to access a bean 
property of a conversation state bean during the decode phase. This property 
returns null (which the 3rd party control hates) when there is no conversation. 
So I thought that I would add a custom method interceptor on the get property 
method to check if the conversation is active and if not, immediately invoke 
the navigation handler (unlike the @Conversational which doesn't change the 
navigation for non-action methods). 

After developing it, it almost looks like Seam 1.0.1 doesn't support custom 
method-level interceptors on POJOs. Is this true? 

Here is my code:
Bean class:
@Name("editReportBean")
  | @Scope(ScopeType.CONVERSATION)
  | public class EditReportBean
  | {
  |   ...
  |   @ConversationRequired(ifNotBegunOutcome="return.report.list")
  |   public TreeModel getAvailTreeModel()
  |   {
  |     return this.availTreeModel;
  |   }

Interceptor:
@Target({TYPE, METHOD})
  | @Retention(RUNTIME)
  | @Interceptors(ConversationRequiredInterceptor.class)
  | public @interface ConversationRequired
  | {
  |   /**
  |    * The JSF outcome if the component is invoked outside
  |    * of the scope of its conversation
  |    */
  |   String ifNotBegunOutcome();
  | }

The interceptor implementation:
@Around({BijectionInterceptor.class,
  |   ValidationInterceptor.class,
  |   ConversationInterceptor.class})
  | @Within({RemoveInterceptor.class})
  | public class ConversationRequiredInterceptor
  | {
  |   @AroundInvoke
  |   public Object ensureActiveConversation(InvocationContext invocation)
  |     throws Exception
  |   {
  |     Method method = invocation.getMethod();
  |     
  |     if (!Manager.instance().isLongRunningConversation())
  |     {
  |       String outcome = 
method.getAnnotation(ConversationRequired.class).ifNotBegunOutcome();
  |       FacesContext context = FacesContext.getCurrentInstance();
  |       
context.getApplication().getNavigationHandler().handleNavigation(context, 
  |         null, outcome);
  |       throw new AbortProcessingException();
  |     }
  |     
  |     return invocation.proceed();
  |   }
  | }

The "ensureActiveConversation" method of the interceptor implementation class 
is never invoked.

Is this possible? What else can I do to stop this (I will probably put a work 
around in, but would like to know if I can get custom interceptors to work on 
POJO methods).

Thanks,
ANdrew


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961957#3961957

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961957
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to