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

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jun 24 19:28:49 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-06-24 19:28:49 -0400 (Wed, 24 Jun 2009)
New Revision: 2888

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/FinalBeanMethodTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/Logger.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/MockLogger.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java
   tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/
   tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/beans.xml
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/DecoratorResolver.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableFactory.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableWBClass.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBType.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/DecoratorDefinitionTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanClass/FinalBeanClassTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/tooManyDecoratorsElements/TooManyDecoratorElementsTest.java
Log:
Fixes to decorator resolution, tests and add more edge case detection

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -339,18 +339,21 @@
     */
    public void addBean(Bean<?> bean)
    {
-      if (beans.contains(bean))
+      synchronized (bean)
       {
+         if (beans.contains(bean))
+         {
+            return;
+         }
+         resolver.clear();
+         beans.add(bean);
+         registerBeanNamespace(bean);
+         for (BeanManagerImpl childActivity : childActivities)
+         {
+            childActivity.addBean(bean);
+         }
          return;
       }
-      resolver.clear();
-      beans.add(bean);
-      registerBeanNamespace(bean);
-      for (BeanManagerImpl childActivity : childActivities)
-      {
-         childActivity.addBean(bean);
-      }
-      return;
    }
 
    public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
@@ -501,37 +504,21 @@
          }
       }
    }
-
-   /**
-    * Wraps a collection of beans into a thread safe list. Since this overwrites
-    * any existing list of beans in the manager, this should only be done on
-    * startup and other controlled situations. Also maps the beans by
-    * implementation class. For internal use.
-    * 
-    * @param beans The set of beans to add
-    * @return A reference to the manager
-    */
-   // TODO Build maps in the deployer :-)
-   public void setBeans(Set<RIBean<?>> beans)
+   
+   public void addRIBean(RIBean<?> bean)
    {
-      synchronized (beans)
+      if (bean instanceof NewEnterpriseBean)
       {
-         for (RIBean<?> bean : beans)
-         {
-            if (bean instanceof NewEnterpriseBean)
-            {
-               newEnterpriseBeans.put(bean.getType(), (EnterpriseBean<?>) bean);
-            }
-            if (bean instanceof DecoratorBean)
-            {
-               decorators.add((DecoratorBean<?>) bean);
-            }
-            riBeans.put(bean.getId(), bean);
-            registerBeanNamespace(bean);
-            this.beans.add(bean);
-         }
-         resolver.clear();
+         newEnterpriseBeans.put(bean.getType(), (EnterpriseBean<?>) bean);
       }
+      if (bean instanceof DecoratorBean)
+      {
+         decorators.add((DecoratorBean<?>) bean);
+      }
+      riBeans.put(bean.getId(), bean);
+      registerBeanNamespace(bean);
+      this.beans.add(bean);
+      resolver.clear();
    }
    
    protected void registerBeanNamespace(Bean<?> bean)
@@ -829,6 +816,12 @@
       return new ArrayList(decoratorResolver.get(ResolvableFactory.of(types, bindings)));
    }
    
+   public List<Decorator<?>> resolveDecorators(Set<Type> types, Set<Annotation> bindings)
+   {
+      // TODO Fix this cast and make the resolver return a list
+      return new ArrayList(decoratorResolver.get(ResolvableFactory.of(types, bindings)));
+   }
+   
    public List<Decorator<?>> resolveDecorators(Bean<?> bean)
    {
       throw new UnsupportedOperationException();

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -165,7 +165,7 @@
       {
          if (!decoratorBeanClasses.contains(clazz))
          {
-            throw new DeploymentException("Enabled decorator " + clazz + " is not the bean class of at least one decorator (detected decorators " + decoratorBeanClasses + ")");
+            throw new DeploymentException("Enabled decorator class " + clazz + " is not the bean class of at least one decorator bean (detected decorator beans " + decoratorBeanClasses + ")");
          }
       }
    }

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -17,7 +17,9 @@
 package org.jboss.webbeans.bean;
 
 import java.lang.annotation.Annotation;
