[weld-commits] Weld SVN: r5637 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/proxy and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jan 27 01:18:35 EST 2010


Author: marius.bogoevici
Date: 2010-01-27 01:18:35 -0500 (Wed, 27 Jan 2010)
New Revision: 5637

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java
Removed:
   core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
Log:
rework decoration process, elliminate recursivity, separate handling of delegate and non-delegate references inside getInjectableReference

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and individual contributors
+ * Copyright 2010, Red Hat, Inc., and individual contributors
  * by the @authors tag. See the copyright.txt in the distribution for a
  * full listing of individual contributors.
  *
@@ -56,7 +56,7 @@
 import org.jboss.interceptor.registry.InterceptorClassMetadataRegistry;
 import org.jboss.interceptor.util.InterceptionUtils;
 import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
-import org.jboss.weld.bean.proxy.DecoratorProxyMethodHandler;
+import org.jboss.weld.bean.proxy.DecorationHelper;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.context.SerializableContextualImpl;
 import org.jboss.weld.context.SerializableContextualInstanceImpl;
@@ -140,8 +140,6 @@
    // Decorators
    private List<Decorator<?>> decorators;
    private Class<T> proxyClassForDecorators;
-   private final ThreadLocal<Integer> decoratorStackPosition;
-   private final ThreadLocal<T> decoratedActualInstance = new ThreadLocal<T>();
 
    // Interceptors
    private boolean hasSerializationOrInvocationInterceptorMethods;
