[webbeans-commits] Webbeans SVN: r2050 - in ri/trunk/impl/src: main/java/org/jboss/webbeans/introspector/jlr and 4 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Mar 16 17:17:53 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-03-16 17:17:53 -0400 (Mon, 16 Mar 2009)
New Revision: 2050

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/ConstructorSignatureImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/AnotherDeploymentType.java
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
   ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/
   ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml
Removed:
   ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/XmlParserImplTest.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedAnnotation.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedClass.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedParameter.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
Log:
fix parser test i/c and add methods to access members by signature

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedClass.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -19,7 +19,6 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.util.List;
 import java.util.Set;
 
 /**
@@ -106,7 +105,7 @@
     * @param parameterTypes the parameters of the constructor
     * @return the matching constructor, or null if not defined
     */
-   public AnnotatedConstructor<T> getDeclaredConstructor(List<AnnotatedClass<?>> parameterTypes);
+   public AnnotatedConstructor<T> getDeclaredConstructor(ConstructorSignature signature);
 
    /**
     * Gets all methods annotated with annotationType
@@ -141,12 +140,11 @@
     * Get a method by name
     * 
     * @param <M> the expected return type
-    * @param methodName the name of the method
+    * @param signature the name of the method
     * @param expectedReturnType the expected return type
-    * @param parameterTypes the parameter types of the method
     * @return the method, or null if it doesn't exist
     */
-   public <M> AnnotatedMethod<M> getDeclaredMethod(String methodName, AnnotatedClass<M> expectedReturnType, AnnotatedClass<?>... parameterTypes);
+   public <M> AnnotatedMethod<M> getDeclaredMethod(MethodSignature signature, AnnotatedClass<M> expectedReturnType);
    
    // TODO Replace with AnnotatedMethod variant
    @Deprecated
@@ -187,5 +185,9 @@
    public boolean isParameterizedType();
    
    public boolean isAbstract();
+   
+   public <S> S cast(Object object);
+   
+   public <U> AnnotatedClass<? extends U> asSubclass(AnnotatedClass<U> clazz);
 
 }
\ No newline at end of file

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedConstructor.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -62,5 +62,7 @@
     * @return An abstraction of the declaring class
     */
    public AnnotatedType<T> getDeclaringClass();
+   
+   public ConstructorSignature getSignature();
 
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedMethod.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -111,5 +111,7 @@
    public boolean isEquivalent(Method method);
 
    public Method getAnnotatedMethod();
+   
+   public MethodSignature getSignature();
 
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotatedParameter.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -17,9 +17,6 @@
 
 package org.jboss.webbeans.introspector;
 
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
 import javax.inject.manager.Manager;
 
 
@@ -42,5 +39,4 @@
    
    public AnnotatedMember<?, ?> getDeclaringMember();
    
-   public AnnotatedParameter<T> wrap(Set<Annotation> annotations);
 }

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.introspector;
+
+
+public interface ConstructorSignature
+{
+   
+   public String[] getParameterTypes();
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ConstructorSignature.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedAnnotation.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedAnnotation.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedAnnotation.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -35,9 +35,4 @@
       return delegate().getMembers();
    }
    
-   public AnnotatedAnnotation<T> wrap(Set<Annotation> annotations)
-   {
-      throw new UnsupportedOperationException();
-   }
-   
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedClass.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedClass.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -18,7 +18,6 @@
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.util.List;
 import java.util.Set;
 
 public abstract class ForwardingAnnotatedClass<T> extends ForwardingAnnotatedType<T> implements AnnotatedClass<T>
@@ -118,14 +117,26 @@
       return delegate().getDeclaredField(fieldName, expectedType);
    }
    
-   public <M> AnnotatedMethod<M> getDeclaredMethod(String methodName, AnnotatedClass<M> expectedReturnType, AnnotatedClass<?>... parameterTypes) 
+   public <M> AnnotatedMethod<M> getDeclaredMethod(MethodSignature signature, AnnotatedClass<M> expectedReturnType) 
    {
-      return delegate().getDeclaredMethod(methodName, expectedReturnType, parameterTypes);
+      return delegate().getDeclaredMethod(signature, expectedReturnType);
    }
    
