Author: pete.muir(a)jboss.org
Date: 2009-06-25 10:30:59 -0400 (Thu, 25 Jun 2009)
New Revision: 2890
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Foo.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Logger.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/MockLogger.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/beans.xml
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
Log:
Finish off decorators
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-06-25 08:13:14
UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-06-25 14:30:59
UTC (rev 2890)
@@ -35,10 +35,12 @@
import javax.enterprise.inject.UnproxyableResolutionException;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.event.Event;
import javax.inject.Obtains;
+import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.DecoratorBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
@@ -141,6 +143,21 @@
}
specializedBeans.add(abstractBean.getSpecializedBean());
}
+ if (Beans.isPassivatingBean(bean, manager) && bean instanceof
AbstractClassBean)
+ {
+ AbstractClassBean<?> classBean = (AbstractClassBean<?>) bean;
+ if (classBean.hasDecorators())
+ {
+ for (Decorator<?> decorator : classBean.getDecorators())
+ {
+ if (!decorator.isSerializable())
+ {
+ throw new UnserializableDependencyException("The bean "
+ bean + " declares a passivating scope but has non-serializable decorator: " +
decorator);
+ }
+ }
+ }
+
+ }
}
boolean normalScoped =
manager.getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-06-25
08:13:14 UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -534,6 +534,7 @@
public boolean isSerializable()
{
+ // TODO WTF - why are we not caching the serializability of injection points!
return _serializable && checkInjectionPointsAreSerializable();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-06-25
08:13:14 UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -17,11 +17,17 @@
package org.jboss.webbeans.bean;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
+import javassist.util.proxy.ProxyFactory;
+import javassist.util.proxy.ProxyObject;
+
import javax.enterprise.context.Dependent;
import javax.enterprise.context.ScopeType;
import javax.enterprise.context.spi.CreationalContext;
@@ -36,6 +42,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.proxy.DecoratorProxyMethodHandler;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
@@ -46,6 +53,7 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Strings;
/**
@@ -68,9 +76,12 @@
private Set<MethodInjectionPoint<?>> initializerMethods;
private Set<String> dependencies;
- private List<Decorator<?>> decoratorStack;
+ private List<Decorator<?>> decorators;
private final String id;
+ private Class<T> proxyClassForDecorators;
+
+ private final ThreadLocal<Integer> decoratorStackPosition;
/**
* Constructor
@@ -83,6 +94,16 @@
super(manager);
this.annotatedItem = type;
this.id = createId(getClass().getSimpleName() + "-" + type.getName());
+ this.decoratorStackPosition = new ThreadLocal<Integer>()
+ {
+
+ @Override
+ protected Integer initialValue()
+ {
+ return 0;
+ }
+
+ };
}
/**
@@ -95,23 +116,95 @@
super.initialize(environment);
checkScopeAllowed();
checkBeanImplementation();
- initDecoratorStack();
+ initDecorators();
+ checkType();
+ initProxyClassForDecoratedBean();
}
- protected void initDecoratorStack()
+ protected void checkType()
{
- this.decoratorStack = getManager().resolveDecorators(getTypes(), getBindings());
+
}
+ protected void initDecorators()
+ {
+ this.decorators = getManager().resolveDecorators(getTypes(), getBindings());
+ }
+
public boolean hasDecorators()
{
- return this.decoratorStack != null && this.decoratorStack.size() > 0;
+ return this.decorators != null && this.decorators.size() > 0;
}
- protected List<Decorator<?>> getDecoratorStack()
+ protected void initProxyClassForDecoratedBean()
{
- return Collections.unmodifiableList(decoratorStack);
+ if (hasDecorators())
+ {
+ Set<Type> types = new LinkedHashSet<Type>(getTypes());
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ @SuppressWarnings("unchecked")
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClassForDecorators = proxyClass;
+ }
}
+
+ protected T applyDecorators(T instance)
+ {
+ if (hasDecorators())
+ {
+ List<SerializableBeanInstance<DecoratorBean<Object>, Object>>
decoratorInstances = new
ArrayList<SerializableBeanInstance<DecoratorBean<Object>,Object>>();
+ boolean outside = decoratorStackPosition.get().intValue() == 0;
+ try
+ {
+ int i = decoratorStackPosition.get();
+ while (i < decorators.size())
+ {
+ Decorator<?> decorator = decorators.get(i);
+ if (decorator instanceof DecoratorBean)
+ {
+ decoratorStackPosition.set(++i);
+ decoratorInstances.add(new
SerializableBeanInstance<DecoratorBean<Object>, Object>((DecoratorBean)
decorator, getManager().getReference(decorator, Object.class)));
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot operate on non container
provided decorator " + decorator);
+ }
+ }
+ }
+ finally
+ {
+ if (outside)
+ {
+ decoratorStackPosition.remove();
+ }
+ }
+ try
+ {
+ T proxy = proxyClassForDecorators.newInstance();
+ ((ProxyObject) proxy).setHandler(new
DecoratorProxyMethodHandler(decoratorInstances, instance));
+ return proxy;
+ }
+ catch (InstantiationException e)
+ {
+ throw new RuntimeException("Could not instantiate decorator proxy for
" + toString(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ throw new RuntimeException("Could not access bean correctly when
creating decorator proxy for " + toString(), e);
+ }
+ }
+ else
+ {
+ return instance;
+ }
+ }
+
+ public List<Decorator<?>> getDecorators()
+ {
+ return Collections.unmodifiableList(decorators);
+ }
/**
* Injects bound fields
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java 2009-06-25
08:13:14 UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -190,7 +190,7 @@
}
@Override
- protected void initDecoratorStack()
+ protected void initDecorators()
{
// No-op, decorators can't have decorators
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-25
08:13:14 UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -232,7 +232,7 @@
creationalContext.push(instance);
((ProxyObject) instance).setHandler(new
EnterpriseBeanProxyMethodHandler(this));
log.trace("Enterprise bean instance created for bean {0}", this);
- return instance;
+ return applyDecorators(instance);
}
catch (InstantiationException e)
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,34 @@
+package org.jboss.webbeans.bean;
+
+import java.io.Serializable;
+
+import org.jboss.webbeans.BeanManagerImpl;
+
+public class SerializableBeanInstance<T extends RIBean<I>, I> implements
Serializable
+{
+
+ private static final long serialVersionUID = 7341389081613003687L;
+
+ private final BeanManagerImpl manager;
+ private final String beanId;
+ private final I instance;
+
+ public SerializableBeanInstance(T bean, I instance)
+ {
+ this.manager = bean.getManager();
+ this.beanId = bean.getId();
+ this.instance = instance;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getBean()
+ {
+ return (T) manager.getRiBeans().get(beanId);
+ }
+
+ public I getInstance()
+ {
+ return instance;
+ }
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SerializableBeanInstance.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-06-25
08:13:14 UTC (rev 2889)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -119,6 +119,7 @@
try
{
instance = constructor.newInstance(manager, creationalContext);
+ instance = applyDecorators(instance);
creationalContext.push(instance);
dependentStorageRequest = DependentStorageRequest.of(dependentInstancesStore,
instance);
DependentContext.instance().startCollectingDependents(dependentStorageRequest);
@@ -302,7 +303,6 @@
{
initConstructor();
super.initialize(environment);
- checkType();
initPostConstruct();
initPreDestroy();
if (getManager().getServices().contains(EjbServices.class))
@@ -357,7 +357,7 @@
{
throw new DefinitionException("Bean class which has decorators cannot be
declared final " + this);
}
- for (Decorator<?> decorator : getDecoratorStack())
+ for (Decorator<?> decorator : getDecorators())
{
if (decorator instanceof DecoratorBean)
{
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.proxy;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import javassist.util.proxy.MethodHandler;
+
+import org.jboss.webbeans.bean.DecoratorBean;
+import org.jboss.webbeans.bean.SerializableBeanInstance;
+import org.jboss.webbeans.introspector.MethodSignature;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.introspector.jlr.MethodSignatureImpl;
+
+/**
+ * Method handler for decorated beans
+ *
+ * @author Pete Muir
+ *
+ */
+public class DecoratorProxyMethodHandler implements MethodHandler, Serializable
+{
+ private static final long serialVersionUID = 4577632640130385060L;
+
+ private final List<SerializableBeanInstance<DecoratorBean<Object>,
Object>> decoratorInstances;
+
+ private final Object instance;
+
+ /**
+ * Constructor
+ *
+ * @param removeMethods
+ *
+ * @param proxy The generic proxy
+ */
+ public
DecoratorProxyMethodHandler(List<SerializableBeanInstance<DecoratorBean<Object>,
Object>> decoratorInstances, Object instance)
+ {
+ this.decoratorInstances = decoratorInstances;
+ this.instance = instance;
+ }
+
+ /**
+ *
+ *
+ * @param self the proxy instance.
+ * @param method the overridden method declared in the super class or
+ * interface.
+ * @param proceed the forwarder method for invoking the overridden method. It
+ * is null if the overridden method is abstract or declared in the
+ * interface.
+ * @param args an array of objects containing the values of the arguments
+ * passed in the method invocation on the proxy instance. If a
+ * 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.
+ */
+ public Object invoke(Object self, Method method, Method proceed, Object[] args) throws
Throwable
+ {
+ MethodSignature methodSignature = new MethodSignatureImpl(method);
+ for (SerializableBeanInstance<DecoratorBean<Object>, Object>
beanInstance : decoratorInstances)
+ {
+ WBMethod<?> decoratorMethod =
beanInstance.getBean().getAnnotatedItem().getMethod(methodSignature);
+ if (decoratorMethod != null)
+ {
+ return decoratorMethod.invokeOnInstance(beanInstance.getInstance(), args);
+ }
+ }
+ return method.invoke(instance, args);
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/DecoratorProxyMethodHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-06-25
08:13:14 UTC (rev 2889)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanProxyMethodHandler.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.bean.proxy;
+import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collection;
@@ -36,8 +37,11 @@
* @author Pete Muir
*
*/
-public class EnterpriseBeanProxyMethodHandler implements MethodHandler
+public class EnterpriseBeanProxyMethodHandler implements MethodHandler, Serializable
{
+
+ private static final long serialVersionUID = 2107723373882153667L;
+
// The log provider
static final transient Log log =
Logging.getLog(EnterpriseBeanProxyMethodHandler.class);
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+import javax.enterprise.inject.Current;
+
+/**
+ * @author pmuir
+ *
+ */
+public class CowShed
+{
+
+ public static final String MESSAGE = "cowShed";
+
+ @Current Logger logger;
+
+ @Current Foo foo;
+
+ public void milk()
+ {
+ logger.log(MESSAGE);
+ }
+
+ public void washDown()
+ {
+ foo.log(MESSAGE);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * @author pmuir
+ *
+ */
+@Artifact
+(a)BeansXml("beans.xml")
+public class DecoratorInvocationTest extends AbstractJSR299Test
+{
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section="8.5", id="a"),
+ @SpecAssertion(section="8.5", id="c"),
+ @SpecAssertion(section="8.5", id="b"),
+ @SpecAssertion(section="8.1.3", id="d"),
+ @SpecAssertion(section="8.1.2", id="f"),
+ @SpecAssertion(section="8.1.2", id="b")
+ })
+ public void testDecoratorInvocation()
+ {
+ TimestampLogger.setMessage(null);
+ MockLogger.setMessage(null);
+ getInstanceByType(CowShed.class).milk();
+ assert TimestampLogger.getMessage().equals(CowShed.MESSAGE);
+ assert MockLogger.getMessage().equals(CowShed.MESSAGE);
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section="8.5", id="d"),
+ @SpecAssertion(section="8.5", id="e"),
+ @SpecAssertion(section="8.5", id="f"),
+ @SpecAssertion(section="8.4", id="a"),
+ @SpecAssertion(section="8.1.3", id="d"),
+ @SpecAssertion(section="8.1.2", id="f"),
+ @SpecAssertion(section="8.1.2", id="b")
+ })
+ public void testChainedDecoratorInvocation()
+ {
+ FooDecorator1.setMessage(null);
+ FooDecorator2.setMessage(null);
+ FooImpl.setMessage(null);
+ getInstanceByType(CowShed.class).washDown();
+ assert FooDecorator1.getMessage().equals(CowShed.MESSAGE);
+ assert FooDecorator2.getMessage().equals(CowShed.MESSAGE + FooDecorator1.SUFFIX);
+ assert FooImpl.getMessage().equals(CowShed.MESSAGE + FooDecorator1.SUFFIX +
FooDecorator2.SUFFIX);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Foo.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Foo.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Foo.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+/**
+ * @author pmuir
+ *
+ */
+public interface Foo
+{
+
+ public void log(String message);
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+/**
+ * @author pmuir
+ *
+ */
+@Decorator
+public class FooDecorator1
+{
+
+ public static final String SUFFIX = "fooDecorator1";
+
+ private static String message;
+
+ /**
+ * @return the message
+ */
+ public static String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public static void setMessage(String message)
+ {
+ FooDecorator1.message = message;
+ }
+
+ @Decorates Foo foo;
+
+ public void log(String message)
+ {
+ FooDecorator1.message = message;
+ foo.log(message + SUFFIX);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+/**
+ * @author pmuir
+ *
+ */
+@Decorator
+public class FooDecorator2
+{
+
+ public static final String SUFFIX = "fooDecorator2";
+
+ private static String message;
+
+ /**
+ * @return the message
+ */
+ public static String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public static void setMessage(String message)
+ {
+ FooDecorator2.message = message;
+ }
+
+ @Decorates Foo foo;
+
+ public void log(String message)
+ {
+ FooDecorator2.message = message;
+ foo.log(message + SUFFIX);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+/**
+ * @author pmuir
+ *
+ */
+public class FooImpl implements Foo
+{
+
+ private static String message;
+
+ /**
+ * @return the message
+ */
+ public static String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public static void setMessage(String message)
+ {
+ FooImpl.message = message;
+ }
+
+ public void log(String message)
+ {
+ FooImpl.message = message;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Logger.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Logger.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Logger.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+
+/**
+ * @author pmuir
+ *
+ */
+public interface Logger
+{
+
+ public void log(String string);
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/Logger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/MockLogger.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/MockLogger.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/MockLogger.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+/**
+ * @author pmuir
+ *
+ */
+public class MockLogger implements Logger
+{
+
+ private static String message = "";
+
+ public void log(String string)
+ {
+ message = string;
+ }
+
+ /**
+ * @return the log
+ */
+ public static String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * @param log the log to set
+ */
+ public static void setMessage(String log)
+ {
+ MockLogger.message = log;
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/MockLogger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.decorators.invocation;
+
+import javax.decorator.Decorates;
+import javax.decorator.Decorator;
+
+
+/**
+ * @author pmuir
+ *
+ */
+@Decorator
+public class TimestampLogger
+{
+
+ private static String message;
+
+ @Decorates
+ private Logger logger;
+
+ public void log(String message)
+ {
+ TimestampLogger.message = message;
+ logger.log(message);
+ }
+
+ /**
+ * @return the message
+ */
+ public static String getMessage()
+ {
+ return message;
+ }
+
+ /**
+ * @param message the message to set
+ */
+ public static void setMessage(String message)
+ {
+ TimestampLogger.message = message;
+ }
+
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/beans.xml
===================================================================
---
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/beans.xml
(rev 0)
+++
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/beans.xml 2009-06-25
14:30:59 UTC (rev 2890)
@@ -0,0 +1,7 @@
+<beans>
+ <decorators>
+
<class>org.jboss.jsr299.tck.tests.decorators.invocation.TimestampLogger</class>
+
<class>org.jboss.jsr299.tck.tests.decorators.invocation.FooDecorator1</class>
+
<class>org.jboss.jsr299.tck.tests.decorators.invocation.FooDecorator2</class>
+ </decorators>
+</beans>
Property changes on:
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/decorators/invocation/beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain