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

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Nov 22 18:48:19 EST 2009


Author: marius.bogoevici
Date: 2009-11-22 18:48:19 -0500 (Sun, 22 Nov 2009)
New Revision: 5110

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/AbstractDecoratorMethodHandler.java
   core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/AbstractDecoratorTestHelper.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegate.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegateAndAbstractMethod.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegate.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndAbstractMethod.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegate.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/Window.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Frame.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/SimpleAbstractDecoratorWithInvalidAbstractMethodTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Window.java
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-simple.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethod.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethodAndInitializerMethod.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withCallToItself.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withConstructor.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withInitializerMethod.xml
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/broken/
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/broken/beans-withInvalidAbstractMethod.xml
Modified:
   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/logging/messages/BeanMessage.java
   core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
   core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
Log:
WELD-296,WELD-298: add support for abstract decorators

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	2009-11-22 15:57:32 UTC (rev 5109)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -23,29 +23,47 @@
 import static org.jboss.weld.logging.messages.BeanMessage.NO_DELEGATE_FOR_DECORATOR;
 import static org.jboss.weld.logging.messages.BeanMessage.TOO_MANY_DELEGATES_FOR_DECORATOR;
 import static org.jboss.weld.logging.messages.BeanMessage.UNABLE_TO_PROCESS;
+import static org.jboss.weld.logging.messages.BeanMessage.ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE;
 
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
 import java.io.Serializable;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import javax.enterprise.inject.spi.Decorator;
-import javax.inject.Inject;
-
+import javassist.util.proxy.ProxyObject;
 import org.jboss.weld.BeanManagerImpl;
 import org.jboss.weld.DefinitionException;
 import org.jboss.weld.ForbiddenStateException;
+import org.jboss.weld.bean.proxy.AbstractDecoratorMethodHandler;
 import org.jboss.weld.bootstrap.BeanDeployerEnvironment;
 import org.jboss.weld.injection.MethodInjectionPoint;
+import org.jboss.weld.injection.ProxyClassConstructorInjectionPointWrapper;
 import org.jboss.weld.injection.WeldInjectionPoint;
+import org.jboss.weld.introspector.MethodSignature;
 import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.WeldConstructor;
+import org.jboss.weld.introspector.WeldMethod;
+import org.jboss.weld.introspector.jlr.WeldClassImpl;
+import org.jboss.weld.introspector.jlr.WeldConstructorImpl;
+import org.jboss.weld.resources.ClassTransformer;
+import org.jboss.weld.util.Proxies;
+import org.jboss.weld.util.Reflections;
 
 public class DecoratorImpl<T> extends ManagedBean<T> implements Decorator<T>
 {
+   private WeldClass<?> annotatedDelegateItem;
 
+   private WeldClass<T> proxyClassForAbstractDecorators;
+   private WeldConstructor<T> constructorForAbstractDecorator;
+
    public static <T> Decorator<T> wrap(final Decorator<T> decorator)
    {
       return new ForwardingDecorator<T>()
@@ -107,6 +125,7 @@
          initDelegateBindings();
          initDelegateType();
          checkDelegateType();
+         checkAbstractMethods();
       }
    }
 
@@ -189,8 +208,28 @@
 
          }
       }
+      annotatedDelegateItem = WeldClassImpl.of(delegateInjectionPoint.getJavaClass(), manager.getServices().get(ClassTransformer.class));
    }
 
