[webbeans-commits] Webbeans SVN: r3129 - examples/trunk/se/numberguess/src/main/java/org/jboss/webbeans/environment/se/example/numberguess and 6 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jul 22 08:50:09 EDT 2009


Author: peteroyle
Date: 2009-07-22 08:50:09 -0400 (Wed, 22 Jul 2009)
New Revision: 3129

Added:
   extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java
   extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java
Modified:
   examples/trunk/se/hello-world/src/main/java/org/jboss/webbeans/environment/se/example/simple/HelloWorld.java
   examples/trunk/se/numberguess/src/main/java/org/jboss/webbeans/environment/se/example/numberguess/NumberGuessFrame.java
   extensions/trunk/se/pom.xml
   extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
   extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/WebBeansManagerUtils.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java
   ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/Deployment.java
   ri/trunk/version-matrix/pom.xml
Log:
- Introduced Deployment service by wrapping the existing SEWebBeanDiscovery class. - Update getInstanceByType utility method to include the required CreationalContext. - Add the jta runtime dependency (needs addressing) - Set webbeans-se version to 1.0.0-SNAPSHOT in version matrix

Modified: examples/trunk/se/hello-world/src/main/java/org/jboss/webbeans/environment/se/example/simple/HelloWorld.java
===================================================================
--- examples/trunk/se/hello-world/src/main/java/org/jboss/webbeans/environment/se/example/simple/HelloWorld.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ examples/trunk/se/hello-world/src/main/java/org/jboss/webbeans/environment/se/example/simple/HelloWorld.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -16,9 +16,9 @@
  */
 package org.jboss.webbeans.environment.se.example.simple;
 
+import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.event.Observes;
 
 /**
  * @author Peter Royle

Modified: examples/trunk/se/numberguess/src/main/java/org/jboss/webbeans/environment/se/example/numberguess/NumberGuessFrame.java
===================================================================
--- examples/trunk/se/numberguess/src/main/java/org/jboss/webbeans/environment/se/example/numberguess/NumberGuessFrame.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ examples/trunk/se/numberguess/src/main/java/org/jboss/webbeans/environment/se/example/numberguess/NumberGuessFrame.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -18,9 +18,9 @@
 
 import java.awt.CardLayout;
 
+import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Current;
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.event.Observes;
 
 /**
  * Swing-based number guess example, main application frame.

Modified: extensions/trunk/se/pom.xml
===================================================================
--- extensions/trunk/se/pom.xml	2009-07-22 12:49:54 UTC (rev 3128)
+++ extensions/trunk/se/pom.xml	2009-07-22 12:50:09 UTC (rev 3129)
@@ -8,7 +8,6 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>org.jboss.webbeans</groupId>
     <artifactId>webbeans-se</artifactId>
-    <version>1.0.0-SNAPSHOT</version>
     <packaging>jar</packaging>
     <name>Web Beans SE Module</name>
     <url>http://maven.apache.org</url>
@@ -65,15 +64,18 @@
         <dependency>
             <groupId>org.jboss.webbeans</groupId>
             <artifactId>webbeans-core</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>javax.transaction</groupId>
+            <artifactId>jta</artifactId>
+        </dependency>
     </dependencies>
-	
+
     <scm>
         <connection>scm:svn:http://anonsvn.jboss.org/repos/webbeans/extensions</connection>
         <developerConnection>scm:svn:https://svn.jboss.org/repos/webbeans/extensions</developerConnection>
         <url>http://fisheye.jboss.org/browse/WebBeans/extensions</url>
     </scm>
+</project>
 
-</project>

Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/StartMain.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -20,10 +20,10 @@
 
 import org.jboss.webbeans.bootstrap.api.Bootstrap;
 import org.jboss.webbeans.bootstrap.api.Environments;
-import org.jboss.webbeans.bootstrap.spi.WebBeanDiscovery;
+import org.jboss.webbeans.bootstrap.spi.Deployment;
 import org.jboss.webbeans.context.api.BeanStore;
 import org.jboss.webbeans.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.webbeans.environment.se.discovery.SEWebBeanDiscovery;
+import org.jboss.webbeans.environment.se.discovery.SEWebBeansDeployment;
 import org.jboss.webbeans.environment.se.util.Reflections;
 import org.jboss.webbeans.environment.se.util.WebBeansManagerUtils;
 import org.jboss.webbeans.manager.api.WebBeansManager;
@@ -60,7 +60,7 @@
     public BeanManager go()
     {
         bootstrap.setEnvironment(Environments.SE);
-        bootstrap.getServices().add(WebBeanDiscovery.class, new SEWebBeanDiscovery() {});
+        bootstrap.getServices().add(Deployment.class, new SEWebBeansDeployment() {});
         bootstrap.setApplicationContext(applicationBeanStore);
         bootstrap.initialize();
         this.manager = bootstrap.getManager();

Added: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java	                        (rev 0)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEBeanDeploymentArchive.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.environment.se.discovery;
+
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.ejb.spi.EjbDescriptor;
+
+/**
+ * A Java SE implementation of BeanDeploymentArchive. It is essentially an
+ * adaptor from the SEWebBeanDiscovery 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 SEWebBeanDiscovery wbDiscovery;
+
+    public SEBeanDeploymentArchive()
+    {
+        wbDiscovery = new SEWebBeanDiscovery() {};
+    }
+
+    /**
+     * @return a collection of all Bean classes on the classpath.
+     */
+    public Iterable<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 Iterable<URL> getBeansXml()
+    {
+        return wbDiscovery.discoverWebBeansXml();
+    }
+
+    /**
+     * @return an empty collection since there are no EJBs in Java SE.
+     */
+    public Iterable<EjbDescriptor<?>> getEjbs()
+    {
+        return Collections.EMPTY_SET;
+    }
+
+}

