[jboss-user] [JBoss Seam] - Double processing on getter() outjection

elponderador do-not-reply at jboss.com
Wed Sep 13 18:39:02 EDT 2006


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?

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971431



More information about the jboss-user mailing list