Author: pete.muir(a)jboss.org
Date: 2009-10-01 13:22:05 -0400 (Thu, 01 Oct 2009)
New Revision: 3829
Added:
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AbstractProducer.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/ResolvableWBClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/trunk/inject-tck-runner/
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AtInjectTCK.java
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/DriversSeatProducer.java
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/SpareTireProducer.java
ri/trunk/osgi-bundle/
ri/trunk/version-matrix/pom.xml
Log:
more fixes for JSR-330
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/SimpleInjectionTarget.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -17,6 +17,7 @@
package org.jboss.webbeans;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -42,8 +43,8 @@
private final BeanManagerImpl beanManager;
private final WBClass<T> type;
private final ConstructorInjectionPoint<T> constructor;
- private final Set<FieldInjectionPoint<?, ?>> injectableFields;
- private final Set<MethodInjectionPoint<?, ?>> initializerMethods;
+ private final List<Set<FieldInjectionPoint<?, ?>>>
injectableFields;
+ private final List<Set<MethodInjectionPoint<?, ?>>>
initializerMethods;
private final WBMethod<?, ?> postConstruct;
private final WBMethod<?, ?> preDestroy;
private final Set<InjectionPoint> injectionPoints;
@@ -69,11 +70,9 @@
// unless someone calls produce()
}
this.constructor = constructor;
- this.injectableFields = new HashSet<FieldInjectionPoint<?,?>>();
- this.injectableFields.addAll(Beans.getFieldInjectionPoints(null, type));
- this.injectionPoints.addAll(injectableFields);
- this.initializerMethods = new HashSet<MethodInjectionPoint<?,?>>();
- this.initializerMethods.addAll(Beans.getInitializerMethods(null, type));
+ this.injectableFields = Beans.getFieldInjectionPoints(null, type);
+ this.injectionPoints.addAll(Beans.getFieldInjectionPoints(null,
this.injectableFields));
+ this.initializerMethods = Beans.getInitializerMethods(null, type);
this.injectionPoints.addAll(Beans.getParameterInjectionPoints(null,
initializerMethods));
this.postConstruct = Beans.getPostConstruct(type);
this.preDestroy = Beans.getPreDestroy(type);
@@ -106,8 +105,7 @@
public void proceed()
{
Beans.injectEEFields(instance, beanManager, ejbInjectionPoints,
persistenceContextInjectionPoints, persistenceUnitInjectionPoints,
resourceInjectionPoints);
- Beans.injectBoundFields(instance, ctx, beanManager, injectableFields);
- Beans.callInitializers(instance, ctx, beanManager, initializerMethods);
+ Beans.injectFieldsAndInitializers(instance, ctx, beanManager,
injectableFields, initializerMethods);
}
}.run();
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-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -65,10 +65,10 @@
private static final LogProvider log =
Logging.getLogProvider(AbstractClassBean.class);
// The item representation
protected WBClass<T> annotatedItem;
- // The injectable fields
- private Set<FieldInjectionPoint<?, ?>> injectableFields;
- // The initializer methods
- private Set<MethodInjectionPoint<?, ?>> initializerMethods;
+ // The injectable fields of each type in the type hierarchy, with the actual type at
the bottom
+ private List<Set<FieldInjectionPoint<?, ?>>> injectableFields;
+ // The initializer methods of each type in the type hierarchy, with the actual type at
the bottom
+ private List<Set<MethodInjectionPoint<?, ?>>> initializerMethods;
private Set<String> dependencies;
private List<Decorator<?>> decorators;
@@ -228,8 +228,8 @@
*/
protected void initInjectableFields()
{
- injectableFields = new HashSet<FieldInjectionPoint<?,
?>>(Beans.getFieldInjectionPoints(this, annotatedItem));
- addInjectionPoints(injectableFields);
+ injectableFields = Beans.getFieldInjectionPoints(this, annotatedItem);
+ addInjectionPoints(Beans.getFieldInjectionPoints(this, injectableFields));
}
/**
@@ -320,17 +320,19 @@
*
* @return The set of annotated methods
*/
- public Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
+ public List<? extends Set<? extends MethodInjectionPoint<?, ?>>>
getInitializerMethods()
{
- return Collections.unmodifiableSet(initializerMethods);
+ // TODO Make immutable
+ return initializerMethods;
}
/**
* @return the injectableFields
*/
- public Set<FieldInjectionPoint<?, ?>> getInjectableFields()
+ public List<? extends Set<FieldInjectionPoint<?, ?>>>
getInjectableFields()
{
- return Collections.unmodifiableSet(injectableFields);
+ // TODO Make immutable
+ return injectableFields;
}
// TODO maybe a better way to expose this?
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -133,8 +133,7 @@
public void proceed()
{
Beans.injectEEFields(instance, getManager(), ejbInjectionPoints,
persistenceContextInjectionPoints, persistenceUnitInjectionPoints,
resourceInjectionPoints);
- Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
- Beans.callInitializers(instance, ctx, getManager(),
getInitializerMethods());
+ Beans.injectFieldsAndInitializers(instance, ctx, getManager(),
getInjectableFields(), getInitializerMethods());
}
}.run();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -228,8 +228,7 @@
public void proceed()
{
- Beans.injectBoundFields(instance, ctx, getManager(), getInjectableFields());
- Beans.callInitializers(instance, ctx, getManager(),
getInitializerMethods());
+ Beans.injectFieldsAndInitializers(instance, ctx, getManager(),
getInjectableFields(), getInitializerMethods());
}
}.run();
@@ -310,12 +309,6 @@
return buffer.toString();
}
- public void postConstruct(T instance, CreationalContext<T> creationalContext)
- {
- Beans.injectBoundFields(instance, creationalContext, getManager(),
getInjectableFields());
- Beans.callInitializers(instance, creationalContext, getManager(),
getInitializerMethods());
- }
-
public void preDestroy(CreationalContext<T> creationalContext)
{
creationalContext.release();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/AbstractBeanDeployer.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -124,7 +124,7 @@
protected void createProducerMethods(AbstractClassBean<?> declaringBean,
WBClass<?> annotatedClass)
{
- for (WBMethod<?, ?> method :
annotatedClass.getDeclaredWBAnnotatedMethods(Produces.class))
+ for (WBMethod<?, ?> method :
annotatedClass.getDeclaredAnnotatedWBMethods(Produces.class))
{
createProducerMethod(declaringBean, method);
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBAnnotated.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -107,7 +107,18 @@
{
return delegate().isPrivate();
}
+
+ public boolean isPackagePrivate()
+ {
+ return delegate().isPackagePrivate();
+ }
+
+ public Package getPackage()
+ {
+ return delegate().getPackage();
+ }
+ @Override
protected abstract WBAnnotated<T, S> delegate();
public boolean isDeclaredAnnotationPresent(Class<? extends Annotation>
annotationType)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/ForwardingWBClass.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -60,9 +60,9 @@
return delegate().getDeclaredAnnotatedWBFields(annotationType);
}
- public Set<WBMethod<?, ?>> getDeclaredWBAnnotatedMethods(Class<?
extends Annotation> annotationType)
+ public Set<WBMethod<?, ?>> getDeclaredAnnotatedWBMethods(Class<?
extends Annotation> annotationType)
{
- return delegate().getDeclaredWBAnnotatedMethods(annotationType);
+ return delegate().getDeclaredAnnotatedWBMethods(annotationType);
}
public Set<WBMethod<?, T>>
getWBDeclaredMethodsWithAnnotatedParameters(Class<? extends Annotation>
annotationType)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBAnnotated.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -177,6 +177,10 @@
public boolean isPublic();
public boolean isPrivate();
+
+ public boolean isPackagePrivate();
+
+ public Package getPackage();
/**
* Gets the name of this AnnotatedItem
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java 2009-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/WBClass.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -44,6 +44,13 @@
* @return A set of abstracted fields
*/
public Set<WBMethod<?, ?>> getWBMethods();
+
+ /**
+ * Gets all fields on the type
+ *
+ * @return A set of abstracted fields
+ */
+ public Set<WBMethod<?, ?>> getDeclaredWBMethods();
/**
* Get a field by name
@@ -131,7 +138,7 @@
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WBMethod<?, ?>> getDeclaredWBAnnotatedMethods(Class<?
extends Annotation> annotationType);
+ public Set<WBMethod<?, ?>> getDeclaredAnnotatedWBMethods(Class<?
extends Annotation> annotationType);
/**
* Find the annotated method for a given methodDescriptor
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractWBMember.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -51,6 +51,8 @@
private String toString;
private final boolean _public;
private final boolean _private;
+ private final boolean _packagePrivate;
+ private final Package _package;
private final WBClass<X> declaringType;
/**
@@ -62,8 +64,10 @@
{
super(annotatedItemHelper, rawType, type);
name = member.getName();
- _public = Modifier.isPublic(member.getModifiers());
- _private = Modifier.isPrivate(member.getModifiers());
+ this._public = Modifier.isPublic(member.getModifiers());
+ this._private = Modifier.isPrivate(member.getModifiers());
+ this._packagePrivate = Reflections.isPackagePrivate(member.getModifiers());
+ this._package = member.getDeclaringClass().getPackage();
this.declaringType = declaringType;
}
@@ -105,6 +109,16 @@
{
return _private;
}
+
+ public boolean isPackagePrivate()
+ {
+ return _packagePrivate;
+ }
+
+ public Package getPackage()
+ {
+ return _package;
+ }
/**
* Gets the current value of the member
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBClassImpl.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -72,7 +72,8 @@
private final String _simpleName;
private final boolean _public;
private final boolean _private;
-
+ private final boolean _packagePrivate;
+ private final Package _package;
private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
@@ -151,8 +152,9 @@
this.superclass = null;
}
this._public = Modifier.isFinal(rawType.getModifiers());
- _private = Modifier.isPrivate(rawType.getModifiers());
-
+ this._private = Modifier.isPrivate(rawType.getModifiers());
+ this._packagePrivate = Reflections.isPackagePrivate(rawType.getModifiers());
+ this._package = rawType.getPackage();
this.fields = new HashSet<WBField<?, ?>>();
this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends
Annotation>, Collection<WBField<?, ?>>>(), new Supplier<
Set<WBField<?, ?>>>()
{
@@ -561,7 +563,7 @@
return Collections.unmodifiableSet(annotatedMethods.get(annotationType));
}
- public Set<WBMethod<?, ?>> getDeclaredWBAnnotatedMethods(Class<?
extends Annotation> annotationType)
+ public Set<WBMethod<?, ?>> getDeclaredAnnotatedWBMethods(Class<?
extends Annotation> annotationType)
{
return Collections.unmodifiableSet(declaredAnnotatedMethods.get(annotationType));
}
@@ -631,6 +633,11 @@
}
return null;
}
+
+ public Set<WBMethod<?, ?>> getDeclaredWBMethods()
+ {
+ return declaredMethods;
+ }
@SuppressWarnings("unchecked")
public <M> WBMethod<M, ?> getDeclaredWBMethod(MethodSignature signature,
WBClass<M> expectedReturnType)
@@ -720,6 +727,16 @@
{
return _private;
}
+
+ public boolean isPackagePrivate()
+ {
+ return _packagePrivate;
+ }
+
+ public Package getPackage()
+ {
+ return _package;
+ }
@SuppressWarnings("unchecked")
public <U> WBClass<? extends U> asWBSubclass(WBClass<U> clazz)
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/WBParameterImpl.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -47,6 +47,8 @@
private final boolean _static = false;
private final boolean _public = false;
private final boolean _private = false;
+ private final boolean _packagePrivate = false;
+ private final Package _package;
private final int position;
private final WBCallable<?, X, ?> declaringMember;
@@ -72,6 +74,7 @@
{
super(AnnotationStore.of(annotations, annotations,
classTransformer.getTypeStore()), rawType, type);
this.declaringMember = declaringMember;
+ this._package = declaringMember.getPackage();
this.position = position;
this.toString = new StringBuilder().append("parameter ").append(position
+ 1).append(" of ").append(declaringMember.toString()).toString();
}
@@ -109,6 +112,16 @@
{
return _private;
}
+
+ public boolean isPackagePrivate()
+ {
+ return _packagePrivate;
+ }
+
+ public Package getPackage()
+ {
+ return _package;
+ }
/**
* Gets the name of the parameter
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/ResolvableWBClass.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/ResolvableWBClass.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/resolution/ResolvableWBClass.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -181,6 +181,16 @@
{
throw new UnsupportedOperationException();
}
+
+ public boolean isPackagePrivate()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Package getPackage()
+ {
+ throw new UnsupportedOperationException();
+ }
public boolean isStatic()
{
@@ -193,6 +203,7 @@
throw new UnsupportedOperationException();
}
+ @Override
public Set<Type> getTypeClosure()
{
return typeClosure;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-10-01 15:20:32 UTC
(rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-10-01 17:22:05 UTC
(rev 3829)
@@ -18,9 +18,12 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -50,6 +53,7 @@
import org.jboss.webbeans.injection.spi.EjbInjectionServices;
import org.jboss.webbeans.injection.spi.JpaInjectionServices;
import org.jboss.webbeans.injection.spi.ResourceInjectionServices;
+import org.jboss.webbeans.introspector.MethodSignature;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBConstructor;
import org.jboss.webbeans.introspector.WBField;
@@ -61,6 +65,10 @@
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.Multimaps;
+
/**
* Helper class for bean inspection
*
@@ -132,18 +140,35 @@
}
}
- public static Set<FieldInjectionPoint<?, ?>>
getFieldInjectionPoints(Bean<?> declaringBean, WBClass<?> annotatedItem)
+ public static List<Set<FieldInjectionPoint<?, ?>>>
getFieldInjectionPoints(Bean<?> declaringBean, WBClass<?> type)
{
- Set<FieldInjectionPoint<?, ?>> injectableFields = new
HashSet<FieldInjectionPoint<?, ?>>();
- for (WBField<?, ?> annotatedField :
annotatedItem.getAnnotatedWBFields(Inject.class))
+ List<Set<FieldInjectionPoint<?, ?>>> injectableFieldsList = new
ArrayList<Set<FieldInjectionPoint<?, ?>>>();
+ WBClass<?> t = type;
+ while (!t.getJavaClass().equals(Object.class))
{
- addFieldInjectionPoint(annotatedField, injectableFields, declaringBean);
+ Set<FieldInjectionPoint<?, ?>> fields = new
HashSet<FieldInjectionPoint<?,?>>();
+ injectableFieldsList.add(0, fields);
+ for (WBField<?, ?> annotatedField :
t.getDeclaredAnnotatedWBFields(Inject.class))
+ {
+ addFieldInjectionPoint(annotatedField, fields, declaringBean);
+ }
+ for (WBField<?, ?> annotatedField :
t.getAnnotatedWBFields(Decorates.class))
+ {
+ addFieldInjectionPoint(annotatedField, fields, declaringBean);
+ }
+ t = t.getWBSuperclass();
}
- for (WBField<?, ?> annotatedField :
annotatedItem.getAnnotatedWBFields(Decorates.class))
+ return injectableFieldsList;
+ }
+
+ public static Set<FieldInjectionPoint<?, ?>>
getFieldInjectionPoints(Bean<?> declaringBean, List<? extends Set<? extends
FieldInjectionPoint<?, ?>>> fieldInjectionPoints)
+ {
+ Set<FieldInjectionPoint<?, ?>> injectionPoints = new
HashSet<FieldInjectionPoint<?,?>>();
+ for (Set<? extends FieldInjectionPoint<?, ?>> i :
fieldInjectionPoints)
{
- addFieldInjectionPoint(annotatedField, injectableFields, declaringBean);
+ injectionPoints.addAll(i);
}
- return injectableFields;
+ return injectionPoints;
}
public static WBMethod<?, ?> getPostConstruct(WBClass<?> type)
@@ -261,32 +286,72 @@
}
}
- public static Set<MethodInjectionPoint<?, ?>>
getInitializerMethods(Bean<?> declaringBean, WBClass<?> type)
+ public static List<Set<MethodInjectionPoint<?, ?>>>
getInitializerMethods(Bean<?> declaringBean, WBClass<?> type)
{
- Set<MethodInjectionPoint<?, ?>> initializerMethods = new
HashSet<MethodInjectionPoint<?, ?>>();
- for (WBMethod<?, ?> method : type.getAnnotatedWBMethods(Inject.class))
+ List<Set<MethodInjectionPoint<?, ?>>> initializerMethodsList =
new ArrayList<Set<MethodInjectionPoint<?, ?>>>();
+ // Keep track of all seen methods so we can ignore overridden methods
+ Multimap<MethodSignature, Package> seenMethods = Multimaps.newSetMultimap(new
HashMap<MethodSignature, Collection<Package>>(), new
Supplier<Set<Package>>()
{
- if (method.getAnnotation(Produces.class) != null)
+
+ public Set<Package> get()
{
- throw new DefinitionException("Initializer method " +
method.toString() + " cannot be annotated @Produces on " + type);
+ return new HashSet<Package>();
}
- else if (method.getAnnotatedWBParameters(Disposes.class).size() > 0)
+
+ });
+ WBClass<?> t = type;
+ while (!t.getJavaClass().equals(Object.class))
+ {
+ Set<MethodInjectionPoint<?, ?>> initializerMethods = new
HashSet<MethodInjectionPoint<?,?>>();
+ initializerMethodsList.add(0, initializerMethods);
+ for (WBMethod<?, ?> method : t.getDeclaredWBMethods())
{
- throw new DefinitionException("Initializer method " +
method.toString() + " cannot have parameters annotated @Disposes on " + type);
+ if (method.isAnnotationPresent(Inject.class))
+ {
+ if (method.getAnnotation(Produces.class) != null)
+ {
+ throw new DefinitionException("Initializer method " +
method.toString() + " cannot be annotated @Produces on " + type);
+ }
+ else if (method.getAnnotatedWBParameters(Disposes.class).size() > 0)
+ {
+ throw new DefinitionException("Initializer method " +
method.toString() + " cannot have parameters annotated @Disposes on " + type);
+ }
+ else if (method.getAnnotatedWBParameters(Observes.class).size() > 0)
+ {
+ throw new DefinitionException("Initializer method " +
method.toString() + " cannot be annotated @Observes on " + type);
+ }
+ else
+ {
+ if (!isOverridden(method, seenMethods))
+ {
+ MethodInjectionPoint<?, ?> initializerMethod =
MethodInjectionPoint.of(declaringBean, method);
+ initializerMethods.add(initializerMethod);
+ }
+ }
+ }
+ seenMethods.put(method.getSignature(), method.getPackage());
}
- else if (method.getAnnotatedWBParameters(Observes.class).size() > 0)
- {
- throw new DefinitionException("Initializer method " +
method.toString() + " cannot be annotated @Observes on " + type);
- }
- else
- {
- MethodInjectionPoint<?, ?> initializerMethod =
MethodInjectionPoint.of(declaringBean, method);
- initializerMethods.add(initializerMethod);
- }
+ t = t.getWBSuperclass();
}
- return initializerMethods;
+ return initializerMethodsList;
}
+ private static boolean isOverridden(WBMethod<?, ?> method,
Multimap<MethodSignature, Package> seenMethods)
+ {
+ if (method.isPrivate())
+ {
+ return false;
+ }
+ else if (method.isPackagePrivate() &&
seenMethods.containsKey(method.getSignature()))
+ {
+ return seenMethods.get(method.getSignature()).contains(method.getPackage());
+ }
+ else
+ {
+ return seenMethods.containsKey(method.getSignature());
+ }
+ }
+
public static Set<ParameterInjectionPoint<?, ?>>
getParameterInjectionPoints(Bean<?> declaringBean, WBConstructor<?>
constructor)
{
Set<ParameterInjectionPoint<?,?>> injectionPoints = new
HashSet<ParameterInjectionPoint<?,?>>();
@@ -297,14 +362,17 @@
return injectionPoints;
}
- public static Set<ParameterInjectionPoint<?, ?>>
getParameterInjectionPoints(Bean<?> declaringBean, Set<MethodInjectionPoint<?,
?>> methodInjectionPoints)
+ public static Set<ParameterInjectionPoint<?, ?>>
getParameterInjectionPoints(Bean<?> declaringBean,
List<Set<MethodInjectionPoint<?, ?>>> methodInjectionPoints)
{
Set<ParameterInjectionPoint<?, ?>> injectionPoints = new
HashSet<ParameterInjectionPoint<?,?>>();
- for (MethodInjectionPoint<?, ?> method : methodInjectionPoints)
+ for (Set<MethodInjectionPoint<?, ?>> i : methodInjectionPoints)
{
- for (WBParameter<?, ?> parameter : method.getWBParameters())
+ for (MethodInjectionPoint<?, ?> method : i)
{
- injectionPoints.add(ParameterInjectionPoint.of(declaringBean, parameter));
+ for (WBParameter<?, ?> parameter : method.getWBParameters())
+ {
+ injectionPoints.add(ParameterInjectionPoint.of(declaringBean,
parameter));
+ }
}
}
return injectionPoints;
@@ -548,7 +616,7 @@
*
* @param instance The instance to inject into
*/
- public static <T> void injectBoundFields(T instance, CreationalContext<T>
creationalContext, BeanManagerImpl manager, Iterable<FieldInjectionPoint<?,
?>> injectableFields)
+ public static <T> void injectBoundFields(T instance, CreationalContext<T>
creationalContext, BeanManagerImpl manager, Iterable<? extends
FieldInjectionPoint<?, ?>> injectableFields)
{
for (FieldInjectionPoint<?, ?> injectableField : injectableFields)
{
@@ -556,6 +624,19 @@
}
}
+ public static<T> void injectFieldsAndInitializers(T instance,
CreationalContext<T> ctx, BeanManagerImpl beanManager, List<? extends
Iterable<? extends FieldInjectionPoint<?, ?>>> injectableFields, List<?
extends Iterable<? extends MethodInjectionPoint<?, ?>>>initializerMethods)
+ {
+ if (injectableFields.size() != initializerMethods.size())
+ {
+ throw new IllegalArgumentException("injectableFields and initializerMethods
must have the same size. InjectableFields: " + injectableFields + ";
InitializerMethods: " + initializerMethods);
+ }
+ for (int i = 0; i < injectableFields.size(); i++)
+ {
+ injectBoundFields(instance, ctx, beanManager, injectableFields.get(i));
+ callInitializers(instance, ctx, beanManager, initializerMethods.get(i));
+ }
+ }
+
/**
* Calls all initializers of the bean
*
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-10-01
15:20:32 UTC (rev 3828)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -317,6 +317,11 @@
{
return type.isPrimitive();
}
+
+ public static boolean isPackagePrivate(int mod)
+ {
+ return !(Modifier.isPrivate(mod) || Modifier.isProtected(mod) ||
Modifier.isPublic(mod));
+ }
/**
* Checks if type is static
Property changes on: ri/trunk/inject-tck-runner
___________________________________________________________________
Name: svn:ignore
- .settings
target
.project
test-output
.classpath
+ .settings
target
.project
test-output
.classpath
bin
Added:
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AbstractProducer.java
===================================================================
---
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AbstractProducer.java
(rev 0)
+++
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AbstractProducer.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -0,0 +1,27 @@
+package org.jboss.webbeans.atinject.tck;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+
+public class AbstractProducer<T>
+{
+
+ protected final InjectionTarget<T> injectionTarget;
+ protected final BeanManager beanManager;
+
+ public AbstractProducer(BeanManager beanManager, Class<T> type)
+ {
+ this.injectionTarget =
beanManager.createInjectionTarget(beanManager.createAnnotatedType(type));
+ this.beanManager = beanManager;
+ }
+
+ public T produce()
+ {
+ CreationalContext<T> ctx = beanManager.createCreationalContext(null);
+ T instance = injectionTarget.produce(ctx);
+ injectionTarget.inject(instance, ctx);
+ return instance;
+ }
+
+}
\ No newline at end of file
Modified:
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AtInjectTCK.java
===================================================================
---
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AtInjectTCK.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/AtInjectTCK.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -12,16 +12,16 @@
import org.atinject.tck.auto.Convertible;
import org.atinject.tck.auto.FuelTank;
import org.atinject.tck.auto.Seat;
+import org.atinject.tck.auto.Tire;
import org.atinject.tck.auto.V8Engine;
import org.atinject.tck.auto.accessories.Cupholder;
-import org.atinject.tck.auto.accessories.SpareTire;
import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.TestContainer;
public class AtInjectTCK
{
- private static final List<Class<?>> classes =
Arrays.<Class<?>>asList(Convertible.class, Seat.class,
DriversSeatProducer.class, V8Engine.class, Cupholder.class, FuelTank.class,
SpareTireProducer.class, SpareTire.class);
+ private static final List<Class<?>> classes =
Arrays.<Class<?>>asList(Convertible.class, Seat.class,
DriversSeatProducer.class, V8Engine.class, Cupholder.class, FuelTank.class,
SpareTireProducer.class, Tire.class);
public static Test suite()
{
@@ -30,6 +30,6 @@
BeanManager beanManager = container.getBeanManager();
Bean<?> bean = beanManager.resolve(beanManager.getBeans(Car.class));
Car instance = (Car) beanManager.getReference(bean, Car.class,
beanManager.createCreationalContext(bean));
- return Tck.testsFor(instance, false /* supportsStatic */, false /* supportsPrivate
*/);
+ return Tck.testsFor(instance, false /* supportsStatic */, true /* supportsPrivate
*/);
}
}
\ No newline at end of file
Modified:
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/DriversSeatProducer.java
===================================================================
---
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/DriversSeatProducer.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/DriversSeatProducer.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -2,30 +2,25 @@
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
import javax.inject.Inject;
import org.atinject.tck.auto.Drivers;
import org.atinject.tck.auto.DriversSeat;
-import org.atinject.tck.auto.Seat;
-public class DriversSeatProducer
+public class DriversSeatProducer extends AbstractProducer<DriversSeat>
{
- private final InjectionTarget<DriversSeat> injectionTarget;
- private final BeanManager beanManager;
-
@Inject
public DriversSeatProducer(BeanManager beanManager)
{
- this.injectionTarget =
beanManager.createInjectionTarget(beanManager.createAnnotatedType(DriversSeat.class));
- this.beanManager = beanManager;
+ super(beanManager, DriversSeat.class);
}
+ @Override
@Produces @Drivers
- public Seat produceDriversSeat()
+ public DriversSeat produce()
{
- return
injectionTarget.produce(beanManager.<DriversSeat>createCreationalContext(null));
+ return super.produce();
}
}
Modified:
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/SpareTireProducer.java
===================================================================
---
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/SpareTireProducer.java 2009-10-01
15:20:32 UTC (rev 3828)
+++
ri/trunk/inject-tck-runner/src/test/java/org/jboss/webbeans/atinject/tck/SpareTireProducer.java 2009-10-01
17:22:05 UTC (rev 3829)
@@ -2,30 +2,25 @@
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
import javax.inject.Inject;
import javax.inject.Named;
-import org.atinject.tck.auto.Tire;
import org.atinject.tck.auto.accessories.SpareTire;
-public class SpareTireProducer
+public class SpareTireProducer extends AbstractProducer<SpareTire>
{
-
- private final InjectionTarget<SpareTire> injectionTarget;
- private final BeanManager beanManager;
-
+
@Inject
public SpareTireProducer(BeanManager beanManager)
{
- this.injectionTarget =
beanManager.createInjectionTarget(beanManager.createAnnotatedType(SpareTire.class));
- this.beanManager = beanManager;
+ super(beanManager, SpareTire.class);
}
-
+
+ @Override
@Produces @Named("spare")
- public Tire produceSpareTire()
+ public SpareTire produce()
{
- return
injectionTarget.produce(beanManager.<SpareTire>createCreationalContext(null));
+ return super.produce();
}
}
Property changes on: ri/trunk/osgi-bundle
___________________________________________________________________
Name: svn:ignore
- target
.settings
.classpath
.project
+ .settings
target
.project
test-output
.classpath
bin
Modified: ri/trunk/version-matrix/pom.xml
===================================================================
--- ri/trunk/version-matrix/pom.xml 2009-10-01 15:20:32 UTC (rev 3828)
+++ ri/trunk/version-matrix/pom.xml 2009-10-01 17:22:05 UTC (rev 3829)
@@ -87,7 +87,7 @@
<dependency>
<groupId>org.atinject</groupId>
<artifactId>inject-tck</artifactId>
- <version>1.0.0-PFD-2</version>
+ <version>1.0.0-PFD-3-jboss-1</version>
</dependency>