[weld-commits] Weld SVN: r6392 - in core/trunk/impl/src/main/java/org/jboss/weld: bootstrap and 3 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Jun 3 07:46:11 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-06-03 07:46:11 -0400 (Thu, 03 Jun 2010)
New Revision: 6392

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
   core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
   core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java
   core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ImmutableArraySet.java
Log:
minor

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -134,7 +134,6 @@
 
    // Decorators
    private List<Decorator<?>> decorators;
-   private Class<T> proxyClassForDecorators;
 
    // Interceptors
    private boolean hasSerializationOrInvocationInterceptorMethods;
@@ -205,7 +204,7 @@
 
       DecorationHelper.getHelperStack().push(decorationHelper);
       proxy = decorationHelper.getNextDelegate(originalInjectionPoint, creationalContext);
-      decorationHelper = (DecorationHelper<T>) DecorationHelper.getHelperStack().pop();
+      DecorationHelper.getHelperStack().pop();
 
       if (proxy == null)
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -144,7 +144,7 @@
                }
                else
                {
-                  return method.invoke(receiver, beanManager, creationalContext, CreationException.class);
+                  return method.invoke(null, beanManager, creationalContext, CreationException.class);
                }
             }
             

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -108,26 +108,26 @@
  */
 public class WeldBootstrap implements Bootstrap
 {
-   
+
    private static final LocLogger log = loggerFactory().getLogger(BOOTSTRAP);
-   
+
    /**
     * 
-    * A Deployment visitor which can find the transitive closure of Bean 
+    * A Deployment visitor which can find the transitive closure of Bean
     * Deployment Archives
     * 
     * @author pmuir
-    *
+    * 
     */
    private static class DeploymentVisitor
    {
-      
+
       private final BeanManagerImpl deploymentManager;
       private final Environment environment;
       private final Deployment deployment;
       private final Map<BeanDeploymentArchive, BeanDeployment> managerAwareBeanDeploymentArchives;
       private final BeanDeploymentArchive implementationBeanDeploymentArchive;
-      
+
       public DeploymentVisitor(BeanManagerImpl deploymentManager, Environment environment, final Deployment deployment)
       {
          this.deploymentManager = deploymentManager;
@@ -136,54 +136,54 @@
          this.managerAwareBeanDeploymentArchives = new ConcurrentHashMap<BeanDeploymentArchive, BeanDeployment>();
          this.implementationBeanDeploymentArchive = new BeanDeploymentArchive()
          {
-            
-            private  final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
-            private final Set<Class<?>> beanClasses = (deployment.getServices().contains(ServletServices.class)) ? Arrays2.<Class<?>> asSet(ConversationImpl.class, ServletConversationManager.class, NumericConversationIdGenerator.class, HttpSessionManager.class) : Collections.<Class<?>>emptySet();
-            
+
+            private final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
+            private final Set<Class<?>> beanClasses = (deployment.getServices().contains(ServletServices.class)) ? Arrays2.<Class<?>> asSet(ConversationImpl.class, ServletConversationManager.class, NumericConversationIdGenerator.class, HttpSessionManager.class) : Collections.<Class<?>> emptySet();
+
             public ServiceRegistry getServices()
             {
                return serviceRegistry;
             }
-            
+
             public String getId()
             {
                return "weld";
             }
-            
+
             public Collection<EjbDescriptor<?>> getEjbs()
             {
                return Collections.emptySet();
             }
-            
+
             public Collection<URL> getBeansXml()
             {
                return Collections.emptySet();
             }
-            
+
             public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
             {
                return Collections.emptySet();
             }
-            
+
             public Collection<Class<?>> getBeanClasses()
             {
                return beanClasses;
             }
          };
       }
-      
+
       public Map<BeanDeploymentArchive, BeanDeployment> visit()
       {
          // Add the impl beans
          visit(implementationBeanDeploymentArchive, managerAwareBeanDeploymentArchives, new HashSet<BeanDeploymentArchive>(), false);
-         
+
          for (BeanDeploymentArchive archvive : deployment.getBeanDeploymentArchives())
          {
             visit(archvive, managerAwareBeanDeploymentArchives, new HashSet<BeanDeploymentArchive>(), true);
          }
          return managerAwareBeanDeploymentArchives;
       }
-      
+
       private BeanDeployment visit(BeanDeploymentArchive beanDeploymentArchive, Map<BeanDeploymentArchive, BeanDeployment> managerAwareBeanDeploymentArchives, Set<BeanDeploymentArchive> seenBeanDeploymentArchives, boolean validate)
       {
          // Check that the required services are specified
@@ -191,13 +191,13 @@
          {
             verifyServices(beanDeploymentArchive.getServices(), environment.getRequiredBeanDeploymentArchiveServices());
          }
-         
+
          // Check the id is not null
          if (beanDeploymentArchive.getId() == null)
          {
             throw new IllegalArgumentException(DEPLOYMENT_ARCHIVE_NULL, beanDeploymentArchive);
          }
-         
+
          BeanDeployment parent = managerAwareBeanDeploymentArchives.get(beanDeploymentArchive);
          if (parent == null)
          {
@@ -219,9 +219,9 @@
          parent.getBeanManager().addAccessibleBeanManager(managerAwareBeanDeploymentArchives.get(implementationBeanDeploymentArchive).getBeanManager());
          return parent;
       }
-      
+
    }
-   
+
    static
    {
       loggerFactory().getLogger(VERSION).info(VersionMessage.VERSION, Names.version(WeldBootstrap.class.getPackage()));
@@ -233,7 +233,7 @@
    private Environment environment;
    private Deployment deployment;
    private DeploymentVisitor deploymentVisitor;
- 
+
    public Bootstrap startContainer(Environment environment, Deployment deployment, BeanStore applicationBeanStore)
    {
       synchronized (this)
@@ -254,61 +254,63 @@
          {
             deployment.getServices().add(ProxyServices.class, new SimpleProxyServices());
          }
-         
+
          verifyServices(deployment.getServices(), environment.getRequiredDeploymentServices());
-         
+
          if (!deployment.getServices().contains(TransactionServices.class))
          {
             log.info(JTA_UNAVAILABLE);
          }
          // TODO Reinstate if we can find a good way to detect.
-//         if (!deployment.getServices().contains(EjbServices.class))
-//         {
-//            log.info("EJB services not available. Session beans will be simple beans, CDI-style injection into non-contextual EJBs, injection of remote EJBs and injection of @EJB in simple beans will not be available");
-//         }
-//         if (!deployment.getServices().contains(JpaInjectionServices.class))
-//         {
-//            log.info("JPA services not available. Injection of @PersistenceContext will not occur. Entity beans will be discovered as simple beans.");
-//         }
-//         if (!deployment.getServices().contains(ResourceInjectionServices.class))
-//         {
-//            log.info("@Resource injection not available.");
-//         }
+         // if (!deployment.getServices().contains(EjbServices.class))
+         // {
+         // log.info("EJB services not available. Session beans will be simple beans, CDI-style injection into non-contextual EJBs, injection of remote EJBs and injection of @EJB in simple beans will not be available");
+         // }
+         // if (!deployment.getServices().contains(JpaInjectionServices.class))
+         // {
+         // log.info("JPA services not available. Injection of @PersistenceContext will not occur. Entity beans will be discovered as simple beans.");
+         // }
+         // if
+         // (!deployment.getServices().contains(ResourceInjectionServices.class))
+         // {
+         // log.info("@Resource injection not available.");
+         // }
          if (applicationBeanStore == null)
          {
             throw new IllegalStateException(BEAN_STORE_MISSING);
          }
-         
+
          this.deployment = deployment;
          ServiceRegistry implementationServices = getImplementationServices(deployment.getServices().get(ResourceLoader.class));
-         
+
          deployment.getServices().addAll(implementationServices.entrySet());
-         
+
          ServiceRegistry deploymentServices = new SimpleServiceRegistry();
          deploymentServices.add(ClassTransformer.class, implementationServices.get(ClassTransformer.class));
          deploymentServices.add(MetaAnnotationStore.class, implementationServices.get(MetaAnnotationStore.class));
          deploymentServices.add(TypeStore.class, implementationServices.get(TypeStore.class));
-         
+
          this.environment = environment;
          this.deploymentManager = BeanManagerImpl.newRootManager("deployment", deploymentServices);
-         
+
          Container.initialize(deploymentManager, ServiceRegistries.unmodifiableServiceRegistry(deployment.getServices()));
          Container.instance().setState(ContainerState.STARTING);
-         
+
          createContexts();
          initializeContexts();
          // Start the application context
          Container.instance().services().get(ContextLifecycle.class).beginApplication(applicationBeanStore);
          new ExtensionBeanDeployerEnvironment(EjbDescriptors.EMPTY, deploymentManager);
          this.deploymentVisitor = new DeploymentVisitor(deploymentManager, environment, deployment);
-         
-         // Read the deployment structure, this will be the physical structure as caused by the presence of beans.xml
+
+         // Read the deployment structure, this will be the physical structure
+         // as caused by the presence of beans.xml
          beanDeployments = deploymentVisitor.visit();
-         
+
          return this;
       }
    }
-   
+
    private ServiceRegistry getImplementationServices(ResourceLoader resourceLoader)
    {
       ServiceRegistry services = new SimpleServiceRegistry();
@@ -318,7 +320,8 @@
       services.add(WSApiAbstraction.class, new WSApiAbstraction(resourceLoader));
       services.add(ServletApiAbstraction.class, new ServletApiAbstraction(resourceLoader));
       // Temporary workaround to provide context for building annotated class
-      // TODO expose AnnotatedClass on SPI and allow container to provide impl of this via ResourceLoader
+      // TODO expose AnnotatedClass on SPI and allow container to provide impl
+      // of this via ResourceLoader
       services.add(Validator.class, new Validator());
       services.add(TypeStore.class, new TypeStore());
       services.add(ClassTransformer.class, new ClassTransformer(services.get(TypeStore.class)));
@@ -329,7 +332,7 @@
       services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint());
       return services;
    }
-   
+
    public BeanManagerImpl getManager(BeanDeploymentArchive beanDeploymentArchive)
    {
       if (beanDeployments.containsKey(beanDeploymentArchive))
@@ -341,7 +344,7 @@
          return null;
       }
    }