+   private void checkAbstractMethods()
+   {
+      if (getAnnotatedItem().isAbstract())
+      {
+         for(WeldMethod<?,?> method: getAnnotatedItem().getWeldMethods())
+         {
+            if (Reflections.isAbstract(((AnnotatedMethod) method).getJavaMember()))
+            {
+               MethodSignature methodSignature = method.getSignature();
+               if (this.annotatedDelegateItem.getWeldMethod(methodSignature) == null)
+               {
+                  throw new DefinitionException(ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE,  method.getSignature(), this, getAnnotatedItem().getName());
+               }
+            }
+         }
+      }
+   }
+
+
    public Set<Annotation> getDelegateQualifiers()
    {
       return delegateBindings;
@@ -210,14 +249,56 @@
    {
       return delegateInjectionPoint;
    }
-   
+
    @Override
+   protected void initType()
+   {
+      super.initType();
+      if (getAnnotatedItem().isAbstract())
+      {
+         Proxies.TypeInfo typeInfo = Proxies.TypeInfo.of(Collections.singleton(getAnnotatedItem().getJavaClass()));
+         Class<T> clazz = Proxies.createProxyClass(null, typeInfo);
+         proxyClassForAbstractDecorators = manager.getServices().get(ClassTransformer.class).loadClass(clazz);
+      }
+   }
+
+   @Override
+   protected void initConstructor()
+   {
+      super.initConstructor();
+      if (getAnnotatedItem().isAbstract())
+      {
+         constructorForAbstractDecorator = WeldConstructorImpl.of(
+               proxyClassForAbstractDecorators.getDeclaredWeldConstructor(getConstructor().getSignature()),
+               proxyClassForAbstractDecorators,
+               manager.getServices().get(ClassTransformer.class));
+      }
+   }
+
+   @Override
    public void initDecorators()
    {
       // No-op, decorators can't have decorators
    }
-   
+
    @Override
+   protected T createInstance(CreationalContext<T> ctx)
+   {
+      if (!getAnnotatedItem().isAbstract())
+      {
+         return super.createInstance(ctx);
+      }
+      else
+      {
+         ProxyClassConstructorInjectionPointWrapper<T> constructorInjectionPointWrapper = new ProxyClassConstructorInjectionPointWrapper(this, constructorForAbstractDecorator, getConstructor());
+         T instance = constructorInjectionPointWrapper.newInstance(manager, ctx);
+         AbstractDecoratorMethodHandler abstractDecoratorMethodHandler = new AbstractDecoratorMethodHandler(annotatedDelegateItem, getDelegateInjectionPoint(), constructorInjectionPointWrapper.getInjectedDelegate());
+         ((ProxyObject)instance).setHandler(abstractDecoratorMethodHandler);
+         return instance;
+      }
+   }
+
+   @Override
    public String getDescription()
    {
       // TODO Auto-generated method stub

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	2009-11-22 15:57:32 UTC (rev 5109)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -58,10 +58,8 @@
 import org.jboss.weld.injection.InjectionContextImpl;
 import org.jboss.weld.injection.WeldInjectionPoint;
 import org.jboss.weld.introspector.WeldClass;
-import org.jboss.weld.introspector.WeldConstructor;
 import org.jboss.weld.introspector.WeldField;
 import org.jboss.weld.introspector.WeldMethod;
-import org.jboss.weld.logging.messages.BeanMessage;
 import org.jboss.weld.metadata.cache.MetaAnnotationStore;
 import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
 import org.jboss.weld.util.Beans;
@@ -244,7 +242,7 @@
 
             public T produce(CreationalContext<T> ctx)
             {
-               T instance = constructor.newInstance(manager, ctx);
+               T instance = ManagedBean.this.createInstance(ctx);
                if (!hasDecorators())
                {
                   // This should be safe, but needs verification PLM
@@ -270,6 +268,11 @@
       }
    }
 
+   protected T createInstance(CreationalContext<T> ctx) 
+   {
+      return constructor.newInstance(manager, ctx);
+   }
+
    @Override
    public void initializeAfterBeanDiscovery()
    {
@@ -456,7 +459,7 @@
     *
     * @return The constructor
     */
-   public WeldConstructor<T> getConstructor()
+   public ConstructorInjectionPoint<T> getConstructor()
    {
       return constructor;
    }

Added: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/AbstractDecoratorMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/AbstractDecoratorMethodHandler.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/AbstractDecoratorMethodHandler.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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 javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.reflect.Method;
+
+import javassist.util.proxy.MethodHandler;
+import org.jboss.weld.injection.FieldInjectionPoint;
+import org.jboss.weld.injection.ParameterInjectionPoint;
+import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.introspector.jlr.MethodSignatureImpl;
+import org.jboss.weld.util.Reflections;
+
+/**
+ * {@link MethodHandler} for Abstract decorators.
+ *
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class AbstractDecoratorMethodHandler implements MethodHandler
+{
+
+   private WeldClass<?> delegateClass;
+
+   private InjectionPoint injectionPoint;
+
+   private Object delegate;
+
+   public AbstractDecoratorMethodHandler(WeldClass<?> delegateClass, InjectionPoint injectionPoint, Object injectedDelegate)
+   {
+      this.delegateClass = delegateClass;
+      this.injectionPoint = injectionPoint;
+      this.delegate = injectedDelegate;
+   }
+
+   public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable
+   {
+      // intercept injection of delegate if not set already
+      // assumes that injection happens on a single thread
+      // TODO: replace this way of initializing field-injected delegates (move out) - MBG
+      if (delegate == null)
+      {
+         if (injectionPoint instanceof FieldInjectionPoint)
+         {
+            this.delegate = ((FieldInjectionPoint) injectionPoint).get(self);
+         }
+         else
+         if (injectionPoint.getMember() instanceof Method && injectionPoint instanceof ParameterInjectionPoint<?, ?>)
+         {
+            if (thisMethod.equals(injectionPoint.getMember()))
+            {
+               int position = ((ParameterInjectionPoint<?, ?>) injectionPoint).getPosition();
+               delegate = args[position];
+            }
+         }
+      }
+      // if method is abstract, invoke the corresponding method on the delegate
+      if (Reflections.isAbstract(thisMethod))
+      {
+         Method method = ((AnnotatedMethod<?>) delegateClass.getWeldMethod(new MethodSignatureImpl(thisMethod))).getJavaMember();
+         return method.invoke(delegate, args);
+      }
+
+      return proceed.invoke(self, args);
+
+   }
+}

Added: core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ProxyClassConstructorInjectionPointWrapper.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.injection;
+
+import javax.decorator.Decorator;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.weld.BeanManagerImpl;
+import org.jboss.weld.introspector.WeldConstructor;
+
+/**
+ * A wrapper on a {@link ConstructorInjectionPoint}, to be used if a proxy subclass is instantiated instead of the
+ * original (e.g. because the original is an abstract {@link Decorator})
+ *
+ * This is a wrapper class, it is not thread-safe and any instance of this class should be used only for temporarily
+ * enhancing the bean instance creation process.
+ *
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class ProxyClassConstructorInjectionPointWrapper<T> extends ConstructorInjectionPoint<T>
+{
+   private ConstructorInjectionPoint<T> originalConstructorInjectionPoint;
+
+   private Object injectedDelegate;
+
+   public ProxyClassConstructorInjectionPointWrapper(Bean<T> declaringBean, WeldConstructor<T> weldConstructor, ConstructorInjectionPoint<T> originalConstructorInjectionPoint)
+   {
+      super(declaringBean, weldConstructor);
+      this.originalConstructorInjectionPoint = originalConstructorInjectionPoint;
+   }
+
+   @Override
+   public List<ParameterInjectionPoint<?, T>> getWeldParameters()
+   {
+      return originalConstructorInjectionPoint.getWeldParameters();
+   }
+
+   @Override
+   protected Object[] getParameterValues(List<ParameterInjectionPoint<?, T>> parameters, Object specialVal, Class<? extends Annotation> specialParam, BeanManagerImpl manager, CreationalContext<?> creationalContext)
+   {
+      Object[] parameterValues = super.getParameterValues(parameters, specialVal, specialParam, manager, creationalContext);
+      if (parameters.size() > 0)
+      {
+         for (ParameterInjectionPoint<?, T> parameterInjectionPoint: parameters)
+         {
+            if (parameterInjectionPoint.isDelegate())
+            {
+               this.injectedDelegate = parameterValues[parameterInjectionPoint.getPosition()];
+            }
+         }
+      }
+      return parameterValues;
+   }
+
+   /**
+    * The delegate injected during the constructed process, if any
+    *
+    * @return
+    */
+   public Object getInjectedDelegate()
+   {
+      return injectedDelegate;
+   }
+}

Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java	2009-11-22 15:57:32 UTC (rev 5109)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/BeanMessage.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -107,6 +107,7 @@
    @MessageId("000086") CANNOT_DESTROY_ENTERPRISE_BEAN_NOT_CREATED,
    @MessageId("000087") MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED,
    @MessageId("000088") OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS,
-   @MessageId("000089") TOO_MANY_EJBS_FOR_CLASS;
+   @MessageId("000089") TOO_MANY_EJBS_FOR_CLASS,
+   @MessageId("000090") ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE;
    
 }

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-11-22 15:57:32 UTC (rev 5109)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Reflections.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -413,6 +413,17 @@
    }
 
    /**
+    * Checks if a method is abstract
+    *
+    * @param method
+    * @return
+    */
+   public static boolean isAbstract(Method method)
+   {
+      return Modifier.isAbstract(method.getModifiers());
+   }
+
+   /**
     * Gets a constructor with matching parameter types
     * 
     * @param <T> The type

Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties	2009-11-22 15:57:32 UTC (rev 5109)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/bean_en.properties	2009-11-22 23:48:19 UTC (rev 5110)
@@ -88,3 +88,4 @@
 MESSAGE_DRIVEN_BEANS_CANNOT_BE_MANAGED=Message driven beans cannot be Managed Beans\:  {0}
 OBSERVER_METHOD_MUST_BE_STATIC_OR_BUSINESS=Observer method must be static or business method\:  {0} on {1}
 TOO_MANY_EJBS_FOR_CLASS=Unable to determine EJB for {0}, multiple EJBs with that class\:  {1}
+ABSTRACT_METHOD_MUST_MATCH_DECORATED_TYPE=Method {0} defined on {1} does not match a method on decorated type {2} 

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/AbstractDecoratorTestHelper.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/AbstractDecoratorTestHelper.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/AbstractDecoratorTestHelper.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+public class AbstractDecoratorTestHelper
+{
+   static void resetAll()
+   {
+      Window.drawn = false;
+      Window.moved = false;
+      FrameWithFieldInjectedDelegate.drawn = false;
+      FrameWithFieldInjectedDelegateAndAbstractMethod.moved = false;
+      FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.moved = false;
+      FrameWithConstructorInjectedDelegate.drawn = false;
+      FrameWithConstructorInjectedDelegateAndAbstractMethod.moved = false;
+      FrameWithInitializerMethodInjectedDelegate.drawn = false;
+      FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.moved = false;
+   }
+}

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegate.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegate.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegate.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithConstructorInjectedDelegate
+{
+
+   static boolean drawn;
+
+   Window window;
+
+   @Inject
+   FrameWithConstructorInjectedDelegate(@Delegate Window window)
+   {
+      this.window = window;
+   }
+
+   public void draw()
+   {
+      drawn = true;
+      window.draw();
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegateAndAbstractMethod.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegateAndAbstractMethod.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithConstructorInjectedDelegateAndAbstractMethod.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithConstructorInjectedDelegateAndAbstractMethod
+{
+
+   Window window;
+
+   static boolean moved = false;
+
+   @Inject
+   FrameWithConstructorInjectedDelegateAndAbstractMethod(@Delegate Window window)
+   {
+      this.window = window;
+   }
+
+   public abstract void draw();
+
+   public void move()
+   {
+     moved = true;
+     draw();
+   }
+   
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegate.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegate.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegate.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithFieldInjectedDelegate
+{
+
+   static boolean drawn;
+
+   @Inject @Delegate
+   Window window;
+
+   public void draw()
+   {
+     drawn = true;
+     window.draw();
+   }
+   
+}

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndAbstractMethod.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndAbstractMethod.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndAbstractMethod.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithFieldInjectedDelegateAndAbstractMethod
+{
+
+   static boolean moved;
+
+   @Inject @Delegate
+   Window window;
+
+   public abstract void draw();
+
+   public void move()
+   {
+      moved = true;
+      window.move();
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod
+{
+
+   static boolean moved;
+
+   @Inject @Delegate
+   Window window;
+
+   public abstract void draw();
+
+   public void move()
+   {
+      moved = true;
+      draw();
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegate.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegate.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegate.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithInitializerMethodInjectedDelegate
+{
+
+   static boolean drawn;
+
+   private Window window;
+
+   @Inject
+   void initWindow(@Delegate Window window){
+      this.window = window;
+   }
+
+   public void draw() {
+      drawn = true;
+      window.draw();
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class FrameWithInitializerMethodInjectedDelegateAndAbstractMethod
+{
+
+   static boolean moved;
+
+   private Window window;
+
+   @Inject
+   void initWindow(@Delegate Window window)
+   {
+      this.window = window;
+   }
+
+   public abstract void draw();
+
+   public void move()
+   {
+      moved = true;
+      window.move();
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.resetAll;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-simple.xml")
+public class SimpleAbstractDecoratorTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      resetAll();
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+      window.draw();
+      assert Window.drawn;
+      assert FrameWithFieldInjectedDelegate.drawn;
+   }
+
+}

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.resetAll;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withAbstractMethodAndInitializerMethod.xml")
+public class SimpleAbstractDecoratorWithAbstractMethodAndInitializerMethodTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+
+      resetAll();
+      window.draw();
+      assert Window.drawn;
+      assert FrameWithFieldInjectedDelegate.drawn;
+      assert !FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.moved;
+
+      resetAll();
+      window.move();
+      assert Window.moved;
+      assert !FrameWithFieldInjectedDelegate.drawn;
+      assert FrameWithInitializerMethodInjectedDelegateAndAbstractMethod.moved;
+
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithAbstractMethodTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.resetAll;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withAbstractMethod.xml")
+public class SimpleAbstractDecoratorWithAbstractMethodTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+
+      resetAll();
+      window.draw();
+      assert Window.drawn;
+      assert FrameWithFieldInjectedDelegate.drawn;
+      assert !FrameWithFieldInjectedDelegateAndAbstractMethod.moved;
+
+      resetAll();
+      window.move();
+      assert Window.moved;
+      assert !FrameWithFieldInjectedDelegate.drawn;
+      assert FrameWithFieldInjectedDelegateAndAbstractMethod.moved;
+
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithCallToItselfTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.resetAll;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withCallToItself.xml")
+public class SimpleAbstractDecoratorWithCallToItselfTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+
+      resetAll();
+      window.move();
+      assert Window.drawn;
+      assert FrameWithFieldInjectedDelegate.drawn;
+      assert FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod.moved;
+
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithConstructorTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.*;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withConstructor.xml")
+public class SimpleAbstractDecoratorWithConstructorTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      resetAll();
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+      window.draw();
+      assert Window.drawn;
+      assert FrameWithConstructorInjectedDelegate.drawn;
+
+      resetAll();
+      window.move();
+      assert !Window.moved;
+      assert Window.drawn;
+      assert FrameWithConstructorInjectedDelegate.drawn;
+      assert FrameWithConstructorInjectedDelegateAndAbstractMethod.moved;
+
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/SimpleAbstractDecoratorWithInitializerMethodTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+import static org.jboss.weld.tests.decorators.abstractDecorator.AbstractDecoratorTestHelper.resetAll;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withInitializerMethod.xml")
+public class SimpleAbstractDecoratorWithInitializerMethodTest extends AbstractWeldTest
+{
+   @Test
+   public void testAbstractDecoratorApplied()
+   {
+
+      resetAll();
+
+      Window window = getCurrentManager().getInstanceByType(Window.class);
+      window.draw();
+      assert Window.drawn;
+      assert FrameWithInitializerMethodInjectedDelegate.drawn;
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/Window.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/Window.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/Window.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator;
+
+/**
+ *
+ * @author Marius Bogoevici
+ */
+public class Window
+{
+   static boolean drawn;
+
+   static boolean moved;
+
+   public void draw()
+   {
+      drawn = true;
+   }
+
+   public void move()
+   {
+      moved = true; 
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Frame.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Frame.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Frame.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator.broken;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.inject.Inject;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Decorator
+public abstract class Frame
+{
+
+   @Inject @Delegate
+   Window window;
+
+   public void draw()
+   {
+      window.draw();
+   }
+
+   public abstract void resize();
+   
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/SimpleAbstractDecoratorWithInvalidAbstractMethodTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/SimpleAbstractDecoratorWithInvalidAbstractMethodTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/SimpleAbstractDecoratorWithInvalidAbstractMethodTest.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator.broken;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.jboss.weld.DefinitionException;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+
+/**
+ * @author <a href="mailto:mariusb at redhat.com">Marius Bogoevici</a>
+ */
+ at Artifact
+ at BeansXml("beans-withInvalidAbstractMethod.xml")
+ at ExpectedDeploymentException(DefinitionException.class)
+public class SimpleAbstractDecoratorWithInvalidAbstractMethodTest extends AbstractWeldTest
+{
+   @Test(groups = "broken")
+   // TODO: needs exception transformer to run in JBAS
+   public void testAbstractDecoratorApplied()
+   {
+      assert false;
+   }
+
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Window.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Window.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/decorators/abstractDecorator/broken/Window.java	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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.tests.decorators.abstractDecorator.broken;
+
+/**
+ *
+ * @author Marius Bogoevici
+ */
+public class Window
+{
+   static boolean drawn;
+
+   static boolean moved;
+
+   public void draw()
+   {
+      drawn = true;
+   }
+
+   public void move()
+   {
+      moved = true;
+   }
+}
\ No newline at end of file

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-simple.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-simple.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-simple.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,5 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethod.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethod.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethod.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,6 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegateAndAbstractMethod</class>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethodAndInitializerMethod.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethodAndInitializerMethod.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withAbstractMethodAndInitializerMethod.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,6 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithInitializerMethodInjectedDelegateAndAbstractMethod</class>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withCallToItself.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withCallToItself.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withCallToItself.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,6 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegateAndSelfInvokedAbstractMethod</class>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithFieldInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withConstructor.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withConstructor.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withConstructor.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,6 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithConstructorInjectedDelegateAndAbstractMethod</class>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithConstructorInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withInitializerMethod.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withInitializerMethod.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/beans-withInitializerMethod.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,5 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.FrameWithInitializerMethodInjectedDelegate</class>
+   </decorators>
+</beans>

Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/broken/beans-withInvalidAbstractMethod.xml
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/broken/beans-withInvalidAbstractMethod.xml	                        (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/decorators/abstractDecorator/broken/beans-withInvalidAbstractMethod.xml	2009-11-22 23:48:19 UTC (rev 5110)
@@ -0,0 +1,5 @@
+<beans> 
+   <decorators>
+      <class>org.jboss.weld.tests.decorators.abstractDecorator.broken.Frame</class>
+   </decorators>
+</beans>



More information about the weld-commits mailing list