[webbeans-commits] Webbeans SVN: r2389 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: mock and 1 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Apr 10 12:31:17 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-04-10 12:31:17 -0400 (Fri, 10 Apr 2009)
New Revision: 2389

Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
Log:
wire resource beans through to XMLEnvironment

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-04-10 16:19:18 UTC (rev 2388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-04-10 16:31:17 UTC (rev 2389)
@@ -66,6 +66,15 @@
       return this;
    }
    
+   public BeanDeployer addBeans(Iterable<? extends RIBean<?>> beans)
+   {
+      for (RIBean<?> bean : beans)
+      {
+         addBean(bean);
+      }
+      return this;
+   }
+   
    public BeanDeployer addClass(Class<?> clazz)
    {
       if (!clazz.isAnnotation() && !clazz.isEnum())

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-04-10 16:19:18 UTC (rev 2388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java	2009-04-10 16:31:17 UTC (rev 2389)
@@ -28,6 +28,7 @@
 import org.jboss.webbeans.BeanValidator;
 import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.ee.AbstractJavaEEResourceBean;
 import org.jboss.webbeans.bean.standard.EventBean;
 import org.jboss.webbeans.bean.standard.InjectionPointBean;
 import org.jboss.webbeans.bean.standard.InstanceBean;
@@ -161,7 +162,7 @@
     * 
     * @param classes The classes to register as Web Beans
     */
-   protected void registerBeans(Iterable<Class<?>> classes, Collection<AnnotatedClass<?>> xmlClasses, EjbDescriptorCache ejbDescriptors)
+   protected void registerBeans(Iterable<Class<?>> classes, Collection<AnnotatedClass<?>> xmlClasses, Iterable<AbstractJavaEEResourceBean<?>> resourceBeans, EjbDescriptorCache ejbDescriptors)
    {
       BeanDeployer beanDeployer = new BeanDeployer(manager, ejbDescriptors);
       beanDeployer.addClasses(classes);
@@ -178,6 +179,7 @@
          beanDeployer.addClass(NumericConversationIdGenerator.class);
          beanDeployer.addClass(HttpSessionManager.class);
       }
+      beanDeployer.addBeans(resourceBeans);
       beanDeployer.createBeans().deploy();
    }
    
@@ -205,7 +207,7 @@
             ejbDescriptors.addAll(getServices().get(EjbServices.class).discoverEjbs());
          }
          
-         XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices(), ejbDescriptors);
+         XmlEnvironment xmlEnvironmentImpl = new XmlEnvironment(getServices(), ejbDescriptors, manager);
          XmlParser parser = new XmlParser(xmlEnvironmentImpl);
          parser.parse();
           
@@ -215,7 +217,7 @@
             manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
          }
          log.info("Deployment types: " + manager.getEnabledDeploymentTypes());
-         registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(), xmlEnvironmentImpl.getClasses(), ejbDescriptors);
+         registerBeans(getServices().get(WebBeanDiscovery.class).discoverWebBeanClasses(), xmlEnvironmentImpl.getClasses(), xmlEnvironmentImpl.getResourceBeans(), ejbDescriptors);
          manager.fireEvent(manager, new InitializedLiteral());
          log.info("Web Beans initialized. Validating beans.");
          manager.getResolver().resolveInjectionPoints();

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java	2009-04-10 16:19:18 UTC (rev 2388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/mock/MockXmlEnvironment.java	2009-04-10 16:31:17 UTC (rev 2389)
@@ -2,6 +2,7 @@
 
 import java.net.URL;
 
+import org.jboss.webbeans.CurrentManager;
 import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
 import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
 import org.jboss.webbeans.ejb.EjbDescriptorCache;
@@ -24,7 +25,7 @@
    
    public MockXmlEnvironment(Iterable<URL> beansXmlUrls, EjbDescriptorCache ejbDescriptors)
    {
-      super(services, beansXmlUrls, ejbDescriptors);
+      super(services, beansXmlUrls, ejbDescriptors, CurrentManager.rootManager());
    }
    
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java	2009-04-10 16:19:18 UTC (rev 2388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlEnvironment.java	2009-04-10 16:31:17 UTC (rev 2389)
@@ -3,14 +3,17 @@
 import java.lang.annotation.Annotation;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.bean.ee.AbstractJavaEEResourceBean;
 import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
 import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
 import org.jboss.webbeans.ejb.EjbDescriptorCache;
 import org.jboss.webbeans.introspector.AnnotatedAnnotation;
 import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 import org.jboss.webbeans.resources.ClassTransformer;
 import org.jboss.webbeans.resources.spi.ResourceLoader;
 
@@ -23,20 +26,24 @@
    private final List<Class<? extends Annotation>> enabledDeploymentTypes;
    private final Iterable<URL> beansXmlUrls;
    private final EjbDescriptorCache ejbDescriptors;
+   private final Set<AbstractJavaEEResourceBean<?>> resourceBeans;
+   private final ManagerImpl manager;
    
-   public XmlEnvironment(ServiceRegistry serviceRegistry, EjbDescriptorCache ejbDescriptors)
+   public XmlEnvironment(ServiceRegistry serviceRegistry, EjbDescriptorCache ejbDescriptors, ManagerImpl manager)
    {
-      this(serviceRegistry, serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml(), ejbDescriptors);
+      this(serviceRegistry, serviceRegistry.get(WebBeanDiscovery.class).discoverWebBeansXml(), ejbDescriptors, manager);
    }
    
-   protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL> beanXmlUrls, EjbDescriptorCache ejbDescriptors)
+   protected XmlEnvironment(ServiceRegistry serviceRegistry, Iterable<URL> beanXmlUrls, EjbDescriptorCache ejbDescriptors, ManagerImpl manager)
    {
       this.classes = new ArrayList<AnnotatedClass<?>>();
       this.annotations = new ArrayList<AnnotatedAnnotation<?>>();
       this.enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
+      this.resourceBeans = new HashSet<AbstractJavaEEResourceBean<?>>();
       this.serviceRegistry = serviceRegistry;
       this.beansXmlUrls = beanXmlUrls;
       this.ejbDescriptors = ejbDescriptors;
+      this.manager = manager;
    }
    
    public List<AnnotatedClass<?>> getClasses()
@@ -83,4 +90,19 @@
       return serviceRegistry.get(ResourceLoader.class).getResource(filePath);
    }
    
+   public ServiceRegistry getServiceRegistry()
+   {
+      return serviceRegistry;
+   }
+   
+   public Set<AbstractJavaEEResourceBean<?>> getResourceBeans()
+   {
+      return resourceBeans;
+   }
+   
+   public ManagerImpl getManager()
+   {
+      return manager;
+   }
+   
 }




More information about the weld-commits mailing list