[weld-commits] Weld SVN: r6308 - 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 18:03:32 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-05-25 18:03:31 -0400 (Tue, 25 May 2010)
New Revision: 6308

Added:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java
Removed:
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/exceptions/
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/url/FileSystemURLHandler.java
   java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java
Log:
Stop exposing the Scanner API at all, javadoc, add helper classes for creating BDAs and Deployments, cleanup now that we don't expose the scanner api

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 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -19,7 +19,6 @@
 import java.lang.annotation.Annotation;
 import java.util.Arrays;
 
-import javax.annotation.PostConstruct;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.UnsatisfiedResolutionException;
 import javax.enterprise.inject.spi.Bean;
@@ -27,30 +26,35 @@
 
 import org.jboss.weld.bootstrap.api.Bootstrap;
 import org.jboss.weld.bootstrap.api.Environments;
+import org.jboss.weld.bootstrap.spi.Deployment;
 import org.jboss.weld.context.api.BeanStore;
 import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.weld.environment.se.discovery.WeldSEDeployment;
-import org.jboss.weld.environment.se.discovery.url.URLScanner;
 import org.jboss.weld.environment.se.discovery.url.WeldSEResourceLoader;
+import org.jboss.weld.environment.se.discovery.url.WeldSEUrlDeployment;
 import org.jboss.weld.resources.spi.ResourceLoader;
 
 /**
- * An alternative means of booting WeldContainer form an arbitrary main method
- * within an SE application, <em>without</em> using the built-in
- * ContainerInitialized event. Typical usage of this API looks like this: <code>
+ * <p>
+ * The preferred method of booting Weld SE.
+ * </p>
+ * 
+ * <p>
+ * Typical usage of this API looks like this:
+ * </p>
+ * 
+ * <pre>
  * WeldContainer weld = new Weld().initialize();
  * weld.instance().select(Foo.class).get();
  * weld.event().select(Bar.class).fire(new Bar());
  * weld.shutdown();
- * </code>
+ * </pre>
  * 
  * @author Peter Royle
+ * @author Pete Muir
  */
 public class Weld
 {
 
-   protected static final String[] RESOURCES = { "META-INF/beans.xml" };
-
    private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.weld.bootstrap.WeldBootstrap";
 
    private ShutdownManager shutdownManager;
@@ -59,12 +63,11 @@
     * Boots Weld and creates and returns a WeldContainer instance, through which
     * beans and events can be accessed.
     */
-   @PostConstruct
    public WeldContainer initialize()
    {
 
       BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
-      WeldSEDeployment deployment = createDeployment();
+      Deployment deployment = createDeployment();
 
       Bootstrap bootstrap = null;
       try
@@ -80,13 +83,9 @@
          throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
       }
 
-      
-      // Kick off the scan
-      deployment.getScanner().scan(deployment.getServices().get(ResourceLoader.class));
-      
       // Set up the container
       bootstrap.startContainer(Environments.SE, deployment, applicationBeanStore);
-      
+
       // Start the container
       bootstrap.startInitialization();
       bootstrap.deployBeans();
@@ -101,23 +100,60 @@
    }
 
    /**
-    * 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 {
+    * <p>
+    * Extensions to Weld SE 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:
+    * </p>
     * 
-    * @Override protected WeldSEDeployment createDeployment() { WeldSEDeployment
-    *           myDeployment = super.createDeployment();
-    *           deployment.getServices().add(ResourceLoader.class, new
-    *           OSGIResourceLoader()); } } </code>
+    * <pre>
+    * public class MyWeld extends Weld
+    * {
+    *    protected Deployment createDeployment()
+    *    {
+    *       Deployment deployment = super.createDeployment();
+    *       deployment.getServices().add(ResourceLoader.class, new MyResourceLoader());
+    *       return deployment;
+    *    }
+    * }
+    *</pre>
+    * 
+    * <p>
+    * This could then be used as normal:
+    * </p>
+    * 
+    * <pre>
+    * WeldContainer container = new MyWeld().initialize();
+    * </pre>
+    * 
     */
-   protected WeldSEDeployment createDeployment()
+   protected Deployment createDeployment()
    {
-      WeldSEDeployment deployment = new WeldSEDeployment(new URLScanner(RESOURCES));
-      deployment.getServices().add(ResourceLoader.class, new WeldSEResourceLoader());
-      return deployment;
+      return new WeldSEUrlDeployment(new WeldSEResourceLoader());
    }