+import java.util.Collections;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import javax.enterprise.context.Dependent;
@@ -29,6 +31,7 @@
 import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.deployment.DeploymentType;
 import javax.enterprise.inject.deployment.Production;
+import javax.enterprise.inject.spi.Decorator;
 import javax.event.Observes;
 
 import org.jboss.webbeans.BeanManagerImpl;
@@ -65,6 +68,8 @@
    private Set<MethodInjectionPoint<?>> initializerMethods;
    private Set<String> dependencies;
    
+   private List<Decorator<?>> decoratorStack;
+   
    private final String id;
 
    /**
@@ -90,7 +95,23 @@
       super.initialize(environment);
       checkScopeAllowed();
       checkBeanImplementation();
+      initDecoratorStack();
    }
+   
+   protected void initDecoratorStack()
+   {
+      this.decoratorStack = getManager().resolveDecorators(getTypes(), getBindings());
+   }
+   
+   public boolean hasDecorators()
+   {
+      return this.decoratorStack != null && this.decoratorStack.size() > 0;
+   }
+   
+   protected List<Decorator<?>> getDecoratorStack()
+   {
+      return Collections.unmodifiableList(decoratorStack);
+   }
 
    /**
     * Injects bound fields

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -120,13 +120,15 @@
 
    protected void initDelegateBindings()
    {
-      this.delegateBindings = this.decorates.getBindings();
+      this.delegateBindings = new HashSet<Annotation>(); 
+      this.delegateBindings.addAll(this.decorates.getBindings());
    }
 
    protected void initDelegateType()
    {
       this.delegateType = this.decorates.getBaseType();
-      this.delegateTypes = this.decorates.getTypeClosure();
+      this.delegateTypes = new HashSet<Type>();
+      delegateTypes.add(delegateType);
    }
 
    protected void checkDelegateType()
@@ -186,5 +188,11 @@
    {
       return delegateTypes;
    }
+   
+   @Override
+   protected void initDecoratorStack()
+   {
+      // No-op, decorators can't have decorators
+   }
 
 }

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-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -24,6 +24,7 @@
 import javax.annotation.PreDestroy;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.Decorator;
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.DefinitionException;
@@ -350,6 +351,32 @@
       {
          throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
       }
+      if (hasDecorators())
+      {
+         if (getAnnotatedItem().isFinal())
+         {
+            throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
+         }
+         for (Decorator<?> decorator : getDecoratorStack())
+         {
+            if (decorator instanceof DecoratorBean)
+            {
+               DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
+               for (WBMethod<?> decoratorMethod : decoratorBean.getAnnotatedItem().getMethods())
+               {
+                  WBMethod<?> method = getAnnotatedItem().getMethod(decoratorMethod.getSignature());  
+                  if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
+                  {
+                     throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
+                  }
+               }
+            }
+            else
+            {
+               throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
+            }
+         }
+      }
    }
 
    @Override

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -143,12 +143,20 @@
    public BeanDeployer deploy()
    {
       Set<RIBean<?>> beans = environment.getBeans();
+      // ensure that all disposal methods are initialized before initializing 
+      // the rest of the beans
+      for (DecoratorBean<?> bean : environment.getDecorators())
+      {
+         bean.initialize(environment);
+         manager.addRIBean(bean);
+         log.debug("Bean: " + bean);
+      }
       for (RIBean<?> bean : beans)
       {
          bean.initialize(environment);
+         manager.addRIBean(bean);
          log.debug("Bean: " + bean);
       }
-      manager.setBeans(beans);
       for (ObserverImpl<?> observer : environment.getObservers())
       {
          observer.initialize();

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -28,6 +28,7 @@
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.DecoratorBean;
 import org.jboss.webbeans.bean.DisposalMethodBean;
 import org.jboss.webbeans.bean.NewBean;
 import org.jboss.webbeans.bean.ProducerMethodBean;
@@ -50,6 +51,7 @@
    private final Set<ObserverImpl<?>> observers;
    private final List<DisposalMethodBean<?>> allDisposalBeans;
    private final Set<DisposalMethodBean<?>> resolvedDisposalBeans;
+   private final Set<DecoratorBean<?>> decorators;
    private final EjbDescriptorCache ejbDescriptors;
    private final Resolver disposalMethodResolver;
    private final BeanManagerImpl manager;
@@ -62,6 +64,7 @@
       this.allDisposalBeans = new ArrayList<DisposalMethodBean<?>>();
       this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
       this.beans = new HashSet<RIBean<?>>();
+      this.decorators = new HashSet<DecoratorBean<?>>();
       this.observers = new HashSet<ObserverImpl<?>>();
       this.ejbDescriptors = ejbDescriptors;
       this.disposalMethodResolver = new Resolver(manager, allDisposalBeans);
@@ -113,7 +116,6 @@
 
    public void addBean(RIBean<?> value)
    {
-
       if (value instanceof AbstractClassBean && !(value instanceof NewBean))
       {
          AbstractClassBean<?> bean = (AbstractClassBean<?>) value;
@@ -130,12 +132,21 @@
          disposalMethodBeanMap.put(bean.getAnnotatedItem(), bean);
       }
       beans.add(value);
+      if (value instanceof DecoratorBean)
+      {
+         decorators.add((DecoratorBean<?>) value);
+      }
    }
 
    public Set<RIBean<?>> getBeans()
    {
       return Collections.unmodifiableSet(beans);
    }
+   
+   public Set<DecoratorBean<?>> getDecorators()
+   {
+      return Collections.unmodifiableSet(decorators);
+   }
 
    public Set<ObserverImpl<?>> getObservers()
    {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/DecoratorResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/DecoratorResolver.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/DecoratorResolver.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -16,8 +16,6 @@
  */
 package org.jboss.webbeans.injection.resolution;
 
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
@@ -27,6 +25,8 @@
 
 import org.jboss.webbeans.BeanManagerImpl;
 import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Reflections;
 
 /**
  * @author pmuir
@@ -46,23 +46,13 @@
       if (bean instanceof DecoratorBean)
       {
          DecoratorBean<?> decoratorBean = (DecoratorBean<?>) bean;
-         return resolvable.matches(getBeanTypes(decoratorBean), getBeanBindings(decoratorBean)) && getManager().getEnabledDecoratorClasses().contains(decoratorBean.getType());
+         return Reflections.isAssignableFrom(decoratorBean.getDelegateTypes(), resolvable.getTypeClosure()) && Beans.containsAllBindings(decoratorBean.getDelegateBindings(), resolvable.getBindings(), getManager()) && getManager().getEnabledDecoratorClasses().contains(decoratorBean.getType());
       }
       else
       {
          throw new IllegalStateException("Unable to process non container generated decorator!");
       }
    }
-
-   private Set<Annotation> getBeanBindings(DecoratorBean<?> bean)
-   {
-      return bean.getDelegateBindings();
-   }
-
-   private Set<Type> getBeanTypes(DecoratorBean<?> bean)
-   {
-      return bean.getDelegateTypes();
-   }
    
    @Override
    protected Set<Bean<?>> sortBeans(Set<Bean<?>> matchedBeans)

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableFactory.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableFactory.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableFactory.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -7,6 +7,7 @@
 import java.util.Set;
 
 import org.jboss.webbeans.introspector.WBAnnotated;
+import org.jboss.webbeans.literal.CurrentLiteral;
 import org.jboss.webbeans.util.Reflections;
 
 public class ResolvableFactory
@@ -48,6 +49,10 @@
       public ResolvableImpl(Set<Annotation> bindings, Set<Type> typeClosure)
       {
          this.bindings = bindings;
+         if (bindings.size() == 0)
+         {
+            this.bindings.add(new CurrentLiteral());
+         }
          this.annotationTypes = new HashSet<Class<? extends Annotation>>();
          this.typeClosure = typeClosure;
          for (Annotation annotation : bindings)

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableWBClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableWBClass.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableWBClass.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -174,6 +174,11 @@
    {
       throw new UnsupportedOperationException();
    }
+   
+   public boolean isPrivate()
+   {
+      throw new UnsupportedOperationException();
+   }
 
    public boolean isStatic()
    {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -102,6 +102,11 @@
    {
       return delegate().isPublic();
    }
+   
+   public boolean isPrivate()
+   {
+      return delegate().isPrivate();
+   }
 
    protected abstract WBAnnotated<T, S> delegate();
 

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -49,6 +49,11 @@
    {
       return delegate().getConstructors();
    }
+   
+   public Set<WBMethod<?>> getMethods()
+   {
+      return delegate().getMethods();
+   }
 
    public Set<WBField<?>> getDeclaredAnnotatedFields(Class<? extends Annotation> annotationType)
    {
@@ -80,6 +85,11 @@
    {
       return delegate().getMethod(method);
    }
+   
+   public <M> WBMethod<M> getMethod(MethodSignature signature)
+   {
+      return delegate().getMethod(signature);
+   }
 
    public Set<WBMethod<?>> getMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
    {

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -172,6 +172,8 @@
     * @return if public, returns true
     */
    public boolean isPublic();
