2 Replies Latest reply on Dec 15, 2005 10:26 AM by tlg

    @Factory and Interceptor problem

    tlg

      I'm using a @Factory to setup a session object and start a conversation, this is all done in a Statefull session bean. (This is latest Seam from CVS)

      @Stateful
      @Name("constraintsUpdater")
      @Interceptor(SeamInterceptor.class)
      @Intercept(InterceptionType.ALWAYS)
      public class ConstraintsUpdaterBean implements Serializable {
      
       @In
       @Out(scope = ScopeType.CONVERSATION)
       private ConstraintsUpdate constraintsUpdate;
      
       @Factory(value = "constraintsUpdate")
       @Begin
       public void initConstraintsUpdate() {
       ...
       }
      ...
      }
      


      The problem is that when the JSF page try to acces the object, the factory method is being invoked, and before it is invoked the SeamInterceptor tries to inject the scoped object, which tries to invoke the factory method,wich gets intercepted, etc ... (it creates a loop).

      Is there something conceptually wrong in what I'm doing or is it a limitation to the @Factory notation.


        • 1. Re: @Factory and Interceptor problem
          gavin.king

          Right, it is conceptuall wrong :-)

          Why do you have the @In annotation there?

          • 2. Re: @Factory and Interceptor problem
            tlg

             


            Why do you have the @In annotation there?


            I actually use the ConstraintsUpdaterBean for a conversation initiated by a get request. The request has parameters

             @In(value = "#{param.email}", required = false)
             private String pemail;
            
             @In(value = "#{param.hash}", required = false)
             private String phash;
            


            In the @Factory method I build a ConstraintsUpdate object wich is use as a data bean in the jsf page (it has all the informations I need to render the page). Then the jsf page calls a method in the conversation bean

            "#{constraintsUpdaterBean.accept}"
            


            and in this method I need access to the data in the ConstraintsUpdate data object. So that's why I use the @In annotation.