-   public AnnotatedConstructor<T> getDeclaredConstructor(List<AnnotatedClass<?>> parameterTypes)
+   public AnnotatedConstructor<T> getDeclaredConstructor(ConstructorSignature signature)
    {
-      return delegate().getDeclaredConstructor(parameterTypes);
+      return delegate().getDeclaredConstructor(signature);
    }
    
+   public <U> AnnotatedClass<? extends U> asSubclass(AnnotatedClass<U> clazz)
+   {
+      return delegate().asSubclass(clazz);
+   }
+   
+   public <S> S cast(Object object)
+   {
+      return delegate().<S>cast(object);
+   }
+   
+   
+   
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedConstructor.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -20,7 +20,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.util.List;
-import java.util.Set;
 
 public abstract class ForwardingAnnotatedConstructor<T> extends ForwardingAnnotatedMember<T, Constructor<T>> implements AnnotatedConstructor<T>
 {
@@ -47,12 +46,11 @@
    {
       return delegate().newInstance(parameters);
    }
-
-   public AnnotatedConstructor<T> wrap(Set<Annotation> annotations)
+   
+   public ConstructorSignature getSignature()
    {
-      throw new UnsupportedOperationException();
+      return delegate().getSignature();
    }
    
    
-   
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedField.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -16,9 +16,7 @@
  */
 package org.jboss.webbeans.introspector;
 
-import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
-import java.util.Set;
 
 public abstract class ForwardingAnnotatedField<T> extends ForwardingAnnotatedMember<T, Field> implements AnnotatedField<T>
 {
@@ -59,12 +57,6 @@
    public boolean isTransient()
    {
       return delegate().isTransient();
-   }
-
-   public AnnotatedField<T> wrap(Set<Annotation> annotations)
-   {
-      throw new UnsupportedOperationException();
-   }
-   
+   }  
       
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedMethod.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -20,7 +20,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
-import java.util.Set;
 
 public abstract class ForwardingAnnotatedMethod<T> extends ForwardingAnnotatedMember<T, Method> implements AnnotatedMethod<T>
 {
@@ -73,9 +72,9 @@
       return delegate().isEquivalent(method);
    }
    
-   public AnnotatedMethod<T> wrap(Set<Annotation> annotations)
+   public MethodSignature getSignature()
    {
-      throw new UnsupportedOperationException();
+      return delegate().getSignature();
    }
    
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedParameter.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedParameter.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingAnnotatedParameter.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -16,9 +16,6 @@
  */
 package org.jboss.webbeans.introspector;
 
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
 import javax.inject.manager.Manager;
 
 public abstract class ForwardingAnnotatedParameter<T> extends ForwardingAnnotatedItem<T, Object> implements AnnotatedParameter<T>
@@ -35,11 +32,6 @@
    public T getValue(Manager manager)
    {
       return delegate().getValue(manager);
-   }
-
-   public AnnotatedParameter<T> wrap(Set<Annotation> annotations)
-   {
-      throw new UnsupportedOperationException();
-   }
+   } 
    
 }

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.introspector;
+
+
+public interface MethodSignature
+{
+   
+   public String getMethodName();
+   
+   public String[] getParameterTypes();
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/MethodSignature.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -35,6 +35,8 @@
 import org.jboss.webbeans.introspector.AnnotatedField;
 import org.jboss.webbeans.introspector.AnnotatedMethod;
 import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.introspector.ConstructorSignature;
+import org.jboss.webbeans.introspector.MethodSignature;
 import org.jboss.webbeans.util.Names;
 import org.jboss.webbeans.util.Reflections;
 import org.jboss.webbeans.util.Strings;
@@ -212,6 +214,8 @@
       }
    }
    
+
+   
    // The set of abstracted fields
    private final Set<AnnotatedField<?>> fields;
    // The map from annotation type to abstracted field with annotation
@@ -221,6 +225,7 @@
    
 // The set of abstracted fields
    private final Set<AnnotatedField<?>> declaredFields;