Added: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java	                        (rev 0)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/discovery/SEWebBeansDeployment.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -0,0 +1,62 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.webbeans.environment.se.discovery;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.webbeans.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.webbeans.bootstrap.spi.Deployment;
+
+/**
+ * WebBeans Deployment for Java SE environment.
+ *
+ * @author Peter Royle
+ */
+public abstract class SEWebBeansDeployment implements Deployment
+{
+    private final BeanDeploymentArchive beanDeploymentArchive;
+    private final List<BeanDeploymentArchive> archInCollection;
+
+    public SEWebBeansDeployment()
+    {
+        this.beanDeploymentArchive = new SEBeanDeploymentArchive();
+        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 descriptos 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;
+    }
+}

Modified: extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/WebBeansManagerUtils.java
===================================================================
--- extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/WebBeansManagerUtils.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ extensions/trunk/se/src/main/java/org/jboss/webbeans/environment/se/util/WebBeansManagerUtils.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -17,6 +17,8 @@
 package org.jboss.webbeans.environment.se.util;
 
 import java.lang.annotation.Annotation;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.BeanManager;
 
 /**
@@ -26,7 +28,13 @@
 public class WebBeansManagerUtils {
 
     public static <T> T getInstanceByType(BeanManager manager, Class<T> type, Annotation... bindings) {
+        final Bean<?> bean = manager.getBeans(type).iterator().next();
+        CreationalContext cc = manager.createCreationalContext(bean);
+        return (T)manager.getReference(bean, type, cc);
+    }
+
+    public static <T> T getInstanceByType(BeanManager manager, Class<T> type, CreationalContext cc, Annotation... bindings) {
         return (T)manager.getReference(
-                manager.getBeans(type).iterator().next(), type, null);
+                manager.getBeans(type).iterator().next(), type, cc);
     }
 }

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/BeanDeploymentArchive.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -49,7 +49,7 @@
 
    /**
     * Get the ordered bean deployment archives which are accessible to this bean
-    * deployment archive and adjacent to it i n the deployment archive graph.
+    * deployment archive and adjacent to it in the deployment archive graph.
     * 
     * The bean deployment archives will be processed in the order specified.
     * 

Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/Deployment.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/Deployment.java	2009-07-22 12:49:54 UTC (rev 3128)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/bootstrap/spi/Deployment.java	2009-07-22 12:50:09 UTC (rev 3129)
@@ -42,6 +42,10 @@
  * bean deployment archive structure built.
  * 
  * TODO Java SE structure
+ * For an application deployed in the SE environment, all library jars and
+ * classpath directories should be searched, and the bean deployment archive
+ * structure built. A single, logical deployment archive will be built for
+ * all beans and beans.xml files found on the classpath.
  * 
  * @see BeanDeploymentArchive
  * 

Modified: ri/trunk/version-matrix/pom.xml
===================================================================
--- ri/trunk/version-matrix/pom.xml	2009-07-22 12:49:54 UTC (rev 3128)
+++ ri/trunk/version-matrix/pom.xml	2009-07-22 12:50:09 UTC (rev 3129)
@@ -50,7 +50,7 @@
       <jsr299.tck.version>1.0.0-SNAPSHOT</jsr299.tck.version>
       <webbeans.version>1.0.0-SNAPSHOT</webbeans.version>
       <webbeans.servlet.version>1.0.0.CR1</webbeans.servlet.version>
-      <webbeans.se.version>1.0.0.BETA1</webbeans.se.version>
+      <webbeans.se.version>1.0.0-SNAPSHOT</webbeans.se.version>
       <jboss.test.harness.version>1.0.0-SNAPSHOT</jboss.test.harness.version>
    </properties>
    




More information about the weld-commits mailing list