Author: pete.muir(a)jboss.org
Date: 2009-07-29 19:12:05 -0400 (Wed, 29 Jul 2009)
New Revision: 3358
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/EJBDecoratorInvocationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigSty.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigStyImpl.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.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/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
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/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/TimestampLogger.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectableReferenceTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
Log:
WBRI-298 WBRI-310 WBRI-327
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -277,7 +277,7 @@
List<Class<?>> defaultEnabledDecoratorClasses = new
ArrayList<Class<?>>();
ListMultimap<Class<? extends Annotation>, Context> contexts =
Multimaps.newListMultimap(new ConcurrentHashMap<Class<? extends Annotation>,
Collection<Context>>(), new Supplier<List<Context>>()
- {
+ {
public List<Context> get()
{
@@ -883,22 +883,29 @@
return getReference(bean, creationalContext);
}
- @SuppressWarnings("unchecked")
- public Object getInjectableReference(InjectionPoint injectionPoint,
CreationalContext<?> creationalContext)
+
+ /**
+ * Get a reference, registering the injection point used.
+ *
+ * @param injectionPoint the injection point to register
+ * @param resolvedBean the bean to get a reference to
+ * @param creationalContext the creationalContext
+ * @return
+ */
+ public Object getReference(InjectionPoint injectionPoint, Bean<?> resolvedBean,
CreationalContext<?> creationalContext)
{
- boolean registerInjectionPoint =
!injectionPoint.getType().equals(InjectionPoint.class);
+ boolean registerInjectionPoint = (injectionPoint != null &&
!injectionPoint.getType().equals(InjectionPoint.class));
try
{
if (registerInjectionPoint)
{
currentInjectionPoint.get().push(injectionPoint);
}
- WBAnnotated<?, ?> element = ResolvableWBClass.of(injectionPoint.getType(),
injectionPoint.getBindings().toArray(new Annotation[0]), this);
- Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
if
(getServices().get(MetaAnnotationStore.class).getScopeModel(resolvedBean.getScopeType()).isNormal()
&& !Proxies.isTypeProxyable(injectionPoint.getType()))
{
throw new UnproxyableResolutionException("Attempting to inject an
unproxyable normal scoped bean " + resolvedBean + " into " +
injectionPoint);
}
+ // TODO Can we move this logic to getReference?
if (creationalContext instanceof CreationalContextImpl)
{
CreationalContextImpl<?> creationalContextImpl =
(CreationalContextImpl<?>) creationalContext;
@@ -924,6 +931,14 @@
}
}
}
+
+
+ public Object getInjectableReference(InjectionPoint injectionPoint,
CreationalContext<?> creationalContext)
+ {
+ WBAnnotated<?, ?> element = ResolvableWBClass.of(injectionPoint.getType(),
injectionPoint.getBindings().toArray(new Annotation[0]), this);
+ Bean<?> resolvedBean = getBean(element, element.getBindingsAsArray());
+ return getReference(injectionPoint, resolvedBean, creationalContext);
+ }
/**
* Returns an instance by API type and binding types
@@ -1080,12 +1095,11 @@
}
/**
- * Accesses the factory used to create each instance of InjectionPoint that
- * is injected into web beans.
+ * The injection point being operated on for this thread
*
- * @return the factory
+ * @return the current injection point
*/
- public InjectionPoint getInjectionPoint()
+ public InjectionPoint getCurrentInjectionPoint()
{
if (!currentInjectionPoint.get().empty())
{
@@ -1096,6 +1110,29 @@
return null;
}
}
+
+ /**
+ * Replaces (or adds) the current injection point. If a current injection
+ * point exists, it will be replaced. If no current injection point exists,
+ * one will be added.
+ *
+ * @param injectionPoint the injection point to use
+ * @return the injection point added, or null if non previous existed
+ */
+ public InjectionPoint replaceOrPushCurrentInjectionPoint(InjectionPoint
injectionPoint)
+ {
+ InjectionPoint originalInjectionPoint = null;
+ if (!currentInjectionPoint.get().empty())
+ {
+ originalInjectionPoint = currentInjectionPoint.get().pop();
+ }
+ else
+ {
+ log.trace("No current injection point to replace #0",
injectionPoint);
+ }
+ currentInjectionPoint.get().push(injectionPoint);
+ return originalInjectionPoint;
+ }
/**
*
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-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -105,17 +105,18 @@
// The API types
protected Set<Type> types;
// The injection points
- protected Set<WBInjectionPoint<?, ?>> injectionPoints;
+ private Set<WBInjectionPoint<?, ?>> injectionPoints;
+ private Set<WBInjectionPoint<?, ?>> delegateInjectionPoints;
// If the type a primitive?
private boolean primitive;
// The Web Beans manager
protected BeanManagerImpl manager;
- protected boolean _serializable;
+ private boolean _serializable;
private boolean initialized;
- private Set<WBInjectionPoint<?, ?>> decoratesInjectionPoint;
+
protected boolean isInitialized()
{
@@ -131,7 +132,8 @@
{
super(manager);
this.manager = manager;
- injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ this.injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ this.delegateInjectionPoints = new HashSet<WBInjectionPoint<?,?>>();
}
/**
@@ -156,34 +158,37 @@
initScopeType();
initSerializable();
initProxyable();
- initInjectionPoints();
- initDecorates();
- checkDecorates();
+ checkDelegateInjectionPoints();
}
- protected void checkDecorates()
+ protected void checkDelegateInjectionPoints()
{
- if (this.decoratesInjectionPoint.size() > 0)
+ if (this.delegateInjectionPoints.size() > 0)
{
throw new DefinitionException("Cannot place @Decorates at an injection
point which is not on a Decorator " + this);
}
}
-
- protected void initDecorates()
+
+ protected void addInjectionPoint(WBInjectionPoint<?, ?> injectionPoint)
{
- this.decoratesInjectionPoint = new HashSet<WBInjectionPoint<?, ?>>();
- for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
+ if (injectionPoint.isAnnotationPresent(Decorates.class))
{
- if (injectionPoint.isAnnotationPresent(Decorates.class))
- {
- this.decoratesInjectionPoint.add(injectionPoint);
- }
+ this.delegateInjectionPoints.add(injectionPoint);
}
+ injectionPoints.add(injectionPoint);
}
+
+ protected void addInjectionPoints(Iterable<? extends WBInjectionPoint<?,
?>> injectionPoints)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : injectionPoints)
+ {
+ addInjectionPoint(injectionPoint);
+ }
+ }
- protected Set<WBInjectionPoint<?, ?>> getDecoratesInjectionPoint()
+ protected Set<WBInjectionPoint<?, ?>> getDelegateInjectionPoints()
{
- return decoratesInjectionPoint;
+ return delegateInjectionPoints;
}
/**
@@ -205,8 +210,6 @@
log.trace("Using binding types " + bindings + " specified by
annotations");
}
- protected abstract void initInjectionPoints();
-
protected void initDefaultBindings()
{
if (bindings.size() == 0)
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-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -39,6 +39,7 @@
import javax.enterprise.inject.deployment.DeploymentType;
import javax.enterprise.inject.deployment.Production;
import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
@@ -113,6 +114,7 @@
public void initialize(BeanDeployerEnvironment environment)
{
initInitializerMethods();
+ initInjectableFields();
super.initialize(environment);
checkBeanImplementation();
initDecorators();
@@ -149,55 +151,55 @@
}
}
- protected T applyDecorators(T instance, CreationalContext<T> creationalContext)
+ protected T applyDecorators(T instance, CreationalContext<T> creationalContext,
InjectionPoint originalInjectionPoint)
{
- if (hasDecorators())
+ List<SerializableBeanInstance<DecoratorBean<Object>, Object>>
decoratorInstances = new
ArrayList<SerializableBeanInstance<DecoratorBean<Object>,Object>>();
+ InjectionPoint ip = originalInjectionPoint;
+ boolean outside = decoratorStackPosition.get().intValue() == 0;
+ try
{
- 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())
{
- int i = decoratorStackPosition.get();
- while (i < decorators.size())
+ Decorator<?> decorator = decorators.get(i);
+ if (decorator instanceof DecoratorBean<?>)
{
- 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, creationalContext)));
- }
- else
- {
- throw new IllegalStateException("Cannot operate on non container
provided decorator " + decorator);
- }
+ decoratorStackPosition.set(++i);
+
+ @SuppressWarnings("unchecked")
+ DecoratorBean<Object> decoratorBean = (DecoratorBean<Object>)
decorator;
+
+ Object decoratorInstance = getManager().getReference(ip, decorator,
creationalContext);
+ decoratorInstances.add(new
SerializableBeanInstance<DecoratorBean<Object>, Object>(decoratorBean,
decoratorInstance));
+ ip = decoratorBean.getDelegateInjectionPoint();
}
- }
- finally
- {
- if (outside)
+ else
{
- decoratorStackPosition.remove();
+ throw new IllegalStateException("Cannot operate on non container
provided decorator " + decorator);
}
}
- try
+ }
+ finally
+ {
+ if (outside)
{
- T proxy = proxyClassForDecorators.newInstance();
- ((ProxyObject) proxy).setHandler(new
DecoratorProxyMethodHandler(decoratorInstances, instance));
- return proxy;
+ decoratorStackPosition.remove();
}
- 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
+ try
{
- return instance;
+ 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);
+ }
}
public List<Decorator<?>> getDecorators()
@@ -248,17 +250,10 @@
/**
* Initializes the injection points
*/
- protected void initInjectionPoints()
+ protected void initInjectableFields()
{
injectableFields = new
HashSet<FieldInjectionPoint<?>>(Beans.getFieldInjectionPoints(annotatedItem,
this));
- super.injectionPoints.addAll(injectableFields);
- for (WBMethod<?> initializer : getInitializerMethods())
- {
- for (WBParameter<?> parameter : initializer.getParameters())
- {
- injectionPoints.add(ParameterInjectionPoint.of(this, parameter));
- }
- }
+ addInjectionPoints(injectableFields);
}
/**
@@ -287,7 +282,12 @@
}
else
{
- initializerMethods.add(MethodInjectionPoint.of(this, method));
+ MethodInjectionPoint<?> initializerMethod =
MethodInjectionPoint.of(this, method);
+ initializerMethods.add(initializerMethod);
+ for (WBParameter<?> parameter : initializerMethod.getParameters())
+ {
+ addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
+ }
}
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -198,7 +198,7 @@
{
throw new IllegalProductException("Producers cannot declare passivating
scope and return a non-serializable class");
}
- InjectionPoint injectionPoint = manager.getInjectionPoint();
+ InjectionPoint injectionPoint = manager.getCurrentInjectionPoint();
if (injectionPoint == null)
{
return;
@@ -280,13 +280,19 @@
return;
}
}
-
+
@Override
protected void initSerializable()
{
- _serializable = true;
+ // No-op
}
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
/**
* Creates an instance of the bean
*
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-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DecoratorBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -32,7 +32,6 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.WBInjectionPoint;
-import org.jboss.webbeans.introspector.WBAnnotated;
import org.jboss.webbeans.introspector.WBClass;
public class DecoratorBean<T> extends SimpleBean<T> implements
Decorator<T>
@@ -77,7 +76,7 @@
return new DecoratorBean<T>(clazz, manager);
}
- private WBAnnotated<?, ?> decorates;
+ private WBInjectionPoint<?, ?> delegateInjectionPoint;
private Set<Annotation> delegateBindings;
private Type delegateType;
private Set<Type> delegateTypes;
@@ -94,7 +93,7 @@
if (!isInitialized())
{
super.initialize(environment);
- initDelegate();
+ initDelegateInjectionPoint();
initDecoratedTypes();
initDelegateBindings();
initDelegateType();
@@ -109,40 +108,40 @@
this.decoratedTypes.remove(Serializable.class);
}
- protected void initDelegate()
+ protected void initDelegateInjectionPoint()
{
- this.decorates = getDecoratesInjectionPoint().iterator().next();
+ this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
}
@Override
- protected void checkDecorates()
+ protected void checkDelegateInjectionPoints()
{
- for (WBInjectionPoint<?, ?> injectionPoint : getDecoratesInjectionPoint())
+ for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
{
- if (injectionPoint instanceof MethodInjectionPoint &&
!injectionPoint.isAnnotationPresent(Initializer.class))
+ if (injectionPoint instanceof MethodInjectionPoint<?> &&
!injectionPoint.isAnnotationPresent(Initializer.class))
{
throw new DefinitionException("Method with @Decorates parameter must be
an initializer method " + injectionPoint);
}
}
- if (getDecoratesInjectionPoint().size() == 0)
+ if (getDelegateInjectionPoints().size() == 0)
{
- throw new DefinitionException("No @Decorates injection point defined "
+ this);
+ throw new DefinitionException("No delegate injection points defined "
+ this);
}
- else if (getDecoratesInjectionPoint().size() > 1)
+ else if (getDelegateInjectionPoints().size() > 1)
{
- throw new DefinitionException("Too many @Decorates injection point defined
" + this);
+ throw new DefinitionException("Too many delegate injection point defined
" + this);
}
}
protected void initDelegateBindings()
{
this.delegateBindings = new HashSet<Annotation>();
- this.delegateBindings.addAll(this.decorates.getBindings());
+ this.delegateBindings.addAll(this.delegateInjectionPoint.getBindings());
}
protected void initDelegateType()
{
- this.delegateType = this.decorates.getBaseType();
+ this.delegateType = this.delegateInjectionPoint.getBaseType();
this.delegateTypes = new HashSet<Type>();
delegateTypes.add(delegateType);
}
@@ -153,7 +152,7 @@
{
if (decoratedType instanceof Class)
{
- if (!((Class<?>)
decoratedType).isAssignableFrom(decorates.getJavaClass()))
+ if (!((Class<?>)
decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
{
throw new DefinitionException("The delegate type must extend or
implement every decorated type. Decorated type " + decoratedType + "." +
this );
}
@@ -161,13 +160,13 @@
else if (decoratedType instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
- if (!decorates.isParameterizedType())
+ if (!delegateInjectionPoint.isParameterizedType())
{
throw new DefinitionException("The decorated type is parameterized,
but the delegate type isn't. Delegate type " + delegateType + "." +
this);
}
- if (!Arrays.equals(decorates.getActualTypeArguments(),
parameterizedType.getActualTypeArguments()));
+ if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(),
parameterizedType.getActualTypeArguments()));
Type rawType = ((ParameterizedType) decoratedType).getRawType();
- if (rawType instanceof Class && !((Class<?>)
rawType).isAssignableFrom(decorates.getJavaClass()))
+ if (rawType instanceof Class && !((Class<?>)
rawType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
{
throw new DefinitionException("The delegate type must extend or
implement every decorated type. Decorated type " + decoratedType + "." +
this );
}
@@ -194,6 +193,11 @@
{
return decoratedTypes;
}
+
+ public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
+ {
+ return delegateInjectionPoint;
+ }
/**
* The type closure of the delegate type
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -33,7 +33,6 @@
import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
public class DisposalMethodBean<T> extends AbstractReceiverBean<T, Method>
@@ -55,7 +54,7 @@
@Override
public void initialize(BeanDeployerEnvironment environment)
{
- // TODO Auto-generated method stub
+ addInjectionPoint(disposalMethodInjectionPoint);
super.initialize(environment);
checkDisposalMethod();
}
@@ -77,11 +76,6 @@
return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
}
- protected void initInjectionPoints()
- {
- injectionPoints.add(disposalMethodInjectionPoint);
- }
-
@Override
protected void initBindings()
{
@@ -105,12 +99,6 @@
}
@Override
- public Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints()
- {
- return injectionPoints;
- }
-
- @Override
public String getName()
{
return null;
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-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -231,7 +231,11 @@
creationalContext.push(instance);
((ProxyObject) instance).setHandler(new
EnterpriseBeanProxyMethodHandler<T>(this, creationalContext));
log.trace("Enterprise bean instance created for bean {0}", this);
- return applyDecorators(instance, creationalContext);
+ if (hasDecorators())
+ {
+ instance = applyDecorators(instance, creationalContext, null);
+ }
+ return instance;
}
catch (InstantiationException e)
{
@@ -315,12 +319,18 @@
{
creationalContext.release();
}
-
+
@Override
protected void initSerializable()
{
- super._serializable = true;
+ // No-op
}
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
public InternalEjbDescriptor<T> getEjbDescriptor()
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -156,12 +156,6 @@
return id;
}
- @Override
- protected void initInjectionPoints()
- {
-
- }
-
public Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -98,6 +98,7 @@
{
if (!isInitialized())
{
+ initProducerMethodInjectableParameters();
super.initialize(environment);
checkProducerMethod();
initDisposalMethod(environment);
@@ -107,11 +108,11 @@
/**
* Initializes the injection points
*/
- protected void initInjectionPoints()
+ protected void initProducerMethodInjectableParameters()
{
for (WBParameter<?> parameter : method.getParameters())
{
- injectionPoints.add(ParameterInjectionPoint.of(this, parameter));
+ addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
}
}
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-07-29
22:38:33 UTC (rev 3357)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -27,6 +27,7 @@
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Initializer;
import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
@@ -49,6 +50,7 @@
import org.jboss.webbeans.persistence.spi.JpaServices;
import org.jboss.webbeans.resources.spi.ResourceServices;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
/**
* Represents a simple bean
@@ -112,16 +114,43 @@
*/
public T create(CreationalContext<T> creationalContext)
{
- T instance = null;
- instance = constructor.newInstance(manager, creationalContext);
- instance = applyDecorators(instance, creationalContext);
- creationalContext.push(instance);
+ InjectionPoint originalInjectionPoint = null;
+ if (hasDecorators())
+ {
+ originalInjectionPoint = attachCorrectInjectionPoint();
+ }
+ T instance = constructor.newInstance(manager, creationalContext);
+ if (!hasDecorators())
+ {
+ // This should be safe, but needs verification PLM
+ // Without this, the chaining of decorators will fail as the incomplete instance
will be resolved
+ creationalContext.push(instance);
+ }
injectEjbAndCommonFields(instance);
injectBoundFields(instance, creationalContext);
callInitializers(instance, creationalContext);
callPostConstruct(instance);
+ if (hasDecorators())
+ {
+ instance = applyDecorators(instance, creationalContext,
originalInjectionPoint);
+ }
return instance;
}
+
+ protected InjectionPoint attachCorrectInjectionPoint()
+ {
+ Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
+ if (decorator instanceof DecoratorBean<?>)
+ {
+ DecoratorBean<?> decoratorBean = (DecoratorBean<?>) decorator;
+ InjectionPoint outerDelegateInjectionPoint =
decoratorBean.getDelegateInjectionPoint();
+ return
getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot operate on user defined
decorator");
+ }
+ }
/**
* Destroys an instance of the bean
@@ -293,19 +322,6 @@
}
/**
- * Initializes the injection points
- */
- @Override
- protected void initInjectionPoints()
- {
- super.initInjectionPoints();
- for (WBParameter<?> parameter : constructor.getParameters())
- {
- injectionPoints.add(ParameterInjectionPoint.of(this, parameter));
- }
- }
-
- /**
* Validates the type
*/
protected void checkType()
@@ -319,7 +335,7 @@
throw new DefinitionException("Simple bean " + type + " cannot be
a parameterized type");
}
boolean passivating =
manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
- if (passivating && !_serializable)
+ if (passivating && !Reflections.isSerializable(getBeanClass()))
{
throw new DefinitionException("Simple bean declaring a passivating scope
must have a serializable implementation class " + toString());
}
@@ -331,7 +347,7 @@
}
for (Decorator<?> decorator : getDecorators())
{
- if (decorator instanceof DecoratorBean)
+ if (decorator instanceof DecoratorBean<?>)
{
DecoratorBean<?> decoratorBean = (DecoratorBean<?>)
decorator;
for (WBMethod<?> decoratorMethod :
decoratorBean.getAnnotatedItem().getMethods())
@@ -426,18 +442,25 @@
{
this.constructor = ConstructorInjectionPoint.of(this,
initializerAnnotatedConstructors.iterator().next());
log.trace("Exactly one constructor (" + constructor + ")
annotated with @Initializer defined, using it as the bean constructor for " +
getType());
- return;
}
-
- if (getAnnotatedItem().getNoArgsConstructor() != null)
+ else if (getAnnotatedItem().getNoArgsConstructor() != null)
{
this.constructor = ConstructorInjectionPoint.of(this,
getAnnotatedItem().getNoArgsConstructor());
log.trace("Exactly one constructor (" + constructor + ") defined,
using it as the bean constructor for " + getType());
- return;
}
-
- throw new DefinitionException("Cannot determine constructor to use for "
+ getType());
+
+ if (this.constructor == null)
+ {
+ throw new DefinitionException("Cannot determine constructor to use for
" + getType());
+ }
+ else
+ {
+ for (WBParameter<?> parameter : constructor.getParameters())
+ {
+ addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
+ }
+ }
}
/**
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -40,7 +40,7 @@
public T create(CreationalContext<T> creationalContext)
{
- InjectionPoint injectionPoint = this.getManager().getInjectionPoint();
+ InjectionPoint injectionPoint = this.getManager().getCurrentInjectionPoint();
if (injectionPoint != null)
{
Type genericType = injectionPoint.getType();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -59,7 +59,7 @@
public InjectionPoint create(CreationalContext<InjectionPoint>
creationalContext)
{
- return getManager().getInjectionPoint();
+ return getManager().getCurrentInjectionPoint();
}
public void destroy(InjectionPoint instance, CreationalContext<InjectionPoint>
creationalContext)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -28,9 +28,11 @@
import java.util.List;
import java.util.Set;
+import javax.decorator.Decorates;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.introspector.ForwardingWBConstructor;
@@ -65,6 +67,7 @@
private final Bean<?> declaringBean;
private final WBConstructor<T> constructor;
+ private final boolean delegate;
public static <T> ConstructorInjectionPoint<T> of(Bean<?>
declaringBean, WBConstructor<T> constructor)
{
@@ -75,6 +78,7 @@
{
this.declaringBean = declaringBean;
this.constructor = constructor;
+ this.delegate = isAnnotationPresent(Decorates.class) && declaringBean
instanceof Decorator<?>;
}
@Override
@@ -189,8 +193,7 @@
public boolean isDelegate()
{
- // TODO Auto-generated method stub
- return false;
+ return delegate;
}
public boolean isTransient()
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -24,9 +24,11 @@
import java.lang.reflect.Type;
import java.util.Set;
+import javax.decorator.Decorates;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.introspector.ForwardingWBField;
@@ -39,6 +41,7 @@
private final Bean<?> declaringBean;
private final WBField<T> field;
+ private final boolean delegate;
public static <T> FieldInjectionPoint<T> of(Bean<?> declaringBean,
WBField<T> field)
{
@@ -49,6 +52,7 @@
{
this.declaringBean = declaringBean;
this.field = field;
+ this.delegate = isAnnotationPresent(Decorates.class) && declaringBean
instanceof Decorator<?>;
}
@Override
@@ -106,8 +110,7 @@
public boolean isDelegate()
{
- // TODO Auto-generated method stub
- return false;
+ return delegate;
}
public Type getType()
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -28,9 +28,11 @@
import java.util.List;
import java.util.Set;
+import javax.decorator.Decorates;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.introspector.ForwardingWBMethod;
@@ -65,6 +67,7 @@
private final Bean<?> declaringBean;
private final WBMethod<T> method;
+ private final boolean delegate;
public static <T> MethodInjectionPoint<T> of(Bean<?> declaringBean,
WBMethod<T> method)
{
@@ -75,6 +78,7 @@
{
this.declaringBean = declaringBean;
this.method = method;
+ this.delegate = isAnnotationPresent(Decorates.class) && declaringBean
instanceof Decorator<?>;
}
@Override
@@ -271,8 +275,7 @@
public boolean isDelegate()
{
- // TODO Auto-generated method stub
- return false;
+ return delegate;
}
public boolean isTransient()
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -21,9 +21,11 @@
import java.lang.reflect.Type;
import java.util.Set;
+import javax.decorator.Decorates;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.introspector.ForwardingWBParameter;
@@ -41,11 +43,13 @@
private final Bean<?> declaringBean;
private final WBParameter<T> parameter;
+ private final boolean delegate;
private ParameterInjectionPoint(Bean<?> declaringBean, WBParameter<T>
parameter)
{
this.declaringBean = declaringBean;
this.parameter = parameter;
+ this.delegate = isAnnotationPresent(Decorates.class) && declaringBean
instanceof Decorator<?>;
}
@Override
@@ -87,8 +91,7 @@
public boolean isDelegate()
{
- // TODO Auto-generated method stub
- return false;
+ return delegate;
}
public boolean isTransient()
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/CowShed.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -28,14 +28,14 @@
public static final String MESSAGE = "cowShed";
@Current Logger logger;
-
- @Current Foo foo;
public void milk()
{
logger.log(MESSAGE);
}
+ @Current Foo foo;
+
public void washDown()
{
foo.log(MESSAGE);
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/DecoratorInvocationTest.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -45,11 +45,11 @@
})
public void testDecoratorInvocation()
{
- TimestampLogger.setMessage(null);
+ TimestampLogger.reset();
MockLogger.setMessage(null);
getInstanceByType(CowShed.class).milk();
assert TimestampLogger.getMessage().equals(CowShed.MESSAGE);
- assert MockLogger.getMessage().equals(CowShed.MESSAGE);
+ assert MockLogger.getMessage().equals(TimestampLogger.PREFIX + CowShed.MESSAGE);
}
@Test
@@ -64,13 +64,19 @@
})
public void testChainedDecoratorInvocation()
{
- FooDecorator1.setMessage(null);
- FooDecorator2.setMessage(null);
- FooImpl.setMessage(null);
+ FooDecorator1.reset();
+ FooDecorator2.reset();
+ FooImpl.reset();
getInstanceByType(CowShed.class).washDown();
assert FooDecorator1.getMessage().equals(CowShed.MESSAGE);
+ assert
FooDecorator1.getInjectionPoint().getBean().getBeanClass().equals(CowShed.class);
+ assert !FooDecorator1.getInjectionPoint().isDelegate();
assert FooDecorator2.getMessage().equals(CowShed.MESSAGE + FooDecorator1.SUFFIX);
+ assert
FooDecorator2.getInjectionPoint().getBean().getBeanClass().equals(FooDecorator1.class);
+ assert FooDecorator2.getInjectionPoint().isDelegate();
assert FooImpl.getMessage().equals(CowShed.MESSAGE + FooDecorator1.SUFFIX +
FooDecorator2.SUFFIX);
+ assert
FooImpl.getInjectionPoint().getBean().getBeanClass().equals(FooDecorator2.class);
+ assert FooImpl.getInjectionPoint().isDelegate();
}
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/EJBDecoratorInvocationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/EJBDecoratorInvocationTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/EJBDecoratorInvocationTest.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -0,0 +1,84 @@
+/*
+ * 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.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * @author pmuir
+ *
+ */
+@Artifact
+(a)BeansXml("beans.xml")
+@SpecVersion("20090625")
+@IntegrationTest
+public class EJBDecoratorInvocationTest 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.reset();
+ MockLogger.setMessage(null);
+ getInstanceByType(PigSty.class).clean();
+ assert TimestampLogger.getMessage().equals(PigSty.MESSAGE);
+ assert MockLogger.getMessage().equals(TimestampLogger.PREFIX + PigSty.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.reset();
+ FooDecorator2.reset();
+ FooImpl.reset();
+ getInstanceByType(PigSty.class).washDown();
+ assert FooDecorator1.getMessage().equals(PigSty.MESSAGE);
+ assert
FooDecorator1.getInjectionPoint().getBean().getBeanClass().equals(PigStyImpl.class);
+ assert !FooDecorator1.getInjectionPoint().isDelegate();
+ assert FooDecorator2.getMessage().equals(PigSty.MESSAGE + FooDecorator1.SUFFIX);
+ assert
FooDecorator2.getInjectionPoint().getBean().getBeanClass().equals(FooDecorator1.class);
+ assert FooDecorator2.getInjectionPoint().isDelegate();
+ assert FooImpl.getMessage().equals(PigSty.MESSAGE + FooDecorator1.SUFFIX +
FooDecorator2.SUFFIX);
+ assert
FooImpl.getInjectionPoint().getBean().getBeanClass().equals(FooDecorator2.class);
+ assert FooImpl.getInjectionPoint().isDelegate();
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/EJBDecoratorInvocationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator1.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -18,6 +18,8 @@
import javax.decorator.Decorates;
import javax.decorator.Decorator;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.InjectionPoint;
/**
* @author pmuir
@@ -27,6 +29,19 @@
public class FooDecorator1
{
+ private static InjectionPoint injectionPoint;
+
+ @Initializer
+ public void setInjectionPoint(InjectionPoint injectionPoint)
+ {
+ FooDecorator1.injectionPoint = injectionPoint;
+ }
+
+ public static InjectionPoint getInjectionPoint()
+ {
+ return injectionPoint;
+ }
+
public static final String SUFFIX = "fooDecorator1";
private static String message;
@@ -42,9 +57,10 @@
/**
* @param message the message to set
*/
- public static void setMessage(String message)
+ public static void reset()
{
- FooDecorator1.message = message;
+ FooDecorator1.message = null;
+ FooDecorator1.injectionPoint = null;
}
@Decorates Foo foo;
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooDecorator2.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -18,6 +18,8 @@
import javax.decorator.Decorates;
import javax.decorator.Decorator;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.InjectionPoint;
/**
* @author pmuir
@@ -27,6 +29,15 @@
public class FooDecorator2
{
+ private static InjectionPoint injectionPoint;
+
+ @Current InjectionPoint ip;
+
+ public static InjectionPoint getInjectionPoint()
+ {
+ return injectionPoint;
+ }
+
public static final String SUFFIX = "fooDecorator2";
private static String message;
@@ -42,9 +53,10 @@
/**
* @param message the message to set
*/
- public static void setMessage(String message)
+ public static void reset()
{
- FooDecorator2.message = message;
+ FooDecorator2.message = null;
+ FooDecorator2.injectionPoint = null;
}
@Decorates Foo foo;
@@ -53,6 +65,7 @@
{
FooDecorator2.message = message;
foo.log(message + SUFFIX);
+ injectionPoint = ip;
}
}
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/FooImpl.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -16,6 +16,9 @@
*/
package org.jboss.jsr299.tck.tests.decorators.invocation;
+import javax.enterprise.inject.Initializer;
+import javax.enterprise.inject.spi.InjectionPoint;
+
/**
* @author pmuir
*
@@ -23,6 +26,23 @@
public class FooImpl implements Foo
{
+ private static InjectionPoint injectionPoint;
+
+ public FooImpl()
+ {
+ }
+
+ @Initializer
+ public FooImpl(InjectionPoint injectionPoint)
+ {
+ FooImpl.injectionPoint = injectionPoint;
+ }
+
+ public static InjectionPoint getInjectionPoint()
+ {
+ return injectionPoint;
+ }
+
private static String message;
/**
@@ -36,9 +56,10 @@
/**
* @param message the message to set
*/
- public static void setMessage(String message)
+ public static void reset()
{
- FooImpl.message = message;
+ FooImpl.message = null;
+ FooImpl.injectionPoint = null;
}
public void log(String message)
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigSty.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigSty.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigSty.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -0,0 +1,32 @@
+/*
+ * 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 PigSty
+{
+
+ public static final String MESSAGE = "smelly work!";
+
+ public void clean();
+
+ public void washDown();
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigSty.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigStyImpl.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigStyImpl.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigStyImpl.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -0,0 +1,42 @@
+/*
+ * 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 PigStyImpl implements PigSty
+{
+
+ @Current Logger logger;
+
+ public void clean()
+ {
+ logger.log(PigSty.MESSAGE);
+ }
+
+ @Current Foo foo;
+
+ public void washDown()
+ {
+ foo.log(MESSAGE);
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/PigStyImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
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 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/invocation/TimestampLogger.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -27,7 +27,9 @@
@Decorator
public class TimestampLogger
{
-
+
+ public static final String PREFIX = TimestampLogger.class.getSimpleName();
+
private static String message;
@Decorates
@@ -36,7 +38,7 @@
public void log(String message)
{
TimestampLogger.message = message;
- logger.log(message);
+ logger.log(PREFIX + message);
}
/**
@@ -50,9 +52,9 @@
/**
* @param message the message to set
*/
- public static void setMessage(String message)
+ public static void reset()
{
- TimestampLogger.message = message;
+ TimestampLogger.message = null;
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectableReferenceTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectableReferenceTest.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectableReferenceTest.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -62,11 +62,10 @@
}
@SuppressWarnings("unchecked")
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section = "11.3.2", id = "b")
})
- // WBRI-296
public void testGetInjectableReferenceReturnsDelegateForDelegateInjectionPoint()
{
// Get hold of the correct IP by inspecting the ones the container created for
LoggerConsumer
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-07-29
22:38:33 UTC (rev 3357)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-07-29
23:12:05 UTC (rev 3358)
@@ -20,8 +20,6 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.HashSet;
import java.util.Set;
import javax.enterprise.context.Dependent;
@@ -31,11 +29,11 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -206,9 +204,8 @@
assert ip2.isTransient();
}
- @Test(groups = { "injectionPoint", "ri-broken" })
+ @Test(groups = { "injectionPoint" })
@SpecAssertion(section = "5.6.9", id="dba")
- // WBRI-310
public void testIsDelegate()
{
assert !getInstanceByType(FieldInjectionPointBean.class,new
CurrentLiteral()).getInjectedBean().getInjectedMetadata().isDelegate();