[weld-commits] Weld SVN: r4750 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Sat Nov 7 16:21:17 EST 2009
Author: jharting
Date: 2009-11-07 16:21:17 -0500 (Sat, 07 Nov 2009)
New Revision: 4750
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/AfterBeanDiscoveryObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/CustomDecoratorImplementation.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/VehicleDecorator.java
Log:
minor
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/AfterBeanDiscoveryObserver.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/AfterBeanDiscoveryObserver.java 2009-11-07 20:27:46 UTC (rev 4749)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/AfterBeanDiscoveryObserver.java 2009-11-07 21:21:17 UTC (rev 4750)
@@ -21,7 +21,7 @@
AnnotatedType<VehicleDecorator> type = beanManager.createAnnotatedType(VehicleDecorator.class);
Set<AnnotatedField<? super VehicleDecorator>> annotatedFields = type.getFields();
AnnotatedField<? super VehicleDecorator> annotatedField = annotatedFields.iterator().next();
- decorator = new CustomDecoratorImplementation(annotatedField);
+ decorator = new CustomDecoratorImplementation(annotatedField, beanManager);
event.addBean(decorator);
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/CustomDecoratorImplementation.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/CustomDecoratorImplementation.java 2009-11-07 20:27:46 UTC (rev 4749)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/CustomDecoratorImplementation.java 2009-11-07 21:21:17 UTC (rev 4750)
@@ -13,6 +13,7 @@
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
@@ -24,12 +25,16 @@
private boolean getDelegateTypeCalled = false;
private AnnotatedField<? super VehicleDecorator> annotatedField;
- private Set<Type> decoratedTypes = new HashSet<Type>();
+ private Set<Type> decoratedTypes;
+ private Set<InjectionPoint> injectionPoints;
+ private BeanManager beanManager;
- public CustomDecoratorImplementation(AnnotatedField<? super VehicleDecorator> annotatedField)
+ public CustomDecoratorImplementation(AnnotatedField<? super VehicleDecorator> annotatedField, BeanManager beanManager)
{
this.annotatedField = annotatedField;
- decoratedTypes.add(Vehicle.class);
+ this.beanManager = beanManager;
+ decoratedTypes = Collections.singleton((Type) Vehicle.class);
+ injectionPoints = Collections.singleton((InjectionPoint) new CustomInjectionPoint());
}
public Set<Type> getDecoratedTypes()
@@ -57,53 +62,7 @@
public Set<InjectionPoint> getInjectionPoints()
{
- InjectionPoint ip = new InjectionPoint()
- {
-
- public boolean isTransient()
- {
- return false;
- }
-
- public boolean isDelegate()
- {
- return true;
- }
-
- public Type getType()
- {
- return Bus.class;
- }
-
- public Set<Annotation> getQualifiers()
- {
- return Collections.emptySet();
- }
-
- public Member getMember()
- {
- try
- {
- return VehicleDecorator.class.getDeclaredField("delegate");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public Bean<?> getBean()
- {
- return AfterBeanDiscoveryObserver.getDecorator();
- }
-
- public Annotated getAnnotated()
- {
- return annotatedField;
- }
- };
-
- return new HashSet<InjectionPoint>(Arrays.asList(ip));
+ return injectionPoints;
}
public String getName()
@@ -141,9 +100,11 @@
return false;
}
- public VehicleDecorator create(CreationalContext<VehicleDecorator> arg0)
+ public VehicleDecorator create(CreationalContext<VehicleDecorator> ctx)
{
- return new VehicleDecorator();
+ VehicleDecorator decorator = new VehicleDecorator();
+ decorator.delegate = (Vehicle) beanManager.getInjectableReference(getInjectionPoints().iterator().next(), ctx);
+ return decorator;
}
public void destroy(VehicleDecorator arg0, CreationalContext<VehicleDecorator> arg1)
@@ -165,4 +126,50 @@
{
return getDelegateTypeCalled;
}
+
+ class CustomInjectionPoint implements InjectionPoint
+ {
+
+ public boolean isTransient()
+ {
+ return false;
+ }
+
+ public boolean isDelegate()
+ {
+ return true;
+ }
+
+ public Type getType()
+ {
+ return Vehicle.class;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return Collections.emptySet();
+ }
+
+ public Member getMember()
+ {
+ try
+ {
+ return VehicleDecorator.class.getDeclaredField("delegate");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Bean<?> getBean()
+ {
+ return AfterBeanDiscoveryObserver.getDecorator();
+ }
+
+ public Annotated getAnnotated()
+ {
+ return annotatedField;
+ }
+ };
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/VehicleDecorator.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/VehicleDecorator.java 2009-11-07 20:27:46 UTC (rev 4749)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/custom/VehicleDecorator.java 2009-11-07 21:21:17 UTC (rev 4750)
@@ -6,7 +6,7 @@
class VehicleDecorator implements Vehicle
{
@Inject @Delegate
- private Vehicle delegate;
+ Vehicle delegate;
public String start()
{
More information about the weld-commits
mailing list