2 Replies Latest reply on Jul 31, 2006 2:29 PM by Andrew

    Is a custom method interceptor in a POJO possible?

    Andrew Apprentice

      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:

      public class EditReportBean
       public TreeModel getAvailTreeModel()
       return this.availTreeModel;

      @Target({TYPE, METHOD})
      public @interface ConversationRequired
       * The JSF outcome if the component is invoked outside
       * of the scope of its conversation
       String ifNotBegunOutcome();

      The interceptor implementation:
      public class ConversationRequiredInterceptor
       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();
       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).