[webbeans-commits] Webbeans SVN: r940 - in ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans: bean and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Jan 13 20:24:09 EST 2009


Author: pete.muir at jboss.org
Date: 2009-01-13 20:24:09 -0500 (Tue, 13 Jan 2009)
New Revision: 940

Modified:
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
Log:
more generics tidyup

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -189,7 +189,7 @@
     * @param bindingTypes The binding types to match
     * @return The set of matching disposal methods
     */
-   public <T> Set<AnnotatedMethod<Object>> resolveDisposalMethods(Class<T> apiType, Annotation... bindings)
+   public <T> Set<AnnotatedMethod<?>> resolveDisposalMethods(Class<T> apiType, Annotation... bindings)
    {
       // TODO Implement disposal methods
       return Collections.emptySet();

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -482,7 +482,7 @@
 
    }
 
-   public void preDestroy(Object target)
+   public void preDestroy(T target)
    {
 
    }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -2,6 +2,7 @@
 
 import java.lang.annotation.Annotation;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -11,6 +12,7 @@
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.binding.NewBinding;
 import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 
 public class NewEnterpriseBean<T> extends EnterpriseBean<T>

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -2,6 +2,7 @@
 
 import java.lang.annotation.Annotation;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -12,6 +13,7 @@
 import org.jboss.webbeans.binding.NewBinding;
 import org.jboss.webbeans.context.DependentContext;
 import org.jboss.webbeans.introspector.AnnotatedClass;