-   
+
+   /**
+    * Utility method allowing managed instances of beans to provide entry points
+    * for non-managed beans (such as {@link WeldContainer}). Should only called
+    * once Weld has finished booting.
+    * 
+    * @param manager the BeanManager to use to access the managed instance
+    * @param type the type of the Bean
+    * @param bindings the bean's qualifiers
+    * @return a managed instance of the bean
+    * @throws IllegalArgumentException if the given type represents a type
+    *            variable
+    * @throws IllegalArgumentException if two instances of the same qualifier
+    *            type are given
+    * @throws IllegalArgumentException if an instance of an annotation that is
+    *            not a qualifier type is given
+    * @throws UnsatisfiedResolutionException if no beans can be resolved * @throws
+    *            AmbiguousResolutionException if the ambiguous dependency
+    *            resolution rules fail
+    * @throws IllegalArgumentException if the given type is not a bean type of
+    *            the given bean
+    * 
+    */
    protected <T> T getInstanceByType(BeanManager manager, Class<T> type, Annotation... bindings)
    {
       final Bean<?> bean = manager.resolve(manager.getBeans(type));

Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,51 @@
+package org.jboss.weld.environment.se.discovery;
+
+import java.util.Collection;
+import java.util.Collections;
+
+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;
+
+/**
+ * Implements the basic requirements of a {@link BeanDeploymentArchive} (bean
+ * archive id and service registry).
+ * 
+ * Suitable for extension by those who need to build custom
+ * {@link BeanDeploymentArchive} implementations.
+ * 
+ * @see MutableBeanDeploymentArchive
+ * @see ImmutableBeanDeploymentArchive
+ * 
+ * @author Pete Muir
+ * 
+ */
+public abstract class AbstractWeldSEBeanDeploymentArchive implements BeanDeploymentArchive
+{
+
+   private final ServiceRegistry serviceRegistry;
+   private final String id;
+
+   public AbstractWeldSEBeanDeploymentArchive(String id)
+   {
+      this.id = id;
+      this.serviceRegistry = new SimpleServiceRegistry();
+   }
+
+   public Collection<EjbDescriptor<?>> getEjbs()
+   {
+      return Collections.emptyList();
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public ServiceRegistry getServices()
+   {
+      return serviceRegistry;
+   }
+
+}
\ No newline at end of file


Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,34 @@
+package org.jboss.weld.environment.se.discovery;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * Implements the basic requirements of a {@link Deployment}. Provides a service
+ * registry.
+ * 
+ * Suitable for extension by those who need to build custom {@link Deployment}
+ * implementations.
+ * 
+ * @author Pete Muir
+ * 
+ */
+public abstract class AbstractWeldSEDeployment implements Deployment
+{
+
+   public static final String[] RESOURCES = { "META-INF/beans.xml" };
+
+   private final ServiceRegistry serviceRegistry;
+
+   public AbstractWeldSEDeployment()
+   {
+      this.serviceRegistry = new SimpleServiceRegistry();
+   }
+
+   public ServiceRegistry getServices()
+   {
+      return serviceRegistry;
+   }
+
+}
\ No newline at end of file


Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,75 @@
+/**
+ * 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.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * An immutable implementation of {@link BeanDeploymentArchive} which must have
+ * classes and beans.xml resources added to it via
+ * {@link ImmutableBeanDeploymentArchive#ImmutableBeanDeploymentArchive(String, Collection, Collection, List)}
+ * or
+ * {@link ImmutableBeanDeploymentArchive#ImmutableBeanDeploymentArchive(String, Collection, Collection)}
+ * 
+ * See {@link Deployment} for more detailed information on creating deployment
+ * structures.
+ * 
+ * @author Pete Muir
+ * 
+ */
+public class ImmutableBeanDeploymentArchive extends AbstractWeldSEBeanDeploymentArchive
+{
+
+   private final Collection<Class<?>> beanClasses;
+   private final Collection<URL> beansXml;
+   private final Collection<BeanDeploymentArchive> beanDeploymentArchives;
+
+   public ImmutableBeanDeploymentArchive(String id, Collection<Class<?>> beanClasses, Collection<URL> beansXml, Collection<BeanDeploymentArchive> beanDeploymentArchives)
+   {
+      super(id);
+      this.beanClasses = beanClasses;
+      this.beansXml = beansXml;
+      this.beanDeploymentArchives = beanDeploymentArchives;
+   }
+
+   public ImmutableBeanDeploymentArchive(String id, Collection<Class<?>> beanClasses, Collection<URL> beansXml)
+   {
+      this(id, beanClasses, beansXml, new ArrayList<BeanDeploymentArchive>());
+   }
+
+   public Collection<Class<?>> getBeanClasses()
+   {
+      return Collections.unmodifiableCollection(beanClasses);
+   }
+
+   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return Collections.unmodifiableCollection(beanDeploymentArchives);
+   }
+
+   public Collection<URL> getBeansXml()
+   {
+      return Collections.unmodifiableCollection(beansXml);
+   }
+}


Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java (from rev 6306, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,71 @@
+/**
+ * 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.HashSet;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * A mutable implementation of {@link BeanDeploymentArchive} which can have
+ * classes and beans.xml resources added to it by calling
+ * <code>getBeanClasses.add()</code> and <code>getBeansXml().add()</code>
+ * respectively.
+ * 
+ * If you are building a complex deployment structure, you can also associate
+ * accessible {@link BeanDeploymentArchive}s by calling
+ * <code>getBeanDeploymentArchives().add()</code>. See {@link Deployment} for
+ * more detailed information on creating deployment structures.
+ * 
+ * @author Pete Muir
+ * 
+ */
+public class MutableBeanDeploymentArchive extends AbstractWeldSEBeanDeploymentArchive
+{
+
+   private final Collection<Class<?>> beanClasses;
+   private final Collection<URL> beansXml;
+   private final List<BeanDeploymentArchive> beanDeploymentArchives;
+
+   public MutableBeanDeploymentArchive(String id)
+   {
+      super(id);
+      this.beanClasses = new HashSet<Class<?>>();
+      this.beansXml = new HashSet<URL>();
+      this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+   }
+
+   public Collection<Class<?>> getBeanClasses()
+   {
+      return beanClasses;
+   }
+
+   public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return beanDeploymentArchives;
+   }
+
+   public Collection<URL> getBeansXml()
+   {
+      return beansXml;
+   }
+}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java	2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,46 +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.List;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-import org.jboss.weld.resources.spi.ResourceLoader;
-
-/**
- * The Scanner is used to find resources to be processed by Weld SE
- * 
- * @author Pete Muir
- * 
- */
-public interface Scanner
-{
-
-   /**
-    * Scan for structures which should be deployed by Weld. For example,
-    * scanning for META-INF/beans.xml should return a graph of
-    * {@link BeanDeploymentArchive}s, representing their accessibility. For more
-    * on deployment structures see {@link Deployment}. 
-    */
-   public void scan(ResourceLoader resourceLoader);   
-
-   public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz);
-
-   public List<BeanDeploymentArchive> getBeanDeploymentArchives();
-
-}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java	2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,95 +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.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 final 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;
-   }
-
-   public ServiceRegistry getServices()
-   {
-      return this.serviceRegistry;
-   }
-}

Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java	2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,70 +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.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 WeldSEDeployment implements Deployment
-{
-
-   public static final String[] RESOURCES = { "META-INF/beans.xml" };
-
-   private final ServiceRegistry serviceRegistry;
-   private final Scanner scanner;
-
-   public WeldSEDeployment(Scanner scanner)
-   {
-      this.serviceRegistry = new SimpleServiceRegistry();
-      this.scanner = scanner;
-   }
-   
-   public Scanner getScanner()
-   {
-      return scanner;
-   }
-
-   /* 
-    * Returns collection containing the singular logical BeanDeploymentArchive
-    * consisting of all Bean classes and beans.xml descriptors in the current
-    * classpath.
-    */
-   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return scanner.getBeanDeploymentArchives();
-   }
-
-   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
-   {
-      return scanner.getBeanDeploymentArchive(beanClass);
-   }
-
-   public ServiceRegistry getServices()
-   {
-      return serviceRegistry;
-   }
-
-}

Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java (from rev 6305, java-se/trunk/src/main/java/org/jboss/weld/environment/se/exceptions/ClasspathScanningException.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,38 @@
+/**
+ * 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.url;
+
+/**
+ * @author Peter Royle
+ */
+public class ClasspathScanningException extends RuntimeException {
+
+    /**
+     * Creates a new instance of <code>ClasspathScanningException</code> without detail message.
+     */
+    public ClasspathScanningException() {
+    }
+
+
+    /**
+     * Constructs an instance of <code>ClasspathScanningException</code> with the specified detail message.
+     * @param msg the detail message.
+     */
+    public ClasspathScanningException(String msg) {
+        super(msg);
+    }
+}

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java	2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -26,7 +26,7 @@
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
+import org.jboss.weld.environment.se.discovery.MutableBeanDeploymentArchive;
 import org.jboss.weld.resources.spi.ResourceLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -48,7 +48,7 @@
       this.resourceLoader = resourceLoader;
    }
 