+   private final Map<String, AnnotatedField<?>> declaredFieldsByName;
    // The map from annotation type to abstracted field with annotation
    private final AnnotatedFieldMap declaredAnnotatedFields;
    // The map from annotation type to abstracted field with meta-annotation
@@ -228,6 +233,7 @@
    
    // The set of abstracted methods
    private final Set<AnnotatedMethod<?>> methods;
+   private final Map<MethodSignature, AnnotatedMethod<?>> declaredMethodsBySignature;
    // 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
@@ -242,6 +248,7 @@
    
    // The set of abstracted constructors
    private final Set<AnnotatedConstructor<T>> constructors;
+   private final Map<ConstructorSignature, AnnotatedConstructor<?>> declaredConstructorsBySignature;
    // The map from annotation type to abstracted constructor with annotation
    private final AnnotatedConstructorMap annotatedConstructors;
    // The map from class list to abstracted constructor
@@ -267,6 +274,7 @@
       this.annotatedFields = new AnnotatedFieldMap();
       this.metaAnnotatedFields = new AnnotatedFieldMap();
       this.declaredFields = new HashSet<AnnotatedField<?>>();
+      this.declaredFieldsByName = new HashMap<String, AnnotatedField<?>>();
       this.declaredAnnotatedFields = new AnnotatedFieldMap();
       this.declaredMetaAnnotatedFields = new AnnotatedFieldMap();
       this._nonStaticMemberClass = Reflections.isNonMemberInnerClass(rawType);
