[webbeans-commits] Webbeans SVN: r704 - in ri/trunk: webbeans-ri and 5 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Dec 24 12:20:12 EST 2008


Author: pete.muir at jboss.org
Date: 2008-12-24 12:20:12 -0500 (Wed, 24 Dec 2008)
New Revision: 704

Removed:
   ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/MethodDescriptor.java
Modified:
   ri/trunk/webbeans-api/
   ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
   ri/trunk/webbeans-ri/
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.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/AnnotatedClassImpl.java
   ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
   ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java
Log:
WBRI-72


Property changes on: ri/trunk/webbeans-api
___________________________________________________________________
Name: svn:ignore
   - .classpath

.project

target

cobertura.ser

   + .classpath

.project

target

cobertura.ser
.settings



Property changes on: ri/trunk/webbeans-ri
___________________________________________________________________
Name: svn:ignore
   - .project
.classpath
target
test-output
temp-testng-customsuite.xml

ObjectStore

   + .classpath

.project

target

cobertura.ser
.settings


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	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -17,6 +17,7 @@
 
 package org.jboss.webbeans.bean;
 
+import java.lang.reflect.Method;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -36,7 +37,6 @@
 
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
-import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
 import org.jboss.webbeans.contexts.DependentContext;
 import org.jboss.webbeans.introspector.AnnotatedField;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -185,10 +185,9 @@
       if (getAnnotatedItem().getAnnotatedMethods(Destructor.class).size() == 1)
       {
          AnnotatedMethod<?> destructorMethod = getAnnotatedItem().getAnnotatedMethods(Destructor.class).iterator().next();
-         for (MethodDescriptor removeMethod : ejbDescriptor.getRemoveMethods())
+         for (Method removeMethod : ejbDescriptor.getRemoveMethods())
          {
-            AnnotatedMethod<?> annotatedRemoveMethod = getAnnotatedItem().getMethod(removeMethod);
-            if (annotatedRemoveMethod != null && annotatedRemoveMethod.equals(destructorMethod))
+            if (removeMethod != null && destructorMethod.isEquivalent(removeMethod))
             {
                this.removeMethod = destructorMethod;
                return;
@@ -196,8 +195,14 @@
          }
          throw new DefinitionException("Method annotated @Destructor is not an EJB remove method on " + toString());
       }
-      // <1 (0) @Destructors
-      Set<MethodDescriptor> noArgsRemoveMethods = getNoArgsRemoveMethods(ejbDescriptor);
+      Set<Method> noArgsRemoveMethods = new HashSet<Method>();
+      for (Method removeMethod : ejbDescriptor.getRemoveMethods())
+      {
+         if (removeMethod.getParameterTypes().length == 0)
+         {
+            noArgsRemoveMethods.add(removeMethod);
+         }
+      }
       if (noArgsRemoveMethods.size() == 1)
       {
          this.removeMethod = annotatedItem.getMethod(noArgsRemoveMethods.iterator().next());
@@ -210,19 +215,6 @@
       }
 
    }
-
-   private static Set<MethodDescriptor> getNoArgsRemoveMethods(EjbDescriptor<?> ejbDescriptor)
-   {
-      Set<MethodDescriptor> noArgsRemoveMethods = new HashSet<MethodDescriptor>();
-      for (MethodDescriptor removeMethod : ejbDescriptor.getRemoveMethods())
-      {
-         if (removeMethod.getMethodParameterTypes().length == 0)
-         {
-            noArgsRemoveMethods.add(removeMethod);
-         }
-      }
-      return noArgsRemoveMethods;
-   }
    
    /**
     * Validates the remove method

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -18,11 +18,10 @@
 package org.jboss.webbeans.introspector;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Set;
 
-import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
-
 /**
  * Represents a Class
  * 
@@ -97,7 +96,7 @@
     * @param methodDescriptor
     * @return
     */
-   public AnnotatedMethod<Object> getMethod(MethodDescriptor methodDescriptor);
+   public AnnotatedMethod<Object> getMethod(Method method);
    
    /**
     * Gets all with parameters annotated with annotationType

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -29,8 +29,8 @@
 import javax.webbeans.AfterTransactionSuccess;
 import javax.webbeans.BeforeTransactionCompletion;
 import javax.webbeans.Disposes;
+import javax.webbeans.Fires;
 import javax.webbeans.IfExists;
-import javax.webbeans.Fires;
 import javax.webbeans.Observes;
 import javax.webbeans.manager.Manager;
 
@@ -119,5 +119,13 @@
     * @return The name
     */
    public String getPropertyName();
+   
+   /**
+    * Checks if a this is equivalent to a JLR method
+    * 
+    * @param method The JLR method
+    * @return true if equivalent
+    */
+   public boolean isEquivalent(Method method);
 
 }

Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/AnnotatedType.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -33,5 +33,12 @@
     * @return The abstracted superclass
     */
    public AnnotatedType<Object> getSuperclass();
