[weld-commits] Weld SVN: r6304 - in java-se/trunk/src/main/java/org/jboss/weld/environment/se: discovery and 1 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Tue May 25 09:39:39 EDT 2010


Author: peteroyle
Date: 2010-05-25 09:39:38 -0400 (Tue, 25 May 2010)
New Revision: 6304

Added:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
Removed:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java
Modified:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java
Log:
WELDSE-25: changed customiseDeployment(...) to createDeployment(...)
WELDSE-25, WELDSE-26: Weld now exposes a discoverBeansAndResources(Deployment) method which can be overridden in order to pass a customised set of discovered bean classes and resources to the Weld bootstrap. The old file-based Scanner code is used by default.

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -24,9 +24,8 @@
 import org.jboss.weld.context.api.BeanStore;
 import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
 import org.jboss.weld.environment.se.beans.InstanceManager;
-import org.jboss.weld.environment.se.discovery.SEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.SEWeldDeployment;
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.NewSEWeldDeployment;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
 import org.jboss.weld.environment.se.discovery.URLScanner;
 import org.jboss.weld.environment.se.util.WeldManagerUtils;
 import org.jboss.weld.manager.api.WeldManager;
@@ -50,11 +49,7 @@
 {
 
    private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.weld.bootstrap.WeldBootstrap";
-   private Bootstrap bootstrap;
-   private BeanStore applicationBeanStore;
    private WeldManager manager;
-   private SEWeldDiscovery discovery;
-   private SEBeanDeploymentArchive beanDeploymentArchive;
 
    public Weld()
    {
@@ -62,15 +57,16 @@
 
    /**
     * Boots Weld and creates and returns a WeldContainer instance, through which
-    * beans and events can be accesed.
+    * beans and events can be accessed.
     */
    @PostConstruct
    public WeldContainer initialize()
    {
 
-      this.applicationBeanStore = new ConcurrentHashMapBeanStore();
-      SEWeldDeployment deployment = initDeployment();
+      BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
+      Deployment deployment = createDeployment();
 
+      Bootstrap bootstrap = null;
       try
       {
          bootstrap = (Bootstrap) deployment.getServices().get(ResourceLoader.class).classForName(BOOTSTRAP_IMPL_CLASS_NAME).newInstance();
@@ -82,16 +78,12 @@
          throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
       }
 
-      final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
-      URLScanner scanner = new URLScanner(resourceLoader, discovery);
-      configureURLHandlers(scanner, resourceLoader, discovery);
-      scanner.scanResources(new String[]
-              {
-                 "META-INF/beans.xml"
-              });
+      BeanDeploymentArchive discovery = discoverBeansAndResources(deployment);
+      // transfer discovered classes and resources to the deployment in a single BeanDeploymentArchive
+      deployment.getBeanDeploymentArchives().add(discovery);
 
-      bootstrap.startContainer(Environments.SE, deployment, this.applicationBeanStore);
-      final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().get(0);
+      bootstrap.startContainer(Environments.SE, deployment, applicationBeanStore);
+      final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().iterator().next();
       this.manager = bootstrap.getManager(mainBeanDepArch);
       bootstrap.startInitialization();
       bootstrap.deployBeans();
@@ -105,53 +97,41 @@
 
    }
 
-   /**
-    * Clients can subclass and override this method to add custom URL handlers
-    * before weld boots up. For example, to set a custom URL handler for OSGi bundles,
-    * you would subclass Weld like so:
-    * <code>
-    * public class MyWeld extends Weld {
-    *    @Override
-    *    public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
-    *       scanner.setURLHandler("bundle", new MyOSGiURLHandler(resourceLoader, discovery));
-    *    }
-    * }
-    * </code>
+   /*
+    * Users can subclass and override this method to customise the classes and
+    * resources that Weld finds when it boots up. 
     */
-   public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
+   protected BeanDeploymentArchive discoverBeansAndResources(Deployment deployment)
    {
+      WeldSEBeanDeploymentArchive discovery = new WeldSEBeanDeploymentArchive("weld-se-main-archive");
+      final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
+      URLScanner scanner = new URLScanner(resourceLoader, discovery);
+      scanner.scanResources(new String[]
+              {
+                 "META-INF/beans.xml"
+              });
+      return discovery;
    }
 
-   private SEWeldDeployment initDeployment()
-   {
-      discovery = new SEWeldDiscovery();
-      beanDeploymentArchive = new SEBeanDeploymentArchive(discovery);
-      SEWeldDeployment deployment = new SEWeldDeployment(beanDeploymentArchive);
-      configureDeployment(deployment);
-      // configure a ResourceLoader if one hasn't been already
-      if (deployment.getServices().get(ResourceLoader.class) == null)
-      {
-         deployment.getServices().add(ResourceLoader.class, new DefaultResourceLoader());
-      }
-      return deployment;
-   }
-
    /**
-    * Clients can subclass and override this method to customise the deployment
+    * Users can subclass and override this method to customise the deployment
     * before weld boots up. For example, to add a custom ResourceLoader, you would
     * subclass Weld like so:
     * <code>
     * public class MyWeld extends Weld {
     *    @Override
-    *    protected void configureDeployment(Deployment deployment) {
+    *    protected void createDeployment() {
+    *       Deployment myDeployment = new MyDeployment();
     *       deployment.getServices().add(ResourceLoader.class, new OSGIResourceLoader());
     *    }
     * }
     * </code>
-    * @param deployment
     */
-   protected void configureDeployment(Deployment deployment)
+   private Deployment createDeployment()
    {
+      NewSEWeldDeployment deployment = new NewSEWeldDeployment();
+      deployment.getServices().add(ResourceLoader.class, new DefaultResourceLoader());
+      return deployment;
    }
 
    /**

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -26,9 +26,9 @@
 {
 
    private final ResourceLoader resourceLoader;
-   private final SEWeldDiscovery weldDiscovery;
+   private final WeldSEBeanDeploymentArchive weldDiscovery;
 
-   public AbstractScanner(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+   public AbstractScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
    {
       this.resourceLoader = resourceLoader;
       this.weldDiscovery = webBeanDiscovery;
@@ -43,7 +43,7 @@
    /**
     * @return the webBeanDiscovery
     */
-   public SEWeldDiscovery getWebBeanDiscovery()
+   public WeldSEBeanDeploymentArchive getWebBeanDiscovery()
    {
       return weldDiscovery;
    }

Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -0,0 +1,68 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.environment.se.discovery;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * Weld Deployment for Java SE environment.
+ * 
+ * @author Peter Royle
+ */
+public class NewSEWeldDeployment implements Deployment
+{
+
+   final List<BeanDeploymentArchive> beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+   final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
+
+   public NewSEWeldDeployment()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    * 
+    * @return A collection containing the singular logical BeanDeploymentArchive
+    *         consisting of all Bean classes and beans.xml descriptors in the
+    *         current classpath.
+    */
+   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return beanDeploymentArchives;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+   {
+      // TODO (PR) (WELDSE-26): This is just a hack. What do we really need to do here?
+      return beanDeploymentArchives.get(0);
+   }
+
+   public ServiceRegistry getServices()
+   {
+      // TODO (PR) (WELDSE-26): Do I need to aggregate all services from all bean archives?
+      return serviceRegistry;
+   }
+
+}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,96 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.environment.se.discovery;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * A Java SE implementation of BeanDeploymentArchive. It is essentially an
- * adaptor from the SEWeldDiscovery to the BeanDeploymentArchive interface.
- * It returns, in a single logical archive, all Bean classes and beans.xml
- * descriptors. It always returns an empty collection of EJBs.
- * 
- * @author Peter Royle
- */
-public class SEBeanDeploymentArchive implements BeanDeploymentArchive
-{
-   private final SEWeldDiscovery wbDiscovery;
-   private final ServiceRegistry serviceRegistry;
-
-   /**
-    * @param deployment Used to gain access to the ResourceLoader, in case one is defined.
-    */
-   public SEBeanDeploymentArchive(SEWeldDiscovery discovery)
-   {
-      this.wbDiscovery = discovery;
-      {
-      };
-      this.serviceRegistry = new SimpleServiceRegistry();
-   }
-
-   /**
-    * @return a collection of all Bean classes on the classpath.
-    */
-   public Collection<Class<?>> getBeanClasses()
-   {
-      return wbDiscovery.getWbClasses();
-   }
-
-   /**
-    * @return an empty collection, since this instance is the only logical
-    *         archive for the current SE classloader.
-    */
-   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return Collections.EMPTY_LIST;
-   }
-
-   /**
-    * @return all beans.xml decriptors found on the classpath.
-    */
-   public Collection<URL> getBeansXml()
-   {
-      return wbDiscovery.discoverWeldXml();
-   }
-
-   /**
-    * @return an empty collection since there are no EJBs in Java SE.
-    */
-   public Collection<EjbDescriptor<?>> getEjbs()
-   {
-      return Collections.EMPTY_SET;
-   }
-
-   public ServiceRegistry getServices()
-   {
-      return this.serviceRegistry;
-   }
-   
-   public String getId()
-   {
-      return "se-module";
-   }
-
-}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,69 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.environment.se.discovery;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-
-/**
- * Weld Deployment for Java SE environment.
- * 
- * @author Peter Royle
- */
-public class SEWeldDeployment implements Deployment
-{
-   private final SEBeanDeploymentArchive beanDeploymentArchive;
-   private final List<BeanDeploymentArchive> archInCollection;
-
-   public SEWeldDeployment(SEBeanDeploymentArchive beanDeploymentArchive)
-   {
-      this.beanDeploymentArchive = beanDeploymentArchive;
-      this.archInCollection = new ArrayList<BeanDeploymentArchive>(1);
-      this.archInCollection.add(this.beanDeploymentArchive);
-   }
-
-   /**
-    * {@inheritDoc}
-    * 
-    * @return A collection containing the singular logical BeanDeploymentArchive
-    *         consisting of all Bean classes and beans.xml descriptors in the
-    *         current classpath.
-    */
-   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return this.archInCollection;
-   }
-
-   /**
-    * {@inheritDoc}
-    * 
-    * @return The singular logical BeanDeploymentArchive consisting of all which
-    *         contains all Beans classes.
-    */
-   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
-   {
-      return this.beanDeploymentArchive;
-   }
-
-   public ServiceRegistry getServices()
-   {
-      return this.beanDeploymentArchive.getServices();
-   }
-}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,66 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
- * contributors by the @authors tag. See the copyright.txt in the
- * distribution for a full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.weld.environment.se.discovery;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * The means by which beans are discovered on the classpath. This will only
- * discover simple beans - there is no EJB/Servlet/JPA integration.
- * 
- * @author Peter Royle
- * @author Pete Muir
- * @author Ales Justin
- */
-public class SEWeldDiscovery
-{
-
-   private final Set<Class<?>> wbClasses;
-   private final Set<URL> wbUrls;
-
-   public SEWeldDiscovery()
-   {
-      this.wbClasses = new HashSet<Class<?>>();
-      this.wbUrls = new HashSet<URL>();
-   }
-
-   public Iterable<Class<?>> discoverWeldClasses()
-   {
-      return Collections.unmodifiableSet(wbClasses);
-   }
-
-   public Collection<URL> discoverWeldXml()
-   {
-      return Collections.unmodifiableSet(wbUrls);
-   }
-
-   public Set<Class<?>> getWbClasses()
-   {
-      return wbClasses;
-   }
-
-   public Set<URL> getWbUrls()
-   {
-      return wbUrls;
-   }
-
-}

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -53,7 +53,7 @@
    private final Map<String, URLHandler> urlHandlers = new HashMap<String, URLHandler>();
    private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
 
