[webbeans-commits] Webbeans SVN: r1804 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean and 4 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Sat Mar 7 13:50:45 EST 2009


Author: pete.muir at jboss.org
Date: 2009-03-07 13:50:45 -0500 (Sat, 07 Mar 2009)
New Revision: 1804

Modified:
   examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewSimpleBeanTest.java
   ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
Log:
tidy up

Modified: examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java
===================================================================
--- examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ examples/trunk/numberguess/src/main/java/org/jboss/webbeans/examples/numberguess/Game.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -63,7 +63,7 @@
       return remainingGuesses;
    }
    
-   public String check()
+   public String check() throws InterruptedException
    {
       if (guess>number)
       {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -43,7 +43,6 @@
 import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
 import org.jboss.webbeans.introspector.AnnotatedClass;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 import org.jboss.webbeans.log.LogProvider;
 import org.jboss.webbeans.log.Logging;
 import org.jboss.webbeans.util.Proxies;
@@ -74,11 +73,6 @@
     * @param manager the current manager
     * @return An Enterprise Web Bean
     */
-   public static <T> EnterpriseBean<T> of(Class<T> clazz, ManagerImpl manager)
-   {
-      return of(AnnotatedClassImpl.of(clazz), manager);
-   }
-
    public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager)
    {
       return new EnterpriseBean<T>(clazz, manager);

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -26,7 +26,6 @@
 
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 import org.jboss.webbeans.literal.NewLiteral;
 
 /**
@@ -51,18 +50,6 @@
    }
 
    /**
-    * Creates an instance of a NewEnterpriseBean from a class
-    * 
-    * @param clazz The class
-    * @param manager The Web Beans manager
-    * @return a new NewEnterpriseBean instance
-    */
-   public static <T> NewEnterpriseBean<T> of(Class<T> clazz, ManagerImpl manager)
-   {
-      return of(AnnotatedClassImpl.of(clazz), manager);
-   }
-
-   /**
     * Protected constructor
     * 
     * @param type An annotated class

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -27,7 +27,6 @@
 
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 import org.jboss.webbeans.literal.NewLiteral;
 
 /**
@@ -52,18 +51,6 @@
    }
 
    /**
-    * Creates an instance of a NewSimpleBean from a class
-    * 
-    * @param clazz The class
-    * @param manager The Web Beans manager
-    * @return a new NewSimpleBean instance
-    */
-   public static <T> NewSimpleBean<T> of(Class<T> clazz, ManagerImpl manager)
-   {
-      return of(AnnotatedClassImpl.of(clazz), manager);
-   }
-
-   /**
     * Protected constructor
     * 
     * @param type An annotated class

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -23,7 +23,6 @@
 
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.introspector.AnnotatedField;
-import org.jboss.webbeans.introspector.jlr.AnnotatedFieldImpl;
 import org.jboss.webbeans.util.Names;
 
 /**
@@ -50,19 +49,6 @@
    {
       return new ProducerFieldBean<T>(field, declaringBean, manager);
    }
-   
-   /**
-    * Creates a producer field Web Bean
-    * 
-    * @param field The underlying method abstraction
-    * @param declaringBean The declaring bean abstraction
-    * @param manager the current manager
-    * @return A producer Web Bean
-    */
-   public static <T> ProducerFieldBean<T> of(Field field, AbstractClassBean<?> declaringBean, ManagerImpl manager)
-   {
-      return new ProducerFieldBean<T>(new AnnotatedFieldImpl<T>(field, declaringBean.getAnnotatedItem()), declaringBean, manager);
-   }
 
    /**
     * Constructor

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -32,7 +32,6 @@
 import org.jboss.webbeans.injection.ParameterInjectionPoint;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.introspector.jlr.AnnotatedMethodImpl;
 import org.jboss.webbeans.metadata.MetaDataCache;
 import org.jboss.webbeans.util.Names;
 
@@ -64,11 +63,6 @@
    {
       return new ProducerMethodBean<T>(method, declaringBean, manager);
    }
-
-   public static <T> ProducerMethodBean<T> of(Method method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
-   {
-      return of(AnnotatedMethodImpl.<T>of(method, declaringBean.getAnnotatedItem()), declaringBean, manager);
-   }
    
    protected ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
    {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -84,6 +84,7 @@
     * @param manager the current manager
     * @return A Web Bean
     */
+   @Deprecated
    public static <T> SimpleBean<T> of(Class<T> clazz, ManagerImpl manager)
    {
       return of(AnnotatedClassImpl.of(clazz), manager);

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -27,8 +27,6 @@
 import javax.inject.manager.InjectionPoint;
 
 import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotatedClass;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 import org.jboss.webbeans.literal.CurrentLiteral;
 
 /**
@@ -56,10 +54,10 @@
     */
    public static InjectionPointBean of(ManagerImpl manager)
    {
-      return new InjectionPointBean(AnnotatedClassImpl.of(InjectionPoint.class), manager);
+      return new InjectionPointBean(manager);
    }
 
-   protected InjectionPointBean(AnnotatedClass<InjectionPoint> clazz, ManagerImpl manager)
+   protected InjectionPointBean(ManagerImpl manager)
    {
       super(manager);
    }

Modified: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/AbstractTest.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -2,8 +2,6 @@
 
 import java.io.IOException;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.List;
@@ -12,15 +10,7 @@
 import javax.inject.Standard;
 
 import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.NewSimpleBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
-import org.jboss.webbeans.bean.SimpleBean;
 import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.mock.MockEjbDescriptor;
 import org.jboss.webbeans.mock.MockLifecycle;
 import org.jboss.webbeans.mock.MockWebBeanDiscovery;
 import org.jboss.webbeans.util.EnumerationIterable;
@@ -35,12 +25,12 @@
       
       protected void setup()
       {
-         AbstractTest.activateDependentContext();
+         DependentContext.INSTANCE.setActive(true);
       }
       
       protected void cleanup()
       {
-         AbstractTest.deactivateDependentContext();
+         DependentContext.INSTANCE.setActive(false);
       }
       
       public final void run() throws Exception
@@ -99,48 +89,6 @@
       return Arrays.asList(Standard.class, Production.class);
    }
    
-   protected <T> EnterpriseBean<T> createEnterpriseBean(Class<T> clazz)
-   {
-      manager.getEjbDescriptorCache().add(MockEjbDescriptor.of(clazz));
-      return EnterpriseBean.of(clazz, manager);
-   }
-   
-   protected <T> NewEnterpriseBean<T> createNewEnterpriseBean(Class<T> clazz)
-   {
-      manager.getEjbDescriptorCache().add(MockEjbDescriptor.of(clazz));
-      return NewEnterpriseBean.of(clazz, manager);
-   }
-   
-   protected <T> NewSimpleBean<T> createNewSimpleBean(Class<T> clazz)
-   {
-      return NewSimpleBean.of(clazz, manager);
-   }
-
-   protected <T> SimpleBean<T> createSimpleBean(Class<T> clazz)
-   {
-      return SimpleBean.of(clazz, manager);
-   }
-   
-   protected <T> ProducerMethodBean<T> createProducerMethod(Method method, AbstractClassBean<?> declaringBean)
-   {
-      return ProducerMethodBean.of(method, declaringBean, manager);
-   }
-   
-   protected <T> ProducerFieldBean<T> createProducerField(Field field, AbstractClassBean<?> declaringBean)
-   {
-      return ProducerFieldBean.of(field, declaringBean, manager);
-   }
-   
-   private static void activateDependentContext()
-   {
-      DependentContext.INSTANCE.setActive(true);
-   }
-   
-   private static void deactivateDependentContext()
-   {
-      DependentContext.INSTANCE.setActive(false);
-   }
-   
    protected void deployBeans(Class<?>... classes)
    {
       discovery.setWebBeanClasses(Arrays.asList(classes));

Modified: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewEnterpriseBeanTest.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -3,9 +3,12 @@
 import java.lang.annotation.Annotation;
 import java.util.Set;
 
+import javax.inject.New;
+
 import org.jboss.webbeans.bean.EnterpriseBean;
 import org.jboss.webbeans.bean.NewEnterpriseBean;
 import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.literal.NewLiteral;
 import org.jboss.webbeans.test.unit.AbstractTest;
 import org.jboss.webbeans.util.Proxies.TypeInfo;
 import org.testng.annotations.BeforeMethod;
@@ -13,15 +16,24 @@
 
 public class NewEnterpriseBeanTest extends AbstractTest
 {
+   
+   private static final New NEW_LITERAL = new NewLiteral();
+   
    private EnterpriseBean<WrappedEnterpriseBean> wrappedEnterpriseBean;
    private NewEnterpriseBean<WrappedEnterpriseBean> newEnterpriseBean;
    
    @BeforeMethod
    public void initNewBean() {
-      wrappedEnterpriseBean = createEnterpriseBean(WrappedEnterpriseBean.class);
-      manager.addBean(wrappedEnterpriseBean);
-      newEnterpriseBean = createNewEnterpriseBean(WrappedEnterpriseBean.class);
-      manager.addBean(newEnterpriseBean);
+      deployBeans(WrappedEnterpriseBean.class);
+      
+      assert manager.resolveByType(WrappedEnterpriseBean.class).size() == 1;
+      assert manager.resolveByType(WrappedEnterpriseBean.class).iterator().next() instanceof EnterpriseBean;
+      wrappedEnterpriseBean = (EnterpriseBean<WrappedEnterpriseBean>) manager.resolveByType(WrappedEnterpriseBean.class).iterator().next();
+      
+      assert manager.resolveByType(WrappedEnterpriseBean.class, NEW_LITERAL).size() == 1;
+      assert manager.resolveByType(WrappedEnterpriseBean.class, NEW_LITERAL).iterator().next() instanceof NewEnterpriseBean;
+      newEnterpriseBean = (NewEnterpriseBean<WrappedEnterpriseBean>) manager.resolveByType(WrappedEnterpriseBean.class, NEW_LITERAL).iterator().next();
+      
    }
    
    @Test(groups = { "new", "broken" })

Modified: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewSimpleBeanTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewSimpleBeanTest.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/implementation/NewSimpleBeanTest.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -2,9 +2,12 @@
 
 import java.util.Set;
 
+import javax.inject.New;
+
 import org.jboss.webbeans.bean.NewSimpleBean;
 import org.jboss.webbeans.bean.SimpleBean;
 import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.literal.NewLiteral;
 import org.jboss.webbeans.test.unit.AbstractTest;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -14,12 +17,19 @@
    private SimpleBean<WrappedSimpleBean> wrappedSimpleBean;
    private NewSimpleBean<WrappedSimpleBean> newSimpleBean;
    
+   private static final New NEW_LITERAL = new NewLiteral();
+   
    @BeforeMethod
    public void initNewBean() {
-      wrappedSimpleBean = createSimpleBean(WrappedSimpleBean.class);
-      manager.addBean(wrappedSimpleBean);
-      newSimpleBean = createNewSimpleBean(WrappedSimpleBean.class);
-      manager.addBean(newSimpleBean);
+      deployBeans(WrappedSimpleBean.class);
+      
+      assert manager.resolveByType(WrappedSimpleBean.class).size() == 1;
+      assert manager.resolveByType(WrappedSimpleBean.class).iterator().next() instanceof SimpleBean;
+      wrappedSimpleBean = (SimpleBean<WrappedSimpleBean>) manager.resolveByType(WrappedSimpleBean.class).iterator().next();
+      
+      assert manager.resolveByType(WrappedSimpleBean.class, NEW_LITERAL).size() == 1;
+      assert manager.resolveByType(WrappedSimpleBean.class, NEW_LITERAL).iterator().next() instanceof NewSimpleBean;
+      newSimpleBean = (NewSimpleBean<WrappedSimpleBean>) manager.resolveByType(WrappedSimpleBean.class, NEW_LITERAL).iterator().next();
    }
 
    @Test(groups = { "new" })

Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-03-07 16:26:56 UTC (rev 1803)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/BeansImpl.java	2009-03-07 18:50:45 UTC (rev 1804)
@@ -1,19 +1,8 @@
 package org.jboss.webbeans.tck;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import javax.inject.manager.Bean;
-
 import org.jboss.jsr299.tck.spi.Beans;
 import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.bean.AbstractClassBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.ProducerFieldBean;
-import org.jboss.webbeans.bean.ProducerMethodBean;
-import org.jboss.webbeans.bean.SimpleBean;
 import org.jboss.webbeans.ejb.spi.EjbDescriptor;
-import org.jboss.webbeans.mock.MockEjbDescriptor;
 import org.jboss.webbeans.util.Reflections;
 
 /**
@@ -24,45 +13,9 @@
  * @author David Allen
  * 
  */
- at Deprecated
 public class BeansImpl implements Beans
 {
 
-   public <T> Bean<T> createSimpleBean(Class<T> clazz)
-   {
-      return SimpleBean.of(clazz, CurrentManager.rootManager());
-   }
-
-   public <T> Bean<T> createProducerMethodBean(Method method, Bean<?> declaringBean)
-   {
-      if (declaringBean instanceof AbstractClassBean)
-      {
-         return ProducerMethodBean.of(method, (AbstractClassBean<?>) declaringBean, CurrentManager.rootManager());
-      }
-      else
-      {
-         throw new IllegalStateException("Cannot create a producer method from a bean that wasn't created by the RI " + declaringBean);
-      }
-   }
-   
-   public <T> Bean<T> createProducerFieldBean(Field field, Bean<?> declaringBean)
-   {
-      if (declaringBean instanceof AbstractClassBean)
-      {
-         return ProducerFieldBean.of(field, (AbstractClassBean<?>) declaringBean, CurrentManager.rootManager());
-      }
-      else
-      {
-         throw new IllegalStateException("Cannot create a producer field from a bean that wasn't created by the RI " + declaringBean);
-      }
-   }
-
-   public <T> Bean<T> createEnterpriseBean(Class<T> clazz)
-   {
-      CurrentManager.rootManager().getEjbDescriptorCache().add(MockEjbDescriptor.of(clazz));
-      return EnterpriseBean.of(clazz, CurrentManager.rootManager());
-   }
-
    public boolean isEnterpriseBean(Class<?> clazz)
    {
       return CurrentManager.rootManager().getEjbDescriptorCache().containsKey(clazz);




More information about the weld-commits mailing list