+   
+   public boolean isPrivate();
 
    /**
     * Gets the name of this AnnotatedItem

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -35,6 +35,13 @@
     * @return A set of abstracted fields
     */
    public Set<WBField<?>> getFields();
+   
+   /**
+    * Gets all fields on the type
+    * 
+    * @return A set of abstracted fields
+    */
+   public Set<WBMethod<?>> getMethods();
 
    /**
     * Get a field by name
@@ -144,6 +151,15 @@
     * @return the method, or null if it doesn't exist
     */
    public <M> WBMethod<M> getDeclaredMethod(MethodSignature signature, WBClass<M> expectedReturnType);
+   
+   /**
+    * Get a method by name
+    * 
+    * @param <M> the expected return type
+    * @param signature the name of the method
+    * @return the method, or null if it doesn't exist
+    */
+   public <M> WBMethod<M> getMethod(MethodSignature signature);
 
    // TODO Replace with AnnotatedMethod variant
    @Deprecated

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -50,6 +50,8 @@
    private String toString;
    
    private final boolean _public;
+   
+   private final boolean _private;
 
    /**
     * Constructor
@@ -61,6 +63,7 @@
       super(annotatedItemHelper, rawType, type);
       name = member.getName();
       _public = Modifier.isPublic(member.getModifiers());
+      _private = Modifier.isPrivate(member.getModifiers());
    }
 
    /**
@@ -96,6 +99,11 @@
    {
       return _public;
    }
+   
+   public boolean isPrivate()
+   {
+      return _private;
+   }
 
    /**
     * Gets the current value of the member

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBType.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBType.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBType.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -47,6 +47,7 @@
    // Cached string representation
    private String toString;
    private final boolean _public;
+   private final boolean _private;
 
    /**
     * Constructor
@@ -67,6 +68,7 @@
          this.superclass = null;
       }
       this._public = Modifier.isFinal(rawType.getModifiers());
+      _private = Modifier.isPrivate(rawType.getModifiers());
    }
 
    /**
@@ -124,6 +126,11 @@
    {
       return getDelegate().equals(clazz);
    }
+   
+   public boolean isPrivate()
+   {
+      return _private;
+   }
 
    /**
     * Gets a string representation of the type

Modified: 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	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/MethodSignatureImpl.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -70,7 +70,7 @@
    {
       int hashCode = 17;
       hashCode += getMethodName().hashCode() * 5;
-      hashCode += getParameterTypes().hashCode() * 7;
+      hashCode += Arrays.hashCode(getParameterTypes()) * 7;
       return hashCode;
    }
    

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -74,6 +74,7 @@
    // The set of abstracted methods
    private final Set<WBMethod<?>> methods;
    private final Map<MethodSignature, WBMethod<?>> declaredMethodsBySignature;
+   private final Map<MethodSignature, WBMethod<?>> methodsBySignature;
    // The map from annotation type to abstracted method with annotation
    private final SetMultiMap<Class<? extends Annotation>, WBMethod<?>> annotatedMethods;
    // The map from annotation type to method with a parameter with annotation
@@ -202,6 +203,7 @@
       this.declaredAnnotatedMethods = new SetHashMultiMap<Class<? extends Annotation>, WBMethod<?>>();
       this.declaredMethodsByAnnotatedParameters = new SetHashMultiMap<Class<? extends Annotation>, WBMethod<?>>();
       this.declaredMethodsBySignature = new HashMap<MethodSignature, WBMethod<?>>();
+      this.methodsBySignature = new HashMap<MethodSignature, WBMethod<?>>();
       for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
       {
          for (Method method : c.getDeclaredMethods())
@@ -213,6 +215,7 @@
             
             WBMethod<?> annotatedMethod = WBMethodImpl.of(method, this);
             this.methods.add(annotatedMethod);
+            this.methodsBySignature.put(annotatedMethod.getSignature(), annotatedMethod);
             if (c == rawType)
             {
                this.declaredMethods.add(annotatedMethod);
@@ -424,6 +427,11 @@
       return null;
    }
    
+   public Set<WBMethod<?>> getMethods()
+   {
+      return Collections.unmodifiableSet(methods);
+   }
+   
    public WBMethod<?> getDeclaredMethod(Method method)
    {
       // TODO Should be cached
@@ -443,6 +451,12 @@
       return (WBMethod<M>) declaredMethodsBySignature.get(signature);
    }
    
+   @SuppressWarnings("unchecked")
+   public <M> WBMethod<M> getMethod(MethodSignature signature)
+   {
+      return (WBMethod<M>) methodsBySignature.get(signature);
+   }
+   
    /**
     * Gets a string representation of the class
     * 

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -41,6 +41,7 @@
    // The static state
    private final boolean _static = false;
    private final boolean _public = false;
+   private final boolean _private = false;
    private final WBMember<?, ?> declaringMember;
 
    // Cached string representation
@@ -103,6 +104,11 @@
    {
       return _public;
    }
+   
+   public boolean isPrivate()
+   {
+      return _private;
+   }
 
    /**
     * Gets the current value

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/DecoratorDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/DecoratorDefinitionTest.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/DecoratorDefinitionTest.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -53,7 +53,7 @@
 
    public void testDecoratorIsManagedBean()
    {
-      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Logger.TYPES);
+      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(MockLogger.TYPES);
       assert decorators.size() == 1;
       Set<Bean<?>> beans = getCurrentManager().getBeans(TimestampLogger.class);
       assert beans.size() == 1;
@@ -68,7 +68,7 @@
    })
    public void testDecoratedTypes()
    {
-      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Foo.TYPES);
+      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(FooBar.TYPES);
       assert decorators.size() == 1;
       assert decorators.get(0).getDecoratedTypes().size() == 3;
       assert decorators.get(0).getDecoratedTypes().contains(Foo.class);
@@ -92,15 +92,15 @@
       assert decorator.getInjectionPoints().iterator().next().getAnnotated().isAnnotationPresent(Decorates.class);
       assert decorator.getDelegateType().equals(Logger.class);
       assert decorator.getDelegateBindings().size() == 1;
-      assert decorator.getDelegateBindings().iterator().next().annotationType().equals(Current.class);
+      assert annotationSetMatches(decorator.getDelegateBindings(), Current.class);
    }
 
    @Test
    @SpecAssertion(section="8.1.3", id="b")
    public void testDecoratorDoesNotImplementDelegateType()
    {
-      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Baz.TYPES);
-      assert decorators.size() == 3;
+      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Bazt.TYPES);
+      assert decorators.size() == 2;
    }
    
    @Test
@@ -110,11 +110,11 @@
    })
    public void testDecoratorOrdering()
    {
-      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Baz.TYPES);
+      List<Decorator<?>> decorators = getCurrentManager().resolveDecorators(Bazt.TYPES);
+      assert decorators.size() == 2;
       assert decorators.get(0).getTypes().contains(BazDecorator.class);
       assert decorators.get(1).getTypes().contains(BazDecorator1.class);
-      assert decorators.get(2).getTypes().contains(FooDecorator.class);
-      assert decorators.size() == 3;
+      
    }
 
    @Test

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanClass/FinalBeanClassTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanClass/FinalBeanClassTest.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanClass/FinalBeanClassTest.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -34,7 +34,7 @@
 public class FinalBeanClassTest extends AbstractJSR299Test
 {
 
-   @Test(groups="broken")
+   @Test
    @SpecAssertion(section="8.1.2", id="d")
    public void testAppliesToFinalManagedBeanClass()
    {

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/FinalBeanMethodTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/FinalBeanMethodTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/FinalBeanMethodTest.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -0,0 +1,44 @@
+/*
+ * 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.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.DefinitionError;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Artifact
+ at ExpectedDeploymentException(DefinitionError.class)
+ at BeansXml("beans.xml")
+public class FinalBeanMethodTest extends AbstractJSR299Test
+{
+
+   @Test
+   @SpecAssertion(section="8.1.2", id="e")
+   public void testAppliesToFinalMethodOnManagedBeanClass()
+   {
+
+   }
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/FinalBeanMethodTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/Logger.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/Logger.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/Logger.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -0,0 +1,29 @@
+/*
+ * 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.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod;
+
+
+/**
+ * @author pmuir
+ *
+ */
+public interface Logger
+{
+
+   public void log(String string);
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/Logger.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/MockLogger.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/MockLogger.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/MockLogger.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -0,0 +1,41 @@
+/*
+ * 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.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockLogger implements Logger
+{
+
+   private static String log = "";
+
+   public final void log(String string)
+   {
+      log += string;
+   }
+
+   /**
+    * @return the log
+    */
+   public static String getLog()
+   {
+      return log;
+   }
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/MockLogger.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -0,0 +1,38 @@
+/*
+ * 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.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+/**
+ * @author pmuir
+ *
+ */
+ at Decorator
+public abstract class TimestampLogger implements Logger
+{
+
+   @Decorates private Logger logger;
+   
+   public void log(String string)
+   {
+      logger.log(string);
+   }
+
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/TimestampLogger.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/tooManyDecoratorsElements/TooManyDecoratorElementsTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/tooManyDecoratorsElements/TooManyDecoratorElementsTest.java	2009-06-24 23:08:02 UTC (rev 2887)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/definition/broken/tooManyDecoratorsElements/TooManyDecoratorElementsTest.java	2009-06-24 23:28:49 UTC (rev 2888)
@@ -43,8 +43,8 @@
 public class TooManyDecoratorElementsTest extends AbstractJSR299Test
 {
 
-   @Test(groups="broken")
-   @SpecAssertion(section="8.2", id="d")
+   @Test
+   @SpecAssertion(section="8.2", id="e")
    public void testTooManyDecoratorElements()
    {
 

Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/beans.xml
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/beans.xml	                        (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/beans.xml	2009-06-24 23:28:49 UTC (rev 2888)
@@ -0,0 +1,5 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.jsr299.tck.tests.decorators.definition.broken.finalBeanMethod.TimestampLogger</class>
+   </decorators>
+</beans>


Property changes on: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/definition/broken/finalBeanMethod/beans.xml
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list