-   public URLScanner(ResourceLoader resourceLoader, SEWeldDiscovery weldDiscovery)
+   public URLScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive weldDiscovery)
    {
       super(resourceLoader, weldDiscovery);
       URLHandler fileSysHandler = new FileSystemURLHandler(resourceLoader, weldDiscovery);

Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java (from rev 6301, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -0,0 +1,102 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.weld.environment.se.discovery;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * A deployment archive to registering classes and resources found in bean
+ * archives on the classpath.
+ * 
+ * @author Peter Royle
+ * @author Pete Muir
+ * @author Ales Justin
+ */
+public class WeldSEBeanDeploymentArchive implements BeanDeploymentArchive
+{
+
+   private final Collection<Class<?>> weldClasses;
+   private final Collection<URL> weldUrls;
+   private final ServiceRegistry serviceRegistry;
+   private final List<BeanDeploymentArchive> beanDeploymentArchives;
+   private String id;
+
+   public WeldSEBeanDeploymentArchive(String id)
+   {
+      this.id = id;
+      this.weldClasses = new HashSet<Class<?>>();
+      this.weldUrls = new HashSet<URL>();
+      this.serviceRegistry = new SimpleServiceRegistry();
+      this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+   }
+
+   /**
+    * This is an alias for getBeansXml(), to make adding resources other than
+    * beans.xml more natural.
+    */
+   public Collection<URL> getUrls()
+   {
+      return weldUrls;
+   }
+
+   public Collection<Class<?>> getBeanClasses()
+   {
+      return weldClasses;
+   }
+
+   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return this.beanDeploymentArchives;
+   }
+
+   public Collection<URL> getBeansXml()
+   {
+      return weldUrls;
+   }
+
+   public Collection<EjbDescriptor<?>> getEjbs()
+   {
+      return Collections.EMPTY_SET;
+   }
+
+   public String getId()
+   {
+      return this.id;
+   }
+
+   /**
+    * @param id the id to set
+    */
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   public ServiceRegistry getServices()
+   {
+      return this.serviceRegistry;
+   }
+}

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -16,7 +16,7 @@
  */
 package org.jboss.weld.environment.se.discovery.handlers;
 
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
 import org.jboss.weld.resources.spi.ResourceLoader;
 
 /**
@@ -27,9 +27,9 @@
 {
 
    private final ResourceLoader resourceLoader;
-   private final SEWeldDiscovery weldDiscovery;
+   private final WeldSEBeanDeploymentArchive weldDiscovery;
 
-   public AbstractURLHandler(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+   public AbstractURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
    {
       this.resourceLoader = resourceLoader;
       this.weldDiscovery = webBeanDiscovery;
@@ -46,7 +46,7 @@
    /**
     * @return the webBeanDiscovery
     */
-   public SEWeldDiscovery getWeldDiscovery()
+   public WeldSEBeanDeploymentArchive getWeldDiscovery()
    {
       return weldDiscovery;
    }

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java	2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java	2010-05-25 13:39:38 UTC (rev 6304)
@@ -26,7 +26,7 @@
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
 import org.jboss.weld.environment.se.discovery.Scanner;
 import org.jboss.weld.resources.spi.ResourceLoader;
 import org.slf4j.Logger;
@@ -45,7 +45,7 @@
 
    private static final Logger log = LoggerFactory.getLogger(FileSystemURLHandler.class);
 
-   public FileSystemURLHandler(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+   public FileSystemURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
    {
       super(resourceLoader, webBeanDiscovery);
    }
@@ -150,14 +150,14 @@
          String className = filenameToClassname(name);
          try
          {
-            getWeldDiscovery().getWbClasses().add(getResourceLoader().classForName(className));
+            getWeldDiscovery().getBeanClasses().add(getResourceLoader().classForName(className));
          } catch (NoClassDefFoundError e)
          {
             log.error("Error loading " + name, e);
          }
       } else if (name.endsWith("beans.xml"))
       {
-         getWeldDiscovery().getWbUrls().add(url);
+         getWeldDiscovery().getUrls().add(url);
       }
    }
 



More information about the weld-commits mailing list