[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: ClassLoader injection Scope issue

adrian@jboss.org do-not-reply at jboss.com
Tue Oct 28 12:15:37 EDT 2008


"alesj" wrote : "adrian at jboss.org" wrote : 
  |   | So another fix would be to somehow make the Deployer's ScopeBuilder
  |   | somehow aware of the class scope when it creates the component scope.
  |   | 
  | ScopeBuilder per attachment type?
  | 
  |   |    public static ScopeBuilder getScopeBuilder(DeploymentContext deploymentContext)
  |   |    {
  |   |       if (deploymentContext == null)
  |   |          throw new IllegalArgumentException("Null deployment context");
  |   |       ScopeBuilder builder = deploymentContext.getTransientAttachments().getAttachment(ScopeBuilder.class);
  |   |       if (builder != null)
  |   |          return builder;
  |   |       DeploymentContext parent = deploymentContext.getParent();
  |   |       if (parent != null)
  |   |          return getScopeBuilder(parent);
  |   |       return DefaultScopeBuilder.INSTANCE;
  |   |    }
  |   | 
  | Setting BeanMD aware ScopeBuilder?

Those sound overly complicated.
The simplest fix would be in the component visitor, something like:


  |    protected static void addBeanComponent(DeploymentUnit unit, BeanMetaData bean)
  |    {
  |       DeploymentUnit component = unit.addComponent(bean.getName());
  |       component.addAttachment(BeanMetaData.class.getName(), bean);
  | +      String className = bean.getBean();
  | +      if (className != null)
  | +         component.getScope().addScope(CommonLevels.CLASS, className);
  |    }
  | 

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

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



More information about the jboss-dev-forums mailing list