+import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
 
 public class NewSimpleBean<T> extends SimpleBean<T>

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -138,7 +138,7 @@
     */
    protected void initDisposalMethod()
    {
-      Set<AnnotatedMethod<Object>> disposalMethods = manager.resolveDisposalMethods(getType(), getBindings().toArray(new Annotation[0]));
+      Set<AnnotatedMethod<?>> disposalMethods = manager.resolveDisposalMethods(getType(), getBindings().toArray(new Annotation[0]));
       if (disposalMethods.size() == 1)
       {
          this.disposalMethod = disposalMethods.iterator().next();

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/SessionBeanInterceptor.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -41,10 +41,11 @@
    @PostConstruct
    public void postConstruct(InvocationContext invocationContext) throws Exception
    {
-      EnterpriseBean<Object> enterpriseBean = getBean(invocationContext);
+      Object target = invocationContext.getTarget();
+      EnterpriseBean<Object> enterpriseBean = getBean(target.getClass());
       if (enterpriseBean != null)
       {
-         enterpriseBean.postConstruct(invocationContext.getTarget());
+         enterpriseBean.postConstruct(target);
       }
       invocationContext.proceed();
    }
@@ -58,10 +59,11 @@
    @PreDestroy
    public void preDestroy(InvocationContext invocationContext) throws Exception
    {
-      EnterpriseBean<Object> enterpriseBean = getBean(invocationContext);
+      Object target = invocationContext.getTarget();
+      EnterpriseBean<Object> enterpriseBean = getBean(target.getClass());
       if (enterpriseBean != null)
       {
-         enterpriseBean.preDestroy(invocationContext.getTarget());
+         enterpriseBean.preDestroy(target);
       }
       invocationContext.proceed();
    }
@@ -73,13 +75,12 @@
     * @return The found bean or null if the bean was not an enterprise bean
     */
    @SuppressWarnings("unchecked")
-   private static EnterpriseBean<Object> getBean(InvocationContext invocationContext)
+   private static <T> EnterpriseBean<T> getBean(Class<? extends T> beanClass)
    {
-      Class<?> beanClass = invocationContext.getTarget().getClass();
       Bean<?> bean = CurrentManager.rootManager().getBeanMap().get(beanClass);
       if (bean instanceof EnterpriseBean)
       {
-         return (EnterpriseBean<Object>) bean;
+         return (EnterpriseBean<T>) bean;
       }
       else
       {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -32,7 +32,7 @@
 public abstract class AbstractAnnotatedType<T> extends AbstractAnnotatedItem<T, Class<T>>
 {
    // The superclass abstraction of the type
-   private final AnnotatedClass<Object> superclass;
+   private final AnnotatedClass<?> superclass;
    // The name of the type
    private final String name;
    
@@ -100,7 +100,7 @@
     * 
     * @return The superclass abstraction
     */
-   public AnnotatedClass<Object> getSuperclass()
+   public AnnotatedClass<?> getSuperclass()
    {
       return superclass;
    }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -112,7 +112,7 @@
       annotatedMembers = new AnnotatedMemberMap();
       for (Method member : clazz.getDeclaredMethods())
       {
-         AnnotatedMethod<? extends Object> annotatedMethod = new AnnotatedMethodImpl<Object>(member, this);
+         AnnotatedMethod<?> annotatedMethod = new AnnotatedMethodImpl<Object>(member, this);
          members.add(annotatedMethod);
          for (Annotation annotation : annotatedMethod.getAnnotations())
          {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -223,7 +223,7 @@
    private final AnnotatedFieldMap metaAnnotatedFields;
 
    // The set of abstracted methods
-   private final Set<AnnotatedMethod<Object>> methods;
+   private final Set<AnnotatedMethod<?>> methods;
    // The map from annotation type to abstracted method with annotation
    private final AnnotatedMethodMap annotatedMethods;
    // The map from annotation type to method with a parameter with annotation
@@ -275,7 +275,7 @@
             {
                field.setAccessible(true);
             }
-            AnnotatedField<Object> annotatedField = new AnnotatedFieldImpl<Object>(field, this);
+            AnnotatedField<?> annotatedField = new AnnotatedFieldImpl<Object>(field, this);
             this.fields.add(annotatedField);
             for (Annotation annotation : annotatedField.getAnnotations())
             {
@@ -312,7 +312,7 @@
          }
       }
 
-      this.methods = new HashSet<AnnotatedMethod<Object>>();
+      this.methods = new HashSet<AnnotatedMethod<?>>();
       this.annotatedMethods = new AnnotatedMethodMap();
       this.methodsByAnnotatedParameters = new AnnotatedMethodMap();
       for (Class<?> c = clazz; c != Object.class && c != null; c = c.getSuperclass())
@@ -324,7 +324,7 @@
                method.setAccessible(true);
             }
 
-            AnnotatedMethod<Object> annotatedMethod = new AnnotatedMethodImpl<Object>(method, this);
+            AnnotatedMethod<?> annotatedMethod = new AnnotatedMethodImpl<Object>(method, this);
             this.methods.add(annotatedMethod);
             for (Annotation annotation : annotatedMethod.getAnnotations())
             {

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -68,7 +68,6 @@
     * @param constructor The constructor method
     * @param declaringClass The declaring class
     */
-   @SuppressWarnings("unchecked")
    public AnnotatedConstructorImpl(Constructor<T> constructor, AnnotatedType<T> declaringClass)
    {
       super(buildAnnotationMap(constructor), constructor);
@@ -81,8 +80,8 @@
       {
          if (constructor.getParameterAnnotations()[i].length > 0)
          {
-            Class<? extends Object> clazz = constructor.getParameterTypes()[i];
-            AnnotatedParameter<Object> parameter = new AnnotatedParameterImpl<Object>(constructor.getParameterAnnotations()[i], (Class<Object>) clazz);
+            Class<?> clazz = constructor.getParameterTypes()[i];
+            AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(constructor.getParameterAnnotations()[i], clazz);
             parameters.add(parameter);
 
             for (Annotation annotation : parameter.getAnnotations())
@@ -92,8 +91,8 @@
          }
          else
          {
-            Class<? extends Object> clazz = constructor.getParameterTypes()[i];
-            AnnotatedParameter<Object> parameter = new AnnotatedParameterImpl<Object>(new Annotation[0], (Class<Object>) clazz);
+            Class<?> clazz = constructor.getParameterTypes()[i];
+            AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], clazz);
             parameters.add(parameter);
 
             for (Annotation annotation : parameter.getAnnotations())

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -95,8 +95,8 @@
       {
          if (method.getParameterAnnotations()[i].length > 0)
          {
-            Class<? extends Object> clazz = method.getParameterTypes()[i];
-            AnnotatedParameter<Object> parameter = new AnnotatedParameterImpl<Object>(method.getParameterAnnotations()[i], (Class<Object>) clazz);
+            Class<?> clazz = method.getParameterTypes()[i];
+            AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(method.getParameterAnnotations()[i], clazz);
             this.parameters.add(parameter);
             for (Annotation annotation : parameter.getAnnotations())
             {
@@ -108,8 +108,8 @@
          }
          else
          {
-            Class<? extends Object> clazz = method.getParameterTypes()[i];
-            AnnotatedParameter<Object> parameter = new AnnotatedParameterImpl<Object>(new Annotation[0], (Class<Object>) clazz);
+            Class<?> clazz = method.getParameterTypes()[i];
+            AnnotatedParameter<?> parameter = AnnotatedParameterImpl.of(new Annotation[0], clazz);
             this.parameters.add(parameter);
          }
       }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java	2009-01-14 00:58:19 UTC (rev 939)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedParameterImpl.java	2009-01-14 01:24:09 UTC (rev 940)
@@ -47,6 +47,11 @@
 
    // Cached string representation
    private String toString;
+   
+   public static <T> AnnotatedParameter<T> of(Annotation[] annotations, Class<T> clazz)
+   {
+      return new AnnotatedParameterImpl<T>(annotations, clazz);
+   }
 
    /**
     * Constructor




More information about the weld-commits mailing list