-   
+
    public Bootstrap startInitialization()
    {
       synchronized (this)
@@ -350,31 +353,36 @@
          {
             throw new IllegalStateException(MANAGER_NOT_INITIALIZED);
          }
-         
+
          ExtensionBeanDeployer extensionBeanDeployer = new ExtensionBeanDeployer(deploymentManager, deployment, beanDeployments);
          extensionBeanDeployer.addExtensions(deployment.getServices().get(ServiceLoaderFactory.class).load(Extension.class));
          extensionBeanDeployer.deployBeans();
-         
+
          // Add the Deployment BeanManager Bean to the Deployment BeanManager
          deploymentManager.addBean(new BeanManagerBean(deploymentManager));
-         
-         // Re-Read the deployment structure, this will be the physical structure, and will add in BDAs for any extensions outside a physical BDA
+
+         // Re-Read the deployment structure, this will be the physical
+         // structure, and will add in BDAs for any extensions outside a
+         // physical BDA
          beanDeployments = deploymentVisitor.visit();
-         
+
          BeforeBeanDiscoveryImpl.fire(deploymentManager, deployment, beanDeployments);
-         
-         // Re-Read the deployment structure, this will be the physical structure, extensions and any classes added using addAnnotatedType outside the physical BDA
+
+         // Re-Read the deployment structure, this will be the physical
+         // structure, extensions and any classes added using addAnnotatedType
+         // outside the physical BDA
          beanDeployments = deploymentVisitor.visit();
-         
+
       }
       return this;
    }
