1 Reply Latest reply on Sep 14, 2006 4:41 AM by Gavin King

    Double processing on getter() outjection

    Lewis Gass Newbie

      Whenever you have a method like this:

      @Out(scope=ScopeType.EVENT) @Factory Boolean getSomeFlag () {
       return this.someMethod() != null;
      }
      


      which is useful for being able to generate a value for a particular scope
      without having to manage a variable inside your bean.

      If inside the someMethod() there is alot of processing, you probably only want that being called once per request, thus the EVENT scope.

      In this scenario this snippit of code from the BijectionInterceptor is processed:

       public Object bijectTargetComponent(InvocationContext invocation) throws Exception
       {
       if (component.needsInjection()) //only needed to hush the log message
       {
       if ( log.isTraceEnabled() )
       {
       log.trace("injecting dependencies of: " + component.getName());
       }
       component.inject(invocation.getTarget()/*, true*/);
       }
      
       Object result = invocation.proceed();
      
       if (component.needsOutjection()) //only needed to hush the log message
       {
       if ( log.isTraceEnabled() )
       {
       log.trace("outjecting dependencies of: " + component.getName());
       }
       component.outject(invocation.getTarget());
       }
      
       return result;
       }
      


      Note that the result for this particular interceptor is already know and stored in the result Object. However since Seam also realizes that outjection is necesary it calls the component.outject(invocation.getTarget()) method whic results in that same method getting called again.

      Would there be anyway for seam to pass down the result value with the name of the outjection to the component.outject() method that way as it loops through the different members to cause outjecting it can take advantage of the fact that it has already called the targeted factory?