+   
+   /**
+    * Check if this is equivalent to a java class
+    * @param clazz The Java class
+    * @return true if equivalent
+    */
+   public boolean isEquivalent(Class<?> clazz);
 
 }

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	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedType.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -104,6 +104,11 @@
    {
       return superclass;
    }
+   
+   public boolean isEquivalent(Class<?> clazz)
+   {
+      return getDelegate().equals(clazz);
+   }
 
    /**
     * Gets a string representation of the type

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	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -31,7 +31,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
 import org.jboss.webbeans.introspector.AnnotatedClass;
 import org.jboss.webbeans.introspector.AnnotatedConstructor;
 import org.jboss.webbeans.introspector.AnnotatedField;
@@ -505,12 +504,12 @@
       return methodsByAnnotatedParameters.get(annotationType);
    }
    
-   public AnnotatedMethod<Object> getMethod(MethodDescriptor methodDescriptor)
+   public AnnotatedMethod<Object> getMethod(Method methodDescriptor)
    {
       // TODO Cache?
       for (AnnotatedMethod<Object> annotatedMethod : methods)
       {
-         if (annotatedMethod.getName().equals(methodDescriptor.getMethodName()) && Arrays.equals(annotatedMethod.getParameterTypesAsArray(), methodDescriptor.getMethodParameterTypes()))
+         if (annotatedMethod.getName().equals(methodDescriptor.getName()) && Arrays.equals(annotatedMethod.getParameterTypesAsArray(), methodDescriptor.getParameterTypes()))
          {
             return annotatedMethod;
          }

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	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -222,6 +222,11 @@
          return false;
       }
    }
+   
+   public boolean isEquivalent(Method method)
+   {
+      return this.getDeclaringClass().isEquivalent(method.getDeclaringClass()) && this.getName().equals(method.getName()) && Arrays.equals(this.getParameterTypesAsArray(), method.getParameterTypes());
+   }
 
    /**
     * Gets the hash code (of the delegate)

Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -13,7 +13,6 @@
 
 import org.jboss.webbeans.bootstrap.spi.BusinessInterfaceDescriptor;
 import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
-import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
 import org.jboss.webbeans.test.annotations.Singleton;
 
 public class MockEjbDescriptor<T> implements EjbDescriptor<T>
@@ -21,7 +20,7 @@
    private final Class<T> type;
    private final String ejbName;
    private final List<BusinessInterfaceDescriptor<?>> localInterfaces;
-   private final HashSet<MethodDescriptor> removeMethods;
+   private final HashSet<Method> removeMethods;
 
    public MockEjbDescriptor(final Class<T> type)
    {
@@ -46,31 +45,12 @@
             
                });
       }
-      this.removeMethods = new HashSet<MethodDescriptor>();
+      this.removeMethods = new HashSet<Method>();
       for (final Method method : type.getMethods())
       {
          if (method.isAnnotationPresent(Remove.class))
          {
-            removeMethods.add(new MethodDescriptor()
-            {
-               
-               public String getMethodName()
-               {
-                  return method.getName();
-               }
-               
-               public Class<?>[] getMethodParameterTypes()
-               {
-                  return method.getParameterTypes();
-               }
-               
-               @Override
-               public String toString()
-               {
-                  return method.toString();
-               }
-               
-            });
+            removeMethods.add(method);
          }
       }
    }
@@ -90,7 +70,7 @@
       return Collections.emptyList();
    }
 
-   public Iterable<MethodDescriptor> getRemoveMethods()
+   public Iterable<Method> getRemoveMethods()
    {
 
       return removeMethods;

Modified: ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java
===================================================================
--- ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/EjbDescriptor.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -17,7 +17,9 @@
 
 package org.jboss.webbeans.bootstrap.spi;
 
+import java.lang.reflect.Method;
 
+
 /**
  * EJB metadata from the EJB descriptor
  * 
@@ -54,7 +56,7 @@
     * 
     * @return An iterator over the remove methods
     */
-   public Iterable<MethodDescriptor> getRemoveMethods();
+   public Iterable<Method> getRemoveMethods();
 
    /**
     * Indicates if the bean is stateless

Deleted: ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/MethodDescriptor.java
===================================================================
--- ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/MethodDescriptor.java	2008-12-24 17:17:44 UTC (rev 703)
+++ ri/trunk/webbeans-ri-spi/src/main/java/org/jboss/webbeans/bootstrap/spi/MethodDescriptor.java	2008-12-24 17:20:12 UTC (rev 704)
@@ -1,10 +0,0 @@
-package org.jboss.webbeans.bootstrap.spi;
-
-public interface MethodDescriptor
-{
-   
-   public String getMethodName();
-   
-   public Class<?>[] getMethodParameterTypes();
-   
-}




More information about the weld-commits mailing list