-   
+
    public Bootstrap deployBeans()
    {
       synchronized (this)
       {
-         // TODO keep a list of new bdas, add them all in, and deploy beans for them, then merge into existing
+         // TODO keep a list of new bdas, add them all in, and deploy beans for
+         // them, then merge into existing
          for (Entry<BeanDeploymentArchive, BeanDeployment> entry : beanDeployments.entrySet())
          {
             entry.getValue().deployBeans(environment);
@@ -384,14 +392,16 @@
          {
             entry.getValue().afterBeanDiscovery(environment);
          }
-         // Re-read the deployment structure, this will be the physical structure, extensions, classes, and any beans added using addBean outside the physical structure
+         // Re-read the deployment structure, this will be the physical
+         // structure, extensions, classes, and any beans added using addBean
+         // outside the physical structure
          beanDeployments = deploymentVisitor.visit();
          Container.instance().putBeanDeployments(beanDeployments);
          Container.instance().setState(ContainerState.INITIALIZED);
       }
       return this;
    }
-   
+
    public Bootstrap validateBeans()
    {
       synchronized (this)
@@ -416,7 +426,7 @@
       }
       return this;
    }
-   
+
    protected void initializeContexts()
    {
       Lifecycle lifecycle = deployment.getServices().get(ContextLifecycle.class);
@@ -427,7 +437,7 @@
       deploymentManager.addContext(lifecycle.getApplicationContext());
       deploymentManager.addContext(lifecycle.getSingletonContext());
    }