@@ -284,6 +292,7 @@
             if (c == rawType)
             {
                this.declaredFields.add(annotatedField);
+               this.declaredFieldsByName.put(annotatedField.getName(), annotatedField);
             }
             for (Annotation annotation : annotatedField.getAnnotationsAsSet())
             {
@@ -308,6 +317,7 @@
       this.constructors = new HashSet<AnnotatedConstructor<T>>();
       this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
       this.annotatedConstructors = new AnnotatedConstructorMap();
+      this.declaredConstructorsBySignature = new HashMap<ConstructorSignature, AnnotatedConstructor<?>>();
       for (Constructor<?> constructor : rawType.getDeclaredConstructors())
       {
          @SuppressWarnings("unchecked")
@@ -320,6 +330,8 @@
          this.constructors.add(annotatedConstructor);
          this.constructorsByArgumentMap.put(Arrays.asList(constructor.getParameterTypes()), annotatedConstructor);
          
+         this.declaredConstructorsBySignature.put(annotatedConstructor.getSignature(), annotatedConstructor);
+         
          for (Annotation annotation : annotatedConstructor.getAnnotationsAsSet())
          {
             if (!annotatedConstructors.containsKey(annotation.annotationType()))
@@ -336,6 +348,7 @@
       this.declaredMethods = new HashSet<AnnotatedMethod<?>>();
       this.declaredAnnotatedMethods = new AnnotatedMethodMap();
       this.declaredMethodsByAnnotatedParameters = new AnnotatedMethodMap();
+      this.declaredMethodsBySignature = new HashMap<MethodSignature, AnnotatedMethod<?>>();
       for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
       {
          for (Method method : c.getDeclaredMethods())
@@ -350,6 +363,7 @@
             if (c == rawType)
             {
                this.declaredMethods.add(annotatedMethod);
+               this.declaredMethodsBySignature.put(annotatedMethod.getSignature(), annotatedMethod);
             }
             for (Annotation annotation : annotatedMethod.getAnnotationsAsSet())
             {
@@ -413,7 +427,7 @@
    
    public <F> AnnotatedField<F> getDeclaredField(String fieldName, AnnotatedClass<F> expectedType)
    {
-      throw new UnsupportedOperationException();
+      return (AnnotatedField<F>) declaredFieldsByName.get(fieldName);
    }
    
    public Set<AnnotatedField<?>> getDeclaredAnnotatedFields(Class<? extends Annotation> annotationType)
@@ -433,9 +447,9 @@
       return Collections.unmodifiableSet(constructors);
    }
    
-   public AnnotatedConstructor<T> getDeclaredConstructor(List<AnnotatedClass<?>> parameterTypes)
+   public AnnotatedConstructor<T> getDeclaredConstructor(ConstructorSignature signature)
    {
-      throw new UnsupportedOperationException();
+      return (AnnotatedConstructor<T>) declaredConstructorsBySignature.get(signature);
    }
    
    /**
@@ -560,9 +574,10 @@
       return null;
    }
    
-   public <M> AnnotatedMethod<M> getDeclaredMethod(String methodName, AnnotatedClass<M> expectedReturnType, AnnotatedClass<?>... parameterTypes)
+   @SuppressWarnings("unchecked")
+   public <M> AnnotatedMethod<M> getDeclaredMethod(MethodSignature signature, AnnotatedClass<M> expectedReturnType)
    {
-      throw new UnsupportedOperationException();
+      return (AnnotatedMethod<M>) declaredMethodsBySignature.get(signature);
    }
    
    /**
@@ -581,4 +596,16 @@
       return toString;
    }
    
+   @SuppressWarnings("unchecked")
+   public <U> AnnotatedClass<? extends U> asSubclass(AnnotatedClass<U> clazz)
+   {
+      return (AnnotatedClass<? extends U>) this;
+   }
+   
+   @SuppressWarnings("unchecked")
+   public T cast(Object object)
+   {
+      return (T) object;
+   }
+   
 }
\ No newline at end of file

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -24,13 +24,13 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 
 import org.jboss.webbeans.ManagerImpl;
 import org.jboss.webbeans.introspector.AnnotatedConstructor;
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 import org.jboss.webbeans.introspector.AnnotatedType;
 import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.introspector.ConstructorSignature;
 import org.jboss.webbeans.util.Names;
 
 /**
@@ -55,6 +55,8 @@
 
    // The declaring class abstraction
    private final AnnotatedType<T> declaringClass;
+   
+   private final ConstructorSignature signature;
 
    // Cached string representation
    private String toString;
@@ -80,6 +82,7 @@
 
       this.parameters = new ArrayList<AnnotatedParameter<?>>();
       annotatedParameters = new AnnotatedParameterMap();
+      
       for (int i = 0; i < constructor.getParameterTypes().length; i++)
       {
          if (constructor.getParameterAnnotations()[i].length > 0)
@@ -107,6 +110,7 @@
             }
          }
       }
+      this.signature = new ConstructorSignatureImpl(this);
    }
 
    /**
@@ -233,9 +237,9 @@
       return toString;
    }
    
-   public AnnotatedConstructor<T> wrap(Set<Annotation> annotations)
+   public ConstructorSignature getSignature()
    {
-      throw new UnsupportedOperationException();
+      return signature;
    }
 
 }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -30,6 +30,7 @@
 import org.jboss.webbeans.introspector.AnnotatedParameter;
 import org.jboss.webbeans.introspector.AnnotatedType;
 import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.introspector.MethodSignature;
 import org.jboss.webbeans.util.Names;
 import org.jboss.webbeans.util.Reflections;
 
@@ -63,6 +64,8 @@
    // Cached string representation
    private String toString;
    
+   private final MethodSignature signature;
+   
    public static <T> AnnotatedMethodImpl<T> of(Method method, AnnotatedType<?> declaringClass)
    {
       return new AnnotatedMethodImpl<T>(method, declaringClass);
@@ -86,6 +89,7 @@
       this.declaringClass = declaringClass;
       this.parameters = new ArrayList<AnnotatedParameter<?>>();
       this.annotatedParameters = new AnnotatedParameterMap();
+      
       for (int i = 0; i < method.getParameterTypes().length; i++)
       {
          if (method.getParameterAnnotations()[i].length > 0)
@@ -120,6 +124,7 @@
       {
          this.propertyName = propertyName;
       }
+      this.signature = new MethodSignatureImpl(this);
    }
 
    public Method getAnnotatedMethod()
@@ -209,4 +214,9 @@
       return toString;
    }
    
+   public MethodSignature getSignature()
+   {
+      return signature;
+   }
+   
 }

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/ConstructorSignatureImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/ConstructorSignatureImpl.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/ConstructorSignatureImpl.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,49 @@
+package org.jboss.webbeans.introspector.jlr;
+
+import java.util.Arrays;
+
+import org.jboss.webbeans.introspector.AnnotatedConstructor;
+import org.jboss.webbeans.introspector.ConstructorSignature;
+import org.jboss.webbeans.introspector.MethodSignature;
+
+public class ConstructorSignatureImpl implements ConstructorSignature
+{
+   
+   private final String[] parameterTypes;
+   
+   public ConstructorSignatureImpl(AnnotatedConstructor<?> method)
+   {
+      this.parameterTypes = new String[method.getParameters().size()];
+      for (int i = 0; i < method.getParameters().size(); i++)
+      {
+         parameterTypes[i] = method.getParameters().get(i).getRawType().getName();
+      }
+      
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof ConstructorSignatureImpl)
+      {
+         MethodSignature that = (MethodSignature) obj;
+         return Arrays.equals(this.getParameterTypes(), that.getParameterTypes());
+      }
+      else
+      {
+         return false;
+      }
+   }
+   
+   @Override
+   public int hashCode()
+   {
+     return getParameterTypes().hashCode();
+   }
+   
+   public String[] getParameterTypes()
+   {
+      return parameterTypes;
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/ConstructorSignatureImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,58 @@
+package org.jboss.webbeans.introspector.jlr;
+
+import java.util.Arrays;
+
+import org.jboss.webbeans.introspector.AnnotatedMethod;
+import org.jboss.webbeans.introspector.MethodSignature;
+
+public class MethodSignatureImpl implements MethodSignature
+{
+   
+   private final String methodName;
+   private final String[] parameterTypes;
+   
+   public MethodSignatureImpl(AnnotatedMethod<?> method)
+   {
+      this.methodName = method.getName();
+      this.parameterTypes = new String[method.getParameters().size()];
+      for (int i = 0; i < method.getParameters().size(); i++)
+      {
+         parameterTypes[i] = method.getParameters().get(i).getRawType().getName();
+      }
+      
+   }
+
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof MethodSignatureImpl)
+      {
+         MethodSignature that = (MethodSignature) obj;
+         return this.getMethodName().equals(that.getMethodName()) && Arrays.equals(this.getParameterTypes(), that.getParameterTypes());
+      }
+      else
+      {
+         return false;
+      }
+   }
+   
+   @Override
+   public int hashCode()
+   {
+      int hashCode = 17;
+      hashCode += getMethodName().hashCode() * 5;
+      hashCode += getParameterTypes().hashCode() * 7;
+      return hashCode;
+   }
+   
+   public String getMethodName()
+   {
+      return methodName;
+   }
+   
+   public String[] getParameterTypes()
+   {
+      return parameterTypes;
+   }
+   
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/XmlParserImplTest.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/XmlParserImplTest.java	2009-03-16 19:15:19 UTC (rev 2049)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/XmlParserImplTest.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -1,55 +0,0 @@
-package org.jboss.webbeans.test.unit.xml;
-
-import java.lang.reflect.AnnotatedElement;
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
-import org.jboss.webbeans.test.unit.xml.beans.Order;
-import org.jboss.webbeans.util.xml.XmlParserImpl;
-import org.testng.annotations.Test;
-
-
-public class XmlParserImplTest extends AbstractWebBeansTest
-{
-   @Test
-   public void testParse()
-   {
-      Set<URL> xmls = new HashSet<URL>();
-      Iterable<URL> urls = getResources("user-defined-beans.xml");
-
-      for (URL url : urls)
-         xmls.add(url);
-
-      XmlParserImpl parser = new XmlParserImpl();
-      Set<AnnotatedElement> aSet = parser.parse(xmls);
-
-      for(AnnotatedElement aElement : aSet){
-    	  assert aElement.equals(Order.class);
-      }
-      assert aSet.size() == 1;
-   }
-}
-
-/*
-<Beans xmlns="urn:java:ee" xmlns:myapp="urn:java:com.mydomain.myapp"
-xmlns:test="urn:java:org.jboss.webbeans.test.unit.xml">
-<Deploy>
-	<Standard />
-	<Production />
-	<test:AnotherDeploymentType />
-</Deploy>
-<myapp:Order>
-	<ConversationScoped />
-	<myapp:PaymentProcessor>
-		<myapp:Asynchronous />
-	</myapp:PaymentProcessor>
-	<myapp:User />
-</myapp:Order>
-<myapp:Login>
-	<ConversationScoped />
-	<BindingType />
-</myapp:Login>
-</Beans>
-*/

Added: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/AnotherDeploymentType.java
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/AnotherDeploymentType.java	                        (rev 0)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/AnotherDeploymentType.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.unit.xml.parser;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.DeploymentType;
+
+ at Target( { TYPE, METHOD })
+ at Retention(RUNTIME)
+ at Documented
+ at DeploymentType
+ at interface AnotherDeploymentType
+{
+
+}
\ No newline at end of file


Property changes on: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/AnotherDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java (from rev 2044, ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/XmlParserImplTest.java)
===================================================================
--- ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java	                        (rev 0)
+++ ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,63 @@
+package org.jboss.webbeans.test.unit.xml.parser;
+
+import java.lang.reflect.AnnotatedElement;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.jboss.webbeans.test.unit.xml.beans.Order;
+import org.jboss.webbeans.util.xml.XmlParserImpl;
+import org.testng.annotations.Test;
+
+ at Artifact
+ at Resources({
+   @Resource(source="/org/jboss/webbeans/test/unit/xml/user-defined-beans.xml", destination="WEB-INF/classes/org/jboss/webbeans/test/unit/xml/user-defined-beans.xml" )
+})
+ at Classes({Order.class})
+public class XmlParserImplTest extends AbstractWebBeansTest
+{
+   @Test
+   public void testParse()
+   {
+      Set<URL> xmls = new HashSet<URL>();
+      Iterable<URL> urls = getResources("user-defined-beans.xml");
+
+      for (URL url : urls)
+         xmls.add(url);
+
+      XmlParserImpl parser = new XmlParserImpl();
+      Set<AnnotatedElement> aSet = parser.parse(xmls);
+
+      for(AnnotatedElement aElement : aSet){
+    	  assert aElement.equals(Order.class);
+      }
+      assert aSet.size() == 1;
+   }
+}
+
+/*
+<Beans xmlns="urn:java:ee" xmlns:myapp="urn:java:com.mydomain.myapp"
+xmlns:test="urn:java:org.jboss.webbeans.test.unit.xml">
+<Deploy>
+	<Standard />
+	<Production />
+	<test:AnotherDeploymentType />
+</Deploy>
+<myapp:Order>
+	<ConversationScoped />
+	<myapp:PaymentProcessor>
+		<myapp:Asynchronous />
+	</myapp:PaymentProcessor>
+	<myapp:User />
+</myapp:Order>
+<myapp:Login>
+	<ConversationScoped />
+	<BindingType />
+</myapp:Login>
+</Beans>
+*/


Property changes on: ri/trunk/impl/src/test/java/org/jboss/webbeans/test/unit/xml/parser/XmlParserImplTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml
===================================================================
--- ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml	                        (rev 0)
+++ ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml	2009-03-16 21:17:53 UTC (rev 2050)
@@ -0,0 +1,19 @@
+<Beans xmlns="urn:java:ee" xmlns:myapp="urn:java:org.jboss.webbeans.test.unit.xml.beans"
+	xmlns:test="urn:java:org.jboss.webbeans.test.unit.xml.parser">
+	<Deploy>
+		<Standard />
+		<Production />
+		<test:AnotherDeploymentType />
+	</Deploy>
+	<myapp:Order>
+		<ConversationScoped />
+		<myapp:PaymentProcessor>
+			<myapp:Asynchronous />
+		</myapp:PaymentProcessor>
+		<myapp:User />
+	</myapp:Order>
+	<myapp:Login>
+		<ConversationScoped />
+		<BindingType />
+	</myapp:Login>
+</Beans>
\ No newline at end of file


Property changes on: ri/trunk/impl/src/test/resources/org/jboss/webbeans/test/unit/xml/parser/user-defined-beans.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list