@@ -165,16 +163,6 @@
    {
       super(idSuffix, beanManager);
       this.annotatedItem = type;
-      this.decoratorStackPosition = new ThreadLocal<Integer>()
-      {
-
-         @Override
-         protected Integer initialValue()
-         {
-            return 0;
-         }
-
-      };
       initStereotypes();
       initAlternative();
       initInitializerMethods();
@@ -230,65 +218,18 @@
 
    protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
    {
-      List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances = new ArrayList<SerializableContextualInstance<Decorator<Object>, Object>>();
-      InjectionPoint ip = originalInjectionPoint;
-      boolean outside = decoratorStackPosition.get().intValue() == 0;
-      if (outside)
-      {
-         decoratedActualInstance.set(instance);
-      }
+      T proxy = null;
+      DecorationHelper<T> decorationHelper = new DecorationHelper(instance, proxyClassForDecorators, beanManager, decorators);
 
-      try
-      {
-         int i = decoratorStackPosition.get();
-         while (i < decorators.size())
-         {
-            Decorator<?> decorator = decorators.get(i);
-            decoratorStackPosition.set(++i);
+      DecorationHelper.getHelperStack().push(decorationHelper);
+      proxy = decorationHelper.getNextDelegate(originalInjectionPoint, creationalContext);
+      decorationHelper = (DecorationHelper<T>) DecorationHelper.getHelperStack().pop();
 
-            Object decoratorInstance = getBeanManager().getReference(ip, decorator, creationalContext);
-            decoratorInstances.add(new SerializableContextualInstanceImpl<Decorator<Object>, Object>((Decorator<Object>) decorator, decoratorInstance, null));
-
-            ip = Beans.getDelegateInjectionPoint(decorator);
-            if (ip == null)
-            {
-               throw new ForbiddenStateException(NON_CONTAINER_DECORATOR, decorator);
-            }
-         }
-      }
-      finally
+      if (proxy == null)
       {
-         if (outside)
-         {
-            decoratorStackPosition.remove();
-         }
+         throw new WeldException(PROXY_INSTANTIATION_FAILED, this);
       }
-      try
-      {
-         T proxy = SecureReflections.newInstance(proxyClassForDecorators);
-         // temporary fix for decorators - make sure that the instance wrapped
-         // by the decorators
-         // is the contextual instance
-         // TODO - correct the decoration algorithm to avoid the creation of new
-         // target class instances
-         Proxies.attachMethodHandler(proxy, new DecoratorProxyMethodHandler(decoratorInstances, decoratedActualInstance.get()));
-         return proxy;
-      }
-      catch (InstantiationException e)
-      {
-         throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
-      }
-      finally
-      {
-         if (outside)
-         {
-            decoratedActualInstance.set(null);
-         }
-      }
+      return proxy;
    }
 
    public List<Decorator<?>> getDecorators()

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/CustomDecoratorWrapper.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -25,7 +25,7 @@
 import org.jboss.weld.introspector.WeldClass;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.util.Deployers;
+import org.jboss.weld.util.Decorators;
 
 /**
  * A wrapper for a decorated instance. Allows to enhance custom decorators with metadata
@@ -49,7 +49,7 @@
    {
       this.delegate = delegate;
       this.weldClass =  beanManager.getServices().get(ClassTransformer.class).loadClass((Class<T>) delegate.getBeanClass());
-      this.decoratedMethodSignatures = Deployers.getDecoratedMethodSignatures(beanManager, delegate.getDecoratedTypes());
+      this.decoratedMethodSignatures = Decorators.getDecoratedMethodSignatures(beanManager, delegate.getDecoratedTypes());
    }
 
    @Override

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -52,7 +52,7 @@
 import org.jboss.weld.introspector.jlr.WeldConstructorImpl;
 import org.jboss.weld.manager.BeanManagerImpl;
 import org.jboss.weld.resources.ClassTransformer;
-import org.jboss.weld.util.Deployers;
+import org.jboss.weld.util.Decorators;
 import org.jboss.weld.util.Proxies;
 import org.jboss.weld.util.reflection.Reflections;
 
@@ -135,7 +135,7 @@
       this.decoratedTypes.addAll(getWeldAnnotated().getInterfaceClosure());
       this.decoratedTypes.remove(Serializable.class);
 
-      this.decoratedMethodSignatures = Deployers.getDecoratedMethodSignatures(getBeanManager(), this.decoratedTypes);
+      this.decoratedMethodSignatures = Decorators.getDecoratedMethodSignatures(getBeanManager(), this.decoratedTypes);
    }
 
    protected void initDelegateInjectionPoint()

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -217,36 +217,37 @@
 
       public T produce(final CreationalContext<T> ctx)
       {
-         final T instance = bean.createInstance(ctx);
+         T instance;
          if (!bean.hasDecorators())
          {
             // This should be safe, but needs verification PLM
             // Without this, the chaining of decorators will fail as the
             // incomplete instance will be resolved
+            instance = bean.createInstance(ctx);
             ctx.push(instance);
          }
-
-         T decoratedInstance = new FixInjectionPoint<T>(bean)
+         else
          {
-
-            @Override
-            protected T work()
+            instance = new FixInjectionPoint<T>(bean)
             {
-               if (bean.hasDecorators())
+               @Override
+               protected T work()
                {
-                  return bean.applyDecorators(instance, ctx, getOriginalInjectionPoint());
+                  // for decorated beans, creation should use the fixed injection point
+                  // thus ensuring that the innermost decorator is provided as InjectionPoint
+                  T undecoratedInstance = bean.createInstance(ctx);
+                  return bean.applyDecorators(undecoratedInstance, ctx, getOriginalInjectionPoint());
                }
-               return instance;
-            }
 
-         }.run();
+            }.run();
+         }
          if (bean.isInterceptionCandidate() && (bean.hasCdiBoundInterceptors() || bean.hasDirectlyDefinedInterceptors()))
          {
-            return bean.applyInterceptors(decoratedInstance, ctx);
+            return bean.applyInterceptors(instance, ctx);
          }
          else
          {
-            return decoratedInstance;
+            return instance;
          }
       }
    }

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecorationHelper.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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.weld.bean.proxy;
+
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_BEAN_ACCESS_FAILED;
+import static org.jboss.weld.logging.messages.BeanMessage.PROXY_INSTANTIATION_FAILED;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import org.jboss.weld.context.SerializableContextualInstanceImpl;
+import org.jboss.weld.exceptions.WeldException;
+import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.Proxies;
+import org.jboss.weld.util.reflection.SecureReflections;
+
+/**
+ * @author Marius Bogoevici
+ */
+public class DecorationHelper<T>
+{
+   private static ThreadLocal<Stack<DecorationHelper<?>>> helperStackHolder = new ThreadLocal<Stack<DecorationHelper<?>>>()
+   {
+      @Override protected Stack<DecorationHelper<?>> initialValue()
+      {
+         return new Stack<DecorationHelper<?>>();
+      }
+   };
+
+   private Class<T> proxyClassForDecorator;
+
+   private T originalInstance;
+
+   private T previousDelegate;
+
+   private int counter;
+
+   private BeanManagerImpl beanManager;
+
+   List<Decorator<?>> decorators;
+
+   public DecorationHelper(T originalInstance, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, List<Decorator<?>> decorators)
+   {
+      this.originalInstance = originalInstance;
+      this.beanManager = beanManager;
+      this.decorators = new LinkedList<Decorator<?>>(decorators);
+      this.proxyClassForDecorator = proxyClassForDecorator;
+      counter = 0;
+   }
+
+   public static Stack<DecorationHelper<?>> getHelperStack()
+   {
+      return helperStackHolder.get();
+   }
+
+   public DecoratorProxyMethodHandler createMethodHandler(InjectionPoint injectionPoint, CreationalContext<?> creationalContext, Decorator<Object> decorator)
+   {
+      Object decoratorInstance = beanManager.getReference(injectionPoint, decorator, creationalContext);
+      SerializableContextualInstanceImpl<Decorator<Object>, Object> serializableContextualInstance = new SerializableContextualInstanceImpl<Decorator<Object>, Object>(decorator, decoratorInstance, null);
+      return new DecoratorProxyMethodHandler(serializableContextualInstance, previousDelegate);
+   }
+
+   public T getNextDelegate(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
+   {
+      if (counter == decorators.size())
+      {
+         previousDelegate = originalInstance;
+         return originalInstance;
+      }
+      else
+      {
+         try
+         {
+            T proxy = SecureReflections.newInstance(proxyClassForDecorator);
+            Proxies.attachMethodHandler(proxy, createMethodHandler(injectionPoint, creationalContext, (Decorator<Object>) decorators.get(counter++)));
+            previousDelegate = proxy;
+            return proxy;
+         }
+         catch (InstantiationException e)
+         {
+            throw new WeldException(PROXY_INSTANTIATION_FAILED, e, this);
+         }
+         catch (IllegalAccessException e)
+         {
+            throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, this);
+         }
+
+      }
+   }
+
+}

Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyMethodHandler.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,15 +1,15 @@
 /*
  * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * Copyright 2010, Red Hat, Inc. and/or its affiliates, 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,  
+ * 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.
@@ -18,11 +18,13 @@
 
 import static org.jboss.weld.logging.messages.BeanMessage.UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR;
 
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
+
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.List;
 
-import javax.enterprise.inject.spi.Decorator;
-
 import org.jboss.interceptor.util.proxy.TargetInstanceProxyMethodHandler;
 import org.jboss.weld.bean.WeldDecorator;
 import org.jboss.weld.exceptions.ForbiddenStateException;
@@ -34,32 +36,33 @@
 
 /**
  * Method handler for decorated beans
- * 
+ *
  * @author Pete Muir
- * 
+ * @author Marius Bogoevici
+ *
  */
 public class DecoratorProxyMethodHandler extends TargetInstanceProxyMethodHandler
 {
    private static final long serialVersionUID = 4577632640130385060L;
 
-   private final List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances;
+   private final SerializableContextualInstance<Decorator<Object>, Object> decoratorInstance;
 
    /**
     * Constructor
-    * 
+    *
     * @param removeMethods
-    * 
+    *
     * @param proxy The generic proxy
     */
-   public DecoratorProxyMethodHandler(List<SerializableContextualInstance<Decorator<Object>, Object>> decoratorInstances, Object instance)
+   public DecoratorProxyMethodHandler(SerializableContextualInstance<Decorator<Object>, Object> decoratorInstance, Object delegateInstance)
    {
-      super (instance, instance.getClass());
-      this.decoratorInstances = decoratorInstances;
+      super (delegateInstance, delegateInstance.getClass());
+      this.decoratorInstance = decoratorInstance;
    }
-   
+
    /**
-    * 
-    * 
+    *
+    *
     * @param self the proxy instance.
     * @param method the overridden method declared in the super class or
     *           interface.
@@ -71,32 +74,34 @@
     *           parameter type is a primitive type, the type of the array
     *           element is a wrapper class.
     * @return the resulting value of the method invocation.
-    * 
+    *
     * @throws Throwable if the method invocation fails.
     */
    @Override
    protected Object doInvoke(Object self, Method method, Method proceed, Object[] args) throws Throwable
    {
+
       MethodSignature methodSignature = new MethodSignatureImpl(method);
-      for (SerializableContextualInstance<Decorator<Object>, Object> beanInstance : decoratorInstances)
+
+      SerializableContextualInstance<Decorator<Object>, Object> beanInstance = decoratorInstance;
+      if (beanInstance.getContextual().get() instanceof WeldDecorator<?>)
       {
-         if (beanInstance.getContextual().get() instanceof WeldDecorator<?>)
+         WeldDecorator<?> decorator = (WeldDecorator<?>) beanInstance.getContextual().get();
+         if (decorator.getDecoratedMethodSignatures().contains(methodSignature)
+               && !method.isAnnotationPresent(Inject.class))
          {
-            WeldDecorator<?> decorator = (WeldDecorator<?>) beanInstance.getContextual().get();
-            if (decorator.getDecoratedMethodSignatures().contains(methodSignature))
+            WeldMethod<?, ?> decoratorMethod = decorator.getWeldAnnotated().getWeldMethod(methodSignature);
+            if (decoratorMethod != null)
             {
-               WeldMethod<?, ?> decoratorMethod = decorator.getWeldAnnotated().getWeldMethod(methodSignature);
-               if (decoratorMethod != null)
-               {
-                  return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
-               }
+               return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
             }
          }
-         else
-         {
-            throw new ForbiddenStateException(UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR, beanInstance.getContextual().get());
-         }
       }
+      else
+      {
+         throw new ForbiddenStateException(UNEXPECTED_UNWRAPPED_CUSTOM_DECORATOR, beanInstance.getContextual().get());
+      }
+
       return SecureReflections.invoke(getTargetInstance(), method, args);
    }
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -76,6 +76,7 @@
 import org.jboss.weld.bean.builtin.AbstractBuiltInBean;
 import org.jboss.weld.bean.builtin.ExtensionBean;
 import org.jboss.weld.bean.proxy.ClientProxyProvider;
+import org.jboss.weld.bean.proxy.DecorationHelper;
 import org.jboss.weld.bootstrap.Validator;
 import org.jboss.weld.bootstrap.api.ServiceRegistry;
 import org.jboss.weld.bootstrap.events.AbstractProcessInjectionTarget;
@@ -866,9 +867,16 @@
 
    public Object getInjectableReference(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
    {
+      if (!injectionPoint.isDelegate())
+      {
          WeldAnnotated<?, ?> element = ResolvableWeldClass.of(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[0]), this);
          Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
          return getReference(injectionPoint, resolvedBean, creationalContext);
+      }
+      else
+      {
+         return DecorationHelper.getHelperStack().peek().getNextDelegate(injectionPoint, creationalContext);
+      }
    }
 
    public <T> Bean<T> getBean(WeldAnnotated<T, ?> element, Annotation... bindings)

Copied: core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java (from rev 5635, core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Decorators.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., 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.weld.util;
+
+import org.jboss.weld.exceptions.ForbiddenStateException;
+import org.jboss.weld.introspector.MethodSignature;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.WeldMethod;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import static org.jboss.weld.logging.messages.BeanMessage.UNABLE_TO_PROCESS;
+
+import javax.inject.Inject;
+
+/**
+ * Helper class for {@link javax.enterprise.inject.spi.Decorator} inspections.
+ * 
+ * @author Marius Bogoevici
+ */
+public class Decorators
+{
+   public static Set<MethodSignature> getDecoratedMethodSignatures(BeanManagerImpl beanManager, Set<Type> decoratedTypes)
+   {
+      Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
+      for (Type type: decoratedTypes)
+      {
+         WeldClass<?> weldClass = getWeldClassOfDecoratedType(beanManager, type);
+         for (WeldMethod<?, ?> method : weldClass.getWeldMethods())
+         {
+            if (!methodSignatures.contains(method.getSignature()))
+            {
+               methodSignatures.add(method.getSignature());
+            }
+         }
+      }
+      return methodSignatures;
+   }
+
+   public static WeldClass<?> getWeldClassOfDecoratedType(BeanManagerImpl beanManager, Type type)
+   {
+      if (type instanceof Class<?>)
+      {
+         return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) type);
+      }
+      if (type instanceof ParameterizedType && (((ParameterizedType) type).getRawType() instanceof Class))
+      {
+         return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) ((ParameterizedType) type).getRawType());
+      }
+      throw new ForbiddenStateException(UNABLE_TO_PROCESS, type);
+   }
+}

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java	2010-01-26 23:36:10 UTC (rev 5636)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Deployers.java	2010-01-27 06:18:35 UTC (rev 5637)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat, Inc., 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.weld.util;
-
-import org.jboss.weld.exceptions.ForbiddenStateException;
-import org.jboss.weld.introspector.MethodSignature;
-import org.jboss.weld.introspector.WeldClass;
-import org.jboss.weld.introspector.WeldMethod;
-import org.jboss.weld.manager.BeanManagerImpl;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.jboss.weld.logging.messages.BeanMessage.UNABLE_TO_PROCESS;
-
-/**
- * Helper class for {@link org.jboss.deployers.spi.deployer.Deployer} inspections.
- * 
- * @author Marius Bogoevici
- */
-public class Deployers
-{
-   public static Set<MethodSignature> getDecoratedMethodSignatures(BeanManagerImpl beanManager, Set<Type> decoratedTypes)
-   {
-      Set<MethodSignature> methodSignatures = new HashSet<MethodSignature>();
-      for (Type type: decoratedTypes)
-      {
-         WeldClass<?> weldClass = getWeldClassOfDecoratedType(beanManager, type);
-         for (WeldMethod<?, ?> method : weldClass.getWeldMethods())
-         {
-            if (!methodSignatures.contains(method.getSignature()))
-            {
-               methodSignatures.add(method.getSignature());
-            }
-         }
-      }
-      return methodSignatures;
-   }
-
-   public static WeldClass<?> getWeldClassOfDecoratedType(BeanManagerImpl beanManager, Type type)
-   {
-      if (type instanceof Class<?>)
-      {
-         return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) type);
-      }
-      if (type instanceof ParameterizedType && (((ParameterizedType) type).getRawType() instanceof Class))
-      {
-         return (WeldClass<?>) beanManager.createAnnotatedType((Class<?>) ((ParameterizedType) type).getRawType());
-      }
-      throw new ForbiddenStateException(UNABLE_TO_PROCESS, type);
-   }
-}



More information about the weld-commits mailing list