-   
+
    protected void createContexts()
    {
       AbstractApplicationContext applicationContext = new ApplicationContext();
@@ -436,35 +446,38 @@
       ConversationContext conversationContext = new ConversationContext();
       RequestContext requestContext = new RequestContext();
       DependentContext dependentContext = new DependentContext();
-      
+
       deployment.getServices().add(ContextLifecycle.class, new ContextLifecycle(applicationContext, singletonContext, sessionContext, conversationContext, requestContext, dependentContext));
    }
-   
+
    public void shutdown()
    {
-      try
+      synchronized (this)
       {
-         Container.instance().services().get(ContextLifecycle.class).endApplication();
          try
          {
-            // Create a fake application context to service this request
-            Container.instance().services().get(ContextLifecycle.class).beginApplication(new HashMapBeanStore());
-            BeforeShutdownImpl.fire(deploymentManager, beanDeployments);
             Container.instance().services().get(ContextLifecycle.class).endApplication();
+            try
+            {
+               // Create a fake application context to service this request
+               Container.instance().services().get(ContextLifecycle.class).beginApplication(new HashMapBeanStore());
+               BeforeShutdownImpl.fire(deploymentManager, beanDeployments);
+               Container.instance().services().get(ContextLifecycle.class).endApplication();
+            }
+            finally
+            {
+
+            }
          }
          finally
          {
-            
+            Container.instance().setState(ContainerState.SHUTDOWN);
+            Container.instance().cleanup();
          }
       }
-      finally
-      {
-         Container.instance().setState(ContainerState.SHUTDOWN);
-         Container.instance().cleanup();
-      }
    }
-   
-   protected static void verifyServices(ServiceRegistry services, Set<Class<? extends Service>> requiredServices) 
+
+   protected static void verifyServices(ServiceRegistry services, Set<Class<? extends Service>> requiredServices)
    {
       for (Class<? extends Service> serviceType : requiredServices)
       {

Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -17,14 +17,12 @@
 
 package org.jboss.weld.injection;
 
+import java.util.List;
+
 import javax.decorator.Decorator;
-import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
-import java.lang.annotation.Annotation;
-import java.util.List;
 
 import org.jboss.weld.introspector.WeldConstructor;
-import org.jboss.weld.manager.BeanManagerImpl;
 
 /**
  * A wrapper on a {@link ConstructorInjectionPoint}, to be used if a proxy subclass is instantiated instead of the

Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -159,7 +159,7 @@
                {
                   parameterType = clazz;
                }
-               WeldParameter<?, T> parameter = WeldParameterImpl.of(new Annotation[0], (Class<Object>) clazz, parameterType, this, i, classTransformer);
+               WeldParameter<?, T> parameter = WeldParameterImpl.of(new Annotation[0], clazz, parameterType, this, i, classTransformer);
                this.parameters.add(parameter);
             }
          }
@@ -185,7 +185,7 @@
                }
             }
          }
-         
+
       }
       this.signature = new ConstructorSignatureImpl(this);
    }
@@ -268,7 +268,7 @@
    public boolean equals(Object other)
    {
 
-      if (super.equals(other) && other instanceof WeldConstructor)
+      if (super.equals(other) && other instanceof WeldConstructor<?>)
       {
          WeldConstructor<?> that = (WeldConstructor<?>) other;
          return this.getJavaMember().equals(that.getJavaMember()) && this.getWeldParameters().equals(that.getWeldParameters());
@@ -276,6 +276,15 @@
       return false;
    }
 
+   @Override
+   public int hashCode()
+   {
+      int hash = 1;
+      hash = hash * 31 + getJavaMember().hashCode();
+      hash = hash * 31 + getWeldParameters().hashCode();
+      return hash;
+   }
+
    /**
     * Gets a string representation of the constructor
     * 
@@ -294,9 +303,9 @@
 
    public List<AnnotatedParameter<T>> getParameters()
    {
-      return Collections.unmodifiableList((List) parameters);
+      return Collections.<AnnotatedParameter<T>> unmodifiableList(parameters);
    }
-   
+
    public boolean isGeneric()
    {
       return getJavaMember().getTypeParameters().length > 0;

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -189,6 +189,12 @@
       }
       return false;
    }
+   
+   @Override
+   public int hashCode()
+   {
+      return elements.hashCode();
+   }
 
    @Override
    public String toString()

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ImmutableArraySet.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ImmutableArraySet.java	2010-06-02 23:05:13 UTC (rev 6391)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ImmutableArraySet.java	2010-06-03 11:46:11 UTC (rev 6392)
@@ -237,6 +237,12 @@
       }
       return false;
    }
+   
+   @Override
+   public int hashCode()
+   {
+      return elements.hashCode();
+   }
 
    @Override
    public String toString()



More information about the weld-commits mailing list