-   public void handle(Collection<String> paths, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+   public void handle(Collection<String> paths, MutableBeanDeploymentArchive beanDeploymentArchive)
    {
       for (String urlPath : paths)
       {
@@ -82,7 +82,7 @@
       }
    }
 
-   private void handleArchiveByFile(File file, WeldSEBeanDeploymentArchive beanDeploymentArchive) throws IOException
+   private void handleArchiveByFile(File file, MutableBeanDeploymentArchive beanDeploymentArchive) throws IOException
    {
       try
       {
@@ -105,12 +105,12 @@
       }
    }
 
-   protected void handleDirectory(File file, String path, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+   protected void handleDirectory(File file, String path, MutableBeanDeploymentArchive beanDeploymentArchive)
    {
       handleDirectory(file, path, new File[0], beanDeploymentArchive);
    }
 
-   private void handleDirectory(File file, String path, File[] excludedDirectories, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+   private void handleDirectory(File file, String path, File[] excludedDirectories, MutableBeanDeploymentArchive beanDeploymentArchive)
    {
       for (File excludedDirectory : excludedDirectories)
       {
@@ -146,7 +146,7 @@
       }
    }
 
-   protected void handle(String name, URL url, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+   protected void handle(String name, URL url, MutableBeanDeploymentArchive beanDeploymentArchive)
    {
       if (name.endsWith(".class"))
       {
@@ -162,7 +162,7 @@
       }
       else if (name.endsWith("beans.xml"))
       {
-         beanDeploymentArchive.getUrls().add(url);
+         beanDeploymentArchive.getBeansXml().add(url);
       }
    }
 

Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java	2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -23,13 +23,9 @@
 import java.net.URLDecoder;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
 
 import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.Scanner;
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.exceptions.ClasspathScanningException;
+import org.jboss.weld.environment.se.discovery.MutableBeanDeploymentArchive;
 import org.jboss.weld.resources.spi.ResourceLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,22 +40,23 @@
  * @author Peter Royle
  * 
  */
-public class URLScanner implements Scanner
+public class URLScanner
 {
 
    private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
-   private final WeldSEBeanDeploymentArchive beanDeploymentArchive;
    private final String[] resources;
+   private final ResourceLoader resourceLoader;
 
-   public URLScanner(String... resources)
+   public URLScanner(ResourceLoader resourceLoader, String... resources)
    {
-      this.beanDeploymentArchive = new WeldSEBeanDeploymentArchive("weld-se");
       this.resources = resources;
+      this.resourceLoader = resourceLoader;
    }
 
-   public void scan(ResourceLoader resourceLoader)
+   public BeanDeploymentArchive scan()
    {
       FileSystemURLHandler handler = new FileSystemURLHandler(resourceLoader);
+      MutableBeanDeploymentArchive beanDeploymentArchive = new MutableBeanDeploymentArchive("classpath");
       Collection<String> paths = new ArrayList<String>();
       for (String resourceName : resources)
       {
@@ -115,15 +112,7 @@
          }
          handler.handle(paths, beanDeploymentArchive);
       }
-   }
-   
-   public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz)
-   {
       return beanDeploymentArchive;
    }
    
-   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
-   {
-      return Collections.<BeanDeploymentArchive>singletonList(beanDeploymentArchive);
-   }
 }

Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java (from rev 6306, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java	                        (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java	2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,52 @@
+/**
+ * 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.url;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.environment.se.discovery.AbstractWeldSEDeployment;
+import org.jboss.weld.resources.spi.ResourceLoader;
+
+/**
+ * Weld Deployment for Java SE environment.
+ * 
+ * @author Peter Royle
+ */
+public class WeldSEUrlDeployment extends AbstractWeldSEDeployment
+{ 
+
+   private final BeanDeploymentArchive beanDeploymentArchive;
+   
+   public WeldSEUrlDeployment(ResourceLoader resourceLoader)
+   {
+      getServices().add(ResourceLoader.class, resourceLoader);
+      this.beanDeploymentArchive = new URLScanner(resourceLoader, RESOURCES).scan();
+   }
+
+   public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+   {
+      return Collections.singletonList(beanDeploymentArchive);
+   }
+
+   public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+   {
+      return beanDeploymentArchive;
+   }
+
+}



More information about the weld-commits mailing list