[webbeans-commits] Webbeans SVN: r3714 - ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-09-21 13:08:54 -0400 (Mon, 21 Sep 2009)
New Revision: 3714
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java
Log:
Package protected builders, which no longer implement Bean
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -23,7 +23,6 @@
import javax.decorator.Decorates;
import javax.enterprise.context.Dependent;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.Bean;
@@ -87,13 +86,13 @@
// The Web Beans manager
protected BeanManagerImpl manager;
- private boolean _serializable;
+ private boolean serializable;
private boolean initialized;
- protected boolean isInitialized()
+ boolean isInitialized()
{
return initialized;
}
@@ -103,7 +102,7 @@
*
* @param manager The Web Beans manager
*/
- public AbstractBeanBuilder(BeanManagerImpl manager)
+ AbstractBeanBuilder(BeanManagerImpl manager)
{
super(manager);
this.manager = manager;
@@ -115,7 +114,7 @@
* Initializes the bean and its metadata
*/
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
if (isSpecializing())
{
@@ -133,12 +132,12 @@
checkDelegateInjectionPoints();
}
- protected void initStereotypes()
+ void initStereotypes()
{
mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
}
- protected void checkDelegateInjectionPoints()
+ void checkDelegateInjectionPoints()
{
if (this.delegateInjectionPoints.size() > 0)
{
@@ -146,7 +145,7 @@
}
}
- protected void addInjectionPoint(WBInjectionPoint<?, ?> injectionPoint)
+ void addInjectionPoint(WBInjectionPoint<?, ?> injectionPoint)
{
if (injectionPoint.isAnnotationPresent(Decorates.class))
{
@@ -155,7 +154,7 @@
injectionPoints.add(injectionPoint);
}
- protected void addInjectionPoints(Iterable<? extends WBInjectionPoint<?, ?>> injectionPoints)
+ void addInjectionPoints(Iterable<? extends WBInjectionPoint<?, ?>> injectionPoints)
{
for (WBInjectionPoint<?, ?> injectionPoint : injectionPoints)
{
@@ -163,7 +162,7 @@
}
}
- protected Set<WBInjectionPoint<?, ?>> getDelegateInjectionPoints()
+ Set<WBInjectionPoint<?, ?>> getDelegateInjectionPoints()
{
return delegateInjectionPoints;
}
@@ -171,7 +170,7 @@
/**
* Initializes the API types
*/
- protected void initTypes()
+ void initTypes()
{
types = getAnnotatedItem().getTypeClosure();
}
@@ -179,7 +178,7 @@
/**
* Initializes the binding types
*/
- protected void initBindings()
+ void initBindings()
{
this.bindings = new HashSet<Annotation>();
this.bindings.addAll(getAnnotatedItem().getMetaAnnotations(Qualifier.class));
@@ -187,7 +186,7 @@
log.trace("Using binding types " + bindings + " specified by annotations");
}
- protected void initDefaultBindings()
+ void initDefaultBindings()
{
if (bindings.size() == 0)
{
@@ -197,7 +196,7 @@
this.bindings.add(ANY_LITERAL);
}
- protected void initPolicy()
+ void initPolicy()
{
if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
{
@@ -212,7 +211,7 @@
/**
* Initializes the name
*/
- protected void initName()
+ void initName()
{
boolean beanNameDefaulted = false;
if (getAnnotatedItem().isAnnotationPresent(Named.class))
@@ -239,7 +238,7 @@
}
}
- protected void initProxyable()
+ void initProxyable()
{
proxyable = getAnnotatedItem().isProxyable();
}
@@ -247,12 +246,12 @@
/**
* Initializes the primitive flag
*/
- protected void initPrimitive()
+ void initPrimitive()
{
this.primitive = Reflections.isPrimitive(getType());
}
- private boolean checkInjectionPointsAreSerializable()
+ boolean checkInjectionPointsAreSerializable()
{
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(this.getScope()).isPassivating();
for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
@@ -273,9 +272,9 @@
/**
* Initializes the scope type
*/
- protected abstract void initScopeType();
+ abstract void initScopeType();
- protected boolean initScopeTypeFromStereotype()
+ boolean initScopeTypeFromStereotype()
{
Set<Annotation> possibleScopeTypes = getMergedStereotypes().getPossibleScopeTypes();
if (possibleScopeTypes.size() == 1)
@@ -295,7 +294,7 @@
}
}
- protected void postSpecialize()
+ void postSpecialize()
{
if (getAnnotatedItem().isAnnotationPresent(Named.class) && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
{
@@ -308,25 +307,31 @@
}
throw new RuntimeException("Next line commented");
-// manager.getSpecializedBeans().put(getSpecializedBean(), this);
+ //manager.getSpecializedBeans().put(getSpecializedBean(), this);
}
- protected void preSpecialize(BeanDeployerEnvironment environment)
+ void preSpecialize(BeanDeployerEnvironment environment)
{
}
- protected void specialize(BeanDeployerEnvironment environment)
+ void specialize(BeanDeployerEnvironment environment)
{
}
+
+ void registerSpecializedBean(Bean<T> bean)
+ {
+ if (isSpecializing())
+ manager.getSpecializedBeans().put(getSpecializedBean(), bean);
+ }
/**
* Returns the annotated time the bean represents
*
* @return The annotated item
*/
- protected abstract WBAnnotated<T, E> getAnnotatedItem();
+ abstract WBAnnotated<T, E> getAnnotatedItem();
/**
* Gets the binding types
@@ -335,7 +340,7 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getQualifiers()
*/
- public Set<Annotation> getQualifiers()
+ Set<Annotation> getQualifiers()
{
return bindings;
}
@@ -345,13 +350,13 @@
*
* @return The default name
*/
- protected abstract String getDefaultName();
+ abstract String getDefaultName();
@Override
- public abstract AbstractBean<?, ?> getSpecializedBean();
+ abstract AbstractBean<?, ?> getSpecializedBean();
@Override
- public Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints()
+ Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints()
{
return injectionPoints;
}
@@ -361,7 +366,7 @@
*
* @return The set of merged stereotypes
*/
- protected MergedStereotypes<T, E> getMergedStereotypes()
+ MergedStereotypes<T, E> getMergedStereotypes()
{
return mergedStereotypes;
}
@@ -373,7 +378,7 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getName()
*/
- public String getName()
+ String getName()
{
return name;
}
@@ -385,7 +390,7 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getScope()
*/
- public Class<? extends Annotation> getScope()
+ Class<? extends Annotation> getScope()
{
return scopeType;
}
@@ -396,7 +401,7 @@
* @return The type
*/
@Override
- public Class<T> getType()
+ Class<T> getType()
{
return type;
}
@@ -408,7 +413,7 @@
*
* @see org.jboss.webbeans.bean.BaseBean#getTypeClosure()
*/
- public Set<Type> getTypes()
+ Set<Type> getTypes()
{
return types;
}
@@ -420,7 +425,7 @@
* @param annotatedItem The other annotation to check
* @return True if assignable, otherwise false
*/
- public boolean isAssignableFrom(WBAnnotated<?, ?> annotatedItem)
+ boolean isAssignableFrom(WBAnnotated<?, ?> annotatedItem)
{
return this.getAnnotatedItem().isAssignableFrom(annotatedItem);
}
@@ -432,7 +437,7 @@
*
* @see org.jboss.webbeans.bean.BaseBean#isNullable()
*/
- public boolean isNullable()
+ boolean isNullable()
{
return !isPrimitive();
}
@@ -443,21 +448,21 @@
* @return True if primitive, false otherwise
*/
@Override
- public boolean isPrimitive()
+ boolean isPrimitive()
{
return primitive;
}
- public boolean isSerializable()
+ boolean isSerializable()
{
// TODO WTF - why are we not caching the serializability of injection
// points!
- return _serializable && checkInjectionPointsAreSerializable();
+ return serializable && checkInjectionPointsAreSerializable();
}
- protected void initSerializable()
+ void initSerializable()
{
- _serializable = Reflections.isSerializable(type);
+ serializable = Reflections.isSerializable(type);
}
/**
@@ -472,41 +477,30 @@
}
@Override
- public boolean isProxyable()
+ boolean isProxyable()
{
return proxyable;
}
- public boolean isAlternative()
+ boolean isAlternative()
{
return policy;
}
@Override
- public boolean isSpecializing()
+ boolean isSpecializing()
{
return getAnnotatedItem().isAnnotationPresent(Specializes.class);
}
- public Set<Class<? extends Annotation>> getStereotypes()
+ Set<Class<? extends Annotation>> getStereotypes()
{
return mergedStereotypes.getStereotypes();
}
@Override
- public String getId()
+ String getId()
{
return null;
}
-
- public T create(CreationalContext<T> creationalContext)
- {
- throw new IllegalStateException("Should not call create() on builder " + this);
- }
-
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- throw new IllegalStateException("Should not call destroy() on builder " + this);
- }
-
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -82,7 +82,7 @@
* @param type The type
* @param manager The Web Beans manager
*/
- protected AbstractClassBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
+ AbstractClassBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
{
super(manager);
this.annotatedItem = type;
@@ -105,10 +105,8 @@
* Initializes the bean and its metadata
*/
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
- initInitializerMethods();
- initInjectableFields();
super.initialize(environment);
checkBeanImplementation();
initDecorators();
@@ -116,22 +114,22 @@
initProxyClassForDecoratedBean();
}
- protected void checkType()
+ void checkType()
{
}
- protected void initDecorators()
+ void initDecorators()
{
this.decorators = getManager().resolveDecorators(getTypes(), getQualifiers());
}
- public boolean hasDecorators()
+ boolean hasDecorators()
{
return this.decorators != null && this.decorators.size() > 0;
}
- protected void initProxyClassForDecoratedBean()
+ void initProxyClassForDecoratedBean()
{
if (hasDecorators())
{
@@ -144,7 +142,7 @@
}
}
- protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
+ T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
{
throw new RuntimeException("NYI");
// List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
@@ -196,31 +194,25 @@
// }
}
- public List<Decorator<?>> getDecorators()
+ List<Decorator<?>> getDecorators()
{
return Collections.unmodifiableList(decorators);
}
- public Class<T> getProxyClassForDecorators()
+ Class<T> getProxyClassForDecorators()
{
return proxyClassForDecorators;
}
- public void setProxyClassForDecorators(Class<T> proxyClassForDecorators)
+ void setProxyClassForDecorators(Class<T> proxyClassForDecorators)
{
this.proxyClassForDecorators = proxyClassForDecorators;
}
- public void dispose(T instance)
- {
- // No-op for class beans
- }
-
-
/**
* Initializes the bean type
*/
- protected void initType()
+ void initType()
{
log.trace("Bean type specified in Java");
this.type = getAnnotatedItem().getJavaClass();
@@ -231,26 +223,8 @@
}
}
- /**
- * Initializes the injection points
- */
- protected void initInjectableFields()
- {
- injectableFields = new HashSet<FieldInjectionPoint<?, ?>>(Beans.getFieldInjectionPoints(this, annotatedItem));
- addInjectionPoints(injectableFields);
- }
-
- /**
- * Initializes the initializer methods
- */
- protected void initInitializerMethods()
- {
- initializerMethods = Beans.getInitializerMethods(this, getAnnotatedItem());
- addInjectionPoints(Beans.getParameterInjectionPoints(this, initializerMethods));
- }
-
@Override
- protected void initScopeType()
+ void initScopeType()
{
for (WBClass<?> clazz = getAnnotatedItem(); clazz != null; clazz = clazz.getWBSuperclass())
{
@@ -287,10 +261,10 @@
/**
* Validates the bean implementation
*/
- protected void checkBeanImplementation() {}
+ void checkBeanImplementation() {}
@Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
+ void preSpecialize(BeanDeployerEnvironment environment)
{
super.preSpecialize(environment);
if (getAnnotatedItem().getWBSuperclass() == null || getAnnotatedItem().getWBSuperclass().getJavaClass().equals(Object.class))
@@ -305,7 +279,7 @@
* @return The annotated item
*/
@Override
- public WBClass<T> getAnnotatedItem()
+ WBClass<T> getAnnotatedItem()
{
return annotatedItem;
}
@@ -316,7 +290,7 @@
* @return The default name
*/
@Override
- protected String getDefaultName()
+ String getDefaultName()
{
String name = Strings.decapitalize(getAnnotatedItem().getSimpleName());
log.trace("Default name of " + type + " is " + name);
@@ -328,7 +302,7 @@
*
* @return The set of annotated methods
*/
- public Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
+ Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
{
return Collections.unmodifiableSet(initializerMethods);
}
@@ -336,13 +310,13 @@
/**
* @return the injectableFields
*/
- public Set<FieldInjectionPoint<?, ?>> getInjectableFields()
+ Set<FieldInjectionPoint<?, ?>> getInjectableFields()
{
return Collections.unmodifiableSet(injectableFields);
}
// TODO maybe a better way to expose this?
- public Set<String> getSuperclasses()
+ Set<String> getSuperclasses()
{
return dependencies;
}
@@ -359,7 +333,7 @@
}
@Override
- public String getId()
+ String getId()
{
return id;
}
@@ -367,7 +341,7 @@
/**
* Initializes the post-construct method
*/
- protected void initPostConstruct()
+ void initPostConstruct()
{
this.postConstruct = Beans.getPostConstruct(getAnnotatedItem());
}
@@ -375,7 +349,7 @@
/**
* Initializes the pre-destroy method
*/
- protected void initPreDestroy()
+ void initPreDestroy()
{
this.preDestroy = Beans.getPreDestroy(getAnnotatedItem());
}
@@ -385,7 +359,7 @@
*
* @return The post-construct method
*/
- public WBMethod<?, ?> getPostConstruct()
+ WBMethod<?, ?> getPostConstruct()
{
return postConstruct;
}
@@ -395,13 +369,13 @@
*
* @return The pre-destroy method
*/
- public WBMethod<?, ?> getPreDestroy()
+ WBMethod<?, ?> getPreDestroy()
{
return preDestroy;
}
@Override
- public AbstractBean<?, ?> getSpecializedBean()
+ AbstractBean<?, ?> getSpecializedBean()
{
return null;
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -30,11 +30,9 @@
import javax.enterprise.context.Dependent;
import javax.enterprise.context.NormalScope;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.Producer;
import javax.inject.Inject;
import javax.inject.Scope;
@@ -58,7 +56,7 @@
* @param <T>
* @param <S>
*/
-abstract class AbstractProducerBeanBuilder<T, S extends Member> extends AbstractReceiverBeanBuilder<T, S> implements Producer<T>
+abstract class AbstractProducerBeanBuilder<T, S extends Member> extends AbstractReceiverBeanBuilder<T, S>
{
private static final LogProvider log = Logging.getLogProvider(AbstractProducerBeanBuilder.class);
@@ -68,17 +66,17 @@
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- public AbstractProducerBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ AbstractProducerBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
{
super(declaringBean, manager);
}
@Override
- public abstract WBMember<T, ?, S> getAnnotatedItem();
+ abstract WBMember<T, ?, S> getAnnotatedItem();
@Override
// Overriden to provide the class of the bean that declares the producer method/field
- public Class<?> getBeanClass()
+ Class<?> getBeanClass()
{
return getDeclaringBean().getBeanClass();
}
@@ -87,7 +85,7 @@
* Initializes the API types
*/
@Override
- protected void initTypes()
+ void initTypes()
{
if (getType().isArray() || getType().isPrimitive())
{
@@ -113,7 +111,7 @@
/**
* Initializes the type
*/
- protected void initType()
+ void initType()
{
try
{
@@ -130,7 +128,7 @@
*
* @return The bean type
*/
- protected Type getDeclaredBeanType()
+ Type getDeclaredBeanType()
{
Type type = getClass();
if (type instanceof ParameterizedType)
@@ -147,7 +145,7 @@
/**
* Validates the producer method
*/
- protected void checkProducerReturnType()
+ void checkProducerReturnType()
{
if (getAnnotatedItem().getBaseType() instanceof TypeVariable<?>)
{
@@ -170,7 +168,7 @@
* Initializes the bean and its metadata
*/
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
getDeclaringBean().initialize(environment);
super.initialize(environment);
@@ -182,7 +180,7 @@
*
* @param instance The instance to validate
*/
- protected void checkReturnValue(T instance)
+ void checkReturnValue(T instance)
{
if (instance == null && !isDependent())
{
@@ -230,7 +228,7 @@
}
@Override
- protected void initScopeType()
+ void initScopeType()
{
Set<Annotation> scopeAnnotations = new HashSet<Annotation>();
scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(Scope.class));
@@ -256,13 +254,13 @@
}
@Override
- protected void initSerializable()
+ void initSerializable()
{
// No-op
}
@Override
- public boolean isSerializable()
+ boolean isSerializable()
{
return true;
}
@@ -287,16 +285,5 @@
}
buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
return buffer.toString();
- }
-
- public void dispose(T instance)
- {
- throw new IllegalStateException("Should not call dispose() on builder " + this);
- }
-
- public T produce(CreationalContext<T> ctx)
- {
- throw new IllegalStateException("Should not call produce() on builder " + this);
- }
-
+ }
}
\ No newline at end of file
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -39,14 +39,14 @@
private AbstractClassBean<?> declaringBean;
private boolean policy;
- public AbstractReceiverBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ AbstractReceiverBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
{
super(manager);
this.declaringBean = declaringBean;
}
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
super.initialize(environment);
}
@@ -56,7 +56,7 @@
*
* @return The receiver
*/
- protected Object getReceiver(CreationalContext<?> creationalContext)
+ Object getReceiver(CreationalContext<?> creationalContext)
{
// This is a bit dangerous, as it means that producer methods can end of
// executing on partially constructed instances. Also, it's not required
@@ -86,7 +86,7 @@
*
* @return The bean representation
*/
- public AbstractClassBean<?> getDeclaringBean()
+ AbstractClassBean<?> getDeclaringBean()
{
return declaringBean;
}
@@ -95,13 +95,13 @@
* @see org.jboss.webbeans.bean.AbstractBean#isPolicy()
*/
@Override
- public boolean isAlternative()
+ boolean isAlternative()
{
return policy;
}
@Override
- protected void initPolicy()
+ void initPolicy()
{
if (getDeclaringBean().isAlternative())
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -35,7 +35,7 @@
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
-class DecoratorBuilder<T> extends ManagedBeanBuilder<T> implements Decorator<T>
+class DecoratorBuilder<T> extends ManagedBeanBuilder<T>
{
public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
@@ -72,7 +72,7 @@
* @param manager the current manager
* @return a Bean
*/
- public static <T> DecoratorBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ static <T> DecoratorBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
{
return new DecoratorBuilder<T>(clazz, manager);
}
@@ -83,13 +83,13 @@
private Set<Type> delegateTypes;
private Set<Type> decoratedTypes;
- protected DecoratorBuilder(WBClass<T> type, BeanManagerImpl manager)
+ DecoratorBuilder(WBClass<T> type, BeanManagerImpl manager)
{
super(type, manager);
}
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
if (!isInitialized())
{
@@ -102,20 +102,20 @@
}
}
- protected void initDecoratedTypes()
+ void initDecoratedTypes()
{
this.decoratedTypes = new HashSet<Type>();
this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
this.decoratedTypes.remove(Serializable.class);
}
- protected void initDelegateInjectionPoint()
+ void initDelegateInjectionPoint()
{
this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
}
@Override
- protected void checkDelegateInjectionPoints()
+ void checkDelegateInjectionPoints()
{
for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
{
@@ -134,20 +134,20 @@
}
}
- protected void initDelegateBindings()
+ void initDelegateBindings()
{
this.delegateBindings = new HashSet<Annotation>();
this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
}
- protected void initDelegateType()
+ void initDelegateType()
{
this.delegateType = this.delegateInjectionPoint.getBaseType();
this.delegateTypes = new HashSet<Type>();
delegateTypes.add(delegateType);
}
- protected void checkDelegateType()
+ void checkDelegateType()
{
for (Type decoratedType : getDecoratedTypes())
{
@@ -180,22 +180,22 @@
}
}
- public Set<Annotation> getDelegateQualifiers()
+ Set<Annotation> getDelegateQualifiers()
{
return delegateBindings;
}
- public Type getDelegateType()
+ Type getDelegateType()
{
return delegateType;
}
- public Set<Type> getDecoratedTypes()
+ Set<Type> getDecoratedTypes()
{
return decoratedTypes;
}
- public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
+ WBInjectionPoint<?, ?> getDelegateInjectionPoint()
{
return delegateInjectionPoint;
}
@@ -205,13 +205,13 @@
*
* @return the delegateTypes
*/
- public Set<Type> getDelegateTypes()
+ Set<Type> getDelegateTypes()
{
return delegateTypes;
}
@Override
- protected void initDecorators()
+ void initDecorators()
{
// No-op, decorators can't have decorators
}
@@ -227,7 +227,7 @@
}
@Override
- public DecoratorImpl<T> createBean()
+ DecoratorImpl<T> createBean()
{
return DecoratorImpl.of(getAnnotatedItem(),
getManager(),
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -46,7 +46,7 @@
//protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
private final String id;
- protected DisposalMethodBuilder(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ DisposalMethodBuilder(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
{
super(declaringBean, manager);
this.disposalMethod = disposalMethod;
@@ -60,31 +60,31 @@
}
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
super.initialize(environment);
checkDisposalMethod();
}
- protected void initType()
+ void initType()
{
disposalMethod.getAnnotatedWBParameters(Disposes.class).get(0).getJavaClass();
this.type = (Class<T>) disposalMethod.getAnnotatedWBParameters(Disposes.class).get(0).getJavaClass();
}
@Override
- public WBMethod<T, ?> getAnnotatedItem()
+ WBMethod<T, ?> getAnnotatedItem()
{
return disposalMethod;
}
- public static <T> DisposalMethodBuilder<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ static <T> DisposalMethodBuilder<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
{
return new DisposalMethodBuilder<T>(manager, disposalMethod, declaringBean);
}
@Override
- protected void initBindings()
+ void initBindings()
{
// At least 1 parameter exists, already checked in constructor
this.bindings = new HashSet<Annotation>();
@@ -97,7 +97,7 @@
* Initializes the API types
*/
@Override
- protected void initTypes()
+ void initTypes()
{
Set<Type> types = new HashSet<Type>();
types = new HashSet<Type>();
@@ -108,19 +108,19 @@
}
@Override
- public String getName()
+ String getName()
{
return null;
}
@Override
- public Class<? extends Annotation> getScope()
+ Class<? extends Annotation> getScope()
{
return null;
}
@Override
- public Set<Type> getTypes()
+ Set<Type> getTypes()
{
return types;
}
@@ -132,31 +132,25 @@
}
@Override
- public boolean isNullable()
+ boolean isNullable()
{
// Not relevant
return false;
}
@Override
- public boolean isSerializable()
+ boolean isSerializable()
{
// Not relevant
return false;
}
@Override
- public boolean isProxyable()
+ boolean isProxyable()
{
return true;
}
- public T create(CreationalContext<T> creationalContext)
- {
- // Not Relevant
- return null;
- }
-
private void checkDisposalMethod()
{
if (!disposalMethod.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
@@ -207,47 +201,42 @@
}
@Override
- public Class<T> getType()
+ Class<T> getType()
{
return type;
}
@Override
- protected String getDefaultName()
+ String getDefaultName()
{
return disposalMethod.getPropertyName();
}
- public void destroy(T instance, CreationalContext<T> creationalContext)
- {
- // No-op. Producer method dependent objects are destroyed in producer method bean
- }
-
@Override
- public String getId()
+ String getId()
{
return id;
}
@Override
- public AbstractBean<?, ?> getSpecializedBean()
+ AbstractBean<?, ?> getSpecializedBean()
{
// Doesn't support specialization
return null;
}
@Override
- protected void initScopeType()
+ void initScopeType()
{
// Disposal methods aren't scoped
}
- public Set<Class<? extends Annotation>> getStereotypes()
+ Set<Class<? extends Annotation>> getStereotypes()
{
return Collections.emptySet();
}
- public DisposalMethod<T> createBean()
+ DisposalMethod<T> createBean()
{
return DisposalMethod.of(manager,
name,
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -16,10 +16,6 @@
*/
package org.jboss.webbeans.bean.builder;
-import java.util.Set;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
@@ -28,16 +24,12 @@
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.ManagedBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.ConstructorInjectionPoint;
-import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
-import org.jboss.webbeans.introspector.WBConstructor;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -53,13 +45,6 @@
// Logger
private static LogProvider log = Logging.getLogProvider(ManagedBeanBuilder.class);
- // The constructor
- private ConstructorInjectionPoint<T> constructor;
- private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
-
private ManagedBean<?> specializedBean;
@@ -72,7 +57,7 @@
* @param manager the current manager
* @return A Web Bean
*/
- public static <T> ManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ static <T> ManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
{
return new ManagedBeanBuilder<T>(clazz, manager);
}
@@ -83,7 +68,7 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected ManagedBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
+ ManagedBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
{
super(type, manager);
initType();
@@ -91,7 +76,7 @@
initBindings();
}
- protected InjectionPoint attachCorrectInjectionPoint()
+ InjectionPoint attachCorrectInjectionPoint()
{
Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
if (decorator instanceof DecoratorBuilder<?>)
@@ -110,31 +95,20 @@
* Initializes the bean and its metadata
*/
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
if (!isInitialized())
{
- initConstructor();
- checkConstructor();
super.initialize(environment);
initPostConstruct();
initPreDestroy();
- initEEInjectionPoints();
}
}
- private void initEEInjectionPoints()
- {
- this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
- this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
- }
-
/**
* Validates the type
*/
- protected void checkType()
+ void checkType()
{
if (getAnnotatedItem().isNonStaticMemberClass())
{
@@ -178,7 +152,7 @@
}
@Override
- protected void checkBeanImplementation()
+ void checkBeanImplementation()
{
super.checkBeanImplementation();
if (!isDependent())
@@ -193,20 +167,8 @@
}
}
- protected void checkConstructor()
- {
- if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
- {
- throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
- }
- if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
- {
- throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
- }
- }
-
@Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
+ void preSpecialize(BeanDeployerEnvironment environment)
{
super.preSpecialize(environment);
if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
@@ -216,7 +178,7 @@
}
@Override
- protected void specialize(BeanDeployerEnvironment environment)
+ void specialize(BeanDeployerEnvironment environment)
{
if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
{
@@ -233,28 +195,7 @@
}
}
-
/**
- * Initializes the constructor
- */
- protected void initConstructor()
- {
- this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
- // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
- addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
- }
-
- /**
- * Returns the constructor
- *
- * @return The constructor
- */
- public WBConstructor<T> getConstructor()
- {
- return constructor;
- }
-
- /**
* Gets a string representation
*
* @return The string representation
@@ -265,7 +206,7 @@
return toString("simple bean");
}
- protected String toString(String beanType)
+ String toString(String beanType)
{
StringBuilder buffer = new StringBuilder();
buffer.append(Names.scopeTypeToString(getScope()));
@@ -283,13 +224,13 @@
}
@Override
- public ManagedBean<?> getSpecializedBean()
+ ManagedBean<?> getSpecializedBean()
{
return specializedBean;
}
@Override
- public ManagedBean<T> createBean()
+ ManagedBean<T> createBean()
{
return ManagedBean.of(
getAnnotatedItem(),
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -42,7 +42,7 @@
* @param manager The Web Beans manager
* @return a new NewSimpleBean instance
*/
- public static <T> NewManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ static <T> NewManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
{
return new NewManagedBeanBuilder<T>(clazz, manager);
}
@@ -55,7 +55,7 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewManagedBeanBuilder(final WBClass<T> type, BeanManagerImpl manager)
+ NewManagedBeanBuilder(final WBClass<T> type, BeanManagerImpl manager)
{
super(type, manager);
this.bindings = new HashSet<Annotation>();
@@ -76,13 +76,13 @@
* @return @Dependent
*/
@Override
- public Class<? extends Annotation> getScope()
+ Class<? extends Annotation> getScope()
{
return Dependent.class;
}
@Override
- public boolean isAlternative()
+ boolean isAlternative()
{
return false;
}
@@ -93,7 +93,7 @@
* @return null
*/
@Override
- public String getName()
+ String getName()
{
return null;
}
@@ -104,19 +104,19 @@
* @returns @New
*/
@Override
- public Set<Annotation> getQualifiers()
+ Set<Annotation> getQualifiers()
{
return bindings;
}
@Override
- public boolean isSpecializing()
+ boolean isSpecializing()
{
return false;
}
@Override
- public NewManagedBean<T> createBean()
+ NewManagedBean<T> createBean()
{
return NewManagedBean.of(
getAnnotatedItem(),
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -44,7 +44,7 @@
* @param manager The Web Beans manager
* @return a new NewEnterpriseBean instance
*/
- public static <T> NewSessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ static <T> NewSessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
{
WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
return new NewSessionBeanBuilder<T>(type, ejbDescriptor, manager);
@@ -58,7 +58,7 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewSessionBeanBuilder(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ NewSessionBeanBuilder(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
{
super(type, ejbDescriptor, manager);
this.bindings = new HashSet<Annotation>();
@@ -79,13 +79,13 @@
* @return @Dependent
*/
@Override
- public Class<? extends Annotation> getScope()
+ Class<? extends Annotation> getScope()
{
return Dependent.class;
}
@Override
- public boolean isAlternative()
+ boolean isAlternative()
{
return false;
}
@@ -96,7 +96,7 @@
* @return null
*/
@Override
- public String getName()
+ String getName()
{
return null;
}
@@ -107,25 +107,25 @@
* @returns @New
*/
@Override
- public Set<Annotation> getQualifiers()
+ Set<Annotation> getQualifiers()
{
return bindings;
}
@Override
- public boolean isSpecializing()
+ boolean isSpecializing()
{
return false;
}
@Override
- protected void checkScopeAllowed()
+ void checkScopeAllowed()
{
// No-op
}
@Override
- public NewSessionBean<T> createBean()
+ NewSessionBean<T> createBean()
{
return NewSessionBean.of(getEjbDescriptor(),
getManager(),
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -22,9 +22,7 @@
import java.util.Collections;
import java.util.Set;
-import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.CreationException;
import javax.enterprise.inject.Disposes;
import org.jboss.webbeans.BeanManagerImpl;
@@ -35,11 +33,7 @@
import org.jboss.webbeans.bean.ProducerMethod;
import org.jboss.webbeans.bean.SessionBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.injection.MethodInjectionPoint;
-import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.introspector.WBParameter;
-import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.util.Names;
/**
@@ -52,7 +46,7 @@
class ProducerMethodBuilder<T> extends AbstractProducerBeanBuilder<T, Method>
{
// The underlying method
- private MethodInjectionPoint<T, ?> method;
+ private WBMethod<T, ?> method;
private DisposalMethod<?> disposalMethodBean;
@@ -76,7 +70,7 @@
protected ProducerMethodBuilder(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
{
super(declaringBean, manager);
- this.method = MethodInjectionPoint.of(this, method);
+ this.method = method;
initType();
initTypes();
initBindings();
@@ -94,7 +88,6 @@
{
if (!isInitialized())
{
- initProducerMethodInjectableParameters();
super.initialize(environment);
checkProducerMethod();
initDisposalMethod(environment);
@@ -102,17 +95,6 @@
}
/**
- * Initializes the injection points
- */
- protected void initProducerMethodInjectableParameters()
- {
- for (WBParameter<?, ?> parameter : method.getWBParameters())
- {
- addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
- }
- }
-
- /**
* Validates the producer method
*/
protected void checkProducerMethod()
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -16,13 +16,13 @@
*/
package org.jboss.webbeans.bean.builder;
+import java.lang.annotation.Annotation;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger;
import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.jboss.webbeans.BeanManagerImpl;
@@ -35,62 +35,64 @@
*
* @author Pete Muir
*/
-abstract class RIBeanBuilder<T> implements Bean<T>
+abstract class RIBeanBuilder<T>
{
private static final ConcurrentMap<String, AtomicInteger> ids = new ConcurrentHashMap<String, AtomicInteger>();
private final BeanManagerImpl manager;
- protected RIBeanBuilder(BeanManagerImpl manager)
+ RIBeanBuilder(BeanManagerImpl manager)
{
this.manager = manager;
// TODO better ID strategy (human readable)
}
- protected static String createId(String prefix)
+ static String createId(String prefix)
{
ids.putIfAbsent(prefix, new AtomicInteger());
int i = ids.get(prefix).getAndIncrement();
return prefix + "-" + i;
}
- protected BeanManagerImpl getManager()
+ BeanManagerImpl getManager()
{
return manager;
}
- public abstract Class<T> getType();
+ abstract Class<T> getType();
- public Class<?> getBeanClass()
+ Class<?> getBeanClass()
{
return getType();
}
- public abstract void initialize(BeanDeployerEnvironment environment);
+ abstract void initialize(BeanDeployerEnvironment environment);
- public abstract boolean isSpecializing();
+ abstract boolean isSpecializing();
- public boolean isDependent()
+ boolean isDependent()
{
return getScope().equals(Dependent.class);
}
- public abstract boolean isProxyable();
+ abstract Class<? extends Annotation> getScope();
+
+ abstract boolean isProxyable();
- public abstract boolean isPrimitive();
+ abstract boolean isPrimitive();
- public abstract Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints();
+ abstract Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints();
@SuppressWarnings("unchecked")
- public Set<InjectionPoint> getInjectionPoints()
+ Set<InjectionPoint> getInjectionPoints()
{
return (Set) getAnnotatedInjectionPoints();
}
- public abstract RIBean<?> getSpecializedBean();
+ abstract RIBean<?> getSpecializedBean();
- public abstract String getId();
+ abstract String getId();
@Override
public boolean equals(Object obj)
@@ -112,5 +114,5 @@
return getId().hashCode();
}
- public abstract RIBean<T> createBean();
+ abstract RIBean<T> createBean();
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java 2009-09-21 17:08:54 UTC (rev 3714)
@@ -74,7 +74,7 @@
* @param manager the current manager
* @return An Enterprise Web Bean
*/
- public static <T> SessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ static <T> SessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
{
WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
return new SessionBeanBuilder<T>(type, ejbDescriptor, manager);
@@ -86,7 +86,7 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected SessionBeanBuilder(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ SessionBeanBuilder(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
{
super(type, manager);
initType();
@@ -99,7 +99,7 @@
* Initializes the bean and its metadata
*/
@Override
- public void initialize(BeanDeployerEnvironment environment)
+ void initialize(BeanDeployerEnvironment environment)
{
if (!isInitialized())
{
@@ -113,7 +113,7 @@
}
@Override
- protected void initTypes()
+ void initTypes()
{
Set<Type> types = new HashSet<Type>();
types = new LinkedHashSet<Type>();
@@ -125,7 +125,7 @@
super.types = types;
}
- protected void initProxyClass()
+ void initProxyClass()
{
Set<Type> types = new LinkedHashSet<Type>(getTypes());
types.add(EnterpriseBeanInstance.class);
@@ -140,7 +140,7 @@
/**
* Validates for non-conflicting roles
*/
- protected void checkConflictingRoles()
+ void checkConflictingRoles()
{
if (getType().isAnnotationPresent(Interceptor.class))
{
@@ -156,7 +156,7 @@
* Check that the scope type is allowed by the stereotypes on the bean and
* the bean type
*/
- protected void checkScopeAllowed()
+ void checkScopeAllowed()
{
if (ejbDescriptor.isStateless() && !isDependent())
{
@@ -172,7 +172,7 @@
* Validates specialization
*/
@Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
+ void preSpecialize(BeanDeployerEnvironment environment)
{
super.preSpecialize(environment);
// We appear to check this twice?
@@ -183,7 +183,7 @@
}
@Override
- protected void specialize(BeanDeployerEnvironment environment)
+ void specialize(BeanDeployerEnvironment environment)
{
if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
{
@@ -235,41 +235,30 @@
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();
- }
-
@Override
- protected void initSerializable()
+ void initSerializable()
{
// No-op
}
@Override
- public boolean isSerializable()
+ boolean isSerializable()
{
return true;
}
- public InternalEjbDescriptor<T> getEjbDescriptor()
+ InternalEjbDescriptor<T> getEjbDescriptor()
{
return ejbDescriptor;
}
- public boolean isClientCanCallRemoveMethods()
+ boolean isClientCanCallRemoveMethods()
{
return getEjbDescriptor().isStateful() && isDependent();
}
@Override
- public SessionBean<?> getSpecializedBean()
+ SessionBean<?> getSpecializedBean()
{
return specializedBean;
}
@@ -278,7 +267,7 @@
* If there are any observer methods, they must be static or business
* methods.
*/
- protected void checkObserverMethods()
+ void checkObserverMethods()
{
for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
{
@@ -293,7 +282,7 @@
}
// TODO must be a nicer way to do this!
- public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
+ boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
{
for (Type type : getTypes())
{
@@ -311,23 +300,18 @@
return false;
}
- public SessionObjectReference createReference()
+ Set<Class<? extends Annotation>> getStereotypes()
{
- return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
return Collections.emptySet();
}
- public Class<T> getProxyClass()
+ Class<T> getProxyClass()
{
return proxyClass;
}
@Override
- public SessionBean<T> createBean()
+ SessionBean<T> createBean()
{
return SessionBean.of(getEjbDescriptor(),
getManager(),
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3713 - in ri/branches/kabir-builder: impl/src/main/java/org/jboss/webbeans/bean/builder and 3 other directories.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-09-21 12:33:40 -0400 (Mon, 21 Sep 2009)
New Revision: 3713
Added:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingDecorator.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerFieldBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderFactoryImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
Log:
Immutable beans and builder. Core tests pass
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -23,10 +23,8 @@
import javax.decorator.Decorates;
import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.stereotype.Stereotype;
import javax.inject.Named;
import javax.inject.Qualifier;
@@ -56,36 +54,45 @@
public abstract class AbstractBean<T, E> extends RIBean<T>
{
- private static final Annotation ANY_LITERAL = new AnyLiteral();
- private static final Annotation CURRENT_LITERAL = new DefaultLiteral();
+// private static final Annotation ANY_LITERAL = new AnyLiteral();
+// private static final Annotation CURRENT_LITERAL = new DefaultLiteral();
+//
+ private final boolean proxyable;
- private boolean proxyable;
-
// Logger
private final Log log = Logging.getLog(AbstractBean.class);
+
// The binding types
- protected Set<Annotation> bindings;
+ private final Set<Annotation> bindings;
+
// The name
- protected String name;
+ protected final String name;
+
// The scope type
- protected Class<? extends Annotation> scopeType;
+ protected final Class<? extends Annotation> scopeType;
+
// The merged stereotypes
- private MergedStereotypes<T, E> mergedStereotypes;
+ private final MergedStereotypes<T, E> mergedStereotypes;
+
// Is it a policy, either defined by stereotypes or directly?
- private boolean policy;
+ private final boolean policy;
+
// The type
- protected Class<T> type;
+ protected final Class<T> type;
+
// The API types
- protected Set<Type> types;
+ protected final Set<Type> types;
+
// The injection points
- private Set<WBInjectionPoint<?, ?>> injectionPoints;
- private Set<WBInjectionPoint<?, ?>> delegateInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> injectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> delegateInjectionPoints;
+
// If the type a primitive?
- private boolean primitive;
+ private final boolean primitive;
// The Web Beans manager
- protected BeanManagerImpl manager;
+ protected final BeanManagerImpl manager;
- private boolean _serializable;
+ private final boolean serializable;
private boolean initialized;
@@ -101,12 +108,33 @@
*
* @param manager The Web Beans manager
*/
- public AbstractBean(BeanManagerImpl manager)
+ public AbstractBean(BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, E> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean serializable,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
super(manager);
this.manager = manager;
this.injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
this.delegateInjectionPoints = new HashSet<WBInjectionPoint<?,?>>();
+
+ this.name = name;
+ this.type = type;
+ this.types = types;
+ this.mergedStereotypes = mergedStereotypes;
+ this.scopeType = scopeType;
+ this.policy = policy;
+ this.primitive = Reflections.isPrimitive(type);
+ this.bindings = bindings;
+ this.serializable = serializable;
+ this.proxyable = proxyable;
+
}
/**
@@ -115,27 +143,9 @@
@Override
public void initialize(BeanDeployerEnvironment environment)
{
- if (isSpecializing())
- {
- preSpecialize(environment);
- specialize(environment);
- postSpecialize();
- }
- initDefaultBindings();
- initPrimitive();
- log.trace("Building Web Bean bean metadata for #0", getType());
- initName();
- initScopeType();
- initSerializable();
- initProxyable();
checkDelegateInjectionPoints();
}
- protected void initStereotypes()
- {
- mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
- }
-
protected void checkDelegateInjectionPoints()
{
if (this.delegateInjectionPoints.size() > 0)
@@ -166,90 +176,6 @@
return delegateInjectionPoints;
}
- /**
- * Initializes the API types
- */
- protected void initTypes()
- {
- types = getAnnotatedItem().getTypeClosure();
- }
-
- /**
- * Initializes the binding types
- */
- protected void initBindings()
- {
- this.bindings = new HashSet<Annotation>();
- this.bindings.addAll(getAnnotatedItem().getMetaAnnotations(Qualifier.class));
- initDefaultBindings();
- log.trace("Using binding types " + bindings + " specified by annotations");
- }
-
- protected void initDefaultBindings()
- {
- if (bindings.size() == 0)
- {
- log.trace("Adding default @Current binding type");
- this.bindings.add(CURRENT_LITERAL);
- }
- this.bindings.add(ANY_LITERAL);
- }
-
- protected void initPolicy()
- {
- if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
- {
- this.policy = true;
- }
- else
- {
- this.policy = getMergedStereotypes().isPolicy();
- }
- }
-
- /**
- * Initializes the name
- */
- protected void initName()
- {
- boolean beanNameDefaulted = false;
- if (getAnnotatedItem().isAnnotationPresent(Named.class))
- {
- String javaName = getAnnotatedItem().getAnnotation(Named.class).value();
- if ("".equals(javaName))
- {
- log.trace("Using default name (specified by annotations)");
- beanNameDefaulted = true;
- }
- else
- {
- if (log.isTraceEnabled())
- log.trace("Using name " + javaName + " specified by annotations");
- this.name = javaName;
- return;
- }
- }
-
- if (beanNameDefaulted || getMergedStereotypes().isBeanNameDefaulted())
- {
- this.name = getDefaultName();
- return;
- }
- }
-
- protected void initProxyable()
- {
- proxyable = getAnnotatedItem().isProxyable();
- }
-
- /**
- * Initializes the primitive flag
- */
- protected void initPrimitive()
- {
- this.primitive = Reflections.isPrimitive(getType());
- }
-
private boolean checkInjectionPointsAreSerializable()
{
boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(this.getScope()).isPassivating();
@@ -269,60 +195,11 @@
}
/**
- * Initializes the scope type
- */
- protected abstract void initScopeType();
-
- protected boolean initScopeTypeFromStereotype()
- {
- Set<Annotation> possibleScopeTypes = getMergedStereotypes().getPossibleScopeTypes();
- if (possibleScopeTypes.size() == 1)
- {
- this.scopeType = possibleScopeTypes.iterator().next().annotationType();
- if (log.isTraceEnabled())
- log.trace("Scope " + scopeType + " specified by stereotype");
- return true;
- }
- else if (possibleScopeTypes.size() > 1)
- {
- throw new DefinitionException("All stereotypes must specify the same scope OR a scope must be specified on " + getAnnotatedItem());
- }
- else
- {
- return false;
- }
- }
-
- protected void postSpecialize()
- {
- if (getAnnotatedItem().isAnnotationPresent(Named.class) && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
- {
- throw new DefinitionException("Cannot put name on specializing and specialized class " + getAnnotatedItem());
- }
- this.bindings.addAll(getSpecializedBean().getQualifiers());
- if (isSpecializing() && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
- {
- this.name = getSpecializedBean().getName();
- }
- manager.getSpecializedBeans().put(getSpecializedBean(), this);
- }
-
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
-
- }
-
- protected void specialize(BeanDeployerEnvironment environment)
- {
-
- }
-
- /**
* Returns the annotated time the bean represents
*
* @return The annotated item
*/
- protected abstract WBAnnotated<T, E> getAnnotatedItem();
+ public abstract WBAnnotated<T, E> getAnnotatedItem();
/**
* Gets the binding types
@@ -448,13 +325,13 @@
{
// TODO WTF - why are we not caching the serializability of injection
// points!
- return _serializable && checkInjectionPointsAreSerializable();
+ return serializable && checkInjectionPointsAreSerializable();
}
- protected void initSerializable()
- {
- _serializable = Reflections.isSerializable(type);
- }
+// protected void initSerializable()
+// {
+// _serializable = Reflections.isSerializable(type);
+// }
/**
* Gets a string representation
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -21,33 +21,26 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
-import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.NormalScope;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
-import javax.inject.Scope;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.DefinitionException;
import org.jboss.webbeans.bean.proxy.DecoratorProxyMethodHandler;
-import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Strings;
/**
@@ -62,22 +55,26 @@
{
// Logger
private static final LogProvider log = Logging.getLogProvider(AbstractClassBean.class);
+
// The item representation
- protected WBClass<T> annotatedItem;
+ protected final WBClass<T> annotatedItem;
+
// The injectable fields
- private Set<FieldInjectionPoint<?, ?>> injectableFields;
+ private final Set<FieldInjectionPoint<?, ?>> injectableFields;
+
// The initializer methods
- private Set<MethodInjectionPoint<?, ?>> initializerMethods;
- private Set<String> dependencies;
+ private final Set<MethodInjectionPoint<?, ?>> initializerMethods;
- private List<Decorator<?>> decorators;
+ private final Set<String> dependencies;
+ private final List<Decorator<?>> decorators;
+
private final String id;
- private Class<T> proxyClassForDecorators;
+ private final Class<T> proxyClassForDecorators;
private final ThreadLocal<Integer> decoratorStackPosition;
- private WBMethod<?, ?> postConstruct;
- private WBMethod<?, ?> preDestroy;
+ private final WBMethod<?, ?> postConstruct;
+ private final WBMethod<?, ?> preDestroy;
/**
* Constructor
@@ -85,9 +82,23 @@
* @param type The type
* @param manager The Web Beans manager
*/
- protected AbstractClassBean(WBClass<T> type, BeanManagerImpl manager)
+ protected AbstractClassBean(WBClass<T> type,
+ BeanManagerImpl manager,
+ String name,
+ Set<Type> types,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean serializable,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy)
{
- super(manager);
+ super(manager, name, type.getJavaClass(), types, mergedStereotypes, scopeType, policy, serializable, proxyable, bindings);
this.annotatedItem = type;
this.id = createId(getClass().getSimpleName() + "-" + type.getName());
this.decoratorStackPosition = new ThreadLocal<Integer>()
@@ -100,23 +111,16 @@
}
};
- initStereotypes();
- initPolicy();
- }
+ this.dependencies = dependencies;
+ this.proxyClassForDecorators = proxyClassForDecorators;
+ this.decorators = decorators;
+ this.postConstruct = postConstruct;
+ this.preDestroy = preDestroy;
+ this.injectableFields = initInjectableFields();
+ this.initializerMethods = initInitializerMethods();
- /**
- * Initializes the bean and its metadata
- */
- @Override
- public void initialize(BeanDeployerEnvironment environment)
- {
- initInitializerMethods();
- initInjectableFields();
- super.initialize(environment);
checkBeanImplementation();
- initDecorators();
checkType();
- initProxyClassForDecoratedBean();
}
protected void checkType()
@@ -124,30 +128,11 @@
}
- protected void initDecorators()
- {
- this.decorators = getManager().resolveDecorators(getTypes(), getQualifiers());
- }
-
public boolean hasDecorators()
{
return this.decorators != null && this.decorators.size() > 0;
}
- protected void initProxyClassForDecoratedBean()
- {
- if (hasDecorators())
- {
- Set<Type> types = new LinkedHashSet<Type>(getTypes());
- ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
-
- @SuppressWarnings("unchecked")
- Class<T> proxyClass = proxyFactory.createClass();
-
- this.proxyClassForDecorators = proxyClass;
- }
- }
-
protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
{
List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
@@ -163,7 +148,6 @@
{
decoratorStackPosition.set(++i);
- @SuppressWarnings("unchecked")
DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
@@ -211,87 +195,30 @@
/**
- * Initializes the bean type
- */
- protected void initType()
- {
- log.trace("Bean type specified in Java");
- this.type = getAnnotatedItem().getJavaClass();
- this.dependencies = new HashSet<String>();
- for (Class<?> clazz = type.getSuperclass(); clazz != Object.class; clazz = clazz.getSuperclass())
- {
- dependencies.add(clazz.getName());
- }
- }
-
- /**
* Initializes the injection points
*/
- protected void initInjectableFields()
+ protected Set<FieldInjectionPoint<?, ?>> initInjectableFields()
{
- injectableFields = new HashSet<FieldInjectionPoint<?, ?>>(Beans.getFieldInjectionPoints(this, annotatedItem));
+ Set<FieldInjectionPoint<?, ?>> injectableFields = new HashSet<FieldInjectionPoint<?, ?>>(Beans.getFieldInjectionPoints(this, annotatedItem));
addInjectionPoints(injectableFields);
+ return injectableFields;
}
/**
* Initializes the initializer methods
*/
- protected void initInitializerMethods()
+ protected Set<MethodInjectionPoint<?, ?>> initInitializerMethods()
{
- initializerMethods = Beans.getInitializerMethods(this, getAnnotatedItem());
+ Set<MethodInjectionPoint<?, ?>> initializerMethods = Beans.getInitializerMethods(this, getAnnotatedItem());
addInjectionPoints(Beans.getParameterInjectionPoints(this, initializerMethods));
+ return initializerMethods;
}
- @Override
- protected void initScopeType()
- {
- for (WBClass<?> clazz = getAnnotatedItem(); clazz != null; clazz = clazz.getWBSuperclass())
- {
- Set<Annotation> scopeTypes = new HashSet<Annotation>();
- scopeTypes.addAll(clazz.getDeclaredMetaAnnotations(Scope.class));
- scopeTypes.addAll(clazz.getDeclaredMetaAnnotations(NormalScope.class));
- if (scopeTypes.size() == 1)
- {
- if (getAnnotatedItem().isAnnotationPresent(scopeTypes.iterator().next().annotationType()))
- {
- this.scopeType = scopeTypes.iterator().next().annotationType();
- log.trace("Scope " + scopeType + " specified by annotation");
- }
- break;
- }
- else if (scopeTypes.size() > 1)
- {
- throw new DefinitionException("At most one scope may be specified on " + getAnnotatedItem());
- }
- }
-
- if (this.scopeType == null)
- {
- initScopeTypeFromStereotype();
- }
-
- if (this.scopeType == null)
- {
- this.scopeType = Dependent.class;
- log.trace("Using default @Dependent scope");
- }
- }
-
/**
* Validates the bean implementation
*/
protected void checkBeanImplementation() {}
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- super.preSpecialize(environment);
- if (getAnnotatedItem().getWBSuperclass() == null || getAnnotatedItem().getWBSuperclass().getJavaClass().equals(Object.class))
- {
- throw new DefinitionException("Specializing bean must extend another bean " + toString());
- }
- }
-
/**
* Gets the annotated item
*
@@ -391,22 +318,6 @@
}
/**
- * Initializes the post-construct method
- */
- protected void initPostConstruct()
- {
- this.postConstruct = Beans.getPostConstruct(getAnnotatedItem());
- }
-
- /**
- * Initializes the pre-destroy method
- */
- protected void initPreDestroy()
- {
- this.preDestroy = Beans.getPreDestroy(getAnnotatedItem());
- }
-
- /**
* Returns the post-construct method
*
* @return The post-construct method
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -25,18 +25,14 @@
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
-import java.util.HashSet;
import java.util.Set;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.NormalScope;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.IllegalProductException;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.Producer;
import javax.inject.Inject;
-import javax.inject.Scope;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.DefinitionException;
@@ -44,6 +40,7 @@
import org.jboss.webbeans.introspector.WBMember;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
@@ -67,13 +64,22 @@
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- public AbstractProducerBean(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ public AbstractProducerBean(AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, S> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(declaringBean, manager);
+ super(declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, false, proxyable, bindings);
}
@Override
- protected abstract WBMember<T, ?, S> getAnnotatedItem();
+ public abstract WBMember<T, ?, S> getAnnotatedItem();
@Override
// Overriden to provide the class of the bean that declares the producer method/field
@@ -82,47 +88,47 @@
return getDeclaringBean().getBeanClass();
}
- /**
- * Initializes the API types
- */
- @Override
- protected void initTypes()
- {
- if (getType().isArray() || getType().isPrimitive())
- {
- Set<Type> types = new HashSet<Type>();
- types = new HashSet<Type>();
- types.add(getType());
- types.add(Object.class);
- super.types = types;
- }
- else if (getType().isInterface())
- {
- Set<Type> types = new HashSet<Type>();
- types.add(Object.class);
- types.addAll(getAnnotatedItem().getTypeClosure());
- super.types = types;
- }
- else
- {
- super.initTypes();
- }
- }
+// /**
+// * Initializes the API types
+// */
+// @Override
+// protected void initTypes()
+// {
+// if (getType().isArray() || getType().isPrimitive())
+// {
+// Set<Type> types = new HashSet<Type>();
+// types = new HashSet<Type>();
+// types.add(getType());
+// types.add(Object.class);
+// super.types = types;
+// }
+// else if (getType().isInterface())
+// {
+// Set<Type> types = new HashSet<Type>();
+// types.add(Object.class);
+// types.addAll(getAnnotatedItem().getTypeClosure());
+// super.types = types;
+// }
+// else
+// {
+// super.initTypes();
+// }
+// }
- /**
- * Initializes the type
- */
- protected void initType()
- {
- try
- {
- this.type = getAnnotatedItem().getJavaClass();
- }
- catch (ClassCastException e)
- {
- throw new RuntimeException(" Cannot cast producer type " + getAnnotatedItem().getJavaClass() + " to bean type " + (getDeclaredBeanType() == null ? " unknown " : getDeclaredBeanType()), e);
- }
- }
+// /**
+// * Initializes the type
+// */
+// protected void initType()
+// {
+// try
+// {
+// this.type = getAnnotatedItem().getJavaClass();
+// }
+// catch (ClassCastException e)
+// {
+// throw new RuntimeException(" Cannot cast producer type " + getAnnotatedItem().getJavaClass() + " to bean type " + (getDeclaredBeanType() == null ? " unknown " : getDeclaredBeanType()), e);
+// }
+// }
/**
* Gets the declared bean type
@@ -228,39 +234,39 @@
}
}
- @Override
- protected void initScopeType()
- {
- Set<Annotation> scopeAnnotations = new HashSet<Annotation>();
- scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(Scope.class));
- scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(NormalScope.class));
- if (scopeAnnotations.size() > 1)
- {
- throw new DefinitionException("At most one scope may be specified");
- }
- if (scopeAnnotations.size() == 1)
- {
- this.scopeType = scopeAnnotations.iterator().next().annotationType();
- log.trace("Scope " + scopeType + " specified by annotation");
- return;
- }
+// @Override
+// protected void initScopeType()
+// {
+// Set<Annotation> scopeAnnotations = new HashSet<Annotation>();
+// scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(Scope.class));
+// scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(NormalScope.class));
+// if (scopeAnnotations.size() > 1)
+// {
+// throw new DefinitionException("At most one scope may be specified");
+// }
+// if (scopeAnnotations.size() == 1)
+// {
+// this.scopeType = scopeAnnotations.iterator().next().annotationType();
+// log.trace("Scope " + scopeType + " specified by annotation");
+// return;
+// }
+//
+// initScopeTypeFromStereotype();
+//
+// if (this.scopeType == null)
+// {
+// this.scopeType = Dependent.class;
+// log.trace("Using default @Dependent scope");
+// }
+// }
+//
+// @Override
+// protected void initSerializable()
+// {
+// // No-op
+// }
- initScopeTypeFromStereotype();
-
- if (this.scopeType == null)
- {
- this.scopeType = Dependent.class;
- log.trace("Using default @Dependent scope");
- }
- }
-
@Override
- protected void initSerializable()
- {
- // No-op
- }
-
- @Override
public boolean isSerializable()
{
return true;
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/AbstractReceiverBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -16,7 +16,10 @@
*/
package org.jboss.webbeans.bean;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Alternative;
@@ -26,6 +29,7 @@
import org.jboss.webbeans.context.WBCreationalContext;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
/**
* @author pmuir
@@ -36,12 +40,23 @@
private static final LogProvider log = Logging.getLogProvider(AbstractReceiverBean.class);
- private AbstractClassBean<?> declaringBean;
- private boolean policy;
+ private final AbstractClassBean<?> declaringBean;
+
- public AbstractReceiverBean(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+
+ public AbstractReceiverBean(AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, S> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean serializable,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(manager);
+ super(manager, name, type, types, mergedStereotypes, scopeType, policy, serializable, proxyable, bindings);
this.declaringBean = declaringBean;
}
@@ -90,31 +105,4 @@
{
return declaringBean;
}
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.bean.AbstractBean#isPolicy()
- */
- @Override
- public boolean isAlternative()
- {
- return policy;
- }
-
- @Override
- protected void initPolicy()
- {
- if (getDeclaringBean().isAlternative())
- {
- this.policy = true;
- }
- else if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
- {
- this.policy = true;
- }
- else if (getMergedStereotypes().isPolicy())
- {
- this.policy = true;
- }
- }
-
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DecoratorImpl.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -33,6 +33,8 @@
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.WBInjectionPoint;
import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
public class DecoratorImpl<T> extends ManagedBean<T> implements Decorator<T>
{
@@ -71,9 +73,21 @@
* @param manager the current manager
* @return a Bean
*/
- public static <T> DecoratorImpl<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ public static <T> DecoratorImpl<T> of(WBClass<T> clazz,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- return new DecoratorImpl<T>(clazz, manager);
+ return new DecoratorImpl<T>(clazz, manager, name, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ postConstruct, preDestroy, specializedBean);
}
private WBInjectionPoint<?, ?> delegateInjectionPoint;
@@ -82,9 +96,21 @@
private Set<Type> delegateTypes;
private Set<Type> decoratedTypes;
- protected DecoratorImpl(WBClass<T> type, BeanManagerImpl manager)
+ protected DecoratorImpl(WBClass<T> type,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- super(type, manager);
+ super(type, manager, name, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies, null, null,
+ postConstruct, preDestroy, specializedBean);
}
@Override
@@ -209,12 +235,6 @@
return delegateTypes;
}
- @Override
- protected void initDecorators()
- {
- // No-op, decorators can't have decorators
- }
-
/* (non-Javadoc)
* @see org.jboss.webbeans.bean.SimpleBean#toString()
*/
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethod.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -34,6 +34,8 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
+import org.jboss.webbeans.util.Reflections;
public class DisposalMethod<T> extends AbstractReceiverBean<T, Method>
{
@@ -41,16 +43,23 @@
protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
private final String id;
- protected DisposalMethod(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ protected DisposalMethod(BeanManagerImpl manager,
+ String name,
+ WBMethod<T, ?> disposalMethod,
+ AbstractClassBean<?> declaringBean,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Method> mergedStereotypes,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(declaringBean, manager);
+ super(declaringBean, manager, name, type, types, mergedStereotypes, null, policy, Reflections.isSerializable(type), proxyable, bindings);
this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
- initBindings();
- initType();
- initTypes();
- initStereotypes();
- initPolicy();
+// initBindings();
+// initType();
+// initTypes();
}
@Override
@@ -61,46 +70,28 @@
checkDisposalMethod();
}
- @SuppressWarnings("unchecked")
- protected void initType()
- {
- this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getJavaClass();
- }
-
@Override
public WBMethod<T, ?> getAnnotatedItem()
{
return disposalMethodInjectionPoint;
}
- public static <T> DisposalMethod<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ public static <T> DisposalMethod<T> of(BeanManagerImpl manager,
+ String name,
+ WBMethod<T, ?> disposalMethod,
+ AbstractClassBean<?> declaringBean,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Method> mergedStereotypes,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- return new DisposalMethod<T>(manager, disposalMethod, declaringBean);
+ return new DisposalMethod<T>(manager, name, disposalMethod, declaringBean, type, types, mergedStereotypes, policy, proxyable, bindings);
}
- @Override
- protected void initBindings()
- {
- // At least 1 parameter exists, already checked in constructor
- this.bindings = new HashSet<Annotation>();
- this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
- initDefaultBindings();
- }
- /**
- * Initializes the API types
- */
@Override
- protected void initTypes()
- {
- Set<Type> types = new HashSet<Type>();
- types = new HashSet<Type>();
- types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
- types.add(Object.class);
- super.types = types;
- }
-
- @Override
public String getName()
{
return null;
@@ -244,11 +235,11 @@
return null;
}
- @Override
- protected void initScopeType()
- {
- // Disposal methods aren't scoped
- }
+// @Override
+// protected void initScopeType()
+// {
+// // Disposal methods aren't scoped
+// }
public Set<Class<? extends Annotation>> getStereotypes()
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ManagedBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -16,6 +16,8 @@
*/
package org.jboss.webbeans.bean;
+import java.lang.annotation.Annotation;
+import java.util.List;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -36,6 +38,7 @@
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Names;
@@ -54,13 +57,13 @@
private static LogProvider log = Logging.getLogProvider(ManagedBean.class);
// The constructor
- private ConstructorInjectionPoint<T> constructor;
- private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
- private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
+ private final ConstructorInjectionPoint<T> constructor;
+ private final Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private final Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
- private ManagedBean<?> specializedBean;
+ private final ManagedBean<?> specializedBean;
@@ -72,9 +75,23 @@
* @param manager the current manager
* @return A Web Bean
*/
- public static <T> ManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ public static <T> ManagedBean<T> of(WBClass<T> clazz,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- return new ManagedBean<T>(clazz, manager);
+ return new ManagedBean<T>(clazz, manager, name, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, specializedBean);
}
/**
@@ -83,12 +100,33 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected ManagedBean(WBClass<T> type, BeanManagerImpl manager)
+ protected ManagedBean(WBClass<T> type,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- super(type, manager);
- initType();
- initTypes();
- initBindings();
+ super(type, manager, name, type.getTypeClosure(), mergedStereotypes, scopeType, policy, Reflections.isSerializable(type.getJavaClass()), proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy);
+ this.specializedBean = specializedBean;
+ this.constructor = initConstructor();
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+
+ checkConstructor();
+
+
}
/**
@@ -182,22 +220,12 @@
{
if (!isInitialized())
{
- initConstructor();
- checkConstructor();
super.initialize(environment);
- initPostConstruct();
- initPreDestroy();
- initEEInjectionPoints();
+// initPostConstruct();
+// initPreDestroy();
}
}
- private void initEEInjectionPoints()
- {
- this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
- this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
- this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
- }
/**
* Validates the type
@@ -273,43 +301,15 @@
}
}
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- super.preSpecialize(environment);
- if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
- {
- throw new DefinitionException("Simple bean must specialize a simple bean");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
- {
- throw new DefinitionException(toString() + " does not specialize a bean");
- }
- AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
- if (!(specializedBean instanceof ManagedBean))
- {
- throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
- }
- else
- {
- this.specializedBean = (ManagedBean<?>) specializedBean;
- }
- }
-
-
/**
* Initializes the constructor
*/
- protected void initConstructor()
+ protected ConstructorInjectionPoint<T> initConstructor()
{
- this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
+ ConstructorInjectionPoint<T> ctor = Beans.getBeanConstructor(this, getAnnotatedItem());
// TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
- addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
+ addInjectionPoints(Beans.getParameterInjectionPoints(this, ctor));
+ return ctor;
}
/**
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewManagedBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -18,13 +18,17 @@
import java.lang.annotation.Annotation;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
/**
* Represents a @New simple bean
@@ -41,9 +45,23 @@
* @param manager The Web Beans manager
* @return a new NewSimpleBean instance
*/
- public static <T> NewManagedBean<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ public static <T> NewManagedBean<T> of(WBClass<T> clazz,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- return new NewManagedBean<T>(clazz, manager);
+ return new NewManagedBean<T>(clazz, manager, name, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, specializedBean);
}
private Set<Annotation> bindings;
@@ -54,9 +72,23 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewManagedBean(final WBClass<T> type, BeanManagerImpl manager)
+ protected NewManagedBean(final WBClass<T> type,
+ BeanManagerImpl manager,
+ String name,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ ManagedBean<?> specializedBean)
{
- super(type, manager);
+ super(type, manager, name, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, specializedBean);
this.bindings = new HashSet<Annotation>();
this.bindings.add(new NewLiteral()
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/NewSessionBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -17,15 +17,20 @@
package org.jboss.webbeans.bean;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.Decorator;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.resources.ClassTransformer;
/**
@@ -43,10 +48,26 @@
* @param manager The Web Beans manager
* @return a new NewEnterpriseBean instance
*/
- public static <T> NewSessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ public static <T> NewSessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor,
+ BeanManagerImpl manager,
+ String name,
+ Set<Type> types,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ Class<T> proxyClass,
+ SessionBean<?> specializedBean)
{
WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new NewSessionBean<T>(type, ejbDescriptor, manager);
+ return new NewSessionBean<T>(type, ejbDescriptor, manager, name, types, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, proxyClass, specializedBean);
}
private Set<Annotation> bindings;
@@ -57,9 +78,26 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewSessionBean(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ protected NewSessionBean(final WBClass<T> type,
+ InternalEjbDescriptor<T> ejbDescriptor,
+ BeanManagerImpl manager,
+ String name,
+ Set<Type> types,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ Class<T> proxyClass,
+ SessionBean<?> specializedBean)
{
- super(type, ejbDescriptor, manager);
+ super(type, ejbDescriptor, manager, name, types, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, proxyClass, specializedBean);
this.bindings = new HashSet<Annotation>();
this.bindings.add(new NewLiteral()
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerField.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -18,6 +18,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
+import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Set;
@@ -26,6 +27,7 @@
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.util.Names;
/**
@@ -38,7 +40,7 @@
public class ProducerField<T> extends AbstractProducerBean<T, Field>
{
// The underlying field
- private WBField<T, ?> field;
+ private final WBField<T, ?> field;
private final String id;
/**
@@ -49,9 +51,19 @@
* @param manager the current manager
* @return A producer field
*/
- public static <T> ProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ public static <T> ProducerField<T> of(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- return new ProducerField<T>(field, declaringBean, manager);
+ return new ProducerField<T>(field, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
}
/**
@@ -61,16 +73,26 @@
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- protected ProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ protected ProducerField(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(declaringBean, manager);
+ super(declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
this.field = field;
- initType();
- initTypes();
- initBindings();
+// initType();
+// initTypes();
+// initBindings();
this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
- initStereotypes();
- initPolicy();
+// initStereotypes();
+// initPolicy();
}
@Override
@@ -104,7 +126,7 @@
* @return The annotated item
*/
@Override
- protected WBField<T, ?> getAnnotatedItem()
+ public WBField<T, ?> getAnnotatedItem()
{
return field;
}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethod.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -34,6 +34,7 @@
import org.jboss.webbeans.injection.ParameterInjectionPoint;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.util.Names;
/**
@@ -48,9 +49,9 @@
// The underlying method
private MethodInjectionPoint<T, ?> method;
- private DisposalMethod<?> disposalMethodBean;
+ private final DisposalMethod<?> disposalMethodBean;
- private ProducerMethod<?> specializedBean;
+ private final ProducerMethod<?> specializedBean;
private final String id;
@@ -62,21 +63,42 @@
* @param manager the current manager
* @return A producer Web Bean
*/
- public static <T> ProducerMethod<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ public static <T> ProducerMethod<T> of(WBMethod<T, ?> method,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Method> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ DisposalMethod<?> disposalMethodBean,
+ final ProducerMethod<?> specializedBean)
{
- return new ProducerMethod<T>(method, declaringBean, manager);
+ return new ProducerMethod<T>(method, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings, disposalMethodBean, specializedBean);
}
- protected ProducerMethod(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ protected ProducerMethod(WBMethod<T, ?> method,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Method> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ DisposalMethod<?> disposalMethodBean,
+ final ProducerMethod<?> specializedBean)
{
- super(declaringBean, manager);
+ super(declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
this.method = MethodInjectionPoint.of(this, method);
- initType();
- initTypes();
- initBindings();
+ this.disposalMethodBean = disposalMethodBean;
+ this.specializedBean = specializedBean;
this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
- initStereotypes();
- initPolicy();
}
public T produce(CreationalContext<T> creationalContext)
@@ -103,7 +125,6 @@
initProducerMethodInjectableParameters();
super.initialize(environment);
checkProducerMethod();
- initDisposalMethod(environment);
}
}
@@ -158,24 +179,6 @@
}
}
- /**
- * Initializes the remove method
- */
- protected void initDisposalMethod(BeanDeployerEnvironment environment)
- {
- Set<DisposalMethod<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
-
- if (disposalBeans.size() == 1)
- {
- this.disposalMethodBean = disposalBeans.iterator().next();
- }
- else if (disposalBeans.size() > 1)
- {
- // TODO List out found disposal methods
- throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
- }
- }
-
public void destroy(T instance, CreationalContext<T> creationalContext)
{
try
@@ -260,26 +263,6 @@
}
@Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
- {
- throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
- if (environment.getProducerMethod(superClassMethod) == null)
- {
- throw new IllegalStateException(toString() + " does not specialize a bean");
- }
- this.specializedBean = environment.getProducerMethod(superClassMethod);
- }
-
- @Override
public String getId()
{
return id;
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -36,7 +36,6 @@
*/
public abstract class RIBean<T> implements Bean<T>
{
-
private static final ConcurrentMap<String, AtomicInteger> ids = new ConcurrentHashMap<String, AtomicInteger>();
private final BeanManagerImpl manager;
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/SessionBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -16,17 +16,14 @@
*/
package org.jboss.webbeans.bean;
-import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Set;
-import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
import javax.decorator.Decorator;
@@ -44,16 +41,15 @@
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.api.SessionObjectReference;
-import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.ejb.spi.EjbServices;
import org.jboss.webbeans.injection.InjectionContextImpl;
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBMethod;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Proxies;
/**
* An enterprise bean representation
@@ -67,11 +63,11 @@
private final Log log = Logging.getLog(SessionBean.class);
// The EJB descriptor
- private InternalEjbDescriptor<T> ejbDescriptor;
+ private final InternalEjbDescriptor<T> ejbDescriptor;
- private Class<T> proxyClass;
+ private final Class<T> proxyClass;
- private SessionBean<?> specializedBean;
+ private final SessionBean<?> specializedBean;
/**
* Creates a simple, annotation defined Enterprise Web Bean
@@ -81,10 +77,26 @@
* @param manager the current manager
* @return An Enterprise Web Bean
*/
- public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor,
+ BeanManagerImpl manager,
+ String name,
+ Set<Type> types,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<javax.enterprise.inject.spi.Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ Class<T> proxyClass,
+ SessionBean<?> specializedBean)
{
WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new SessionBean<T>(type, ejbDescriptor, manager);
+ return new SessionBean<T>(type, ejbDescriptor, manager, name, types, mergedStereotypes, scopeType, policy, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy, proxyClass, specializedBean);
}
/**
@@ -93,13 +105,29 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected SessionBean(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ protected SessionBean(WBClass<T> type,
+ InternalEjbDescriptor<T> ejbDescriptor,
+ BeanManagerImpl manager,
+ String name,
+ Set<Type> types,
+ MergedStereotypes<T, Class<T>> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings,
+ Set<String> dependencies,
+ Class<T> proxyClassForDecorators,
+ List<javax.enterprise.inject.spi.Decorator<?>> decorators,
+ WBMethod<?, ?> postConstruct,
+ WBMethod<?, ?> preDestroy,
+ Class<T> proxyClass,
+ SessionBean<?> specializedBean)
{
- super(type, manager);
- initType();
+ super(type, manager, name, types, mergedStereotypes, scopeType, policy, false, proxyable, bindings, dependencies,
+ proxyClassForDecorators, decorators, postConstruct, preDestroy);
this.ejbDescriptor = ejbDescriptor;
- initTypes();
- initBindings();
+ this.proxyClass = proxyClass;
+ this.specializedBean = specializedBean;
}
/**
@@ -111,7 +139,7 @@
if (!isInitialized())
{
super.initialize(environment);
- initProxyClass();
+// initProxyClass();
checkEJBTypeAllowed();
checkConflictingRoles();
checkObserverMethods();
@@ -119,32 +147,19 @@
}
}
- @Override
- protected void initTypes()
- {
- Set<Type> types = new HashSet<Type>();
- types = new LinkedHashSet<Type>();
- types.add(Object.class);
- for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
- {
- types.add(businessInterfaceDescriptor.getInterface());
- }
- super.types = types;
- }
+// protected void initProxyClass()
+// {
+// Set<Type> types = new LinkedHashSet<Type>(getTypes());
+// types.add(EnterpriseBeanInstance.class);
+// types.add(Serializable.class);
+// ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+//
+// @SuppressWarnings("unchecked")
+// Class<T> proxyClass = proxyFactory.createClass();
+//
+// this.proxyClass = proxyClass;
+// }
- protected void initProxyClass()
- {
- Set<Type> types = new LinkedHashSet<Type>(getTypes());
- types.add(EnterpriseBeanInstance.class);
- types.add(Serializable.class);
- ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
-
- @SuppressWarnings("unchecked")
- Class<T> proxyClass = proxyFactory.createClass();
-
- this.proxyClass = proxyClass;
- }
-
/**
* Validates for non-conflicting roles
*/
@@ -177,38 +192,6 @@
}
/**
- * Validates specialization
- */
- @Override
- protected void preSpecialize(BeanDeployerEnvironment environment)
- {
- super.preSpecialize(environment);
- // We appear to check this twice?
- if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
- {
- throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
- }
- }
-
- @Override
- protected void specialize(BeanDeployerEnvironment environment)
- {
- if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
- {
- throw new IllegalStateException(toString() + " does not specialize a bean");
- }
- AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
- if (!(specializedBean instanceof SessionBean<?>))
- {
- throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
- }
- else
- {
- this.specializedBean = (SessionBean<?>) specializedBean;
- }
- }
-
- /**
* Creates an instance of the bean
*
* @return The instance
@@ -324,12 +307,6 @@
}
@Override
- protected void initSerializable()
- {
- // No-op
- }
-
- @Override
public boolean isSerializable()
{
return true;
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,512 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.decorator.Decorates;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Specializes;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.stereotype.Stereotype;
+import javax.inject.Named;
+import javax.inject.Qualifier;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBAnnotated;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.literal.AnyLiteral;
+import org.jboss.webbeans.literal.DefaultLiteral;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * An abstract bean representation common for all beans
+ *
+ * @author Pete Muir
+ *
+ * @param <T> the type of bean
+ * @param <E> the Class<?> of the bean type
+ */
+abstract class AbstractBeanBuilder<T, E> extends RIBeanBuilder<T>
+{
+
+ private static final Annotation ANY_LITERAL = new AnyLiteral();
+ private static final Annotation CURRENT_LITERAL = new DefaultLiteral();
+
+ private boolean proxyable;
+
+ // Logger
+ private final Log log = Logging.getLog(AbstractBeanBuilder.class);
+ // The binding types
+ protected Set<Annotation> bindings;
+ // The name
+ protected String name;
+ // The scope type
+ protected Class<? extends Annotation> scopeType;
+ // The merged stereotypes
+ private MergedStereotypes<T, E> mergedStereotypes;
+ // Is it a policy, either defined by stereotypes or directly?
+ private boolean policy;
+ // The type
+ protected Class<T> type;
+ // The API types
+ protected Set<Type> types;
+ // The injection points
+ private Set<WBInjectionPoint<?, ?>> injectionPoints;
+ private Set<WBInjectionPoint<?, ?>> delegateInjectionPoints;
+ // If the type a primitive?
+ private boolean primitive;
+ // The Web Beans manager
+ protected BeanManagerImpl manager;
+
+ private boolean _serializable;
+
+ private boolean initialized;
+
+
+
+ protected boolean isInitialized()
+ {
+ return initialized;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ */
+ public AbstractBeanBuilder(BeanManagerImpl manager)
+ {
+ super(manager);
+ this.manager = manager;
+ this.injectionPoints = new HashSet<WBInjectionPoint<?, ?>>();
+ this.delegateInjectionPoints = new HashSet<WBInjectionPoint<?,?>>();
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (isSpecializing())
+ {
+ preSpecialize(environment);
+ specialize(environment);
+ postSpecialize();
+ }
+ initDefaultBindings();
+ initPrimitive();
+ log.trace("Building Web Bean bean metadata for #0", getType());
+ initName();
+ initScopeType();
+ initSerializable();
+ initProxyable();
+ checkDelegateInjectionPoints();
+ }
+
+ protected void initStereotypes()
+ {
+ mergedStereotypes = new MergedStereotypes<T, E>(getAnnotatedItem().getMetaAnnotations(Stereotype.class), manager);
+ }
+
+ protected void checkDelegateInjectionPoints()
+ {
+ if (this.delegateInjectionPoints.size() > 0)
+ {
+ throw new DefinitionException("Cannot place @Decorates at an injection point which is not on a Decorator " + this);
+ }
+ }
+
+ protected void addInjectionPoint(WBInjectionPoint<?, ?> injectionPoint)
+ {
+ if (injectionPoint.isAnnotationPresent(Decorates.class))
+ {
+ this.delegateInjectionPoints.add(injectionPoint);
+ }
+ injectionPoints.add(injectionPoint);
+ }
+
+ protected void addInjectionPoints(Iterable<? extends WBInjectionPoint<?, ?>> injectionPoints)
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : injectionPoints)
+ {
+ addInjectionPoint(injectionPoint);
+ }
+ }
+
+ protected Set<WBInjectionPoint<?, ?>> getDelegateInjectionPoints()
+ {
+ return delegateInjectionPoints;
+ }
+
+ /**
+ * Initializes the API types
+ */
+ protected void initTypes()
+ {
+ types = getAnnotatedItem().getTypeClosure();
+ }
+
+ /**
+ * Initializes the binding types
+ */
+ protected void initBindings()
+ {
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.addAll(getAnnotatedItem().getMetaAnnotations(Qualifier.class));
+ initDefaultBindings();
+ log.trace("Using binding types " + bindings + " specified by annotations");
+ }
+
+ protected void initDefaultBindings()
+ {
+ if (bindings.size() == 0)
+ {
+ log.trace("Adding default @Current binding type");
+ this.bindings.add(CURRENT_LITERAL);
+ }
+ this.bindings.add(ANY_LITERAL);
+ }
+
+ protected void initPolicy()
+ {
+ if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
+ {
+ this.policy = true;
+ }
+ else
+ {
+ this.policy = getMergedStereotypes().isPolicy();
+ }
+ }
+
+ /**
+ * Initializes the name
+ */
+ protected void initName()
+ {
+ boolean beanNameDefaulted = false;
+ if (getAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ String javaName = getAnnotatedItem().getAnnotation(Named.class).value();
+ if ("".equals(javaName))
+ {
+ log.trace("Using default name (specified by annotations)");
+ beanNameDefaulted = true;
+ }
+ else
+ {
+ if (log.isTraceEnabled())
+ log.trace("Using name " + javaName + " specified by annotations");
+ this.name = javaName;
+ return;
+ }
+ }
+
+ if (beanNameDefaulted || getMergedStereotypes().isBeanNameDefaulted())
+ {
+ this.name = getDefaultName();
+ return;
+ }
+ }
+
+ protected void initProxyable()
+ {
+ proxyable = getAnnotatedItem().isProxyable();
+ }
+
+ /**
+ * Initializes the primitive flag
+ */
+ protected void initPrimitive()
+ {
+ this.primitive = Reflections.isPrimitive(getType());
+ }
+
+ private boolean checkInjectionPointsAreSerializable()
+ {
+ boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(this.getScope()).isPassivating();
+ for (WBInjectionPoint<?, ?> injectionPoint : getAnnotatedInjectionPoints())
+ {
+ Annotation[] bindings = injectionPoint.getMetaAnnotationsAsArray(Qualifier.class);
+ Bean<?> resolvedBean = manager.getBeans(injectionPoint.getJavaClass(), bindings).iterator().next();
+ if (passivating)
+ {
+ if (Dependent.class.equals(resolvedBean.getScope()) && !Reflections.isSerializable(resolvedBean.getBeanClass()) && (((injectionPoint instanceof WBField<?, ?>) && !((WBField<?, ?>) injectionPoint).isTransient()) || (injectionPoint instanceof WBParameter<?, ?>)))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Initializes the scope type
+ */
+ protected abstract void initScopeType();
+
+ protected boolean initScopeTypeFromStereotype()
+ {
+ Set<Annotation> possibleScopeTypes = getMergedStereotypes().getPossibleScopeTypes();
+ if (possibleScopeTypes.size() == 1)
+ {
+ this.scopeType = possibleScopeTypes.iterator().next().annotationType();
+ if (log.isTraceEnabled())
+ log.trace("Scope " + scopeType + " specified by stereotype");
+ return true;
+ }
+ else if (possibleScopeTypes.size() > 1)
+ {
+ throw new DefinitionException("All stereotypes must specify the same scope OR a scope must be specified on " + getAnnotatedItem());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ protected void postSpecialize()
+ {
+ if (getAnnotatedItem().isAnnotationPresent(Named.class) && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ throw new DefinitionException("Cannot put name on specializing and specialized class " + getAnnotatedItem());
+ }
+ this.bindings.addAll(getSpecializedBean().getQualifiers());
+ if (isSpecializing() && getSpecializedBean().getAnnotatedItem().isAnnotationPresent(Named.class))
+ {
+ this.name = getSpecializedBean().getName();
+ }
+
+ throw new RuntimeException("Next line commented");
+// manager.getSpecializedBeans().put(getSpecializedBean(), this);
+ }
+
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+
+ }
+
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+
+ }
+
+ /**
+ * Returns the annotated time the bean represents
+ *
+ * @return The annotated item
+ */
+ protected abstract WBAnnotated<T, E> getAnnotatedItem();
+
+ /**
+ * Gets the binding types
+ *
+ * @return The set of binding types
+ *
+ * @see org.jboss.webbeans.bean.BaseBean#getQualifiers()
+ */
+ public Set<Annotation> getQualifiers()
+ {
+ return bindings;
+ }
+
+ /**
+ * Gets the default name of the bean
+ *
+ * @return The default name
+ */
+ protected abstract String getDefaultName();
+
+ @Override
+ public abstract AbstractBean<?, ?> getSpecializedBean();
+
+ @Override
+ public Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints()
+ {
+ return injectionPoints;
+ }
+
+ /**
+ * Gets the merged stereotypes of the bean
+ *
+ * @return The set of merged stereotypes
+ */
+ protected MergedStereotypes<T, E> getMergedStereotypes()
+ {
+ return mergedStereotypes;
+ }
+
+ /**
+ * Gets the name of the bean
+ *
+ * @return The name
+ *
+ * @see org.jboss.webbeans.bean.BaseBean#getName()
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * Gets the scope type of the bean
+ *
+ * @return The scope type
+ *
+ * @see org.jboss.webbeans.bean.BaseBean#getScope()
+ */
+ public Class<? extends Annotation> getScope()
+ {
+ return scopeType;
+ }
+
+ /**
+ * Gets the type of the bean
+ *
+ * @return The type
+ */
+ @Override
+ public Class<T> getType()
+ {
+ return type;
+ }
+
+ /**
+ * Gets the API types of the bean
+ *
+ * @return The set of API types
+ *
+ * @see org.jboss.webbeans.bean.BaseBean#getTypeClosure()
+ */
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+ /**
+ * Checks if this beans annotated item is assignable from another annotated
+ * item
+ *
+ * @param annotatedItem The other annotation to check
+ * @return True if assignable, otherwise false
+ */
+ public boolean isAssignableFrom(WBAnnotated<?, ?> annotatedItem)
+ {
+ return this.getAnnotatedItem().isAssignableFrom(annotatedItem);
+ }
+
+ /**
+ * Indicates if bean is nullable
+ *
+ * @return True if nullable, false otherwise
+ *
+ * @see org.jboss.webbeans.bean.BaseBean#isNullable()
+ */
+ public boolean isNullable()
+ {
+ return !isPrimitive();
+ }
+
+ /**
+ * Indicates if bean type is a primitive
+ *
+ * @return True if primitive, false otherwise
+ */
+ @Override
+ public boolean isPrimitive()
+ {
+ return primitive;
+ }
+
+ public boolean isSerializable()
+ {
+ // TODO WTF - why are we not caching the serializability of injection
+ // points!
+ return _serializable && checkInjectionPointsAreSerializable();
+ }
+
+ protected void initSerializable()
+ {
+ _serializable = Reflections.isSerializable(type);
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "AbstractBean " + getName();
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ return proxyable;
+ }
+
+ public boolean isAlternative()
+ {
+ return policy;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return getAnnotatedItem().isAnnotationPresent(Specializes.class);
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return mergedStereotypes.getStereotypes();
+ }
+
+ @Override
+ public String getId()
+ {
+ return null;
+ }
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ throw new IllegalStateException("Should not call create() on builder " + this);
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ throw new IllegalStateException("Should not call destroy() on builder " + this);
+ }
+
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractClassBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,408 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import javassist.util.proxy.ProxyFactory;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.NormalScope;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Scope;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.FieldInjectionPoint;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
+import org.jboss.webbeans.util.Strings;
+
+/**
+ * An abstract bean representation common for class-based beans
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ * @param <E>
+ */
+abstract class AbstractClassBeanBuilder<T> extends AbstractBeanBuilder<T, Class<T>>
+{
+ // Logger
+ private static final LogProvider log = Logging.getLogProvider(AbstractClassBeanBuilder.class);
+ // The item representation
+ protected WBClass<T> annotatedItem;
+ // The injectable fields
+ private Set<FieldInjectionPoint<?, ?>> injectableFields;
+ // The initializer methods
+ private Set<MethodInjectionPoint<?, ?>> initializerMethods;
+ private Set<String> dependencies;
+
+ private List<Decorator<?>> decorators;
+
+ private final String id;
+ private Class<T> proxyClassForDecorators;
+
+ private final ThreadLocal<Integer> decoratorStackPosition;
+ private WBMethod<?, ?> postConstruct;
+ private WBMethod<?, ?> preDestroy;
+
+ /**
+ * Constructor
+ *
+ * @param type The type
+ * @param manager The Web Beans manager
+ */
+ protected AbstractClassBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(manager);
+ this.annotatedItem = type;
+ this.id = createId(getClass().getSimpleName() + "-" + type.getName());
+ this.decoratorStackPosition = new ThreadLocal<Integer>()
+ {
+
+ @Override
+ protected Integer initialValue()
+ {
+ return 0;
+ }
+
+ };
+ initStereotypes();
+ initPolicy();
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ initInitializerMethods();
+ initInjectableFields();
+ super.initialize(environment);
+ checkBeanImplementation();
+ initDecorators();
+ checkType();
+ initProxyClassForDecoratedBean();
+ }
+
+ protected void checkType()
+ {
+
+ }
+
+ protected void initDecorators()
+ {
+ this.decorators = getManager().resolveDecorators(getTypes(), getQualifiers());
+ }
+
+ public boolean hasDecorators()
+ {
+ return this.decorators != null && this.decorators.size() > 0;
+ }
+
+ protected void initProxyClassForDecoratedBean()
+ {
+ if (hasDecorators())
+ {
+ Set<Type> types = new LinkedHashSet<Type>(getTypes());
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClassForDecorators = proxyClass;
+ }
+ }
+
+ protected T applyDecorators(T instance, CreationalContext<T> creationalContext, InjectionPoint originalInjectionPoint)
+ {
+ throw new RuntimeException("NYI");
+// List<SerializableBeanInstance<DecoratorImpl<Object>, Object>> decoratorInstances = new ArrayList<SerializableBeanInstance<DecoratorImpl<Object>,Object>>();
+// InjectionPoint ip = originalInjectionPoint;
+// boolean outside = decoratorStackPosition.get().intValue() == 0;
+// try
+// {
+// int i = decoratorStackPosition.get();
+// while (i < decorators.size())
+// {
+// Decorator<?> decorator = decorators.get(i);
+// if (decorator instanceof DecoratorImpl<?>)
+// {
+// decoratorStackPosition.set(++i);
+//
+// @SuppressWarnings("unchecked")
+// DecoratorImpl<Object> decoratorBean = (DecoratorImpl<Object>) decorator;
+//
+// Object decoratorInstance = getManager().getReference(ip, decorator, creationalContext);
+// decoratorInstances.add(new SerializableBeanInstance<DecoratorImpl<Object>, Object>(decoratorBean, decoratorInstance));
+// ip = decoratorBean.getDelegateInjectionPoint();
+// }
+// else
+// {
+// throw new IllegalStateException("Cannot operate on non container provided decorator " + decorator);
+// }
+// }
+// }
+// finally
+// {
+// if (outside)
+// {
+// decoratorStackPosition.remove();
+// }
+// }
+// try
+// {
+// T proxy = proxyClassForDecorators.newInstance();
+// ((ProxyObject) proxy).setHandler(new DecoratorProxyMethodHandler(decoratorInstances, instance));
+// return proxy;
+// }
+// catch (InstantiationException e)
+// {
+// throw new RuntimeException("Could not instantiate decorator proxy for " + toString(), e);
+// }
+// catch (IllegalAccessException e)
+// {
+// throw new RuntimeException("Could not access bean correctly when creating decorator proxy for " + toString(), e);
+// }
+ }
+
+ public List<Decorator<?>> getDecorators()
+ {
+ return Collections.unmodifiableList(decorators);
+ }
+
+ public Class<T> getProxyClassForDecorators()
+ {
+ return proxyClassForDecorators;
+ }
+
+ public void setProxyClassForDecorators(Class<T> proxyClassForDecorators)
+ {
+ this.proxyClassForDecorators = proxyClassForDecorators;
+ }
+
+ public void dispose(T instance)
+ {
+ // No-op for class beans
+ }
+
+
+ /**
+ * Initializes the bean type
+ */
+ protected void initType()
+ {
+ log.trace("Bean type specified in Java");
+ this.type = getAnnotatedItem().getJavaClass();
+ this.dependencies = new HashSet<String>();
+ for (Class<?> clazz = type.getSuperclass(); clazz != Object.class; clazz = clazz.getSuperclass())
+ {
+ dependencies.add(clazz.getName());
+ }
+ }
+
+ /**
+ * Initializes the injection points
+ */
+ protected void initInjectableFields()
+ {
+ injectableFields = new HashSet<FieldInjectionPoint<?, ?>>(Beans.getFieldInjectionPoints(this, annotatedItem));
+ addInjectionPoints(injectableFields);
+ }
+
+ /**
+ * Initializes the initializer methods
+ */
+ protected void initInitializerMethods()
+ {
+ initializerMethods = Beans.getInitializerMethods(this, getAnnotatedItem());
+ addInjectionPoints(Beans.getParameterInjectionPoints(this, initializerMethods));
+ }
+
+ @Override
+ protected void initScopeType()
+ {
+ for (WBClass<?> clazz = getAnnotatedItem(); clazz != null; clazz = clazz.getWBSuperclass())
+ {
+ Set<Annotation> scopeTypes = new HashSet<Annotation>();
+ scopeTypes.addAll(clazz.getDeclaredMetaAnnotations(Scope.class));
+ scopeTypes.addAll(clazz.getDeclaredMetaAnnotations(NormalScope.class));
+ if (scopeTypes.size() == 1)
+ {
+ if (getAnnotatedItem().isAnnotationPresent(scopeTypes.iterator().next().annotationType()))
+ {
+ this.scopeType = scopeTypes.iterator().next().annotationType();
+ log.trace("Scope " + scopeType + " specified by annotation");
+ }
+ break;
+ }
+ else if (scopeTypes.size() > 1)
+ {
+ throw new DefinitionException("At most one scope may be specified on " + getAnnotatedItem());
+ }
+ }
+
+ if (this.scopeType == null)
+ {
+ initScopeTypeFromStereotype();
+ }
+
+ if (this.scopeType == null)
+ {
+ this.scopeType = Dependent.class;
+ log.trace("Using default @Dependent scope");
+ }
+ }
+
+ /**
+ * Validates the bean implementation
+ */
+ protected void checkBeanImplementation() {}
+
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ super.preSpecialize(environment);
+ if (getAnnotatedItem().getWBSuperclass() == null || getAnnotatedItem().getWBSuperclass().getJavaClass().equals(Object.class))
+ {
+ throw new DefinitionException("Specializing bean must extend another bean " + toString());
+ }
+ }
+
+ /**
+ * Gets the annotated item
+ *
+ * @return The annotated item
+ */
+ @Override
+ public WBClass<T> getAnnotatedItem()
+ {
+ return annotatedItem;
+ }
+
+ /**
+ * Gets the default name
+ *
+ * @return The default name
+ */
+ @Override
+ protected String getDefaultName()
+ {
+ String name = Strings.decapitalize(getAnnotatedItem().getSimpleName());
+ log.trace("Default name of " + type + " is " + name);
+ return name;
+ }
+
+ /**
+ * Gets the annotated methods
+ *
+ * @return The set of annotated methods
+ */
+ public Set<? extends MethodInjectionPoint<?, ?>> getInitializerMethods()
+ {
+ return Collections.unmodifiableSet(initializerMethods);
+ }
+
+ /**
+ * @return the injectableFields
+ */
+ public Set<FieldInjectionPoint<?, ?>> getInjectableFields()
+ {
+ return Collections.unmodifiableSet(injectableFields);
+ }
+
+ // TODO maybe a better way to expose this?
+ public Set<String> getSuperclasses()
+ {
+ return dependencies;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "AbstractClassBean " + getName();
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ /**
+ * Initializes the post-construct method
+ */
+ protected void initPostConstruct()
+ {
+ this.postConstruct = Beans.getPostConstruct(getAnnotatedItem());
+ }
+
+ /**
+ * Initializes the pre-destroy method
+ */
+ protected void initPreDestroy()
+ {
+ this.preDestroy = Beans.getPreDestroy(getAnnotatedItem());
+ }
+
+ /**
+ * Returns the post-construct method
+ *
+ * @return The post-construct method
+ */
+ public WBMethod<?, ?> getPostConstruct()
+ {
+ return postConstruct;
+ }
+
+ /**
+ * Returns the pre-destroy method
+ *
+ * @return The pre-destroy method
+ */
+ public WBMethod<?, ?> getPreDestroy()
+ {
+ return preDestroy;
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return null;
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractProducerBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.NormalScope;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.IllegalProductException;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.Producer;
+import javax.inject.Inject;
+import javax.inject.Scope;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.introspector.WBMember;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * The implicit producer bean
+ *
+ * @author Gavin King
+ *
+ * @param <T>
+ * @param <S>
+ */
+abstract class AbstractProducerBeanBuilder<T, S extends Member> extends AbstractReceiverBeanBuilder<T, S> implements Producer<T>
+{
+ private static final LogProvider log = Logging.getLogProvider(AbstractProducerBeanBuilder.class);
+
+ /**
+ * Constructor
+ *
+ * @param declaringBean The declaring bean
+ * @param manager The Web Beans manager
+ */
+ public AbstractProducerBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(declaringBean, manager);
+ }
+
+ @Override
+ public abstract WBMember<T, ?, S> getAnnotatedItem();
+
+ @Override
+ // Overriden to provide the class of the bean that declares the producer method/field
+ public Class<?> getBeanClass()
+ {
+ return getDeclaringBean().getBeanClass();
+ }
+
+ /**
+ * Initializes the API types
+ */
+ @Override
+ protected void initTypes()
+ {
+ if (getType().isArray() || getType().isPrimitive())
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new HashSet<Type>();
+ types.add(getType());
+ types.add(Object.class);
+ super.types = types;
+ }
+ else if (getType().isInterface())
+ {
+ Set<Type> types = new HashSet<Type>();
+ types.add(Object.class);
+ types.addAll(getAnnotatedItem().getTypeClosure());
+ super.types = types;
+ }
+ else
+ {
+ super.initTypes();
+ }
+ }
+
+ /**
+ * Initializes the type
+ */
+ protected void initType()
+ {
+ try
+ {
+ this.type = getAnnotatedItem().getJavaClass();
+ }
+ catch (ClassCastException e)
+ {
+ throw new RuntimeException(" Cannot cast producer type " + getAnnotatedItem().getJavaClass() + " to bean type " + (getDeclaredBeanType() == null ? " unknown " : getDeclaredBeanType()), e);
+ }
+ }
+
+ /**
+ * Gets the declared bean type
+ *
+ * @return The bean type
+ */
+ protected Type getDeclaredBeanType()
+ {
+ Type type = getClass();
+ if (type instanceof ParameterizedType)
+ {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ if (parameterizedType.getActualTypeArguments().length == 1)
+ {
+ return parameterizedType.getActualTypeArguments()[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Validates the producer method
+ */
+ protected void checkProducerReturnType()
+ {
+ if (getAnnotatedItem().getBaseType() instanceof TypeVariable<?>)
+ {
+ throw new DefinitionException("Return type must be concrete " + getAnnotatedItem().getBaseType());
+ }
+ if (getAnnotatedItem().getBaseType() instanceof WildcardType)
+ {
+ throw new DefinitionException("Return type must be concrete " + getAnnotatedItem().getBaseType());
+ }
+ for (Type type : getAnnotatedItem().getActualTypeArguments())
+ {
+ if (!(type instanceof Class))
+ {
+ throw new DefinitionException("Producer type cannot be parameterized with type parameter or wildcard:\n" + this.getAnnotatedItem());
+ }
+ }
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ getDeclaringBean().initialize(environment);
+ super.initialize(environment);
+ checkProducerReturnType();
+ }
+
+ /**
+ * Validates the return value
+ *
+ * @param instance The instance to validate
+ */
+ protected void checkReturnValue(T instance)
+ {
+ if (instance == null && !isDependent())
+ {
+ throw new IllegalProductException("Cannot return null from a non-dependent producer method");
+ }
+ else if (instance != null)
+ {
+ boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(getScope()).isPassivating();
+ if (passivating && !Reflections.isSerializable(instance.getClass()))
+ {
+ throw new IllegalProductException("Producers cannot declare passivating scope and return a non-serializable class");
+ }
+ InjectionPoint injectionPoint = manager.getCurrentInjectionPoint();
+ if (injectionPoint == null)
+ {
+ return;
+ }
+ if (!Reflections.isSerializable(instance.getClass()) && Beans.isPassivationCapableBean(injectionPoint.getBean()))
+ {
+ if (injectionPoint.getMember() instanceof Field)
+ {
+ if (!Reflections.isTransient(injectionPoint.getMember()) && instance != null && !Reflections.isSerializable(instance.getClass()))
+ {
+ throw new IllegalProductException("Producers cannot produce non-serializable instances for injection into non-transient fields of passivating beans\n\nProducer: " + this.toString() + "\nInjection Point: " + injectionPoint.toString());
+ }
+ }
+ else if (injectionPoint.getMember() instanceof Method)
+ {
+ Method method = (Method) injectionPoint.getMember();
+ if (method.isAnnotationPresent(Inject.class))
+ {
+ throw new IllegalProductException("Producers cannot produce non-serializable instances for injection into parameters of intializers of beans declaring passivating scope. Bean " + toString() + " being injected into " + injectionPoint.toString());
+ }
+ if (method.isAnnotationPresent(Produces.class))
+ {
+ throw new IllegalProductException("Producers cannot produce non-serializable instances for injection into parameters of producer methods declaring passivating scope. Bean " + toString() + " being injected into " + injectionPoint.toString());
+ }
+ }
+ else if (injectionPoint.getMember() instanceof Constructor)
+ {
+ throw new IllegalProductException("Producers cannot produce non-serializable instances for injection into parameters of constructors of beans declaring passivating scope. Bean " + toString() + " being injected into " + injectionPoint.toString());
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void initScopeType()
+ {
+ Set<Annotation> scopeAnnotations = new HashSet<Annotation>();
+ scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(Scope.class));
+ scopeAnnotations.addAll(getAnnotatedItem().getMetaAnnotations(NormalScope.class));
+ if (scopeAnnotations.size() > 1)
+ {
+ throw new DefinitionException("At most one scope may be specified");
+ }
+ if (scopeAnnotations.size() == 1)
+ {
+ this.scopeType = scopeAnnotations.iterator().next().annotationType();
+ log.trace("Scope " + scopeType + " specified by annotation");
+ return;
+ }
+
+ initScopeTypeFromStereotype();
+
+ if (this.scopeType == null)
+ {
+ this.scopeType = Dependent.class;
+ log.trace("Using default @Dependent scope");
+ }
+ }
+
+ @Override
+ protected void initSerializable()
+ {
+ // No-op
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed producer bean");
+ }
+ else
+ {
+ buffer.append("simple producer bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ public void dispose(T instance)
+ {
+ throw new IllegalStateException("Should not call dispose() on builder " + this);
+ }
+
+ public T produce(CreationalContext<T> ctx)
+ {
+ throw new IllegalStateException("Should not call produce() on builder " + this);
+ }
+
+}
\ No newline at end of file
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/AbstractReceiverBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.reflect.Member;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Alternative;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.context.WBCreationalContext;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+/**
+ * @author pmuir
+ *
+ */
+abstract class AbstractReceiverBeanBuilder<T, S extends Member> extends AbstractBeanBuilder<T, S>
+{
+ private static final LogProvider log = Logging.getLogProvider(AbstractReceiverBeanBuilder.class);
+
+ private AbstractClassBean<?> declaringBean;
+ private boolean policy;
+
+ public AbstractReceiverBeanBuilder(AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(manager);
+ this.declaringBean = declaringBean;
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ super.initialize(environment);
+ }
+
+ /**
+ * Gets the receiver of the product
+ *
+ * @return The receiver
+ */
+ protected Object getReceiver(CreationalContext<?> creationalContext)
+ {
+ // This is a bit dangerous, as it means that producer methods can end of
+ // executing on partially constructed instances. Also, it's not required
+ // by the spec...
+ if (getAnnotatedItem().isStatic())
+ {
+ return null;
+ }
+ else
+ {
+ if (creationalContext instanceof WBCreationalContext<?>)
+ {
+ WBCreationalContext<?> creationalContextImpl = (WBCreationalContext<?>) creationalContext;
+ if (creationalContextImpl.containsIncompleteInstance(getDeclaringBean()))
+ {
+ log.warn("Executing producer field or method " + getAnnotatedItem() + " on incomplete declaring bean " + getDeclaringBean() + " due to circular injection");
+ return creationalContextImpl.getIncompleteInstance(getDeclaringBean());
+ }
+ }
+ return manager.getReference(getDeclaringBean(), Object.class, creationalContext);
+ }
+ }
+
+
+ /**
+ * Returns the declaring bean
+ *
+ * @return The bean representation
+ */
+ public AbstractClassBean<?> getDeclaringBean()
+ {
+ return declaringBean;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.bean.AbstractBean#isPolicy()
+ */
+ @Override
+ public boolean isAlternative()
+ {
+ return policy;
+ }
+
+ @Override
+ protected void initPolicy()
+ {
+ if (getDeclaringBean().isAlternative())
+ {
+ this.policy = true;
+ }
+ else if (getAnnotatedItem().isAnnotationPresent(Alternative.class))
+ {
+ this.policy = true;
+ }
+ else if (getMergedStereotypes().isPolicy())
+ {
+ this.policy = true;
+ }
+ }
+
+}
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderFactoryImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderFactoryImpl.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderFactoryImpl.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -30,10 +30,12 @@
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.BeanManager;
+import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.builder.spi.DecoratorBeanBuilder;
import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.EjbDescriptors;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
/**
@@ -76,54 +78,56 @@
public <T> SimpleBeanBuilder<T> getSimpleBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType)
{
- return getBeanBuilderImpl(beanManager, false, annotatedType, null, false);
+ return getBeanBuilderImpl(beanManager, annotatedType, null, false);
}
public <T> EnterpriseBeanBuilder<T> getEnterpriseBeanBuilder(BeanManager beanManager, EjbDescriptor<T> ejbDescriptor)
{
- return getBeanBuilderImpl(beanManager, false, null, ejbDescriptor, false);
+ return getBeanBuilderImpl(beanManager, null, ejbDescriptor, false);
}
public <T> DecoratorBeanBuilder<T> getDecoratorBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType)
{
- return getBeanBuilderImpl(beanManager, false, annotatedType, null, true);
+ return getBeanBuilderImpl(beanManager, annotatedType, null, true);
}
- public <T> SimpleBeanBuilder<T> getInternalSimpleBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType)
- {
- return getBeanBuilderImpl(beanManager, true, annotatedType, null, false);
- }
-
- public <T> EnterpriseBeanBuilder<T> getInternalEnterpriseBeanBuilder(BeanManager beanManager, EjbDescriptor<T> ejbDescriptor)
- {
- return getBeanBuilderImpl(beanManager, true, null, ejbDescriptor, false);
- }
-
- public <T> DecoratorBeanBuilder<T> getInternalDecoratorBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType)
- {
- return getBeanBuilderImpl(beanManager, true, annotatedType, null, false);
- }
-
public <T> InternalObserverMethodBuilder<T> getInternalObserverMethodBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType)
{
- return getBeanBuilderImpl(beanManager, true, annotatedType, null, false);
+ return getBeanBuilderImpl(beanManager, annotatedType, null, false);
}
- private <T> BeanBuilderImpl<T> getBeanBuilderImpl(BeanManager beanManager, boolean delayInitialization, AnnotatedType<T> annotatedType, EjbDescriptor<T> ejbDescriptor, boolean decorator)
+ private <T> BeanBuilderImpl<T> getBeanBuilderImpl(BeanManager beanManager, AnnotatedType<T> annotatedType, EjbDescriptor<T> ejbDescriptor, boolean decorator)
{
lock.readLock().lock();
try
{
WeakReference<BeanDeployerEnvironment> ref = beanDeployerEnvironments.get(beanManager);
- if (ref == null)
- throw new IllegalStateException("BeanManager not registered " + beanManager);
+ BeanDeployerEnvironment environment = null;
+
+ if (ref != null)
+ {
+ environment = ref.get();
+ }
+ else
+ {
+ lock.readLock().unlock();
+ try
+ {
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new IllegalStateException("BeanManager is not a BeanManagerImpl");
+ environment = new BeanDeployerEnvironment(new EjbDescriptors(), (BeanManagerImpl)beanManager);
+ registerBeanManager(beanManager, environment);
+ }
+ finally
+ {
+ lock.readLock().lock();
+ }
+ }
- BeanDeployerEnvironment environment = ref.get();
-
if (environment == null)
throw new IllegalStateException("BeanManager registered but no longer valid " + beanManager);
- return BeanBuilderImpl.initialiseBuilder(beanManager, environment, annotatedType, ejbDescriptor, decorator, delayInitialization);
+ return BeanBuilderImpl.initialiseBuilder(beanManager, environment, annotatedType, ejbDescriptor, decorator);
}
finally
{
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/BeanBuilderImpl.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -52,11 +52,8 @@
import org.jboss.webbeans.bean.builder.spi.DecoratorBeanBuilder;
import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
-import org.jboss.webbeans.bean.ee.EEResourceProducerField;
-import org.jboss.webbeans.bean.ee.PersistenceContextProducerField;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.bootstrap.ProcessObserverMethodImpl;
-import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.ejb.InternalEjbDescriptor;
import org.jboss.webbeans.ejb.spi.EjbDescriptor;
import org.jboss.webbeans.event.ObserverFactory;
@@ -64,9 +61,7 @@
import org.jboss.webbeans.introspector.WBClass;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.introspector.WBMethod;
-import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
import org.jboss.webbeans.resources.ClassTransformer;
-import org.jboss.webbeans.ws.WSApiAbstraction;
/**
*
@@ -85,8 +80,6 @@
private final boolean decorator;
- private final boolean delayInitialization;
-
private Bean<T> mainBean;
private Bean<T> newBean;
@@ -99,20 +92,19 @@
private final List<Throwable> definitionErrors = new ArrayList<Throwable>();
- private BeanBuilderImpl(BeanManager beanManager, BeanDeployerEnvironment beanDeployerEnvironment, AnnotatedType<T> type, EjbDescriptor<T> ejbDescriptor, boolean decorator, boolean delayInitialization)
+ private BeanBuilderImpl(BeanManager beanManager, BeanDeployerEnvironment beanDeployerEnvironment, AnnotatedType<T> type, EjbDescriptor<T> ejbDescriptor, boolean decorator)
{
if (beanManager != beanManager)
throw new IllegalStateException("beanManager is not an instance of " + BeanManagerImpl.class.getName());
this.beanManager = (BeanManagerImpl)beanManager;
this.beanDeployerEnvironment = beanDeployerEnvironment;
- this.delayInitialization = delayInitialization;
this.decorator = decorator;
this.type = type;
this.ejbDescriptor = ejbDescriptor;
}
- static <T> BeanBuilderImpl<T> initialiseBuilder(BeanManager beanManager, BeanDeployerEnvironment beanDeployerEnvironment, AnnotatedType<T> type, EjbDescriptor<T> ejbDescriptor, boolean decorator, boolean delayInitialization)
+ static <T> BeanBuilderImpl<T> initialiseBuilder(BeanManager beanManager, BeanDeployerEnvironment beanDeployerEnvironment, AnnotatedType<T> type, EjbDescriptor<T> ejbDescriptor, boolean decorator)
{
if (type == null && ejbDescriptor == null)
throw new IllegalArgumentException("Need a type or an ejbDescriptor");
@@ -125,7 +117,7 @@
if (ejbDescriptor != null && decorator)
throw new IllegalArgumentException("Cannot create a decorator from an ejb");
- BeanBuilderImpl<T> builder = new BeanBuilderImpl<T>(beanManager, beanDeployerEnvironment, type, ejbDescriptor, decorator, delayInitialization);
+ BeanBuilderImpl<T> builder = new BeanBuilderImpl<T>(beanManager, beanDeployerEnvironment, type, ejbDescriptor, decorator);
builder.createBeans();
return builder;
@@ -186,61 +178,105 @@
private Set<Bean<?>> createSimpleBeans(WBClass<T> clazz)
{
+// beans = new LinkedHashSet<Bean<?>>();
+// ManagedBeanBuilder<T> mainBuilder = ManagedBeanBuilder.of(clazz, beanManager);
+//
+// mainBean = bean;
+//
+// beanDeployerEnvironment.addBean(bean);
+// beans.add(bean);
+//
+// createSubBeans(beans, bean);
+//
+// NewManagedBean<T> newBean = NewManagedBean.of(clazz, beanManager);
+// beanDeployerEnvironment.addBean(newBean);
+// beans.add(newBean);
+// this.newBean = newBean;
+//
+// if (!delayInitialization)
+// newBean.initialize(beanDeployerEnvironment);
+//
+// return beans;
beans = new LinkedHashSet<Bean<?>>();
- ManagedBean<T> bean = ManagedBean.of(clazz, beanManager);
- mainBean = bean;
-
+
+ ManagedBeanBuilder<T> builder = ManagedBeanBuilder.of(clazz, beanManager);
+ builder.initialize(beanDeployerEnvironment);
+ ManagedBean<T> bean = builder.createBean();
+ this.mainBean = bean;
beanDeployerEnvironment.addBean(bean);
- beans.add(bean);
-
- if (!delayInitialization)
- bean.initialize(beanDeployerEnvironment);
-
+ beans.add(mainBean);
+
createSubBeans(beans, bean);
- NewManagedBean<T> newBean = NewManagedBean.of(clazz, beanManager);
+ NewManagedBeanBuilder<T> newBeanBuilder = NewManagedBeanBuilder.of(clazz, beanManager);
+ newBeanBuilder.initialize(beanDeployerEnvironment);
+ NewManagedBean<T> newBean = newBeanBuilder.createBean();
+ this.newBean = newBean;
beanDeployerEnvironment.addBean(newBean);
beans.add(newBean);
- this.newBean = newBean;
- if (!delayInitialization)
- newBean.initialize(beanDeployerEnvironment);
-
return beans;
+
}
private Set<Bean<?>> createEnterpriseBeans(InternalEjbDescriptor<T> ejbDescriptor)
{
- beans = new LinkedHashSet<Bean<?>>();
- SessionBean<T> bean = SessionBean.of(ejbDescriptor, beanManager);
- mainBean = bean;
+// beans = new LinkedHashSet<Bean<?>>();
+// SessionBean<T> bean = SessionBean.of(ejbDescriptor, beanManager);
+// mainBean = bean;
+//
+// beanDeployerEnvironment.addBean(bean);
+// beans.add(bean);
+// if (!delayInitialization)
+// bean.initialize(beanDeployerEnvironment);
+//
+// createSubBeans(beans, bean);
+//
+// NewSessionBean<T> newBean = NewSessionBean.of(ejbDescriptor, beanManager);
+// beanDeployerEnvironment.addBean(newBean);
+// beans.add(newBean);
+// this.newBean = newBean;
+//
+// if (!delayInitialization)
+// newBean.initialize(beanDeployerEnvironment);
+//
+// return beans;
- beanDeployerEnvironment.addBean(bean);
- beans.add(bean);
- if (!delayInitialization)
- bean.initialize(beanDeployerEnvironment);
-
- createSubBeans(beans, bean);
-
- NewSessionBean<T> newBean = NewSessionBean.of(ejbDescriptor, beanManager);
- beanDeployerEnvironment.addBean(newBean);
- beans.add(newBean);
- this.newBean = newBean;
-
- if (!delayInitialization)
- newBean.initialize(beanDeployerEnvironment);
-
- return beans;
+ beans = new LinkedHashSet<Bean<?>>();
+
+ SessionBeanBuilder<T> builder = SessionBeanBuilder.of(ejbDescriptor, beanManager);
+ builder.initialize(beanDeployerEnvironment);
+ SessionBean<T> bean = builder.createBean();
+ beanDeployerEnvironment.addBean(bean);
+ beans.add(bean);
+
+ createSubBeans(beans, bean);
+
+ NewSessionBeanBuilder<T> newBeanBuilder = NewSessionBeanBuilder.of(ejbDescriptor, beanManager);
+ newBeanBuilder.initialize(beanDeployerEnvironment);
+ NewSessionBean<T> newBean = newBeanBuilder.createBean();
+ this.newBean = newBean;
+ beanDeployerEnvironment.addBean(newBean);
+ beans.add(newBean);
+
+ return beans;
}
private Bean<T> createDecorator(WBClass<T> annotatedClass)
{
- DecoratorImpl<T> bean = DecoratorImpl.of(annotatedClass, beanManager);
- mainBean = bean;
+// DecoratorImpl<T> bean = DecoratorImpl.of(annotatedClass, beanManager);
+// mainBean = bean;
+//
+// beanDeployerEnvironment.addBean(bean);
+// if (!delayInitialization)
+// bean.initialize(beanDeployerEnvironment);
+//
+// return bean;
- beanDeployerEnvironment.addBean(bean);
- if (!delayInitialization)
- bean.initialize(beanDeployerEnvironment);
+ DecoratorBuilder<T> builder = DecoratorBuilder.of(annotatedClass, beanManager);
+ builder.initialize(beanDeployerEnvironment);
+ DecoratorImpl<T> bean = builder.createBean();
+ this.mainBean = bean;
return bean;
}
@@ -283,20 +319,33 @@
{
for (WBMethod<?, ?> method : annotatedClass.getWBDeclaredMethodsWithAnnotatedParameters(Disposes.class))
{
- DisposalMethod<?> disposalBean = DisposalMethod.of(beanManager, method, declaringBean);
+// DisposalMethod<?> disposalBean = DisposalMethod.of(beanManager, method, declaringBean);
+// beanDeployerEnvironment.addBean(disposalBean);
+// //Do not delay initialization of decorator beans, they get initialized right away in the original impl
+// disposalBean.initialize(beanDeployerEnvironment);
+
+ DisposalMethodBuilder<?> builder = DisposalMethodBuilder.of(beanManager, method, declaringBean);
+ //Do not delay initialization of decorator beans, they get initialized right away in the original impl
+ builder.initialize(beanDeployerEnvironment);
+ DisposalMethod<?> disposalBean = builder.createBean();
beanDeployerEnvironment.addBean(disposalBean);
- //Do not delay initialization of decorator beans, they get initialized right away in the original impl
- disposalBean.initialize(beanDeployerEnvironment);
+
}
}
protected <T> void createProducerMethod(Set<Bean<?>> beans, AbstractClassBean<?> declaringBean, WBMethod<T, ?> annotatedMethod)
{
- ProducerMethod<T> bean = ProducerMethod.of(annotatedMethod, declaringBean, beanManager);
+// ProducerMethod<T> bean = ProducerMethod.of(annotatedMethod, declaringBean, beanManager);
+// beanDeployerEnvironment.addBean(bean);
+// beans.add(bean);
+// if (!delayInitialization)
+// bean.initialize(beanDeployerEnvironment);
+
+ ProducerMethodBuilder<T> builder = ProducerMethodBuilder.of(annotatedMethod, declaringBean, beanManager);
+ builder.initialize(beanDeployerEnvironment);
+ ProducerMethod<T> bean = builder.createBean();
beanDeployerEnvironment.addBean(bean);
beans.add(bean);
- if (!delayInitialization)
- bean.initialize(beanDeployerEnvironment);
}
protected void createProducerFields(Set<Bean<?>> beans, AbstractClassBean<?> declaringBean, WBClass<?> annotatedClass)
@@ -309,24 +358,29 @@
protected <T> void createProducerField(Set<Bean<?>> beans, AbstractClassBean<?> declaringBean, WBField<T, ?> field)
{
- ProducerField<T> bean;
- if (isPersistenceContextProducerField(field))
- {
- bean = PersistenceContextProducerField.of(field, declaringBean, beanManager);
- }
- else if (isEEResourceProducerField(field))
- {
- bean = EEResourceProducerField.of(field, declaringBean, beanManager);
- }
- else
- {
- bean = ProducerField.of(field, declaringBean, beanManager);
- }
+// ProducerField<T> bean;
+// if (isPersistenceContextProducerField(field))
+// {
+// bean = PersistenceContextProducerField.of(field, declaringBean, beanManager);
+// }
+// else if (isEEResourceProducerField(field))
+// {
+// bean = EEResourceProducerField.of(field, declaringBean, beanManager);
+// }
+// else
+// {
+// bean = ProducerField.of(field, declaringBean, beanManager);
+// }
+//
+// beanDeployerEnvironment.addBean(bean);
+// beans.add(bean);
+// if (!delayInitialization)
+// bean.initialize(beanDeployerEnvironment);
- beanDeployerEnvironment.addBean(bean);
+ ProducerFieldBuilder<T> builder = ProducerFieldBuilder.of(field, declaringBean, beanManager);
+ builder.initialize(beanDeployerEnvironment);
+ ProducerField<T> bean = builder.createBean();
beans.add(bean);
- if (!delayInitialization)
- bean.initialize(beanDeployerEnvironment);
}
public Set<ObserverMethod<T, ?>> createObserverMethods(RIBean<T> declaringBean, WBClass<T> annotatedClass)
@@ -343,13 +397,21 @@
protected <X, T> ObserverMethodImpl<X, T> createObserverMethod(RIBean<X> declaringBean, WBMethod<T, X> method)
{
+// ObserverMethodImpl<X, T> observer = ObserverFactory.create(method, declaringBean, beanManager);
+// ProcessObserverMethod<?, ?> event = createProcessObserverMethodEvent(observer, method);
+// beanManager.fireEvent(event);
+// beanDeployerEnvironment.addObserver(observer);
+// if (!delayInitialization)
+// observer.initialize();
+// return observer;
+
ObserverMethodImpl<X, T> observer = ObserverFactory.create(method, declaringBean, beanManager);
ProcessObserverMethod<?, ?> event = createProcessObserverMethodEvent(observer, method);
beanManager.fireEvent(event);
beanDeployerEnvironment.addObserver(observer);
- if (!delayInitialization)
- observer.initialize();
+ observer.initialize();
return observer;
+
}
private <X, T> ProcessObserverMethod<X, T> createProcessObserverMethodEvent(ObserverMethod<X, T> observer, AnnotatedMethod<X> method)
@@ -373,20 +435,4 @@
return new InternalEjbDescriptor<T>(ejbDescriptor);
}
-
- protected boolean isEEResourceProducerField(WBField<?, ?> field)
- {
- EJBApiAbstraction ejbApiAbstraction = beanManager.getServices().get(EJBApiAbstraction.class);
- PersistenceApiAbstraction persistenceApiAbstraction = beanManager.getServices().get(PersistenceApiAbstraction.class);
- WSApiAbstraction wsApiAbstraction = beanManager.getServices().get(WSApiAbstraction.class);
- return field.isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS) || field.isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || field.isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS);
- }
-
- protected boolean isPersistenceContextProducerField(WBField<?, ?> field)
- {
- PersistenceApiAbstraction persistenceApiAbstraction = beanManager.getServices().get(PersistenceApiAbstraction.class);
- return field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS);
- }
-
-
}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DecoratorBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Decorator;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.DecoratorImpl;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+
+class DecoratorBuilder<T> extends ManagedBeanBuilder<T> implements Decorator<T>
+{
+
+ public static <T> Decorator<T> wrapForResolver(final Decorator<T> decorator)
+ {
+ return new ForwardingDecorator<T>()
+ {
+
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return delegate().getDelegateQualifiers();
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return delegate().getTypes();
+ }
+
+ @Override
+ protected Decorator<T> delegate()
+ {
+ return decorator;
+ }
+
+ };
+ }
+
+ /**
+ * Creates a decorator bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return a Bean
+ */
+ public static <T> DecoratorBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new DecoratorBuilder<T>(clazz, manager);
+ }
+
+ private WBInjectionPoint<?, ?> delegateInjectionPoint;
+ private Set<Annotation> delegateBindings;
+ private Type delegateType;
+ private Set<Type> delegateTypes;
+ private Set<Type> decoratedTypes;
+
+ protected DecoratorBuilder(WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ initDelegateInjectionPoint();
+ initDecoratedTypes();
+ initDelegateBindings();
+ initDelegateType();
+ checkDelegateType();
+ }
+ }
+
+ protected void initDecoratedTypes()
+ {
+ this.decoratedTypes = new HashSet<Type>();
+ this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
+ this.decoratedTypes.remove(Serializable.class);
+ }
+
+ protected void initDelegateInjectionPoint()
+ {
+ this.delegateInjectionPoint = getDelegateInjectionPoints().iterator().next();
+ }
+
+ @Override
+ protected void checkDelegateInjectionPoints()
+ {
+ for (WBInjectionPoint<?, ?> injectionPoint : getDelegateInjectionPoints())
+ {
+ if (injectionPoint instanceof MethodInjectionPoint<?, ?> && !injectionPoint.isAnnotationPresent(Inject.class))
+ {
+ throw new DefinitionException("Method with @Decorates parameter must be an initializer method " + injectionPoint);
+ }
+ }
+ if (getDelegateInjectionPoints().size() == 0)
+ {
+ throw new DefinitionException("No delegate injection points defined " + this);
+ }
+ else if (getDelegateInjectionPoints().size() > 1)
+ {
+ throw new DefinitionException("Too many delegate injection point defined " + this);
+ }
+ }
+
+ protected void initDelegateBindings()
+ {
+ this.delegateBindings = new HashSet<Annotation>();
+ this.delegateBindings.addAll(this.delegateInjectionPoint.getQualifiers());
+ }
+
+ protected void initDelegateType()
+ {
+ this.delegateType = this.delegateInjectionPoint.getBaseType();
+ this.delegateTypes = new HashSet<Type>();
+ delegateTypes.add(delegateType);
+ }
+
+ protected void checkDelegateType()
+ {
+ for (Type decoratedType : getDecoratedTypes())
+ {
+ if (decoratedType instanceof Class)
+ {
+ if (!((Class<?>) decoratedType).isAssignableFrom(delegateInjectionPoint.getJavaClass()))
+ {
+ throw new DefinitionException("The delegate type must extend or implement every decorated type. Decorated type " + decoratedType + "." + this );
+ }
+ }
+ else if (decoratedType instanceof ParameterizedType)
+ {
+ ParameterizedType parameterizedType = (ParameterizedType) decoratedType;
+ if (!delegateInjectionPoint.isParameterizedType())
+ {
+ throw new DefinitionException("The decorated type is parameterized, but the delegate type isn't. Delegate type " + delegateType + "." + this);
+ }
+ if (!Arrays.equals(delegateInjectionPoint.getActualTypeArguments(), parameterizedType.getActualTypeArguments()));
+ Type rawType = ((ParameterizedType) decoratedType).getRawType();
+ 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 );
+ }
+ else
+ {
+ throw new IllegalStateException("Unable to process " + decoratedType);
+ }
+
+ }
+ }
+ }
+
+ public Set<Annotation> getDelegateQualifiers()
+ {
+ return delegateBindings;
+ }
+
+ public Type getDelegateType()
+ {
+ return delegateType;
+ }
+
+ public Set<Type> getDecoratedTypes()
+ {
+ return decoratedTypes;
+ }
+
+ public WBInjectionPoint<?, ?> getDelegateInjectionPoint()
+ {
+ return delegateInjectionPoint;
+ }
+
+ /**
+ * The type closure of the delegate type
+ *
+ * @return the delegateTypes
+ */
+ public Set<Type> getDelegateTypes()
+ {
+ return delegateTypes;
+ }
+
+ @Override
+ protected void initDecorators()
+ {
+ // No-op, decorators can't have decorators
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.webbeans.bean.SimpleBean#toString()
+ */
+ @Override
+ public String toString()
+ {
+ // TODO Auto-generated method stub
+ return super.toString("decorator");
+ }
+
+ @Override
+ public DecoratorImpl<T> createBean()
+ {
+ return DecoratorImpl.of(getAnnotatedItem(),
+ getManager(),
+ name,
+ getMergedStereotypes(),
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings,
+ getSuperclasses(),
+ getPostConstruct(),
+ getPreDestroy(),
+ getSpecializedBean());
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/DisposalMethodBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.introspector.WBMethod;
+
+class DisposalMethodBuilder<T> extends AbstractReceiverBeanBuilder<T, Method>
+{
+
+ protected WBMethod<T, ?> disposalMethod;
+
+ //protected MethodInjectionPoint<T, ?> disposalMethodInjectionPoint;
+ private final String id;
+
+ protected DisposalMethodBuilder(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ {
+ super(declaringBean, manager);
+ this.disposalMethod = disposalMethod;
+ //this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
+ this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
+ initBindings();
+ initType();
+ initTypes();
+ initStereotypes();
+ initPolicy();
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ super.initialize(environment);
+ checkDisposalMethod();
+ }
+
+ protected void initType()
+ {
+ disposalMethod.getAnnotatedWBParameters(Disposes.class).get(0).getJavaClass();
+ this.type = (Class<T>) disposalMethod.getAnnotatedWBParameters(Disposes.class).get(0).getJavaClass();
+ }
+
+ @Override
+ public WBMethod<T, ?> getAnnotatedItem()
+ {
+ return disposalMethod;
+ }
+
+ public static <T> DisposalMethodBuilder<T> of(BeanManagerImpl manager, WBMethod<T, ?> disposalMethod, AbstractClassBean<?> declaringBean)
+ {
+ return new DisposalMethodBuilder<T>(manager, disposalMethod, declaringBean);
+ }
+
+ @Override
+ protected void initBindings()
+ {
+ // At least 1 parameter exists, already checked in constructor
+ this.bindings = new HashSet<Annotation>();
+ //this.bindings.addAll(disposalMethodInjectionPoint.getWBParameters().get(0).getQualifiers());
+ this.bindings.addAll(disposalMethod.getWBParameters().get(0).getQualifiers());
+ initDefaultBindings();
+ }
+
+ /**
+ * Initializes the API types
+ */
+ @Override
+ protected void initTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new HashSet<Type>();
+ //types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getTypeClosure());
+ types.addAll(disposalMethod.getAnnotatedWBParameters(Disposes.class).get(0).getTypeClosure());
+ types.add(Object.class);
+ super.types = types;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+ @Override
+ public String toString()
+ {
+ return disposalMethod.toString();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ // Not relevant
+ return false;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ // Not relevant
+ return false;
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ return true;
+ }
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ // Not Relevant
+ return null;
+ }
+
+ private void checkDisposalMethod()
+ {
+ if (!disposalMethod.getWBParameters().get(0).isAnnotationPresent(Disposes.class))
+ {
+ throw new DefinitionException(disposalMethod.toString() + " doesn't have @Dispose as first parameter");
+ }
+ if (disposalMethod.getAnnotatedWBParameters(Disposes.class).size() > 1)
+ {
+ throw new DefinitionException(disposalMethod.toString() + " has more than one @Dispose parameters");
+ }
+ if (disposalMethod.getAnnotatedWBParameters(Observes.class).size() > 0)
+ {
+ throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethod.toString());
+ }
+ if (disposalMethod.getAnnotation(Inject.class) != null)
+ {
+ throw new DefinitionException("@Inject is not allowed on a disposal method, see " + disposalMethod.toString());
+ }
+ if (disposalMethod.getAnnotation(Produces.class) != null)
+ {
+ throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethod.toString());
+ }
+ if (getDeclaringBean() instanceof SessionBean<?>)
+ {
+ boolean methodDeclaredOnTypes = false;
+ // TODO use annotated item?
+ for (Type type : getDeclaringBean().getTypes())
+ {
+ if (type instanceof Class<?>)
+ {
+ Class<?> clazz = (Class<?>) type;
+ try
+ {
+ clazz.getDeclaredMethod(disposalMethod.getName(), disposalMethod.getParameterTypesAsArray());
+ methodDeclaredOnTypes = true;
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // No - op
+ }
+ }
+ }
+ if (!methodDeclaredOnTypes)
+ {
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+ }
+ }
+ }
+
+ @Override
+ public Class<T> getType()
+ {
+ return type;
+ }
+
+ @Override
+ protected String getDefaultName()
+ {
+ return disposalMethod.getPropertyName();
+ }
+
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ // No-op. Producer method dependent objects are destroyed in producer method bean
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ // Doesn't support specialization
+ return null;
+ }
+
+ @Override
+ protected void initScopeType()
+ {
+ // Disposal methods aren't scoped
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public DisposalMethod<T> createBean()
+ {
+ return DisposalMethod.of(manager,
+ name,
+ disposalMethod,
+ getDeclaringBean(),
+ type,
+ types,
+ getMergedStereotypes(),
+ isAlternative(),
+ isProxyable(),
+ bindings);
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingBean.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingBean.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingBean.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,172 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+/**
+ * A delegating bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+public abstract class ForwardingBean<T> implements Bean<T>
+{
+
+ /**
+ * Creates an instance of the delegate
+ *
+ * @return an instance of the delegate
+ */
+ public T create(CreationalContext<T> creationalContext)
+ {
+ return delegate().create(creationalContext);
+ }
+
+ /**
+ * Abstract getter for the delegate
+ *
+ * @return The delegate
+ */
+ protected abstract Bean<T> delegate();
+
+ /**
+ * Destroys an instance through the delegate
+ *
+ * @param instance The instance to destroy
+ */
+ public void destroy(T instance, CreationalContext<T> creationalContext)
+ {
+ delegate().destroy(instance, creationalContext);
+ }
+
+ /**
+ * Compares an object with the delegate
+ *
+ * @return True if equals, false otherwise
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ return delegate().equals(obj);
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return delegate().getBeanClass();
+ }
+
+ /**
+ * Gets the binding types of the delegate
+ *
+ * @return The binding types
+ */
+ public Set<Annotation> getQualifiers()
+ {
+ return delegate().getQualifiers();
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return delegate().getInjectionPoints();
+ }
+
+ /**
+ * Gets the name of the delegate
+ *
+ * @return The name
+ */
+ public String getName()
+ {
+ return delegate().getName();
+ }
+
+ /**
+ * The stereotypes applied to this bean
+ *
+ * @return stereotypes if any
+ */
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return delegate().getStereotypes();
+ }
+
+ /**
+ * Gets the scope type of the delegate
+ *
+ * @return The scope type
+ */
+ public Class<? extends Annotation> getScope()
+ {
+ return delegate().getScope();
+ }
+
+ /**
+ * Gets the API types of the delegate
+ *
+ * @return The API types
+ */
+ public Set<Type> getTypes()
+ {
+ return delegate().getTypes();
+ }
+
+ /**
+ * Gets the hash code of the delegate
+ *
+ * @return The hash code
+ */
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ /**
+ * Indicates if the delegate is nullable
+ *
+ * @return True if nullable, false otherwise
+ */
+ public boolean isNullable()
+ {
+ return delegate().isNullable();
+ }
+
+ public boolean isAlternative()
+ {
+ return delegate().isAlternative();
+ }
+
+ /**
+ * Returns a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return "ForwardingBean " + getName() + " for " + delegate().toString();
+ }
+
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingDecorator.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingDecorator.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ForwardingDecorator.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Decorator;
+
+public abstract class ForwardingDecorator<T> extends ForwardingBean<T> implements Decorator<T>
+{
+
+ @Override
+ protected abstract Decorator<T> delegate();
+
+ public Set<Type> getDecoratedTypes()
+ {
+ return delegate().getDecoratedTypes();
+ }
+
+ public Set<Annotation> getDelegateQualifiers()
+ {
+ return delegate().getDelegateQualifiers();
+ }
+
+ public Type getDelegateType()
+ {
+ return delegate().getDelegateType();
+ }
+
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ManagedBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,310 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.ManagedBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.ConstructorInjectionPoint;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBConstructor;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Represents a simple bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T> The type (class) of the bean
+ */
+class ManagedBeanBuilder<T> extends AbstractClassBeanBuilder<T>
+{
+ // Logger
+ private static LogProvider log = Logging.getLogProvider(ManagedBeanBuilder.class);
+
+ // The constructor
+ private ConstructorInjectionPoint<T> constructor;
+ private Set<WBInjectionPoint<?, ?>> ejbInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceContextInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> persistenceUnitInjectionPoints;
+ private Set<WBInjectionPoint<?, ?>> resourceInjectionPoints;
+
+ private ManagedBean<?> specializedBean;
+
+
+
+ /**
+ * Creates a simple, annotation defined Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return A Web Bean
+ */
+ public static <T> ManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new ManagedBeanBuilder<T>(clazz, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param type The type of the bean
+ * @param manager The Web Beans manager
+ */
+ protected ManagedBeanBuilder(WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ initType();
+ initTypes();
+ initBindings();
+ }
+
+ protected InjectionPoint attachCorrectInjectionPoint()
+ {
+ Decorator<?> decorator = getDecorators().get(getDecorators().size() - 1);
+ if (decorator instanceof DecoratorBuilder<?>)
+ {
+ DecoratorBuilder<?> decoratorBean = (DecoratorBuilder<?>) decorator;
+ InjectionPoint outerDelegateInjectionPoint = decoratorBean.getDelegateInjectionPoint();
+ return getManager().replaceOrPushCurrentInjectionPoint(outerDelegateInjectionPoint);
+ }
+ else
+ {
+ throw new IllegalStateException("Cannot operate on user defined decorator");
+ }
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ initConstructor();
+ checkConstructor();
+ super.initialize(environment);
+ initPostConstruct();
+ initPreDestroy();
+ initEEInjectionPoints();
+ }
+ }
+
+ private void initEEInjectionPoints()
+ {
+ this.ejbInjectionPoints = Beans.getEjbInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceContextInjectionPoints = Beans.getPersistenceContextInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.persistenceUnitInjectionPoints = Beans.getPersistenceUnitInjectionPoints(this, getAnnotatedItem(), getManager());
+ this.resourceInjectionPoints = Beans.getResourceInjectionPoints(this, getAnnotatedItem(), manager);
+ }
+
+ /**
+ * Validates the type
+ */
+ protected void checkType()
+ {
+ if (getAnnotatedItem().isNonStaticMemberClass())
+ {
+ throw new DefinitionException("Simple bean " + type + " cannot be a non-static inner class");
+ }
+ if (!isDependent() && getAnnotatedItem().isParameterizedType())
+ {
+ throw new DefinitionException("Managed bean " + type + " must be @Dependent");
+ }
+ boolean passivating = manager.getServices().get(MetaAnnotationStore.class).getScopeModel(scopeType).isPassivating();
+ if (passivating && !Reflections.isSerializable(getBeanClass()))
+ {
+ throw new DefinitionException("Simple bean declaring a passivating scope must have a serializable implementation class " + toString());
+ }
+ if (hasDecorators())
+ {
+ if (getAnnotatedItem().isFinal())
+ {
+ throw new DefinitionException("Bean class which has decorators cannot be declared final " + this);
+ }
+ for (Decorator<?> decorator : getDecorators())
+ {
+ if (decorator instanceof DecoratorBuilder<?>)
+ {
+ DecoratorBuilder<?> decoratorBean = (DecoratorBuilder<?>) decorator;
+ for (WBMethod<?, ?> decoratorMethod : decoratorBean.getAnnotatedItem().getWBMethods())
+ {
+ WBMethod<?, ?> method = getAnnotatedItem().getWBMethod(decoratorMethod.getSignature());
+ if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal())
+ {
+ throw new DefinitionException("Decorated bean method " + method + " (decorated by "+ decoratorMethod + ") cannot be declarted final");
+ }
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Can only operate on container provided decorators " + decorator);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void checkBeanImplementation()
+ {
+ super.checkBeanImplementation();
+ if (!isDependent())
+ {
+ for (WBField<?, ?> field : getAnnotatedItem().getWBFields())
+ {
+ if (field.isPublic() && !field.isStatic())
+ {
+ throw new DefinitionException("Normal scoped Web Bean implementation class has a public field " + getAnnotatedItem());
+ }
+ }
+ }
+ }
+
+ protected void checkConstructor()
+ {
+ if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Disposes " + constructor);
+ }
+ if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
+ {
+ throw new DefinitionException("Managed bean constructor must not have a parameter annotated @Observes " + constructor);
+ }
+ }
+
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ super.preSpecialize(environment);
+ if (environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+ {
+ throw new DefinitionException("Simple bean must specialize a simple bean");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+ {
+ throw new DefinitionException(toString() + " does not specialize a bean");
+ }
+ AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+ if (!(specializedBean instanceof ManagedBean))
+ {
+ throw new DefinitionException(toString() + " doesn't have a simple bean as a superclass " + specializedBean);
+ }
+ else
+ {
+ this.specializedBean = (ManagedBean<?>) specializedBean;
+ }
+ }
+
+
+ /**
+ * Initializes the constructor
+ */
+ protected void initConstructor()
+ {
+ this.constructor = Beans.getBeanConstructor(this, getAnnotatedItem());
+ // TODO We loop unecessarily many times here, I want to probably introduce some callback mechanism. PLM.
+ addInjectionPoints(Beans.getParameterInjectionPoints(this, constructor));
+ }
+
+ /**
+ * Returns the constructor
+ *
+ * @return The constructor
+ */
+ public WBConstructor<T> getConstructor()
+ {
+ return constructor;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ return toString("simple bean");
+ }
+
+ protected String toString(String beanType)
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed ").append(beanType);
+ }
+ else
+ {
+ buffer.append(beanType).append(" '" + getName() + "'");
+ }
+ buffer.append(" ").append(getType().getName()).append(", ");
+ buffer.append(" API types = ").append(Names.typesToString(getTypes())).append(", binding types = " + Names.annotationsToString(getQualifiers()));
+ return buffer.toString();
+ }
+
+ @Override
+ public ManagedBean<?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ @Override
+ public ManagedBean<T> createBean()
+ {
+ return ManagedBean.of(
+ getAnnotatedItem(),
+ getManager(),
+ name,
+ getMergedStereotypes(),
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings,
+ getSuperclasses(),
+ getProxyClassForDecorators(),
+ getDecorators(),
+ getPostConstruct(),
+ getPreDestroy(),
+ getSpecializedBean());
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewManagedBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,137 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.NewManagedBean;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+
+/**
+ * Represents a @New simple bean
+ *
+ * @author Nicklas Karlsson
+ */
+class NewManagedBeanBuilder<T> extends ManagedBeanBuilder<T>
+{
+
+ /**
+ * Creates an instance of a NewSimpleBean from an annotated class
+ *
+ * @param clazz The annotated class
+ * @param manager The Web Beans manager
+ * @return a new NewSimpleBean instance
+ */
+ public static <T> NewManagedBeanBuilder<T> of(WBClass<T> clazz, BeanManagerImpl manager)
+ {
+ return new NewManagedBeanBuilder<T>(clazz, manager);
+ }
+
+ private Set<Annotation> bindings;
+
+ /**
+ * Protected constructor
+ *
+ * @param type An annotated class
+ * @param manager The Web Beans manager
+ */
+ protected NewManagedBeanBuilder(final WBClass<T> type, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.add(new NewLiteral()
+ {
+
+ public Class<?> value()
+ {
+ return type.getJavaClass();
+ }
+
+ });
+ }
+
+ /**
+ * Gets the scope type
+ *
+ * @return @Dependent
+ */
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ /**
+ * Gets the name of the bean
+ *
+ * @return null
+ */
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the bindings
+ *
+ * @returns @New
+ */
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return bindings;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ public NewManagedBean<T> createBean()
+ {
+ return NewManagedBean.of(
+ getAnnotatedItem(),
+ getManager(),
+ name,
+ getMergedStereotypes(),
+ getScope(),
+ isAlternative(),
+ isAlternative(),
+ bindings,
+ getSuperclasses(),
+ getProxyClassForDecorators(),
+ getDecorators(),
+ getPostConstruct(),
+ getPreDestroy(),
+ getSpecializedBean());
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/NewSessionBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.NewSessionBean;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.literal.NewLiteral;
+import org.jboss.webbeans.resources.ClassTransformer;
+
+/**
+ * Represents a @New enterprise bean
+ *
+ * @author Nicklas Karlsson
+ */
+class NewSessionBeanBuilder<T> extends SessionBeanBuilder<T>
+{
+
+ /**
+ * Creates an instance of a NewEnterpriseBean from an annotated class
+ *
+ * @param clazz The annotated class
+ * @param manager The Web Beans manager
+ * @return a new NewEnterpriseBean instance
+ */
+ public static <T> NewSessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+ return new NewSessionBeanBuilder<T>(type, ejbDescriptor, manager);
+ }
+
+ private Set<Annotation> bindings;
+
+ /**
+ * Protected constructor
+ *
+ * @param type An annotated class
+ * @param manager The Web Beans manager
+ */
+ protected NewSessionBeanBuilder(final WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ super(type, ejbDescriptor, manager);
+ this.bindings = new HashSet<Annotation>();
+ this.bindings.add(new NewLiteral()
+ {
+
+ public Class<?> value()
+ {
+ return type.getJavaClass();
+ }
+
+ });
+ }
+
+ /**
+ * Gets the scope type
+ *
+ * @return @Dependent
+ */
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ /**
+ * Gets the name of the bean
+ *
+ * @return null
+ */
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ /**
+ * Gets the bindings
+ *
+ * @returns @New
+ */
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return bindings;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ protected void checkScopeAllowed()
+ {
+ // No-op
+ }
+
+ @Override
+ public NewSessionBean<T> createBean()
+ {
+ return NewSessionBean.of(getEjbDescriptor(),
+ getManager(),
+ name,
+ types,
+ getMergedStereotypes(),
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings,
+ getSuperclasses(),
+ getProxyClassForDecorators(),
+ getDecorators(),
+ getPostConstruct(),
+ getPreDestroy(),
+ getProxyClass(),
+ getSpecializedBean());
+ }
+
+
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerFieldBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerFieldBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerFieldBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,223 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.Collections;
+import java.util.Set;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.ProducerField;
+import org.jboss.webbeans.bean.ee.EEResourceProducerField;
+import org.jboss.webbeans.bean.ee.PersistenceContextProducerField;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.EJBApiAbstraction;
+import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
+import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.ws.WSApiAbstraction;
+
+/**
+ * Represents a producer field
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+class ProducerFieldBuilder<T> extends AbstractProducerBeanBuilder<T, Field>
+{
+ // The underlying field
+ private WBField<T, ?> field;
+ private final String id;
+
+ /**
+ * Creates a producer field
+ *
+ * @param field The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer field
+ */
+ public static <T> ProducerFieldBuilder<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new ProducerFieldBuilder<T>(field, declaringBean, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param method The producer field abstraction
+ * @param declaringBean The declaring bean
+ * @param manager The Web Beans manager
+ */
+ protected ProducerFieldBuilder(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(declaringBean, manager);
+ this.field = field;
+ initType();
+ initTypes();
+ initBindings();
+ this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-"+ field.getName());
+ initStereotypes();
+ initPolicy();
+ }
+
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ }
+ }
+
+ /**
+ * Gets the annotated item representing the field
+ *
+ * @return The annotated item
+ */
+ @Override
+ public WBField<T, ?> getAnnotatedItem()
+ {
+ return field;
+ }
+
+ /**
+ * Returns the default name
+ *
+ * @return The default name
+ */
+ @Override
+ protected String getDefaultName()
+ {
+ return field.getPropertyName();
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Annotated " + Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed producer field bean");
+ }
+ else
+ {
+ buffer.append("simple producer field bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isSpecializing()
+ {
+ return false;
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public ProducerField<T> createBean()
+ {
+ if (isPersistenceContextProducerField(field))
+ {
+ return PersistenceContextProducerField.of(field,
+ getDeclaringBean(),
+ manager,
+ name,
+ type,
+ types,
+ getMergedStereotypes(), //Should be empty?
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings);
+
+ }
+ else if (isEEResourceProducerField(field))
+ {
+ return EEResourceProducerField.of(field,
+ getDeclaringBean(),
+ manager,
+ name,
+ type,
+ types,
+ getMergedStereotypes(), //Should be empty?
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings);
+ }
+ else
+ {
+ return ProducerField.of(field,
+ getDeclaringBean(),
+ manager,
+ name,
+ type,
+ types,
+ getMergedStereotypes(), //Should be empty?
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings);
+ }
+ }
+
+ private Set<Class<? extends Annotation>> createEmptyStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ protected boolean isPersistenceContextProducerField(WBField<?, ?> field)
+ {
+ PersistenceApiAbstraction persistenceApiAbstraction = getManager().getServices().get(PersistenceApiAbstraction.class);
+ return field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_CONTEXT_ANNOTATION_CLASS);
+ }
+
+ protected boolean isEEResourceProducerField(WBField<?, ?> field)
+ {
+ EJBApiAbstraction ejbApiAbstraction = getManager().getServices().get(EJBApiAbstraction.class);
+ PersistenceApiAbstraction persistenceApiAbstraction = getManager().getServices().get(PersistenceApiAbstraction.class);
+ WSApiAbstraction wsApiAbstraction = getManager().getServices().get(WSApiAbstraction.class);
+ return field.isAnnotationPresent(ejbApiAbstraction.EJB_ANNOTATION_CLASS) || field.isAnnotationPresent(ejbApiAbstraction.RESOURCE_ANNOTATION_CLASS) || field.isAnnotationPresent(persistenceApiAbstraction.PERSISTENCE_UNIT_ANNOTATION_CLASS) || field.isAnnotationPresent(wsApiAbstraction.WEB_SERVICE_REF_ANNOTATION_CLASS);
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/ProducerMethodBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,280 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.CreationException;
+import javax.enterprise.inject.Disposes;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractBean;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.DisposalMethod;
+import org.jboss.webbeans.bean.ProducerMethod;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.MethodInjectionPoint;
+import org.jboss.webbeans.injection.ParameterInjectionPoint;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.introspector.WBParameter;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
+import org.jboss.webbeans.util.Names;
+
+/**
+ * Represents a producer method bean
+ *
+ * @author Pete Muir
+ *
+ * @param <T>
+ */
+class ProducerMethodBuilder<T> extends AbstractProducerBeanBuilder<T, Method>
+{
+ // The underlying method
+ private MethodInjectionPoint<T, ?> method;
+
+ private DisposalMethod<?> disposalMethodBean;
+
+ private ProducerMethod<?> specializedBean;
+
+ private final String id;
+
+ /**
+ * Creates a producer method Web Bean
+ *
+ * @param method The underlying method abstraction
+ * @param declaringBean The declaring bean abstraction
+ * @param manager the current manager
+ * @return A producer Web Bean
+ */
+ public static <T> ProducerMethodBuilder<T> of(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ return new ProducerMethodBuilder<T>(method, declaringBean, manager);
+ }
+
+ protected ProducerMethodBuilder(WBMethod<T, ?> method, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ {
+ super(declaringBean, manager);
+ this.method = MethodInjectionPoint.of(this, method);
+ initType();
+ initTypes();
+ initBindings();
+ this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
+ initStereotypes();
+ initPolicy();
+ }
+
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ initProducerMethodInjectableParameters();
+ super.initialize(environment);
+ checkProducerMethod();
+ initDisposalMethod(environment);
+ }
+ }
+
+ /**
+ * Initializes the injection points
+ */
+ protected void initProducerMethodInjectableParameters()
+ {
+ for (WBParameter<?, ?> parameter : method.getWBParameters())
+ {
+ addInjectionPoint(ParameterInjectionPoint.of(this, parameter));
+ }
+ }
+
+ /**
+ * Validates the producer method
+ */
+ protected void checkProducerMethod()
+ {
+ if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
+ {
+ throw new DefinitionException("Producer method cannot have parameter annotated @Observes");
+ }
+ else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
+ {
+ throw new DefinitionException("Producer method cannot have parameter annotated @Disposes");
+ }
+ else if (getDeclaringBean() instanceof SessionBean<?>)
+ {
+ boolean methodDeclaredOnTypes = false;
+ // TODO use annotated item?
+ for (Type type : getDeclaringBean().getTypes())
+ {
+ if (type instanceof Class)
+ {
+ Class<?> clazz = (Class<?>) type;
+ try
+ {
+ clazz.getDeclaredMethod(getAnnotatedItem().getName(), getAnnotatedItem().getParameterTypesAsArray());
+ methodDeclaredOnTypes = true;
+ }
+ catch (NoSuchMethodException nsme)
+ {
+ // No - op
+ }
+ }
+ }
+ if (!methodDeclaredOnTypes)
+ {
+ throw new DefinitionException("Producer method " + toString() + " must be declared on a business interface of " + getDeclaringBean());
+ }
+ }
+ }
+
+ /**
+ * Initializes the remove method
+ */
+ protected void initDisposalMethod(BeanDeployerEnvironment environment)
+ {
+ Set<DisposalMethod<?>> disposalBeans = environment.resolveDisposalBeans(getTypes(), getQualifiers(), getDeclaringBean());
+
+ if (disposalBeans.size() == 1)
+ {
+ this.disposalMethodBean = disposalBeans.iterator().next();
+ }
+ else if (disposalBeans.size() > 1)
+ {
+ // TODO List out found disposal methods
+ throw new DefinitionException("Cannot declare multiple disposal methods for this producer method. Producer method: " + this + ". Disposal methods: " + disposalBeans);
+ }
+ }
+
+ /**
+ * Gets the annotated item representing the method
+ *
+ * @return The annotated item
+ */
+ @Override
+ public WBMethod<T, ?> getAnnotatedItem()
+ {
+ return method;
+ }
+
+ /**
+ * Returns the default name
+ *
+ * @return The default name
+ */
+ @Override
+ protected String getDefaultName()
+ {
+ return method.getPropertyName();
+ }
+
+ /**
+ * Returns the disposal method
+ *
+ * @return The method representation
+ */
+ public DisposalMethod<?> getDisposalMethod()
+ {
+ return disposalMethodBean;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(Names.scopeTypeToString(getScope()));
+ if (getName() == null)
+ {
+ buffer.append("unnamed producer method bean");
+ }
+ else
+ {
+ buffer.append("simple producer method bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getBeanClass().getName() + "] for class type [" + getType().getName() + "] API types " + getTypes() + ", binding types " + getQualifiers());
+ return buffer.toString();
+ }
+
+ @Override
+ public AbstractBean<?, ?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ if (getDeclaringBean().getAnnotatedItem().getWBSuperclass().getDeclaredWBMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+ {
+ throw new DefinitionException("Specialized producer method does not override a method on the direct superclass");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ WBMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWBSuperclass().getWBMethod(getAnnotatedItem().getAnnotatedMethod());
+ if (environment.getProducerMethod(superClassMethod) == null)
+ {
+ throw new IllegalStateException(toString() + " does not specialize a bean");
+ }
+ this.specializedBean = environment.getProducerMethod(superClassMethod);
+ }
+
+ @Override
+ public String getId()
+ {
+ return id;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public ProducerMethod<T> createBean()
+ {
+ return ProducerMethod.of(method,
+ getDeclaringBean(),
+ manager,
+ name,
+ type,
+ types,
+ getMergedStereotypes(),
+ scopeType,
+ isAlternative(),
+ isProxyable(),
+ bindings,
+ disposalMethodBean,
+ specializedBean);
+ }
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/RIBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.injection.WBInjectionPoint;
+
+/**
+ * Abstract base class with functions specific to RI built-in beans
+ *
+ * @author Pete Muir
+ */
+abstract class RIBeanBuilder<T> implements Bean<T>
+{
+
+ private static final ConcurrentMap<String, AtomicInteger> ids = new ConcurrentHashMap<String, AtomicInteger>();
+
+ private final BeanManagerImpl manager;
+
+ protected RIBeanBuilder(BeanManagerImpl manager)
+ {
+ this.manager = manager;
+ // TODO better ID strategy (human readable)
+ }
+
+ protected static String createId(String prefix)
+ {
+ ids.putIfAbsent(prefix, new AtomicInteger());
+ int i = ids.get(prefix).getAndIncrement();
+ return prefix + "-" + i;
+ }
+
+ protected BeanManagerImpl getManager()
+ {
+ return manager;
+ }
+
+ public abstract Class<T> getType();
+
+ public Class<?> getBeanClass()
+ {
+ return getType();
+ }
+
+ public abstract void initialize(BeanDeployerEnvironment environment);
+
+ public abstract boolean isSpecializing();
+
+ public boolean isDependent()
+ {
+ return getScope().equals(Dependent.class);
+ }
+
+ public abstract boolean isProxyable();
+
+ public abstract boolean isPrimitive();
+
+ public abstract Set<WBInjectionPoint<?, ?>> getAnnotatedInjectionPoints();
+
+ @SuppressWarnings("unchecked")
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return (Set) getAnnotatedInjectionPoints();
+ }
+
+ public abstract RIBean<?> getSpecializedBean();
+
+ public abstract String getId();
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof RIBeanBuilder)
+ {
+ RIBeanBuilder<?> that = (RIBeanBuilder<?>) obj;
+ return this.getId().equals(that.getId());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return getId().hashCode();
+ }
+
+ public abstract RIBean<T> createBean();
+}
Added: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java (rev 0)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/SessionBeanBuilder.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -0,0 +1,350 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.bean.builder;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javassist.util.proxy.ProxyFactory;
+
+import javax.decorator.Decorator;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.interceptor.Interceptor;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.DefinitionException;
+import org.jboss.webbeans.bean.AbstractClassBean;
+import org.jboss.webbeans.bean.SessionBean;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
+import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
+import org.jboss.webbeans.ejb.InternalEjbDescriptor;
+import org.jboss.webbeans.ejb.api.SessionObjectReference;
+import org.jboss.webbeans.ejb.spi.BusinessInterfaceDescriptor;
+import org.jboss.webbeans.ejb.spi.EjbServices;
+import org.jboss.webbeans.introspector.WBClass;
+import org.jboss.webbeans.introspector.WBMethod;
+import org.jboss.webbeans.resources.ClassTransformer;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
+
+/**
+ * An enterprise bean representation
+ *
+ * @author Pete Muir
+ *
+ * @param <T> The type (class) of the bean
+ */
+class SessionBeanBuilder<T> extends AbstractClassBeanBuilder<T>
+{
+ // The EJB descriptor
+ private InternalEjbDescriptor<T> ejbDescriptor;
+
+ private Class<T> proxyClass;
+
+ private SessionBean<?> specializedBean;
+
+ /**
+ * Creates a simple, annotation defined Enterprise Web Bean
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param manager the current manager
+ * @return An Enterprise Web Bean
+ */
+ public static <T> SessionBeanBuilder<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ WBClass<T> type = manager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
+ return new SessionBeanBuilder<T>(type, ejbDescriptor, manager);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param type The type of the bean
+ * @param manager The Web Beans manager
+ */
+ protected SessionBeanBuilder(WBClass<T> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager)
+ {
+ super(type, manager);
+ initType();
+ this.ejbDescriptor = ejbDescriptor;
+ initTypes();
+ initBindings();
+ }
+
+ /**
+ * Initializes the bean and its metadata
+ */
+ @Override
+ public void initialize(BeanDeployerEnvironment environment)
+ {
+ if (!isInitialized())
+ {
+ super.initialize(environment);
+ initProxyClass();
+ checkEJBTypeAllowed();
+ checkConflictingRoles();
+ checkObserverMethods();
+ checkScopeAllowed();
+ }
+ }
+
+ @Override
+ protected void initTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new LinkedHashSet<Type>();
+ types.add(Object.class);
+ for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
+ {
+ types.add(businessInterfaceDescriptor.getInterface());
+ }
+ super.types = types;
+ }
+
+ protected void initProxyClass()
+ {
+ Set<Type> types = new LinkedHashSet<Type>(getTypes());
+ types.add(EnterpriseBeanInstance.class);
+ types.add(Serializable.class);
+ ProxyFactory proxyFactory = Proxies.getProxyFactory(types);
+
+ Class<T> proxyClass = proxyFactory.createClass();
+
+ this.proxyClass = proxyClass;
+ }
+
+ /**
+ * Validates for non-conflicting roles
+ */
+ protected void checkConflictingRoles()
+ {
+ if (getType().isAnnotationPresent(Interceptor.class))
+ {
+ throw new DefinitionException("Enterprise beans cannot be interceptors");
+ }
+ if (getType().isAnnotationPresent(Decorator.class))
+ {
+ throw new DefinitionException("Enterprise beans cannot be decorators");
+ }
+ }
+
+ /**
+ * Check that the scope type is allowed by the stereotypes on the bean and
+ * the bean type
+ */
+ protected void checkScopeAllowed()
+ {
+ if (ejbDescriptor.isStateless() && !isDependent())
+ {
+ throw new DefinitionException("Scope " + getScope() + " is not allowed on stateless enterpise beans for " + getType() + ". Only @Dependent is allowed on stateless enterprise beans");
+ }
+ if (ejbDescriptor.isSingleton() && !(isDependent() || getScope().equals(ApplicationScoped.class)))
+ {
+ throw new DefinitionException("Scope " + getScope() + " is not allowed on singleton enterpise beans for " + getType() + ". Only @Dependent or @ApplicationScoped is allowed on singleton enterprise beans");
+ }
+ }
+
+ /**
+ * Validates specialization
+ */
+ @Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ super.preSpecialize(environment);
+ // We appear to check this twice?
+ if (!environment.getEjbDescriptors().contains(getAnnotatedItem().getWBSuperclass().getJavaClass()))
+ {
+ throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ if (environment.getClassBean(getAnnotatedItem().getWBSuperclass()) == null)
+ {
+ throw new IllegalStateException(toString() + " does not specialize a bean");
+ }
+ AbstractClassBean<?> specializedBean = environment.getClassBean(getAnnotatedItem().getWBSuperclass());
+ if (!(specializedBean instanceof SessionBean<?>))
+ {
+ throw new IllegalStateException(toString() + " doesn't have a session bean as a superclass " + specializedBean);
+ }
+ else
+ {
+ this.specializedBean = (SessionBean<?>) specializedBean;
+ }
+ }
+
+ /**
+ * Validates the bean type
+ */
+ private void checkEJBTypeAllowed()
+ {
+ if (ejbDescriptor.isMessageDriven())
+ {
+ throw new DefinitionException("Message Driven Beans can't be Web Beans");
+ }
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return The string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ // buffer.append("Annotated " + Names.scopeTypeToString(getScopeType()) +
+ // Names.ejbTypeFromMetaData(getEjbMetaData()));
+ if (getName() == null)
+ {
+ buffer.append(" unnamed enterprise bean");
+ }
+ else
+ {
+ buffer.append(" enterprise bean '" + getName() + "'");
+ }
+ buffer.append(" [" + getType().getName() + "] ");
+ buffer.append("API types " + getTypes() + ", binding types " + getQualifiers());
+ 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();
+ }
+
+ @Override
+ protected void initSerializable()
+ {
+ // No-op
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return true;
+ }
+
+ public InternalEjbDescriptor<T> getEjbDescriptor()
+ {
+ return ejbDescriptor;
+ }
+
+ public boolean isClientCanCallRemoveMethods()
+ {
+ return getEjbDescriptor().isStateful() && isDependent();
+ }
+
+ @Override
+ public SessionBean<?> getSpecializedBean()
+ {
+ return specializedBean;
+ }
+
+ /**
+ * If there are any observer methods, they must be static or business
+ * methods.
+ */
+ protected void checkObserverMethods()
+ {
+ for (WBMethod<?, ?> method : this.annotatedItem.getWBDeclaredMethodsWithAnnotatedParameters(Observes.class))
+ {
+ if (!method.isStatic())
+ {
+ if (!isMethodExistsOnTypes(method))
+ {
+ throw new DefinitionException("Observer method must be static or business method: " + method + " on " + getAnnotatedItem());
+ }
+ }
+ }
+ }
+
+ // TODO must be a nicer way to do this!
+ public boolean isMethodExistsOnTypes(WBMethod<?, ?> method)
+ {
+ for (Type type : getTypes())
+ {
+ if (type instanceof Class)
+ {
+ for (Method m : ((Class<?>) type).getMethods())
+ {
+ if (method.getName().equals(m.getName()) && Arrays.equals(method.getParameterTypesAsArray(), m.getParameterTypes()))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public SessionObjectReference createReference()
+ {
+ return manager.getServices().get(EjbServices.class).resolveEjb(getEjbDescriptor().delegate());
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public Class<T> getProxyClass()
+ {
+ return proxyClass;
+ }
+
+ @Override
+ public SessionBean<T> createBean()
+ {
+ return SessionBean.of(getEjbDescriptor(),
+ getManager(),
+ name,
+ types,
+ getMergedStereotypes(),
+ getScope(),
+ isAlternative(),
+ isProxyable(),
+ bindings,
+ getSuperclasses(),
+ getProxyClassForDecorators(),
+ getDecorators(),
+ getPostConstruct(),
+ getPreDestroy(),
+ getProxyClass(),
+ getSpecializedBean());
+ }
+}
+
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/EEResourceProducerField.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -16,12 +16,18 @@
*/
package org.jboss.webbeans.bean.ee;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.util.Set;
+
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.ProducerField;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.ejb.EJBApiAbstraction;
import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
import org.jboss.webbeans.persistence.PersistenceApiAbstraction;
import org.jboss.webbeans.ws.WSApiAbstraction;
@@ -40,14 +46,34 @@
* @param manager the current manager
* @return A producer field
*/
- public static <T> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ public static <T> EEResourceProducerField<T> of(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- return new EEResourceProducerField<T>(field, declaringBean, manager);
+ return new EEResourceProducerField<T>(field, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
}
- protected EEResourceProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ protected EEResourceProducerField(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(field, declaringBean, manager);
+ super(field, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
}
@Override
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/ee/PersistenceContextProducerField.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -16,11 +16,17 @@
*/
package org.jboss.webbeans.bean.ee;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+import java.util.Set;
+
import javax.persistence.EntityManager;
import org.jboss.webbeans.BeanManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.introspector.WBField;
+import org.jboss.webbeans.metadata.cache.MergedStereotypes;
/**
* @author pmuir
@@ -37,9 +43,19 @@
* @param manager the current manager
* @return A producer field
*/
- public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ public static <T extends EntityManager> EEResourceProducerField<T> of(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- return new PersistenceContextProducerField<T>(field, declaringBean, manager);
+ return new PersistenceContextProducerField<T>(field, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
}
/**
@@ -47,9 +63,19 @@
* @param declaringBean
* @param manager
*/
- protected PersistenceContextProducerField(WBField<T, ?> field, AbstractClassBean<?> declaringBean, BeanManagerImpl manager)
+ protected PersistenceContextProducerField(WBField<T, ?> field,
+ AbstractClassBean<?> declaringBean,
+ BeanManagerImpl manager,
+ String name,
+ Class<T> type,
+ Set<Type> types,
+ MergedStereotypes<T, Field> mergedStereotypes,
+ Class<? extends Annotation> scopeType,
+ boolean policy,
+ boolean proxyable,
+ Set<Annotation> bindings)
{
- super(field, declaringBean, manager);
+ super(field, declaringBean, manager, name, type, types, mergedStereotypes, scopeType, policy, proxyable, bindings);
}
public void dispose(T instance)
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/util/Reflections.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -302,6 +302,8 @@
*/
public static boolean isPrimitive(Class<?> type)
{
+ if (type == null)
+ throw new NullPointerException();
return type.isPrimitive();
}
Modified: ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java
===================================================================
--- ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-21 04:37:58 UTC (rev 3712)
+++ ri/branches/kabir-builder/tests/src/test/java/org/jboss/webbeans/test/unit/deployment/structure/AccessibleManagerResolutionTest.java 2009-09-21 16:33:40 UTC (rev 3713)
@@ -8,6 +8,8 @@
import org.jboss.webbeans.ContextualIdStore;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.ManagedBean;
+import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
+import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -38,10 +40,9 @@
private void addBean(BeanManagerImpl manager, Class<?> c)
{
WBClass<?> clazz = WBClassImpl.of(c, classTransformer);
- RIBean<?> bean = ManagedBean.of(clazz, manager);
+ SimpleBeanBuilder<?> builder = BeanBuilderFactory.getInstance().getSimpleBeanBuilder(manager, clazz);
+ Bean<?> bean = builder.getBean();
manager.addBean(bean);
- BeanDeployerEnvironment environment = new BeanDeployerEnvironment(new EjbDescriptors(), manager);
- bean.initialize(environment);
}
@Test
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3712 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-09-21 00:37:58 -0400 (Mon, 21 Sep 2009)
New Revision: 3712
Modified:
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
section 6 assertions
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 03:43:31 UTC (rev 3711)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 04:37:58 UTC (rev 3712)
@@ -2670,10 +2670,14 @@
<assertion id="e">
<text>Contexts with normal scopes must obey the following rule: Suppose beans A, B and Z all have normal scopes. Suppose A has an injection point x, and B has an injection point y. Suppose further that both x and y resolve to bean Z according to the typesafe resolution algorithm. If a is the current instance of A, and b is the current instance of B, then both a.x and b.y refer to the same instance of Z. This instance is the current instance of Z.</text>
+ </assertion>
+
+ <assertion id="ea">
+ <text>All normal scopes must be explicitly declared |@NormalScope|, to indicate to the container that a client proxy is required.</text>
</assertion>
- <assertion id="f" testable="false">
- <text>All pseudo-scopes must be explicitly declared |@ScopeType(normal=false)|, to indicate to the container that no client proxy is required</text>
+ <assertion id="fa" testable="false">
+ <text>All pseudo-scopes must be explicitly declared |@Scope|, to indicate to the container that no client proxy is required.</text>
<note>A statement of intent</note>
</assertion>
@@ -2685,15 +2689,15 @@
<section id="6.4" title="Dependent pseudo-scope">
<assertion id="a">
- <text>When a bean is declared to have |@Dependent| scope, no injected instance of the bean is ever shared between multiple injection points</text>
+ <text>When a bean is declared to have |@Dependent| scope, no injected instance of the bean is ever shared between multiple injection points.</text>
</assertion>
<assertion id="b">
- <text>When a bean is declared to have |@Dependent| scope, any injected instance of the bean is bound to the lifecycle of the bean, servlet or EJB into which it is injected</text>
+ <text>When a bean is declared to have |@Dependent| scope, any injected instance of the bean is bound to the lifecycle of the bean, servlet or EJB into which it is injected.</text>
</assertion>
- <assertion id="c">
- <text>When a bean is declared to have |@Dependent| scope, any instance of the bean that is used to evaluate a Unified EL expression exists to service that evaluation only</text>
+ <assertion id="ca">
+ <text>When a bean is declared to have |@Dependent| scope, when a unified EL expression in a JSF or JSP page that refers to the bean by its EL name is evaluated, at most one instance of the bean is instantiated. This instance exists to service just a single evaluation of the EL expression. It is reused if the bean EL name appears multiple times in the EL expression, but is never reused when the EL expression is evaluated again, or when another EL expression is evaluated.</text>
</assertion>
<assertion id="da">
@@ -2813,13 +2817,23 @@
<assertion id="eee">
- <text>The container must ensure that all |@Dependent| scoped contextual instances created during an EL expression evaluation are destroyed when the evaluation completes.</text>
+ <text>The container must ensure that all |@Dependent| scoped contextual instances created during evaluation of a Unified EL expression in a JSP or JSF page are destroyed when the evaluation completes.</text>
</assertion>
<assertion id="e" testable="false">
- <text>The container is permitted to destroy any |@Dependent| scoped contextual instance at any time if the instance is no longer referenced by the application (excluding weak, soft and phantom references)</text>
+ <text>The container is permitted to destroy any |@Dependent| scoped contextual instance at any time if the instance is no longer referenced by the application (excluding weak, soft and phantom references).</text>
<note>In other words this is unspecified</note>
</assertion>
+ </section>
+
+ <section id="6.4.3" title="Dependent pseudo-scope and Unified EL">
+ <assertion id="a">
+ <text>Suppose a Unified EL expression in a JSF or JSP page refers to a bean with scope |@Dependent| by its EL name. Each time the EL expression is evaluated the bean is instantiated at most once, and the resulting instance is reused for every appearance of the EL name, and the resulting instance is destroyed when the evaluation completes.</text>
+ </assertion>
+
+ <assertion id="b">
+ <text>Portable extensions that integrate with the container via Unified EL should also ensure that these rules are enforced.</text>
+ </assertion>
</section>
<section id="6.5" title="Contextual instances and contextual references">
@@ -2873,7 +2887,7 @@
</assertion>
<assertion id="d">
- <text>The container must ensure that every injection point of type |InjectionPoint| and binding |@Current| of any dependent object instantiated during this process receives an instance of |InjectionPoint| representing the injection point into which the dependent object will be injected, or a null value if it is not being injected into any injection point.</text>
+ <text>The container must ensure that every injection point of type |InjectionPoint| and binding |@Default| of any dependent object instantiated during this process receives an instance of |InjectionPoint| representing the injection point into which the dependent object will be injected, or a null value if it is not being injected into any injection point.</text>
</assertion>
</section>
@@ -2921,7 +2935,11 @@
</group>
<group>
- <text>A producer method is passivation capable if and only if it never returns a value which is not passivation capable at runtime. A producer method with a return type that implements or extends serializable is passivation capable. A producer method with a return type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
+ <text>A producer method is passivation capable if and only if it never returns a value which is not passivation capable at runtime. A producer method with a primitive return type or a return type that implements or extends serializable is passivation capable. A producer method with a return type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
+
+ <assertion id="caa">
+ <text>Test that a producer method with a primitive return type is passivation capable.</text>
+ </assertion>
<assertion id="ca">
<text>Test that a producer method with a serializable return type is passivation capable.</text>
@@ -2933,7 +2951,11 @@
</group>
<group>
- <text>A producer field is passivation capable if and only if it never refers to a value which is not passivation capable at runtime. A producer field with a type that implements or extends |Serializable| is passivation capable. A producer field with a type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
+ <text>A producer field is passivation capable if and only if it never refers to a value which is not passivation capable at runtime. A producer field with a primitive type or a type that implements or extends |Serializable| is passivation capable. A producer field with a type that is declared |final| and does not implement |Serializable| is not passivation capable.</text>
+
+ <assertion id="daa">
+ <text>Test that a producer field with a primitive type is passivation capable.</text>
+ </assertion>
<assertion id="da">
<text>Test that a producer field with a serializable type is passivation capable.</text>
@@ -2961,7 +2983,9 @@
<text>The |getId()| ~method of the |PassivationCapable| implementation must return a value that uniquely identifies the instance of |Bean| or |Contextual|. It~ is recommended that the string contain the package name of the class that implements |Bean| or |Contextual|.</text>
<note>Recommendation only</note>
</assertion>
- </section><section id="6.6.2" title="Passivation capable dependencies">
+ </section>
+
+ <section id="6.6.2" title="Passivation capable dependencies">
<assertion id="a">
<text>The container must guarantee that all session beans are passivation capable dependencies.</text>
</assertion>
@@ -3001,7 +3025,7 @@
</group>
<assertion id="b" testable="false">
- <text>Passivating scopes must be explicitly declared |@ScopeType(passivating=true)|.</text>
+ <text>Passivating scopes must be explicitly declared |@NormalScope(passivating=true)|.</text>
<note>A statement of intent</note>
</assertion>
</section>
@@ -3462,7 +3486,7 @@
<section id="6.7.5" title="The Conversation interface">
<group>
- <text>The container provides a built-in bean with bean type |Conversation|, scope |@RequestScoped|, and binding |@Current|, named |javax.enterprise.context.conversation|.</text>
+ <text>The container provides a built-in bean with bean type |Conversation|, scope |@RequestScoped|, and binding |@Default|, named |javax.enterprise.context.conversation|.</text>
<assertion id="iaa">
<text>Test the bean type is correct.</text>
</assertion>
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3711 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-09-20 23:43:31 -0400 (Sun, 20 Sep 2009)
New Revision: 3711
Modified:
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
section 5 assertions
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 02:47:18 UTC (rev 3710)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 03:43:31 UTC (rev 3711)
@@ -1864,25 +1864,27 @@
</section>
- <section id="5.2" title="Policy enablement">
+ <section id="5.2" title="Alternative selection">
<assertion id="a">
- <text>A policy is never available for injection, lookup or EL resolution in a Java EE module or library that is not a bean deployment archive (a module or library with no beans.xml file).</text>
+ <text>An alternative is never available for injection, lookup or EL resolution in a Java EE module or library that is not a bean deployment archive (a module or library with no |beans.xml| file).</text>
</assertion>
<assertion id="b">
- <text>Nor is a policy available for injection, lookup or EL resolution in every bean deployment archive. A policy must be explicitly enabled in every bean deployment archive in which the policy should be available for injection, lookup and EL resolution.</text>
+ <text>Nor is an alternative available for injection, lookup or EL resolution in every bean deployment archive. An alternative must be explicitly selected in every bean deployment archive in which the alternative should be available for injection, lookup and EL resolution.</text>
</assertion>
-
+ </section>
+
+ <section id="5.2.1" title="Declaring selected alternatives for a bean deployment archive">
<assertion id="c">
- <text>By default, a bean deployment archive has no enabled policies. A policy must be explicitly declared using the <policies> element of the |beans.xml| file of the bean deployment archive.</text>
+ <text>By default, a bean deployment archive has no selected alternatives. An alternative must be explicitly declared using the <alternatives> element of the |beans.xml| file of the bean deployment archive.</text>
</assertion>
<assertion id="d" testable="false">
- <text>The <policies> element contains a list of bean classes and stereotypes. </text>
+ <text>The <alternatives> element contains a list of bean classes and stereotypes. </text>
</assertion>
<group>
- <text>A policy is enabled for the bean deployment archive if the policy is a managed bean or session bean and the bean class of the bean is listed.</text>
+ <text>An alternative is selected for the bean deployment archive if the alternative is a managed bean or session bean and the bean class of the bean is listed.</text>
<assertion id="ea">
<text>Test with a managed bean.</text>
@@ -1894,7 +1896,7 @@
</group>
<group>
- <text>A policy is enabled for the bean deployment archive if the policy is a producer method, field or resource, and the bean class that declares the method or field is listed.</text>
+ <text>An alternative is selected for the bean deployment archive if the policy is a producer method, field or resource, and the bean class that declares the method or field is listed.</text>
<assertion id="fa">
<text>Test for enablement of a producer method and field.</text>
@@ -1906,11 +1908,11 @@
</group>
<assertion id="g">
- <text>A policy is enabled for the bean deployment archive if any |@Alternative| stereotype of the policy is listed.</text>
+ <text>An alternative is selected for the bean deployment archive if any |@Alternative| stereotype of the alternative is listed.</text>
</assertion>
<assertion id="h">
- <text>Each child <class> element must specify the name of a policy bean class. If there is no class with the specified name, or if the class with the specified name is not a policy bean class, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>Each child <class> element must specify the name of a alternative bean class. If there is no class with the specified name, or if the class with the specified name is not an alternative bean class, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
<assertion id="i">
@@ -1918,33 +1920,45 @@
</assertion>
<assertion id="j">
- <text>If the same type is listed twice under the <policies> element, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If the same type is listed twice under the <alternatives> element, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
<assertion id="k">
- <text>For a custom implementation of the |Bean| interface defined in Section 11.1, "The Bean interface", the container calls |isPolicy()| to determine whether the bean is a policy, and |getBeanClass()| and |getStereotypes()| to determine whether a policy is enabled in a certain bean deployment archive.</text>
+ <text>For a custom implementation of the |Bean| interface defined in Section 11.1, "The Bean interface", the container calls |isAlternative()| to determine whether the bean is an alternative, and |getBeanClass()| and |getStereotypes()| to determine whether an alternative is selected in a certain bean deployment archive.</text>
</assertion>
-
- <assertion id="l" testable="false">
- <text>A bean is said to be enabled if it is not a policy, or if it is enabled in at least one bean deployment archive.</text>
+ </section>
+
+ <section id="5.2.2" title="Enabled and disabled beans">
+ <assertion id="a">
+ <text>A bean is said to be enabled if it is not a producer method or field of a disabled bean, and it is not specialized by any other enabled bean, and either it is not an alternative, or it is a selected alternative of at least one bean deployment archive. Otherwise, the bean is said to be disabled.</text>
</assertion>
+ </section>
+
+ <section id="5.2.3" title="Inconsistent specialization">
+ <assertion id="a">
+ <text>Suppose an enabled bean X specializes a second bean Y. If there is another enabled bean that specializes Y we say that inconsistent specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ </assertion>
</section>
- <section id="5.3" title="Typesafe resolution">
+ <section id="5.3" title="Typesafe resolution">
+ <assertion id="a">
+ <text>A bean is eligible for injection into a given class if the bean is enabled, and the bean is either not an alternative, or is a selected alternative of the bean deployment archive of the given class, and in a Java EE or servlet container, the bean class is required to be accessible to the given class, according to the class loading requirements of the Java EE platform and Java Servlet specifications.</text>
+ </assertion>
+
<assertion id="hq">
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not _interceptors_ or decorators and which have a bean type that matches the required type.</text>
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not _interceptors_ or decorators and which have a bean type that matches the required type.</text>
</assertion>
<assertion id="hb">
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or _decorators_ and which have a bean type that matches the required type.</text>
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or _decorators_ and which have a bean type that matches the required type.</text>
</assertion>
<assertion id="hc">
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have a _bean type that matches the required type_.</text>
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have a _bean type that matches the required type_.</text>
</assertion>
<group>
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have a bean type that matches the required type. For this purpose, primitive types are considered to match their corresponding wrapper types in |java.lang| and array types are considered to match only if their element types are identical. Parameterized and raw types are considered to match if they are identical or if the bean type is assignable to the required type, as defined in Section 5.3.3, "Assignability of raw and parameterized types".</text>
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have a bean type that matches the required type. For this purpose, primitive types are considered to match their corresponding wrapper types in |java.lang| and array types are considered to match only if their element types are identical. Parameterized and raw types are considered to match if they are identical or if the bean type is assignable to the required type, as defined in Section 5.3.3, "Assignability of raw and parameterized types".</text>
<assertion id="i">
<text>Test with a primitive type.</text>
@@ -1964,38 +1978,38 @@
</group>
<group>
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have the required bindings. If no required bindings were explicitly specified, the container assumes the required binding |@Current|. The container narrows the set of matching beans to just those where for each required binding, the bean declares a matching binding with (a) the same type and (b) the same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding| (see Section 5.3.5, "Binding annotations with members").</text>
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which have the required qualifiers. If no required qualifiers were explicitly specified, the container assumes the required binding |@Default|. The container narrows the set of matching beans to just those where for each required qualifier, the bean declares a matching qualifier with (a) the same type and (b) the same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding| (see Section 5.3.5, "Qualifier annotations with members").</text>
<assertion id="la">
- <text>Test with beans with required bindings.</text>
+ <text>Test with beans with required qualifiers.</text>
</assertion>
<assertion id="lb">
- <text>Test with beans without required bindings.</text>
+ <text>Test with beans without required qualifiers.</text>
</assertion>
<assertion id="lc">
- <text>Test with matching beans with matching binding with same type.</text>
+ <text>Test with matching beans with matching qualifier with same type.</text>
</assertion>
<assertion id="ld">
- <text>Test with matching beans with matching binding with same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding|.</text>
+ <text>Test with matching beans with matching qualifier with same annotation member value for each member which is not annotated |(a)javax.enterprise.inject.NonBinding|.</text>
</assertion>
</group>
- <assertion id="m">
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators. In a Java EE or servlet container, the bean class is required to be accessible to the class that declares the injection point, according to the class loading requirements of the Java EE platform and Java Servlet specifications.</text>
+ <assertion id="n">
+ <text>When determining the set of beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are eligible for injection into the class that declares the injection point.</text>
</assertion>
<group>
- <text>When resolving beans that are eligible for injection to an injection point, the container identifies the set of matching beans which are not interceptors or decorators and which are not a policy, or is an enabled policy of the bean deployment archive of the class that declares the injection point. For a custom implementation of the |Bean| interface defined in Section 11.1, "The Bean interface", the container calls |getTypes()| and |getQualifiers()| to determine the bean types and bindings.</text>
+ <text>For a custom implementation of the |Bean| interface defined in Section 11.1, "The Bean interface", the container calls |getTypes()| and |getQualifiers()| to determine the bean types and bindings.</text>
<assertion id="na">
<text>Test |getTypes()| determines bean types.</text>
</assertion>
<assertion id="nb">
- <text>Test |getQualifiers()| determines bindings.</text>
+ <text>Test |getQualifiers()| determines qualifiers.</text>
</assertion>
</group>
</section>
@@ -2073,47 +2087,51 @@
</assertion>
</section>
- <section id="5.3.5" title="Binding annotations with members">
+ <section id="5.3.5" title="Qualifier annotations with members">
<assertion id="a" testable="false">
- <text>Binding types with members are supported</text>
+ <text>Qualifier types with members are supported</text>
<note>A statement of intent</note>
</assertion>
<assertion id="b">
- <text>An annotation member may be excluded from consideration using the |@NonBinding| annotation</text>
+ <text>An annotation member may be excluded from consideration using the |@NonBinding| annotation.</text>
</assertion>
+
+ <group>
+ <text>Array-valued or annotation-valued members of a qualifier type must be annotated |@NonBinding| in a portable application. If an array-valued or annotation-valued member of a binding type is not annotated |@NonBinding|, non-portable behavior results.</text>
+
+ <assertion id="d">
+ <text>Test with an array-valued member.</text>
+ </assertion>
- <assertion id="ca">
- <text>Array-valued ~or annotation-valued~ members of a binding type must be annotated |@NonBinding|. If an array-valued ~or annotation-valued~ member of a binding type is not annotated |@NonBinding|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
-
- <assertion id="cb">
- <text>~Array-valued or ~annotation-valued members of a binding type must be annotated |@NonBinding|. If an ~array-valued or ~annotation-valued member of a binding type is not annotated |@NonBinding|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
+ <assertion id="e">
+ <text>Test with an annotation-valued member.</text>
+ </assertion>
+ </group>
</section>
- <section id="5.3.6" title="Multiple bindings">
+ <section id="5.3.6" title="Multiple qualifiers">
<assertion id="a">
- <text>A bean class may declare multiple bindings</text>
+ <text>A bean class may declare multiple qualifiers.</text>
</assertion>
<assertion id="b">
- <text>A producer method may declare multiple bindings</text>
+ <text>A producer method may declare multiple qualifiers.</text>
</assertion>
<assertion id="c">
- <text>A producer field may declare multiple bindings</text>
+ <text>A producer field may declare multiple qualifiers.</text>
</assertion>
<assertion id="d">
- <text>A bean must declare all of the bindings that are specified at the injection point to be considered a candidate for injection</text>
+ <text>A bean must declare all of the qualifiers that are specified at the injection point to be considered a candidate for injection.</text>
</assertion>
</section>
<section id="5.4" title="EL Name resolution">
- <assertion id="ba">
- <text>When resolving a bean by name, the container identifies the set of matching beans which have the given EL name, and are accessible to classes in the war containing the JSP or JSF page with the EL expression, according to the class loading requirements of the Java EE platform and Java Servlet specifications, and which are not a policy or an enabled policy of the war containing the JSP or JSF page with the EL expression.</text>
+ <assertion id="baa">
+ <text>When resolving a bean by name, the container identifies the set of matching beans which have the given EL name, and are enabled, and are either not an alternative, or is a selected alternative of the war containing the JSP or JSF page with the EL expression, and are accessible to classes in the war containing the JSP or JSF page with the EL expression, according to the class loading requirements of the Java EE platform and Java Servlet specifications, and which are not a policy or an enabled policy of the war containing the JSP or JSF page with the EL expression.</text>
</assertion>
<assertion id="e">
@@ -2122,16 +2140,16 @@
</section>
<section id="5.4.1" title="Ambiguous EL names">
- <assertion id="c">
- <text>An ambiguous EL name exists in an EL expression when there are multiple beans which match the given EL name. When an ambiguous EL name exists, the container attempts to resolve the ambiguity - if any matching beans are policies, the container eliminates all matching beans that are not policies. The container eliminates all matching beans that are specialized by some other matching bean. If there is exactly one bean remaining, the container will select this bean, and the ambiguous name is called resolvable.</text>
+ <assertion id="ca">
+ <text>An ambiguous EL name exists in an EL expression when there are multiple beans which match the given EL name. When an ambiguous EL name exists, the container attempts to resolve the ambiguity - if any matching beans are alternatives, the container eliminates all matching beans that are not alternatives.If there is exactly one bean remaining, the container will select this bean, and the ambiguous name is called resolvable.</text>
</assertion>
<assertion id="da">
- <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, according to the class loading requirements of the Java EE platform and Java Servlet specifications. If each bean is either not a policy, or is an enabled policy of the war, and either _the two beans have the same EL name and the name is not resolvable_, or the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is the EL name of the other bean, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, according to the class loading requirements of the Java EE platform and Java Servlet specifications. If each bean is either not an alternative, or is a selected alternative of the war, and either _the two beans have the same EL name and the name is not resolvable_, or the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is the EL name of the other bean, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
<assertion id="db">
- <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, according to the class loading requirements of the Java EE platform and Java Servlet specifications. If each bean is either not a policy, or is an enabled policy of the war, and either the two beans have the same EL name and the name is not resolvable, _or the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is the EL name of the other bean_, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>All unresolvable ambiguous EL names are detected by the container when the application is initialized. Suppose two beans are both accessible to classes in a certain war, according to the class loading requirements of the Java EE platform and Java Servlet specifications. If each bean is either not an alternative, or is a selected alternative of the war, and either the two beans have the same EL name and the name is not resolvable, _or the EL name of one bean is of the form x.y, where y is a valid bean EL name, and x is the EL name of the other bean_, the container automatically detects the problem and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
</section>
@@ -2303,11 +2321,11 @@
</assertion>
<assertion id="c">
- <text>When the container calls a producer method, if the method is non-static the container must determine the most specialized enabled bean that specializes the bean which declares the method, as defined in Section 4.3.2 "Most specializaed enabled bean for a bean", then obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
+ <text>When the container calls a producer method, if the method is non-static the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
</assertion>
<assertion id="d">
- <text>When the container calls a disposal method, if the method is non-static the container must determine the most specialized enabled bean that specializes the bean which declares the method, as defined in Section 4.3.2 "Most specializaed enabled bean for a bean", then obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
+ <text>When the container calls a disposal method, if the method is non-static the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then invoke the method upon this instance.</text>
</assertion>
<assertion id="e">
@@ -2321,7 +2339,7 @@
</assertion>
<assertion id="b">
- <text>When the container accesses the value of a producer field, if the producer field is non-static, the container must determine the most specialized enabled bean that specializes the bean which declares the producer field, as defined in Section 4.3.2 "Most specialized enabled bean for a bean", then obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then access the field value of this instance.</text>
+ <text>When the container accesses the value of a producer field, if the producer field is non-static, the container must obtain a contextual instance of the most specialized bean, as defined by Section 6.5.2 "Contextual instance of a bean", then access the field value of this instance.</text>
</assertion>
</section>
@@ -2330,8 +2348,8 @@
<text>When the container calls an observer method (defined in Section 10.4 "Observer methods"), if the observer method is static, the container must invoke the method.</text>
</assertion>
- <assertion id="ba">
- <text>When the container calls an observer method (defined in Section 10.5 "Observer methods"), if the observer method is non-static, the container must determine the most specialized enabled bean that specializes the bean which declares the observer method, as defined in Section 4.3.2 "Most specialized enabled bean for a bean", then obtain a contextual instance of the bean according to Section 6.5.2 "Contextual instance of a bean". If this observer method is a conditional observer method, obtain the contextual instance that already exists, without creating a new contextual instance. Finally, the container must invoke the observer method on the resulting instance, if any, as a business method invocation, as defined in Section 7.2 "Container invocations and interception".</text>
+ <assertion id="baa">
+ <text>When the container calls an observer method (defined in Section 10.5 "Observer methods"), if the observer method is non-static, the container must obtain a contextual instance of the bean according to Section 6.5.2 "Contextual instance of a bean". If this observer method is a conditional observer method, obtain the contextual instance that already exists, only if the scope of the bean that declares the observer method is currently active, without creating a new contextual instance. Finally, the container must invoke the observer method on the resulting instance, if any, as a business method invocation, as defined in Section 7.2 "Container invocations and interception".</text>
</assertion>
<assertion id="c">
@@ -2353,7 +2371,7 @@
</assertion>
<assertion id="bc">
- <text>The |javax.enterprise.inject.spi.InjectionPoint.getQualifiers()| method returns the declared bindings of the injection point.</text>
+ <text>The |javax.enterprise.inject.spi.InjectionPoint.getQualifiers()| method returns the declared qualifiers of the injection point.</text>
</assertion>
<assertion id="ca">
@@ -2365,7 +2383,7 @@
</assertion>
<assertion id="cc">
- <text>The |javax.enterprise.inject.spi.InjectionPoint.getMember()| method returns the |Constructor| object in the case of constructor parameter injection</text>
+ <text>The |javax.enterprise.inject.spi.InjectionPoint.getMember()| method returns the |Constructor| object in the case of constructor parameter injection.</text>
</assertion>
<assertion id="daa">
@@ -2381,7 +2399,7 @@
</assertion>
<assertion id="ea">
- <text>The container must provide a bean with scope |@Dependent|, bean type |InjectionPoint| and binding |@Current|, allowing dependent objects, as defined in Section 6.4.2, "Dependent objects", to obtain information about the injection point to which they belong.</text>
+ <text>The container must provide a bean with scope |@Dependent|, bean type |InjectionPoint| and qualifier |@Default|, allowing dependent objects, as defined in Section 6.4.1, "Dependent objects", to obtain information about the injection point to which they belong.</text>
</assertion>
<assertion id="eb">
@@ -2389,11 +2407,11 @@
</assertion>
<assertion id="f">
- <text>If a bean that declares any scope other than |@Dependent| has an injection point of type |InjectionPoint| and binding |@Current|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a bean that declares any scope other than |@Dependent| has an injection point of type |InjectionPoint| and binding |@Default|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
- <assertion id="g">
- <text>If an object that is not a bean has an injection point of type |InjectionPoint| and binding |@Current|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <assertion id="ga">
+ <text>If a Java EE component class supporting injection that is not a bean has an injection point of type |InjectionPoint| and binding |@Default|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
</section>
@@ -2407,37 +2425,37 @@
</assertion>
<assertion id="ca">
- <text>Any combination of bindings may be specified at the injection point.</text>
+ <text>Any combination of qualifiers may be specified at the injection point.</text>
</assertion>
<assertion id="da">
- <text>The |@Any| binding may be used to allow the application to specify bindings dynamically.</text>
+ <text>The |@Any| qualifier may be used to allow the application to specify qualifiers dynamically.</text>
</assertion>
</section>
<section id="5.7.1" title="The Instance interface">
<assertion id="aa">
- <text>The |Instance| interface provides a method for obtaining instances of beans with a specified combination of required type and bindings, and inherites the ability to iterate beans with that combination of required type and bindings from |java.lang.Iterable|.</text>
+ <text>The |Instance| interface provides a method for obtaining instances of beans with a specified combination of required type and qualifiers, and inherites the ability to iterate beans with that combination of required type and qualifiers from |java.lang.Iterable|.</text>
</assertion>
<assertion id="ab">
- <text>For an injected |Instance|, the required type is the type parameter specified at the injection point, and the required bindings are the bindings specified at the injection point.</text>
+ <text>For an injected |Instance|, the required type is the type parameter specified at the injection point, and the required qualifiers are the qualifiers specified at the injection point.</text>
</assertion>
<assertion id="ba">
- <text>The |select()| method returns a child |Instance| for a given required type and additional required bindings. If no required type is given, the required type is the same as the parent.</text>
+ <text>The |select()| method returns a child |Instance| for a given required type and additional required qualifiers. If no required type is given, the required type is the same as the parent.</text>
</assertion>
<assertion id="da">
- <text>If two instances of the same binding type are passed to |select()|, an |IllegalArgumentException| is thrown.</text>
+ <text>If two instances of the same qualifier type are passed to |select()|, an |IllegalArgumentException| is thrown.</text>
</assertion>
<assertion id="e">
- <text>If an instance of an annotation that is not a binding type is passed to |select()|, an |IllegalArgumentException| is thrown.</text>
+ <text>If an instance of an annotation that is not a qualifier type is passed to |select()|, an |IllegalArgumentException| is thrown.</text>
</assertion>
<assertion id="fa">
- <text>The |get()| method must identify a bean that matches the required type and required bindings and is accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution" and resolving ambiguities according to Section 5.3.1, "Unsatisfied and ambiguous dependencies".</text>
+ <text>The |get()| method must identify a bean that matches the required type and required qualifiers and is accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution" and resolving ambiguities according to Section 5.3.1, "Unsatisfied and ambiguous dependencies".</text>
</assertion>
<assertion id="fba">
@@ -2453,7 +2471,7 @@
</assertion>
<assertion id="ja">
- <text>The |iterator()| method must identify the set of beans that match the required type and required bindings and are accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution".</text>
+ <text>The |iterator()| method must identify the set of beans that match the required type and required qualifiers and are accessible to the class into which the parent |Instance| was injected, according to the rules of typesafe resolution, as defined in Section 5.3, "Typesafe resolution".</text>
</assertion>
<assertion id="ka">
@@ -2461,21 +2479,21 @@
</assertion>
<assertion id="l">
- <text>The method |isUnsatisfied()| returns true if there is no bean that matches the required type and bindings, or false otherwise.</text>
+ <text>The method |isUnsatisfied()| returns true if there is no bean that matches the required type and qualifiers, or false otherwise.</text>
</assertion>
<assertion id="m">
- <text>The method |isAmbiguous()| returns true if there is more than one bean that matches the required type and bindings, or false otherwise.</text>
+ <text>The method |isAmbiguous()| returns true if there is more than one bean that matches the required type and qualifiers, or false otherwise.</text>
</assertion>
</section>
<section id="5.7.2" title="The built-in Instance">
<assertion id="a">
- <text>The container must provide a built-in bean with |Instance<X>| for every legal bean type X in its set of bean types</text>
+ <text>The container must provide a built-in bean with |Instance<X>| and |Provider<X>| for every legal bean type |x| in its set of bean types.</text>
</assertion>
<assertion id="b">
- <text>The container must provide a built-in bean with every binding type in its set of binding types.</text>
+ <text>The container must provide a built-in bean with every qualifier type in its set of qualifier types.</text>
</assertion>
<assertion id="d">
@@ -2517,10 +2535,6 @@
<assertion id="bc">
<text>Otherwise, if a name used in an EL expression resolves to exactly one bean, the |ELResolver| must return a contextual instance of the bean, as defined in Section 6.5.2, "Contextual instance of a bean".</text>
</assertion>
-
- <assertion id="c">
- <text>For each distinct name that appears in the EL expression, the resolver must be called at most once. Even if a name appears more than once in the same expression, the container may not call the resolver multiple times with that name. This restriction ensures that there is a unique instance of each bean with scope |@Dependent| in any EL evaluation.</text>
- </assertion>
</section>
<section id="6" title="Scopes and contexts">
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3710 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-09-20 22:47:18 -0400 (Sun, 20 Sep 2009)
New Revision: 3710
Modified:
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
Log:
section 4 assertions
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 02:09:51 UTC (rev 3709)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 02:47:18 UTC (rev 3710)
@@ -1470,14 +1470,14 @@
<section id="4.1" title="Inheritance of type-level metadata">
<group>
- <text>Suppose a class X is extended directly or indirectly by the bean class of a managed bean or session bean Y. If X is annotated with a binding type, stereotype or interceptor binding type Z then Y inherits the annotation if and only if Z declares the |@Inherited| meta-annotation and neither Y nor any intermediate class that is a subclass of X and a superclass of Y declares an annotation of type Z.</text>
+ <text>Suppose a class X is extended directly or indirectly by the bean class of a managed bean or session bean Y. If X is annotated with a qualifier type, stereotype or interceptor binding type Z then Y inherits the annotation if and only if Z declares the |@Inherited| meta-annotation and neither Y nor any intermediate class that is a subclass of X and a superclass of Y declares an annotation of type Z.</text>
<assertion id="aa">
- <text>Test binding type for directly extended managed bean annotated |@Inherited| is inherited.</text>
+ <text>Test qualifier type for directly extended managed bean annotated |@Inherited| is inherited.</text>
</assertion>
<assertion id="aaa">
- <text>Test binding type for directly extended managed bean not annotated |@Inherited| is not inherited.</text>
+ <text>Test qualifier type for directly extended managed bean not annotated |@Inherited| is not inherited.</text>
</assertion>
<assertion id="ab">
@@ -1497,11 +1497,11 @@
</assertion>
<assertion id="ag">
- <text>Test binding type for indirectly extended managed bean annotated |@Inherited| is inherited.</text>
+ <text>Test qualifier type for indirectly extended managed bean annotated |@Inherited| is inherited.</text>
</assertion>
<assertion id="aga">
- <text>Test binding type for indirectly extended managed bean not annotated |@Inherited| is not inherited.</text>
+ <text>Test qualifier type for indirectly extended managed bean not annotated |@Inherited| is not inherited.</text>
</assertion>
<assertion id="ah">
@@ -1521,11 +1521,11 @@
</assertion>
<assertion id="al">
- <text>Test binding type for directly extended session bean annotated |@Inherited| is inherited.</text>
+ <text>Test qualifier type for directly extended session bean annotated |@Inherited| is inherited.</text>
</assertion>
<assertion id="ala">
- <text>Test binding type for directly extended session bean not annotated |@Inherited| is not inherited.</text>
+ <text>Test qualifier type for directly extended session bean not annotated |@Inherited| is not inherited.</text>
</assertion>
<assertion id="am">
@@ -1545,11 +1545,11 @@
</assertion>
<assertion id="ap">
- <text>Test binding type for indirectly extended session bean annotated |@Inherited| is inherited.</text>
+ <text>Test qualifier type for indirectly extended session bean annotated |@Inherited| is inherited.</text>
</assertion>
<assertion id="apa">
- <text>Test binding type for indirectly extended session bean not annotated |@Inherited| is not inherited.</text>
+ <text>Test qualifier type for indirectly extended session bean not annotated |@Inherited| is not inherited.</text>
</assertion>
<assertion id="aq">
@@ -1774,7 +1774,7 @@
<section id="4.3" title="Specialization">
<assertion id="a" testable="false">
- <text>If two beans both support a certain bean type, and share at least one binding, then they are both eligible for injection to any injection point with that declared type and binding.</text>
+ <text>If two beans both support a certain bean type, and share at least one qualifier, then they are both eligible for injection to any injection point with that declared type and binding.</text>
</assertion>
<assertion id="ca">
@@ -1797,7 +1797,7 @@
</assertion>
<assertion id="j">
- <text>A bean X that specializes bean Y will include all bindings of Y, together with all bindings declared explicitly by X.</text>
+ <text>A bean X that specializes bean Y will include all qualifiers of Y, together with all qualifiers declared explicitly by X.</text>
</assertion>
<assertion id="k">
@@ -1805,7 +1805,7 @@
</assertion>
<group>
- <text>If X declares a name explicitly, using @Named, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If X declares a name explicitly, using |@Named|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
<assertion id="la">
<text>Test that a specializing producer method with a name throws a deployment exception.</text>
@@ -1825,43 +1825,6 @@
</assertion>
</section>
- <section id="4.3.2" title="Most specialized enabled bean for a bean">
- <group>
- <text>Non-static producer methods, producer fields, disposal methods and observer methods of a bean are invoked upon an instance of the most specialized enabled bean that specializes the bean, as defined by Section 5.6.6, "Invocation of producer or disposal methods", Section 5.6.7, "Access to producer field values" and Section 5.6.8, "Invocation of observer methods".</text>
-
- <assertion id="aa">
- <text>Test with non-static producer method on an enterprise bean.</text>
- </assertion>
-
- <assertion id="ab">
- <text>Test with non-static producer method on a managed bean.</text>
- </assertion>
-
- <assertion id="b">
- <text>Test with non-static producer field.</text>
- </assertion>
-
- <assertion id="c">
- <text>Test with non-static disposal method.</text>
- </assertion>
-
- <assertion id="d">
- <text>Test with non-static observer method.</text>
- </assertion>
- </group>
-
- </section>
-
- <section id="4.3.3" title="Inconsistent specialization">
- <assertion id="c">
- <text>If, for an enabled bean X that directly specializes a second bean Y, there is another enabled bean that directly specializes Y, we say that inconsistent specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
-
- <assertion id="d">
- <text>If, for an enabled bean X that directly specializes a second bean Y, there is an injection point that matches Y and not X, according to the typesafe resolution algorithm defined in Section 5.3 "Typesafe resolution", we say that inconsistent specialization exists. The container automatically detects inconsistent specialization and treats it as a deployment problem, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
- </section>
-
<section id="5" title="Dependency injection, lookup, and EL">
<assertion id="b">
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3709 - tck/trunk/impl/src/main/resources.
by webbeans-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2009-09-20 22:09:51 -0400 (Sun, 20 Sep 2009)
New Revision: 3709
Modified:
tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
tck/trunk/impl/src/main/resources/tck-audit-mb.xml
Log:
section 2 and 3 assertions for PFD2
Modified: tck/trunk/impl/src/main/resources/tck-audit-cdi.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-19 16:08:53 UTC (rev 3708)
+++ tck/trunk/impl/src/main/resources/tck-audit-cdi.xml 2009-09-21 02:09:51 UTC (rev 3709)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://jboss.com/products/webbeans/tck/audit /Users/pmuir/workspace/jboss-test-audit/api/src/main/resources/tck-audit.xsd"
name="JSR-299: Contexts and Dependency Injection for Java Enterprise Edition"
id="cdi"
- version="1.0.20090625">
+ version="PFD2">
<section id="2" title="Concepts">
@@ -13,7 +13,7 @@
</assertion>
<assertion id="b">
- <text>A bean comprises of a (nonempty) set of bindings.</text>
+ <text>A bean comprises of a (nonempty) set of qualifiers.</text>
</assertion>
<assertion id="c">
@@ -31,6 +31,9 @@
<assertion id="g">
<text>A bean comprises of a bean implementation.</text>
</assertion>
+ </section>
+
+ <section id="2.1" title="Functionality provided by the container to the bean">
</section>
<section id="2.2" title="Bean types">
@@ -101,93 +104,101 @@
</assertion>
</section>
- <section id="2.3" title="Bindings">
+ <section id="2.3" title="Qualifiers">
</section>
- <section id="2.3.1" title="Built-in binding types">
+ <section id="2.3.1" title="Built-in qualifier types">
<assertion id="a0">
<text>Every bean has the built-in binding |@Any|, even if it does not explicitly declare this binding, except for beans with the built-in binding |@New| defined in Section 3.11, "Beans with the @New binding".</text>
</assertion>
<assertion id="aa">
- <text>If a bean does not explicitly declare a binding, the bean has exactly one additional binding, of type |@Current|.</text>
+ <text>If a bean does not explicitly declare a qualifier other than |@Named|, the bean has exactly one additional qualifier, of type |@Default|. This is called the default qualifier.</text>
</assertion>
<assertion id="b">
- <text>The default binding is also assumed for any injection point that does not explicitly declare a binding.</text>
+ <text>The default qualifier is also assumed for any injection point that does not explicitly declare a qualifier.</text>
</assertion>
</section>
- <section id="2.3.2" title="Defining new binding types">
+ <section id="2.3.2" title="Defining new qualifier types">
<assertion id="aa" testable="false">
- <text>A binding type is a Java annotation defined as |@Target({METHOD, FIELD, PARAMETER, TYPE})|~ and |@Retention(RUNTIME)|~.</text>
+ <text>A qualifier type is a Java annotation defined as |@Target({METHOD, FIELD, PARAMETER, TYPE})|~ and |@Retention(RUNTIME)|~.</text>
</assertion>
<assertion id="ab" testable="false">
- <text>A binding type is a Java annotation defined as ~|@Target({METHOD, FIELD, PARAMETER, TYPE})| and ~|@Retention(RUNTIME)|.</text>
+ <text>A qualifier type is a Java annotation defined as ~|@Target({METHOD, FIELD, PARAMETER, TYPE})| and ~|@Retention(RUNTIME)|.</text>
<note>Non-runtime retention annotations are discarded by the compiler</note>
</assertion>
<assertion id="ba">
- <text>A binding type may be declared by specifying the |(a)javax.enterprise.inject.BindingType| meta-annotation.</text>
+ <text>A binding type may be declared by specifying the |(a)javax.inject.Qualifier| meta-annotation.</text>
</assertion>
<assertion id="d" testable="false">
- <text>A binding type may define annotation members.</text>
+ <text>A qualifier type may define annotation members.</text>
<note>This is true by default in the JLS</note>
</assertion>
</section>
- <section id="2.3.3" title="Declaring the bindings of a bean">
- <assertion id="a">
- <text>A bean's bindings are declared by annotating the bean class with the binding types.</text>
- </assertion>
+ <section id="2.3.3" title="Declaring the qualifiers of a bean">
+ <group>
+ <text>A bean's qualifiers are declared by annotating the bean class or producer method or field with the qualifier types.</text>
+
+ <assertion id="a">
+ <text>Test by annotating a bean class.</text>
+ </assertion>
- <assertion id="b">
- <text>A bean's bindings are declared by annotating the producer method with the binding types.</text>
- </assertion>
+ <assertion id="b">
+ <text>Test by annotating a producer method.</text>
+ </assertion>
- <assertion id="c">
- <text>A bean's bindings are declared by annotating the producer field with the binding types.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test by annotating a producer field.</text>
+ </assertion>
+ </group>
<assertion id="d">
- <text>Any bean may declare multiple binding types.</text>
+ <text>Any bean may declare multiple qualifier types.</text>
</assertion>
</section>
- <section id="2.3.4" title="Specifying bindings of an injected field">
+ <section id="2.3.4" title="Specifying qualifiers of an injected field">
<assertion id="a">
- <text>Binding types may be applied to injected fields (see Section 3.8, "Injected fields") to determine the bean that is injected, according to the rules of typesafe resolution defined in Section 5.3, "Typesafe resolution".</text>
+ <text>Qualifier types may be applied to injected fields (see Section 3.8, "Injected fields") to determine the bean that is injected, according to the rules of typesafe resolution defined in Section 5.3, "Typesafe resolution".</text>
</assertion>
<assertion id="b">
- <text>A bean may only be injected to an injection point if it has all the bindings of the injection point.</text>
+ <text>A bean may only be injected to an injection point if it has all the qualifiers of the injection point.</text>
</assertion>
</section>
- <section id="2.3.5" title="Specifying bindings of a method or constructor parameter">
- <assertion id="a">
- <text>Binding types may be applied to parameters of producer methods (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
- </assertion>
+ <section id="2.3.5" title="Specifying qualifiers of a method or constructor parameter">
+ <group>
+ <text>Qualifier types may be applied to parameters of producer methods, initializer methods, disposer methods, observer methods or bean constructors (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
+
+ <assertion id="a">
+ <text>Test producer method.</text>
+ </assertion>
- <assertion id="b">
- <text>Binding types may be applied to parameters of initializer methods (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
- </assertion>
+ <assertion id="b">
+ <text>Test initializer method.</text>
+ </assertion>
- <assertion id="c">
- <text>Binding types may be applied to parameters of disposal methods (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test disposer method.</text>
+ </assertion>
- <assertion id="ca">
- <text>Binding types may be applied to parameters of observer methods (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
- </assertion>
+ <assertion id="ca">
+ <text>Test observer method.</text>
+ </assertion>
- <assertion id="d">
- <text>Binding types may be applied to parameters of bean constructors (see Chapter 3, Bean implementation) to determine the bean instance that is passed when the method is called by the container.</text>
- </assertion>
+ <assertion id="d">
+ <text>Test bean constructor.</text>
+ </assertion>
+ </group>
</section>
<section id="2.4" title="Scopes">
@@ -238,7 +249,7 @@
</assertion>
<assertion id="ba">
- <text>All scope types must specify the |(a)javax.enterprise.context.ScopeType| meta-annotation.</text>
+ <text>All scope types must specify the |(a)javax.inject.Scope| or |(a)javax.enterprise.context.NormalScope| meta-annotation.</text>
</assertion>
</section>
@@ -288,38 +299,46 @@
</section>
<section id="2.5.1" title="Declaring the bean EL name">
+
+ <group>
+ <text>To specify the EL name of a bean, the |(a)javax.inject.Named| annotation is applied to the bean class or producer method or field.</text>
+
+ <assertion id="a">
+ <text>Test with a bean class.</text>
+ </assertion>
- <assertion id="a">
- <text>To specify the EL name of a bean, the |(a)javax.enterprise.inject.Named| annotation is applied to the bean class.</text>
- </assertion>
+ <assertion id="b">
+ <text>Test with a producer method.</text>
+ </assertion>
- <assertion id="b">
- <text>To specify the EL name of a bean, the |(a)javax.enterprise.inject.Named| annotation is applied to the producer method.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test with a producer field.</text>
+ </assertion>
+ </group>
- <assertion id="c">
- <text>To specify the EL name of a bean, the |(a)javax.enterprise.inject.Named| annotation is applied to the producer field.</text>
- </assertion>
-
<assertion id="d">
- <text>If the |@Named| annotation does not specify the value member, the default EL name is assumed.</text>
+ <text>If the |@Named| annotation does not specify the |value| member, the default EL name is assumed.</text>
</assertion>
</section>
<section id="2.5.2" title="Default bean EL names">
+
+ <group>
+ <text>A default EL name must be assigned by the container when a bean class or producer method or field of a bean declares a |@Named| annotation and no EL name is explicitly specified by the value member.</text>
+
+ <assertion id="a">
+ <text>Test with a bean class.</text>
+ </assertion>
- <assertion id="a">
- <text>A default EL name must be assigned by the container when a bean class declares a |@Named| annotation and no EL name is explicitly specified by the value member.</text>
- </assertion>
+ <assertion id="b">
+ <text>Test with a producer method.</text>
+ </assertion>
- <assertion id="b">
- <text>A default EL name must be assigned by the container when a producer method of a bean declares a |@Named| annotation and EL no name is explicitly specified by the value member.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test with a producer field.</text>
+ </assertion>
+ </group>
- <assertion id="c">
- <text>A default EL name must be assigned by the container when a producer field of a bean declares a |@Named| annotation and no EL name is explicitly specified by the value member.</text>
- </assertion>
-
<assertion id="e">
<text>A default EL name must be assigned by the container when a bean declares a stereotype that declares an empty |@Named| annotation, and the bean does not explicitly specify an EL name.</text>
</assertion>
@@ -332,32 +351,32 @@
</assertion>
</section>
- <section id="2.6" title="Policies">
+ <section id="2.6" title="Alternatives">
<assertion id="a">
- <text>A policy is a bean that must be explicitly declared in the in the beans.xml file if it should be available for lookup, injection or EL resolution.</text>
+ <text>An alternative is a bean that must be explicitly declared in the |beans.xml| file if it should be available for lookup, injection or EL resolution.</text>
</assertion>
</section>
- <section id="2.6.1" title="Declaring a policy">
+ <section id="2.6.1" title="Declaring an alternative">
<assertion id="a">
- <text>A policy may be declared by annotating the bean class with the |@Alternative| annotation.</text>
+ <text>An alternative may be declared by annotating the bean class with the |@Alternative| annotation.</text>
</assertion>
+
+ <group>
+ <text>An alternative may be declared by annotating a bean, producer method or producer field with a stereotype that declares an |@Alternative| annotation.</text>
+
+ <assertion id="b">
+ <text>Test with a bean.</text>
+ </assertion>
- <assertion id="b">
- <text>A policy may be declared by annotating a bean with a stereotype that declares a |@Alternative| annotation.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test with a producer method.</text>
+ </assertion>
- <assertion id="c">
- <text>A policy may be declared by annotating a producer method with a stereotype that declares a |@Alternative| annotation.</text>
- </assertion>
-
- <assertion id="d">
- <text>A policy may be declared by annotating a producer field with a stereotype that declares a |@Alternative| annotation.</text>
- </assertion>
-
- <assertion id="e">
- <text>If a bean is a policy, all producer methods and fields of the bean are also policies.</text>
- </assertion>
+ <assertion id="d">
+ <text>Test with a producer field.</text>
+ </assertion>
+ </group>
</section>
<section id="2.7" title="Stereotypes">
@@ -367,66 +386,73 @@
</assertion>
<assertion id="aa">
- <text>A stereotype may specify that all beans with the stereotype are policies.</text>
+ <text>A stereotype may specify that all beans with the stereotype are alternatives.</text>
</assertion>
+
+ <group>
+ <text>A bean may declare zero, one or multiple stereotypes.</text>
+
+ <assertion id="b" testable="false">
+ <text>A bean may declare zero stereotypes.</text>
+ <note>Not testable through API</note>
+ </assertion>
- <assertion id="b" testable="false">
- <text>A bean may declare zero stereotypes.</text>
- <note>Not testable through API</note>
- </assertion>
+ <assertion id="c">
+ <text>Test with one stereotype.</text>
+ </assertion>
- <assertion id="c">
- <text>A bean may declare one stereotype.</text>
- </assertion>
+ <assertion id="d">
+ <text>Test with multiple stereotypes.</text>
+ </assertion>
+ </group>
- <assertion id="d">
- <text>A bean may declare multiple stereotypes.</text>
- </assertion>
-
</section>
- <section id="2.7.1" title="Defining new stereotypes">
- <assertion id="aa" testable="false">
- <text>A beans stereotype is a Java annotation defined as |@Target({TYPE, METHOD, FIELD})|~, |@Target(TYPE)|, |@Target(METHOD)|, |@Target(FIELD)| or |@Target({METHOD, FIELD})| and |@Retention(RUNTIME)|~.</text>
- </assertion>
+ <section id="2.7.1" title="Defining new stereotypes">
+ <group>
+ <text>A beans stereotype is a Java annotation defined as |@Target({TYPE, METHOD, FIELD})|, |@Target(TYPE)|, |@Target(METHOD)|, |@Target(FIELD)| or |@Target({METHOD, FIELD})| and |@Retention(RUNTIME)|.</text>
+
+ <assertion id="aa" testable="false">
+ <text>Test |@Target({TYPE, METHOD, FIELD})|.</text>
+ </assertion>
- <assertion id="ab" testable="false">
- <text>A beans stereotype is a Java annotation defined as ~|@Target({TYPE, METHOD, FIELD})|,~ |@Target(TYPE)|~, |@Target(METHOD)|, |@Target(FIELD)| or |@Target({METHOD, FIELD})| and |@Retention(RUNTIME)|~.</text>
- </assertion>
+ <assertion id="ab" testable="false">
+ <text>Test |@Target(TYPE)|.</text>
+ </assertion>
- <assertion id="ac" testable="false">
- <text>A beans stereotype is a Java annotation defined as ~|@Target({TYPE, METHOD, FIELD})|, |@Target(TYPE)|, |@Target(METHOD)|, ~|@Target(FIELD)| ~or |@Target({METHOD, FIELD})| and |@Retention(RUNTIME)|~.</text>
- </assertion>
+ <assertion id="ac" testable="false">
+ <text>Test |@Target(FIELD)|.</text>
+ </assertion>
- <assertion id="ad" testable="false">
- <text>A beans stereotype is a Java annotation defined as ~|@Target({TYPE, METHOD, FIELD})|, |@Target(TYPE)|, |@Target(METHOD)|, |@Target(FIELD)| or~ |@Target({METHOD, FIELD})|~ and |@Retention(RUNTIME)|~.</text>
- </assertion>
+ <assertion id="ad" testable="false">
+ <text>Test |@Target({METHOD, FIELD})|.</text>
+ </assertion>
- <assertion id="ae" testable="false">
- <text>A beans stereotype is a Java annotation defined as ~|@Target({TYPE, METHOD, FIELD})|, |@Target(TYPE)|, |@Target(METHOD)|, |@Target(FIELD)| or |@Target({METHOD, FIELD})| and~ |@Retention(RUNTIME)|.</text>
- <note>Non-runtime retention annotations are discarded by the compiler</note>
- </assertion>
+ <assertion id="ae" testable="false">
+ <text>|@Retention(RUNTIME)| - untestable.</text>
+ <note>Non-runtime retention annotations are discarded by the compiler</note>
+ </assertion>
+ </group>
<assertion id="b">
- <text>A stereotype may be declared by specifying the |(a)javax.enterprise.inject.stereotype.Stereotype| meta-annotation.</text>
+ <text>A stereotype may be declared by specifying the |(a)javax.enterprise.inject.Stereotype| meta-annotation.</text>
</assertion>
-
- <assertion id="da">
- <text>A stereotype may not declare any binding annotation. If a stereotype declares a binding annotation, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
</section>
<section id="2.7.1.1" title="Declaring the default scope for a stereotype">
- <assertion id="aa">
- <text>A stereotype may declare at most one scope. ~If a stereotype declares more than one scope, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the
-container".~</text>
- </assertion>
+
+ <group>
+ <text>A stereotype may declare at most one scope. If a stereotype declares more than one scope, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+
+ <assertion id="aa">
+ <text>Test with one scope.</text>
+ </assertion>
+
+ <assertion id="ab">
+ <text>Test that a stereotype with multiple scopes throws an exception.</text>
+ </assertion>
+ </group>
- <assertion id="ab">
- <text>A stereotype may declare at most one scope. _If a stereotype declares more than one scope, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the
-container"._</text>
- </assertion>
-
</section>
<section id="2.7.1.2" title="Specifying interceptor bindings for a stereotype">
@@ -450,12 +476,17 @@
<assertion id="aab">
<text>If a stereotype declares a non-empty |@Named| annotation, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ </assertion>
+
+ <assertion id="b" testable="false">
+ <text>A stereotype should not declare any qualifier annotation other than |@Named|. If a stereotype declares any other qualifier annotation, non-portable behavior results.</text>
+ <note>The behavior here is undefined.</note>
</assertion>
</section>
- <section id="2.7.1.4" title="Declaring a @Alternative stereotype">
+ <section id="2.7.1.4" title="Declaring an @Alternative stereotype">
<assertion id="a">
- <text>A stereotype may declare a @Alternative annotation, which specifies that every bean with the stereotype is a policy.</text>
+ <text>A stereotype may declare an |@Alternative| annotation, which specifies that every bean with the stereotype is an alternative.</text>
</assertion>
</section>
@@ -475,18 +506,22 @@
</section>
- <section id="2.7.2" title="Declaring the stereotypes for a bean">
- <assertion id="a">
- <text>Stereotype annotations may be applied to a bean class.</text>
- </assertion>
+ <section id="2.7.2" title="Declaring the stereotypes for a bean">
+ <group>
+ <text>Stereotype annotations may be applied to a bean class or producer method or field.</text>
+
+ <assertion id="a">
+ <text>Test with a bean class.</text>
+ </assertion>
- <assertion id="b">
- <text>Stereotype annotations may be applied to a producer method.</text>
- </assertion>
+ <assertion id="b">
+ <text>Test with a producer method.</text>
+ </assertion>
- <assertion id="c">
- <text>Stereotype annotations may be applied to a producer field.</text>
- </assertion>
+ <assertion id="c">
+ <text>Test with a producer field.</text>
+ </assertion>
+ </group>
<assertion id="db">
<text>The default scope declared by the stereotype may be overridden by the bean.</text>
@@ -499,7 +534,7 @@
<section id="2.7.3" title="Built-in stereotypes">
<assertion id="aa" testable="false">
- <text>The built-in stereotype |(a)javax.enterprise.inject.stereotype.Model| is intended for use with beans that define the model layer of an MVC web application architecture such as JSF.</text>
+ <text>The built-in stereotype |(a)javax.enterprise.inject.Model| is intended for use with beans that define the model layer of an MVC web application architecture such as JSF.</text>
<note>Tested by API signature test</note>
</assertion>
</section>
@@ -571,69 +606,38 @@
<section id="3.1.3" title="Declaring a managed bean">
<assertion id="a">
<text>A managed bean with a constructor that takes no parameters does not require any special annotations</text>
+ </assertion>
+
+ <assertion id="ab">
+ <text>If the managed bean does not have a constructor that takes no parameters, it must have a constructor annotated |@Inject|. No additional special annotations are required.</text>
</assertion>
+
+ <group>
+ <text>A bean class may also specify a scope, name, stereotypes and/or qualifiers.</text>
+
+ <assertion id="ba">
+ <text>Test a bean with a scope.</text>
+ </assertion>
- <assertion id="ba">
- <text>A bean class may also specify a scope~, name, stereotypes and/or bindings~</text>
- </assertion>
+ <assertion id="bb">
+ <text>Test a bean with a name.</text>
+ </assertion>
- <assertion id="bb">
- <text>A bean class may also specify a ~scope, ~name~, stereotypes and/or bindings~</text>
- </assertion>
+ <assertion id="bd">
+ <text>Test a bean with a stereotype.</text>
+ </assertion>
- <assertion id="bd">
- <text>A bean class may also specify ~a scope, name, ~stereotypes~ and/or bindings~</text>
- </assertion>
+ <assertion id="be">
+ <text>Test a bean with a qualifier.</text>
+ </assertion>
+ </group>
- <assertion id="be">
- <text>A bean class may also specify ~a scope, name, stereotypes and/or ~bindings</text>
- </assertion>
-
<assertion id="c">
- <text>A managed bean may extend another managed bean</text>
+ <text>A managed bean may extend another managed bean.</text>
</assertion>
</section>
- <section id="3.1.4" title="Bean constructors">
- <assertion id="a">
- <text>When the container instantiates a managed bean, it calls the bean constructor. The bean constructor is a constructor of the bean class</text>
- </assertion>
- </section>
-
- <section id="3.1.4.1" title="Declaring a bean constructor">
- <assertion id="a">
- <text>The bean constructor may be identified by annotating the constructor |@Inject|</text>
- </assertion>
-
- <assertion id="ba">
- <text>If a managed bean does not explicitly declare a constructor using |@Inject|, the constructor that accepts no parameters is the bean constructor</text>
- <note>Can't check implicit constructor</note>
- </assertion>
-
- <assertion id="ca">
- <text>If a managed bean has more than one constructor annotated |@Inject|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
-
- <assertion id="da">
- <text>If a bean constructor has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
-
- <assertion id="ea">
- <text>If a bean constructor has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
- </section>
-
- <section id="3.1.4.2" title="Bean constructor parameters">
- <assertion id="b">
- <text>A bean constructor may have any number of parameters.</text>
- </assertion>
-
- <assertion id="c">
- <text>All parameters of a bean constructor are injection points.</text>
- </assertion>
- </section>
-
- <section id="3.1.5" title="Specializing a managed bean">
+ <section id="3.1.4" title="Specializing a managed bean">
<assertion id="aa">
<text>If a bean class of a managed bean X is annotated @Specializes, then the bean class of X must directly extend the bean class of another managed bean Y. Then X directly specializes Y, as defined in Section 4.3, "Specialization".</text>
</assertion>
@@ -732,28 +736,32 @@
</section>
<section id="3.2.3" title="Declaring a session bean">
- <assertion id="a">
- <text>A session bean does not require any special annotations</text>
+ <assertion id="aa">
+ <text>A session bean does not require any special annotations apart from the component-defining annotation (or XML declaration) required by the EJB specification.</text>
</assertion>
+
+ <group>
+ <text>A bean class may also specify a scope, name, stereotypes and/or qualifiers.</text>
+
+ <assertion id="ba">
+ <text>Test a bean class with a scope.</text>
+ </assertion>
- <assertion id="ba">
- <text>A bean class may also specify a scope~, name, stereotypes and/or bindings~</text>
- </assertion>
+ <assertion id="bb">
+ <text>Test a bean class with a name.</text>
+ </assertion>
- <assertion id="bb">
- <text>A bean class may also specify a ~scope, ~name~, stereotypes and/or bindings~</text>
- </assertion>
+ <assertion id="bd">
+ <text>Test a bean class with a stereotype.</text>
+ </assertion>
- <assertion id="bd">
- <text>A bean class may also specify ~a scope, name, ~stereotypes~ and/or bindings~</text>
- </assertion>
+ <assertion id="be">
+ <text>Test a bean class with a qualifier.</text>
+ </assertion>
+ </group>
- <assertion id="be">
- <text>A bean class may also specify ~a scope, name, stereotypes and/or ~bindings</text>
- </assertion>
-
<assertion id="c">
- <text>A session bean class may extend another bean class</text>
+ <text>A session bean class may extend another bean class.</text>
</assertion>
</section>
@@ -865,19 +873,23 @@
<assertion id="be">
<text>A producer method may specify a binding type</text>
</assertion>
+
+ <group>
+ <text>If a producer method is annotated |@Inject|, has a parameter annotated |@Disposes|, or has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+
+ <assertion id="ca">
+ <text>Test with a producer method annotated |@Inject|.</text>
+ </assertion>
- <assertion id="ca">
- <text>If a producer method is annotated |@Inject|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
+ <assertion id="da">
+ <text>Test with a producer method annotated |@Disposes|.</text>
+ </assertion>
- <assertion id="da">
- <text>If a producer method has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
+ <assertion id="ea">
+ <text>Test with a producer method annotated |@Observes|.</text>
+ </assertion>
+ </group>
- <assertion id="ea">
- <text>If a producer method has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
- </assertion>
-
<assertion id="fa">
<text>If a non-static method of a session bean class is annotated |@Produces|, and the method is not a business method of the session bean, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
@@ -916,8 +928,8 @@
</section>
<section id="3.3.5" title="Disposer methods">
- <assertion id="a">
- <text>A disposer method must be a method of a managed bean class or session bean class.</text>
+ <assertion id="aa">
+ <text>A disposer method must be a non-abstract method of a managed bean class or session bean class.</text>
</assertion>
<assertion id="b">
@@ -957,7 +969,7 @@
</assertion>
<assertion id="b0">
- <text>Bindings may be declared by annotating the disposed parameter.</text>
+ <text>Qualifiers may be declared by annotating the disposed parameter.</text>
</assertion>
<assertion id="ba">
@@ -983,7 +995,7 @@
<section id="3.3.8" title="Disposer method parameters">
<assertion id="a">
- <text>In addition to the disposed parameter, a disposer method may declare additional parameters, which may also specify bindings. These additional parameters are injection points.</text>
+ <text>In addition to the disposed parameter, a disposer method may declare additional parameters, which may also specify qualifiers. These additional parameters are injection points.</text>
</assertion>
</section>
@@ -1158,7 +1170,7 @@
</assertion>
<assertion id="hh">
- <text>The bean type and bindings of the resource are determined by the producer field declaration.</text>
+ <text>The bean type and qualifiers of the resource are determined by the producer field declaration.</text>
</assertion>
</section>
@@ -1171,44 +1183,87 @@
<section id="3.6" title="Additional built-in beans">
<assertion id="a">
- <text>A Java EE or embeddable EJB container must provide a bean with binding |@Current| and bean type |javax.transaction.UserTransaction|, allowing injection of a reference to the JTA |UserTransaction|.</text>
+ <text>A Java EE or embeddable EJB container must provide a bean with binding |@Default| and bean type |javax.transaction.UserTransaction|, allowing injection of a reference to the JTA |UserTransaction|.</text>
</assertion>
<assertion id="b">
- <text>A Java EE or embeddable EJB container must provide a bean with binding |@Current| and bean type |javax.security.Principal|, allowing injection of a |Principal| representing the current caller identity.</text>
+ <text>A Java EE or embeddable EJB container must provide a bean with binding |@Default| and bean type |javax.security.Principal|, allowing injection of a |Principal| representing the current caller identity.</text>
</assertion>
<assertion id="c">
- <text>A Java EE or embeddable EJB container must provide a bean with binding |@Current| and bean type |javax.validation.ValidationFactory|, allowing injection of the default Bean Validation |ValidationFactory|.</text>
+ <text>A Java EE or embeddable EJB container must provide a bean with binding |@Default| and bean type |javax.validation.ValidationFactory|, allowing injection of the default Bean Validation |ValidationFactory|.</text>
</assertion>
<assertion id="d">
- <text>A Java EE or embeddable EJB container must provide a bean with binding |@Current| and bean type |javax.validation.Validator|, allowing injection of a |Validator| for the default Bean Validation |ValidationFactory|.</text>
+ <text>A Java EE or embeddable EJB container must provide a bean with binding |@Default| and bean type |javax.validation.Validator|, allowing injection of a |Validator| for the default Bean Validation |ValidationFactory|.</text>
</assertion>
<assertion id="e">
- <text>If a Java EE component class has an injection point of type |UserTransaction| and binding |@Current|, and may not validly make use of the JTA |UserTransaction| according to the Java EE platform specification, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ <text>If a Java EE component class has an injection point of type |UserTransaction| and binding |@Default|, and may not validly make use of the JTA |UserTransaction| according to the Java EE platform specification, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
+ </section>
+
+ <section id="3.7" title="Bean constructors">
+ <assertion id="a">
+ <text>When the container instantiates a managed bean, it calls the bean constructor. The bean constructor is a constructor of the bean class</text>
+ </assertion>
</section>
- <section id="3.7" title="Injected fields">
- <assertion id="aa">
- <text>An injected field is a non-static~, non-final~ field of a bean class.</text>
+ <section id="3.7.1" title="Declaring a bean constructor">
+ <assertion id="a">
+ <text>The bean constructor may be identified by annotating the constructor |@Inject|</text>
</assertion>
- <assertion id="ab">
- <text>An injected field is a ~non-static, ~non-final field of a bean class.</text>
+ <assertion id="ba">
+ <text>If a bean class does not explicitly declare a constructor using |@Inject|, the constructor that accepts no parameters is the bean constructor.</text>
+ <note>Can't check implicit constructor</note>
</assertion>
- <assertion id="ba">
- <text>An injected field is a non-static, ~non-final~ field of any Java EE component class supporting injection.</text>
+ <assertion id="ca">
+ <text>If a bean class has more than one constructor annotated |@Inject|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
- <assertion id="bb">
- <text>An injected field is a ~non-static~, non-final field of any Java EE component class supporting injection.</text>
+ <assertion id="da">
+ <text>If a bean constructor has a parameter annotated |@Disposes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
<assertion id="ea">
+ <text>If a bean constructor has a parameter annotated |@Observes|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ </assertion>
+ </section>
+
+ <section id="3.7.2" title="Bean constructor parameters">
+ <assertion id="b">
+ <text>A bean constructor may have any number of parameters.</text>
+ </assertion>
+
+ <assertion id="c">
+ <text>All parameters of a bean constructor are injection points.</text>
+ </assertion>
+ </section>
+
+ <section id="3.8" title="Injected fields">
+ <group>
+ <text>An injected field is a non-static, non-final field of a bean class, or of any Java EE component class supporting injection.</text>
+
+ <assertion id="aa">
+ <text>Test a non-static field in a bean class.</text>
+ </assertion>
+
+ <assertion id="ab">
+ <text>Test a non-final field in a bean class.</text>
+ </assertion>
+
+ <assertion id="ba">
+ <text>Test a non-static field in a Java EE component class.</text>
+ </assertion>
+
+ <assertion id="bb">
+ <text>Test a non-final field in a Java EE component class.</text>
+ </assertion>
+ </group>
+
+ <assertion id="ea">
<text>Injected fields are initialized by the container before initializer methods are called, and before the |@PostConstruct| callback occurs.</text>
</assertion>
@@ -1217,23 +1272,39 @@
</assertion>
</section>
- <section id="3.7.1" title="Declaring an injected field">
- <assertion id="a">
- <text>An injected field may be declared by annotating the field with any binding type.</text>
+ <section id="3.8.1" title="Declaring an injected field">
+ <assertion id="aa">
+ <text>An injected field may be declared by annotating the field |(a)javax.inject.Inject|.</text>
</assertion>
</section>
- <section id="3.8" title="Initializer methods">
- <assertion id="aa">
- <text>An initializer method is a non-static method of a bean class.</text>
- </assertion>
+ <section id="3.9" title="Initializer methods">
+ <group>
+ <text>An initializer method is a non-abstract, non-static method of a bean class, or of any Java EE component class supporting injection.</text>
+
+ <assertion id="aaa">
+ <text>Test with a non-abstract method of a bean-class.</text>
+ </assertion>
+
+ <assertion id="aa">
+ <text>Test with a non-static method of a bean class.</text>
+ </assertion>
+
+ <assertion id="caa">
+ <text>Test with a non-abstract method of a Java EE component class.</text>
+ </assertion>
+
+ <assertion id="ca">
+ <text>Test with a non-static method of a Java EE component class.</text>
+ </assertion>
+ </group>
- <assertion id="ca">
- <text>An initializer method is a non-static method of any Java EE component class supporting injection.</text>
- </assertion>
-
<assertion id="e">
- <text>If the bean is a session bean, the initializer method is not required to be a business method of the session bean</text>
+ <text>If the bean is a session bean, the initializer method is not required to be a business method of the session bean.</text>
+ </assertion>
+
+ <assertion id="ea">
+ <text>A generic method may not be an initializer method.</text>
</assertion>
<assertion id="f">
@@ -1254,9 +1325,9 @@
</assertion>
</section>
- <section id="3.8.1" title="Declaring an initializer method">
+ <section id="3.9.1" title="Declaring an initializer method">
<assertion id="a">
- <text>An initializer method may be declared by annotating the method |(a)javax.enterprise.inject.Initializer|</text>
+ <text>An initializer method may be declared by annotating the method |(a)javax.inject.Inject|</text>
</assertion>
<assertion id="ab">
@@ -1277,7 +1348,7 @@
</section>
- <section id="3.8.2" title="Initializer method parameters">
+ <section id="3.9.2" title="Initializer method parameters">
<assertion id="aa">
<text>An initializer method may have any number of parameters.</text>
</assertion>
@@ -1287,13 +1358,23 @@
</assertion>
</section>
- <section id="3.9" title="The default binding at injection points">
+ <section id="3.10" title="The default qualifier at injection points">
<assertion id="a">
- <text>If an injection point declares no binding, the default binding |@Current| is assumed.</text>
+ <text>If an injection point declares no qualifier, the default binding |@Default| is assumed.</text>
</assertion>
+ </section>
+
+ <section id="3.11" title="The qualifier @Named at injection points">
+ <assertion id="a">
+ <text>If an injected field declares a |@Named| annotation that does not specify the value member, the name of the field is assumed.</text>
+ </assertion>
+
+ <assertion id="b">
+ <text>If any other injection point declares a |@Named| annotation that does not specify the value member, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
+ </assertion>
</section>
- <section id="3.10" title="Beans with the @New binding">
+ <section id="3.12" title="Beans with the @New qualifier">
<assertion id="d">
<text>For each managed bean, a second bean exists which has the same bean class.</text>
</assertion>
@@ -1375,11 +1456,11 @@
</assertion>
<assertion id="xb">
- <text>This second bean is not a policy.</text>
+ <text>This second bean is not an alternative.</text>
</assertion>
<assertion id="z">
- <text>When the binding |@New| is specified at an injection point and no value member is explicitly specified, the container defaults the value to the declared type of the injection point.</text>
+ <text>When the binding |@New| is specified at an injection point and no |value| member is explicitly specified, the container defaults the |value| to the declared type of the injection point.</text>
</assertion>
</section>
Modified: tck/trunk/impl/src/main/resources/tck-audit-mb.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit-mb.xml 2009-09-19 16:08:53 UTC (rev 3708)
+++ tck/trunk/impl/src/main/resources/tck-audit-mb.xml 2009-09-21 02:09:51 UTC (rev 3709)
@@ -72,8 +72,9 @@
<text>The name can be specified using an element of the |ManagedBean| annotation.</text>
</assertion>
- <assertion id="c">
+ <assertion id="c" testable="false">
<text>Managed Bean names must be unique within a Java EE module. It is an error if a Java EE module contains an EJB component and a Managed Bean with the same name.</text>
+ <note>The behaviour here is unspecified.</note>
</assertion>
<group>
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3708 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/extensions/observer and 8 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-09-19 12:08:53 -0400 (Sat, 19 Sep 2009)
New Revision: 3708
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventA.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventAObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodEventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventB.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventBObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodErrorTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventC.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventCObserver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodExceptionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodObserver.java
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/javax.enterprise.inject.spi.Extension
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/javax.enterprise.inject.spi.Extension
tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/javax.enterprise.inject.spi.Extension
Log:
New tests for ProcessObserverMethod events; currently RI broken due to a problem with resolution.
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventA.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventA.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventA.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.extensions.observer;
+
+class EventA
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventA.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventAObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventAObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventAObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.extensions.observer;
+
+import javax.enterprise.event.Observes;
+
+class EventAObserver
+{
+ public void observeEvent(@Observes EventA event)
+ {
+
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/EventAObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodEventTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodEventTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodEventTest.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.jsr299.tck.tests.extensions.observer;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+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.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for the extensions provided by the ProcessObserverMethod events.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+@Resources({
+ @Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
+})
+@IntegrationTest
+@SpecVersion(spec="cdi", version="1.0.20090625")
+public class ProcessObserverMethodEventTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ // Event resolution seems to be broken here
+ @SpecAssertion(section = "11.5.9", id = "aa")
+ public void testProcessObserverMethodEventsSent()
+ {
+ assert ProcessObserverMethodObserver.getEventtypes().contains(EventA.class);
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.5.9", id = "ab")
+ public void testGetAnnotatedMethod()
+ {
+ assert ProcessObserverMethodObserver.getAnnotatedMethod().getParameters().iterator().next().getBaseType().equals(EventA.class);
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.5.9", id = "ba")
+ public void testGetObserverMethod()
+ {
+ assert ProcessObserverMethodObserver.getObserverMethod().getObservedType().equals(EventA.class);
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodEventTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,39 @@
+package org.jboss.jsr299.tck.tests.extensions.observer;
+
+import java.lang.reflect.Type;
+import java.util.HashSet;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ObserverMethod;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+class ProcessObserverMethodObserver implements Extension
+{
+ private static final HashSet<Type> eventTypes = new HashSet<Type>();
+ private static AnnotatedMethod<?> annotatedMethod;
+ private static ObserverMethod<?, ?> observerMethod;
+
+ public void observeObserverMethodForEventA(@Observes ProcessObserverMethod<?, ?> event)
+ {
+ eventTypes.add(event.getObserverMethod().getObservedType());
+ annotatedMethod = event.getAnnotatedMethod();
+ observerMethod = event.getObserverMethod();
+ }
+
+ public static HashSet<Type> getEventtypes()
+ {
+ return eventTypes;
+ }
+
+ public static AnnotatedMethod<?> getAnnotatedMethod()
+ {
+ return annotatedMethod;
+ }
+
+ public static ObserverMethod<?, ?> getObserverMethod()
+ {
+ return observerMethod;
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/ProcessObserverMethodObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventB.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventB.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventB.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.definitionError;
+
+class EventB
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventB.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventBObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventBObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventBObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.definitionError;
+
+import javax.enterprise.event.Observes;
+
+class EventBObserver
+{
+ public void observeEvent(@Observes EventB event)
+ {
+
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/EventBObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodErrorTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodErrorTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodErrorTest.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.definitionError;
+
+import org.jboss.jsr299.tck.DefinitionError;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.testng.annotations.Test;
+
+/**
+ * Tests adding definition errors to the event object.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+(a)ExpectedDeploymentException(DefinitionError.class)
+@Resources({
+ @Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
+})
+@IntegrationTest
+@SpecVersion(spec="cdi", version="1.0.20090625")
+public class ProcessObserverMethodErrorTest
+{
+
+ @Test
+ @SpecAssertion(section = "11.5.9", id = "da")
+ public void testAddDefinitionError()
+ {
+ assert false;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodErrorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.definitionError;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+class ProcessObserverMethodObserver implements Extension
+{
+
+ public void observeObserverMethodForEventB(@Observes ProcessObserverMethod<?, EventB> event)
+ {
+ event.addDefinitionError(new RuntimeException("Definition error for EventB"));
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/ProcessObserverMethodObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventC.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventC.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventC.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.exception;
+
+class EventC
+{
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventC.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventCObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventCObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventCObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.exception;
+
+import javax.enterprise.event.Observes;
+
+class EventCObserver
+{
+ public void observeEvent(@Observes EventC event)
+ {
+
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/EventCObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodExceptionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodExceptionTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodExceptionTest.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.exception;
+
+import org.jboss.jsr299.tck.DefinitionError;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.testng.annotations.Test;
+
+/**
+ * Tests event observer throwing exception causes container to produce
+ * a definition error.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+(a)ExpectedDeploymentException(DefinitionError.class)
+@Resources({
+ @Resource(source="javax.enterprise.inject.spi.Extension", destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
+})
+@IntegrationTest
+@SpecVersion(spec="cdi", version="1.0.20090625")
+public class ProcessObserverMethodExceptionTest
+{
+
+ @Test
+ @SpecAssertion(section = "11.5.9", id = "db")
+ public void testExceptionIsDefinitionError()
+ {
+ assert false;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodExceptionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodObserver.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodObserver.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodObserver.java 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.extensions.observer.broken.exception;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+
+class ProcessObserverMethodObserver implements Extension
+{
+ public void observeObserverMethodForEventC(@Observes ProcessObserverMethod<?, EventC> event)
+ {
+ new RuntimeException("Definition error for EventC");
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/ProcessObserverMethodObserver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/javax.enterprise.inject.spi.Extension
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/javax.enterprise.inject.spi.Extension (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/definitionError/javax.enterprise.inject.spi.Extension 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1 @@
+org.jboss.jsr299.tck.tests.extensions.observer.broken.definitionError.ProcessObserverMethodObserver
Added: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/javax.enterprise.inject.spi.Extension
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/javax.enterprise.inject.spi.Extension (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/broken/exception/javax.enterprise.inject.spi.Extension 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1 @@
+org.jboss.jsr299.tck.tests.extensions.observer.broken.exception.ProcessObserverMethodObserver
Copied: tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/javax.enterprise.inject.spi.Extension (from rev 3653, tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/producer/javax.enterprise.inject.spi.Extension)
===================================================================
--- tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/javax.enterprise.inject.spi.Extension (rev 0)
+++ tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/extensions/observer/javax.enterprise.inject.spi.Extension 2009-09-19 16:08:53 UTC (rev 3708)
@@ -0,0 +1 @@
+org.jboss.jsr299.tck.tests.extensions.observer.ProcessObserverMethodObserver
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3707 - in extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test: beans and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: peteroyle
Date: 2009-09-19 00:05:25 -0400 (Sat, 19 Sep 2009)
New Revision: 3707
Added:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java
Modified:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
Log:
Added tests for custom and built-in event observers. Built-in events don't seem to be working for SE at the moment.
Modified: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-18 13:17:03 UTC (rev 3706)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -21,7 +21,9 @@
import org.jboss.webbeans.environment.se.StartMain;
import org.jboss.webbeans.environment.se.events.Shutdown;
+import org.jboss.webbeans.environment.se.test.beans.CustomEvent;
import org.jboss.webbeans.environment.se.test.beans.MainTestBean;
+import org.jboss.webbeans.environment.se.test.beans.ObserverTestBean;
import org.jboss.webbeans.environment.se.test.beans.ParametersTestBean;
import org.jboss.webbeans.environment.se.util.WebBeansManagerUtils;
import org.testng.Assert;
@@ -82,6 +84,19 @@
shutdownManager(manager);
}
+ @Test
+ public void testObservers() {
+ BeanManager manager = new StartMain(ARGS_EMPTY).go();
+
+ manager.fireEvent( new CustomEvent() );
+
+ ObserverTestBean observerTestBean = WebBeansManagerUtils.getInstanceByType( manager, ObserverTestBean.class );
+ Assert.assertNotNull( observerTestBean );
+ Assert.assertTrue( observerTestBean.isCustomObserved() );
+ Assert.assertTrue( observerTestBean.isBuiltInObserved() );
+
+ }
+
private void shutdownManager( BeanManager manager )
{
manager.fireEvent( manager, new ShutdownAnnotation() );
Added: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java (rev 0)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -0,0 +1,27 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.environment.se.test.beans;
+
+/**
+ * A custom event fired and observed by one of the tests, to test
+ * application-specific events.
+ *
+ * @author Peter Royle
+ */
+public class CustomEvent {
+
+}
Added: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java (rev 0)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -0,0 +1,62 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.environment.se.test.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+
+/**
+ * Tests the observing of both built-in and application-specific events.
+ *
+ * @author Peter Royle
+ */
+@ApplicationScoped
+public class ObserverTestBean {
+
+ private boolean builtInObserved = false;
+ private boolean customObserved = false;
+
+ public ObserverTestBean() {
+ }
+
+ public void observeBuiltInEvent(@Observes AfterDeploymentValidation after) {
+ this.builtInObserved = true;
+ }
+
+ public void observeCustomEvent(@Observes CustomEvent event) {
+ this.customObserved = true;
+
+ }
+
+ /**
+ * @return the observed
+ */
+ public boolean isBuiltInObserved() {
+ return builtInObserved;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isCustomObserved() {
+ return customObserved;
+ }
+
+
+
+}
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3706 - ri/tags.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-09-18 09:17:03 -0400 (Fri, 18 Sep 2009)
New Revision: 3706
Added:
ri/tags/kabir_before_immutable/
Log:
Tag before I start messing around with immutable beans
Copied: ri/tags/kabir_before_immutable (from rev 3705, ri/branches/kabir-builder)
14 years, 8 months
[webbeans-commits] Webbeans SVN: r3705 - ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder.
by webbeans-commits@lists.jboss.org
Author: kabir.khan(a)jboss.com
Date: 2009-09-18 06:26:33 -0400 (Fri, 18 Sep 2009)
New Revision: 3705
Modified:
ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/InternalBeanBuilderFactory.java
Log:
Get rid of the unused InternalBeanBuilderFactory stuff
Modified: ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/InternalBeanBuilderFactory.java
===================================================================
--- ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/InternalBeanBuilderFactory.java 2009-09-17 21:41:23 UTC (rev 3704)
+++ ri/branches/kabir-builder/impl/src/main/java/org/jboss/webbeans/bean/builder/InternalBeanBuilderFactory.java 2009-09-18 10:26:33 UTC (rev 3705)
@@ -25,11 +25,7 @@
import javax.enterprise.inject.spi.BeanManager;
import org.jboss.webbeans.bean.builder.spi.BeanBuilderFactory;
-import org.jboss.webbeans.bean.builder.spi.DecoratorBeanBuilder;
-import org.jboss.webbeans.bean.builder.spi.EnterpriseBeanBuilder;
-import org.jboss.webbeans.bean.builder.spi.SimpleBeanBuilder;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
-import org.jboss.webbeans.ejb.spi.EjbDescriptor;
/**
*
@@ -43,17 +39,9 @@
{
return (InternalBeanBuilderFactory)BeanBuilderFactory.getInstance();
}
-
- public abstract <T> SimpleBeanBuilder<T> getInternalSimpleBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType);
- public abstract <T> EnterpriseBeanBuilder<T> getInternalEnterpriseBeanBuilder(BeanManager beanManager, EjbDescriptor<T> ejbDescriptor);
-
- public abstract <T> DecoratorBeanBuilder<T> getInternalDecoratorBeanBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType);
-
public abstract <T> InternalObserverMethodBuilder<T> getInternalObserverMethodBuilder(BeanManager beanManager, AnnotatedType<T> annotatedType);
public abstract void registerBeanManager(BeanManager manager, BeanDeployerEnvironment environment);
- public abstract void unregisterBeanManager(BeanManager manager);
-
}
14 years, 8 months