You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ar...@apache.org on 2013/01/24 09:27:27 UTC
svn commit: r1437893 [1/3] - in /openwebbeans/trunk:
webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/
webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/
webbeans-impl/src/main/java/org/apache/webbeans/component/ webbean...
Author: arne
Date: Thu Jan 24 08:27:26 2013
New Revision: 1437893
URL: http://svn.apache.org/viewvc?rev=1437893&view=rev
Log:
OWB-765: Created BeanAttributesBuilder
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
- copied, changed from r1436940, openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
Removed:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/NewEjbBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/NewManagedBeanBuilder.java
Modified:
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EjbInterceptorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AnnotatedTypeBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/CdiInterceptorBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/EjbInterceptorBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ExtensionBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ResourceBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/SelfInterceptorBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/third/ThirdpartyBeanImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/InjectionResolver.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorResolutionService.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/CdiInterceptorBeanBuilderTest.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/EjbInterceptorBeanBuilderTest.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/resolution/SelfInterceptorBeanBuilderTest.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/component/JmsBean.java
openwebbeans/trunk/webbeans-jms/src/main/java/org/apache/webbeans/jms/component/JmsComponentFactory.java
Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/BaseEjbBean.java Thu Jan 24 08:27:26 2013
@@ -18,18 +18,16 @@
*/
package org.apache.webbeans.ejb.common.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.SessionBeanType;
+import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.EnterpriseBeanMarker;
import org.apache.webbeans.component.WebBeansType;
@@ -58,13 +56,10 @@ public abstract class BaseEjbBean<T> ext
protected BaseEjbBean(WebBeansContext webBeansContext,
SessionBeanType type,
AnnotatedType<T> annotatedType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> beanClass)
{
- super(webBeansContext, WebBeansType.ENTERPRISE, annotatedType, types, qualifiers, scope, beanClass, stereotypes);
+ super(webBeansContext, WebBeansType.ENTERPRISE, annotatedType, beanAttributes, beanClass);
//type of the ejb
this.ejbType = type;
}
Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/component/EjbBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -18,8 +18,6 @@
*/
package org.apache.webbeans.ejb.common.component;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
import java.util.List;
import java.util.Set;
@@ -30,6 +28,7 @@ import javax.enterprise.inject.spi.Injec
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.ObserverMethod;
+import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.creation.AbstractInjectionTargetBeanBuilder;
import org.apache.webbeans.config.WebBeansContext;
@@ -45,9 +44,9 @@ import org.apache.webbeans.portable.Abst
*/
public abstract class EjbBeanBuilder<T, E extends BaseEjbBean<T>> extends AbstractInjectionTargetBeanBuilder<T, E>
{
- public EjbBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+ public EjbBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
{
- super(webBeansContext, annotatedType);
+ super(webBeansContext, annotatedType, beanAttributes);
}
/**
@@ -57,16 +56,10 @@ public abstract class EjbBeanBuilder<T,
public void checkCreateConditions()
{
EjbValidator.validateDecoratorOrInterceptor(getBeanType());
- }
-
- public void defineScopeType(String errorMessage)
- {
- super.defineScopeType(errorMessage);
-
EjbValidator.validateEjbScopeType(getBean());
- EjbValidator.validateGenericBeanType(getBeanType(), getScope());
+ EjbValidator.validateGenericBeanType(getBeanType(), getBeanAttributes().getScope());
}
-
+
/* (non-Javadoc)
* @see org.apache.webbeans.component.creation.AbstractInjectedTargetBeanCreator#defineObserverMethods()
*/
@@ -80,9 +73,7 @@ public abstract class EjbBeanBuilder<T,
}
@Override
- protected InjectionTarget<T> buildInjectionTarget(Set<Type> types,
- Set<Annotation> qualifiers,
- AnnotatedType<T> annotatedType,
+ protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
Set<InjectionPoint> points,
WebBeansContext webBeansContext,
List<AnnotatedMethod<?>> postConstructMethods,
Modified: openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java (original)
+++ openwebbeans/trunk/webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/EjbUtility.java Thu Jan 24 08:27:26 2013
@@ -21,7 +21,6 @@ package org.apache.webbeans.ejb.common.u
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -36,8 +35,10 @@ import javax.enterprise.inject.spi.Obser
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.inject.spi.Producer;
+import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.component.creation.BeanAttributesBuilder;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.ejb.common.component.BaseEjbBean;
@@ -69,18 +70,11 @@ public final class EjbUtility
AnnotatedType<T> annotatedType = annotatedElementFactory.newAnnotatedType(clazz);
//Fires ProcessAnnotatedType
- ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = (ProcessAnnotatedTypeImpl<T>)event;
- EjbBeanBuilder<T, BaseEjbBean<T>> ejbBeanCreator = new EjbBeanBuilder<T, BaseEjbBean<T>>(ejbBean.getWebBeansContext(), annotatedType) {
+ ProcessAnnotatedTypeImpl<T> processAnnotatedEvent = (ProcessAnnotatedTypeImpl<T>)event;
+ BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
+ EjbBeanBuilder<T, BaseEjbBean<T>> ejbBeanCreator = new EjbBeanBuilder<T, BaseEjbBean<T>>(ejbBean.getWebBeansContext(), annotatedType, beanAttributes) {
@Override
- protected BaseEjbBean<T> createBean(Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative,
- boolean enabled)
+ protected BaseEjbBean<T> createBean(Class<T> beanClass, boolean enabled)
{
return ejbBean;
}
@@ -99,11 +93,6 @@ public final class EjbUtility
}
//Define meta-data
- ejbBeanCreator.defineStereoTypes();
- ejbBeanCreator.defineApiType();
- ejbBeanCreator.defineScopeType("Session Bean implementation class : " + clazz.getName() + " stereotypes must declare same @ScopeType annotations");
- ejbBeanCreator.defineName();
- ejbBeanCreator.defineQualifiers();
Set<ProducerMethodBean<?>> producerMethodBeans = ejbBeanCreator.defineProducerMethods(ejbBean);
checkProducerMethods(producerMethodBeans, ejbBean);
Set<ProducerFieldBean<?>> producerFieldBeans = ejbBeanCreator.defineProducerFields(ejbBean);
@@ -199,17 +188,12 @@ public final class EjbUtility
final AnnotatedType<T> annotatedType = ejbBean.getAnnotatedType();
- final EjbBeanBuilder<T, BaseEjbBean<T>> ejbBeanCreator = new EjbBeanBuilder<T, BaseEjbBean<T>>(ejbBean.getWebBeansContext(), annotatedType) {
+ final BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes(annotatedType).build();
+
+ final EjbBeanBuilder<T, BaseEjbBean<T>> ejbBeanCreator = new EjbBeanBuilder<T, BaseEjbBean<T>>(ejbBean.getWebBeansContext(), annotatedType, beanAttributes) {
@Override
- protected BaseEjbBean<T> createBean(Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope, String name,
- boolean nullable,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative,
- boolean enabled)
+ protected BaseEjbBean<T> createBean(Class<T> beanClass, boolean enabled)
{
return ejbBean;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractOwbBean.java Thu Jan 24 08:27:26 2013
@@ -88,34 +88,10 @@ public abstract class AbstractOwbBean<T>
protected AbstractOwbBean(WebBeansContext webBeansContext,
WebBeansType webBeansType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- Class<?> beanClass,
- Set<Class<? extends Annotation>> stereotypes)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<?> beanClass)
{
- this(webBeansContext, webBeansType, types, qualifiers, scope, null, false, beanClass, stereotypes, false);
- }
-
- /**
- * Constructor definiton. Each subclass redefines its own constructor with
- * calling this.
- *
- * @param webBeansContext
- * @param webBeansType web beans type
- */
- protected AbstractOwbBean(WebBeansContext webBeansContext,
- WebBeansType webBeansType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<?> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
- {
- super(types, qualifiers, scope, name, nullable, stereotypes, alternative);
+ super(beanAttributes);
this.webBeansType = webBeansType;
this.beanClass = beanClass;
this.webBeansContext = webBeansContext;
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractProducerBean.java Thu Jan 24 08:27:26 2013
@@ -19,10 +19,7 @@
package org.apache.webbeans.component;
import java.io.Serializable;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
@@ -49,16 +46,10 @@ public abstract class AbstractProducerBe
*/
protected AbstractProducerBean(InjectionTargetBean<?> ownerComponent,
WebBeansType webBeansType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> returnType,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> returnType)
{
- super(ownerComponent.getWebBeansContext(), webBeansType, types, qualifiers, scope, name, nullable, ownerComponent.getBeanClass(), stereotypes, alternative);
+ super(ownerComponent.getWebBeansContext(), webBeansType, beanAttributes, ownerComponent.getBeanClass());
this.ownerComponent = ownerComponent;
this.returnType = returnType;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanAttributesImpl.java Thu Jan 24 08:27:26 2013
@@ -24,6 +24,11 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.util.AnnotationUtil;
+
public class BeanAttributesImpl<T>
{
private final Set<Type> types;
@@ -34,6 +39,45 @@ public class BeanAttributesImpl<T>
private final Set<Class<? extends Annotation>> stereotypes;
private final boolean alternative;
+ public BeanAttributesImpl(Bean<T> bean)
+ {
+ this(bean.getTypes(),
+ bean.getQualifiers(),
+ bean.getScope(),
+ bean.getName(),
+ bean.isNullable(),
+ bean.getStereotypes(),
+ bean.isAlternative());
+ }
+
+ public BeanAttributesImpl(BeanAttributesImpl<T> beanAttributes)
+ {
+ this(beanAttributes.getTypes(),
+ beanAttributes.getQualifiers(),
+ beanAttributes.getScope(),
+ beanAttributes.getName(),
+ beanAttributes.isNullable(),
+ beanAttributes.getStereotypes(),
+ beanAttributes.isAlternative());
+ }
+
+ public BeanAttributesImpl(Set<Type> types)
+ {
+ this(types, AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, Dependent.class, null, false, Collections.<Class<? extends Annotation>>emptySet(), false);
+ }
+
+ public BeanAttributesImpl(Set<Type> types, Set<Annotation> qualifiers)
+ {
+ this(types, qualifiers, Dependent.class, null, false, Collections.<Class<? extends Annotation>>emptySet(), false);
+ }
+
+ public BeanAttributesImpl(Set<Type> types,
+ Set<Annotation> qualifiers,
+ Class<? extends Annotation> scope)
+ {
+ this(types, qualifiers, scope, null, false, Collections.<Class<? extends Annotation>>emptySet(), false);
+ }
+
public BeanAttributesImpl(Set<Type> types,
Set<Annotation> qualifiers,
Class<? extends Annotation> scope,
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BeanManagerBean.java Thu Jan 24 08:27:26 2013
@@ -18,11 +18,8 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
-import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.BeanManager;
import org.apache.webbeans.config.WebBeansContext;
@@ -36,11 +33,8 @@ public class BeanManagerBean extends Abs
{
super(webBeansContext,
WebBeansType.MANAGER,
- CollectionUtil.<Type>unmodifiableSet(BeanManager.class, Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- Dependent.class,
- BeanManager.class,
- Collections.<Class<? extends Annotation>>emptySet());
+ new BeanAttributesImpl<BeanManager>(CollectionUtil.<Type>unmodifiableSet(BeanManager.class, Object.class), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION),
+ BeanManager.class);
setProducer(new BeanManagerProducer(webBeansContext));
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/BuildInOwbBean.java Thu Jan 24 08:27:26 2013
@@ -18,12 +18,7 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
-
-import javax.enterprise.context.Dependent;
-import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.CollectionUtil;
import org.apache.webbeans.config.WebBeansContext;
@@ -33,12 +28,6 @@ public abstract class BuildInOwbBean<T>
protected BuildInOwbBean(WebBeansContext webBeansContext, WebBeansType webBeansType, Class<T> returnType)
{
- super(webBeansContext,
- webBeansType,
- CollectionUtil.<Type>unmodifiableSet(returnType, Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- Dependent.class,
- returnType,
- Collections.<Class<? extends Annotation>>emptySet());
+ super(webBeansContext, webBeansType, new BeanAttributesImpl<T>(CollectionUtil.<Type>unmodifiableSet(returnType, Object.class)), returnType);
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/CdiInterceptorBean.java Thu Jan 24 08:27:26 2013
@@ -23,7 +23,6 @@ import javax.enterprise.inject.spi.Inter
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Map;
import java.util.Set;
@@ -43,13 +42,13 @@ public class CdiInterceptorBean<T> exten
public CdiInterceptorBean(WebBeansContext webBeansContext,
AnnotatedType<T> annotatedType,
- Set<Type> types,
+ BeanAttributesImpl<T> beanAttributes,
Class<T> beanClass,
Set<Annotation> interceptorBindings,
boolean enabled,
Map<InterceptionType, Method[]> interceptionMethods)
{
- super(webBeansContext, annotatedType, types, beanClass, interceptionMethods);
+ super(webBeansContext, annotatedType, beanAttributes, beanClass, interceptionMethods);
this.interceptorBindings = interceptorBindings;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ConversationBean.java Thu Jan 24 08:27:26 2013
@@ -47,13 +47,15 @@ public class ConversationBean extends In
super(webBeansContext,
WebBeansType.CONVERSATION,
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(ConversationImpl.class),
- CollectionUtil.<Type>unmodifiableSet(Conversation.class, ConversationImpl.class, Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- RequestScoped.class,
- "javax.enterprise.context.conversation",
- ConversationImpl.class,
- Collections.<Class<? extends Annotation>>emptySet(),
- false);
+ new BeanAttributesImpl<ConversationImpl>(
+ CollectionUtil.<Type>unmodifiableSet(Conversation.class, ConversationImpl.class, Object.class),
+ AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
+ RequestScoped.class,
+ "javax.enterprise.context.conversation",
+ false,
+ Collections.<Class<? extends Annotation>>emptySet(),
+ false),
+ ConversationImpl.class);
setEnabled(true);
setProducer(new ConversationProducer(getAnnotatedType(), webBeansContext));
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.java Thu Jan 24 08:27:26 2013
@@ -53,10 +53,13 @@ public class DecoratorBean<T> extends In
private Set<Annotation> delegateQualifiers;
- public DecoratorBean(WebBeansContext webBeansContext, WebBeansType webBeansType, AnnotatedType<T> annotatedType, Set<Type> types,
- Set<Annotation> qualifiers, Class<? extends Annotation> scope, Class<T> beanClass, Set<Class<? extends Annotation>> stereotypes)
+ public DecoratorBean(WebBeansContext webBeansContext,
+ WebBeansType webBeansType,
+ AnnotatedType<T> annotatedType,
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> beanClass)
{
- super(webBeansContext, webBeansType, annotatedType, types, qualifiers, scope, beanClass, stereotypes);
+ super(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass);
}
public void setDecoratorInfo(Set<Type> decoratedTypes, Type delegateType, Set<Annotation> delegateQualifiers)
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EjbInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EjbInterceptorBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EjbInterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EjbInterceptorBean.java Thu Jan 24 08:27:26 2013
@@ -23,7 +23,6 @@ import javax.enterprise.inject.spi.Inter
import javax.enterprise.inject.spi.Interceptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -38,9 +37,13 @@ import org.apache.webbeans.config.WebBea
public class EjbInterceptorBean<T> extends InterceptorBean<T> implements Interceptor<T>
{
- public EjbInterceptorBean(WebBeansContext webBeansContext, AnnotatedType<T> annotated, Set<Type> types, Class<T> beanClass, Map<InterceptionType, Method[]> interceptionMethods)
+ public EjbInterceptorBean(WebBeansContext webBeansContext,
+ AnnotatedType<T> annotated,
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> beanClass,
+ Map<InterceptionType, Method[]> interceptionMethods)
{
- super(webBeansContext, annotated, types, beanClass, interceptionMethods);
+ super(webBeansContext, annotated, beanAttributes, beanClass, interceptionMethods);
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/EventBean.java Thu Jan 24 08:27:26 2013
@@ -18,17 +18,13 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
-import javax.enterprise.context.Dependent;
import javax.enterprise.event.Event;
import javax.enterprise.util.TypeLiteral;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.portable.EventProducer;
-import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.CollectionUtil;
/**
@@ -48,11 +44,8 @@ public class EventBean<T> extends Abstra
{
super(webBeansContext,
WebBeansType.OBSERVABLE,
- CollectionUtil.<Type>unmodifiableSet(new TypeLiteral<Event<T>>() {}.getRawType(), Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- Dependent.class,
- new TypeLiteral<Event<T>>(){}.getRawType(),
- Collections.<Class<? extends Annotation>>emptySet());
+ new BeanAttributesImpl<Event<T>>(CollectionUtil.<Type>unmodifiableSet(new TypeLiteral<Event<T>>() {}.getRawType(), Object.class)),
+ new TypeLiteral<Event<T>>(){}.getRawType());
setProducer(new EventProducer<T>(webBeansContext));
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ExtensionBean.java Thu Jan 24 08:27:26 2013
@@ -18,9 +18,6 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-
import javax.enterprise.context.ApplicationScoped;
import org.apache.webbeans.config.WebBeansContext;
@@ -47,11 +44,11 @@ public class ExtensionBean<T> extends In
super(webBeansContext,
WebBeansType.EXTENSION,
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(returnType),
- webBeansContext.getAnnotatedElementFactory().newAnnotatedType(returnType).getTypeClosure(),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- ApplicationScoped.class,
- returnType,
- Collections.<Class<? extends Annotation>>emptySet());
+ new BeanAttributesImpl<T>(
+ webBeansContext.getAnnotatedElementFactory().getAnnotatedType(returnType).getTypeClosure(),
+ AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
+ ApplicationScoped.class),
+ returnType);
setEnabled(true);
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionPointBean.java Thu Jan 24 08:27:26 2013
@@ -18,16 +18,12 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
-import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.portable.InjectionPointProducer;
-import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.CollectionUtil;
public class InjectionPointBean extends AbstractOwbBean<InjectionPoint>
@@ -36,11 +32,8 @@ public class InjectionPointBean extends
{
super(webBeansContext,
WebBeansType.INJECTIONPOINT,
- CollectionUtil.<Type>unmodifiableSet(InjectionPoint.class, Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- Dependent.class,
- InjectionPoint.class,
- Collections.<Class<? extends Annotation>>emptySet());
+ new BeanAttributesImpl<InjectionPoint>(CollectionUtil.<Type>unmodifiableSet(InjectionPoint.class, Object.class)),
+ InjectionPoint.class);
setProducer(new InjectionPointProducer());
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InjectionTargetBean.java Thu Jan 24 08:27:26 2013
@@ -18,16 +18,13 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -55,36 +52,19 @@ public abstract class InjectionTargetBea
/**Annotated type for bean*/
private AnnotatedType<T> annotatedType;
- protected InjectionTargetBean(WebBeansContext webBeansContext,
- WebBeansType webBeansType,
- AnnotatedType<T> annotatedType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes)
- {
- this(webBeansContext, webBeansType, annotatedType, types, qualifiers, scope, null, beanClass, stereotypes, false);
- setEnabled(true);
- }
-
/**
* Initializes the InjectionTarget Bean part.
*/
protected InjectionTargetBean(WebBeansContext webBeansContext,
WebBeansType webBeansType,
AnnotatedType<T> annotatedType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> beanClass)
{
- super(webBeansContext, webBeansType, types, qualifiers, scope, name, false, beanClass, stereotypes, alternative);
+ super(webBeansContext, webBeansType, beanAttributes, beanClass);
Asserts.assertNotNull(annotatedType, "AnnotatedType may not be null");
this.annotatedType = annotatedType;
+ setEnabled(true);
}
public InjectionTarget<T> getInjectionTarget()
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InstanceBean.java Thu Jan 24 08:27:26 2013
@@ -18,11 +18,8 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Collections;
-import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Instance;
import javax.enterprise.util.TypeLiteral;
import javax.inject.Provider;
@@ -40,11 +37,11 @@ public class InstanceBean<T> extends Abs
{
super(webBeansContext,
WebBeansType.INSTANCE,
- CollectionUtil.<Type>unmodifiableSet(new TypeLiteral<Instance<T>>(){}.getRawType(), new TypeLiteral<Provider<T>>() {}.getRawType(), Object.class),
- AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION,
- Dependent.class,
- new TypeLiteral<Instance<T>>(){}.getRawType(),
- Collections.<Class<? extends Annotation>>emptySet());
+ new BeanAttributesImpl<Instance<T>>(CollectionUtil.<Type>unmodifiableSet(
+ new TypeLiteral<Instance<T>>(){}.getRawType(),
+ new TypeLiteral<Provider<T>>() {}.getRawType(),
+ Object.class)),
+ new TypeLiteral<Instance<T>>(){}.getRawType());
setProducer(new InstanceProducer<T>(getReturnType(), AnnotationUtil.DEFAULT_AND_ANY_ANNOTATION, webBeansContext));
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/InterceptorBean.java Thu Jan 24 08:27:26 2013
@@ -26,10 +26,8 @@ import javax.interceptor.InvocationConte
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Map;
-import java.util.Set;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.util.ExceptionUtil;
@@ -61,18 +59,15 @@ public abstract class InterceptorBean<T>
public InterceptorBean(WebBeansContext webBeansContext,
AnnotatedType<T> annotatedType,
- Set<Type> types,
+ BeanAttributesImpl<T> beanAttributes,
Class<T> beanClass,
Map<InterceptionType, Method[]> interceptionMethods)
{
super(webBeansContext,
WebBeansType.INTERCEPTOR,
annotatedType,
- types,
- Collections.<Annotation>emptySet(),
- Dependent.class,
- beanClass,
- Collections.<Class<? extends Annotation>>emptySet());
+ beanAttributes,
+ beanClass);
this.interceptionMethods = Collections.unmodifiableMap(interceptionMethods);
for (Method[] methods: interceptionMethods.values())
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ManagedBean.java Thu Jan 24 08:27:26 2013
@@ -18,10 +18,7 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
-import java.lang.reflect.Type;
-import java.util.Set;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.PassivationCapable;
@@ -40,28 +37,11 @@ public class ManagedBean<T> extends Inje
public ManagedBean(WebBeansContext webBeansContext,
WebBeansType webBeansType,
- AnnotatedType<T> annotatedType,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes)
- {
- super(webBeansContext, webBeansType, annotatedType, types, qualifiers, scope, beanClass, stereotypes);
- }
-
- public ManagedBean(WebBeansContext webBeansContext,
- WebBeansType webBeansType,
AnnotatedType<T> annotated,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> beanClass)
{
- super(webBeansContext, webBeansType, annotated, types, qualifiers, scope, name, beanClass, stereotypes, alternative);
+ super(webBeansContext, webBeansType, annotated, beanAttributes, beanClass);
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/NewManagedBean.java Thu Jan 24 08:27:26 2013
@@ -18,14 +18,15 @@
*/
package org.apache.webbeans.component;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
+import java.util.Collections;
import java.util.Set;
-import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.portable.InjectionTargetImpl;
/**
* Component definition with {@link javax.enterprise.inject.New} binding annotation.
@@ -41,12 +42,13 @@ public class NewManagedBean<T> extends M
public NewManagedBean(WebBeansContext webBeansContext,
WebBeansType webBeansType,
AnnotatedType<T> annotatedType,
- Set<Type> types,
- Set<Annotation> qualifiers,
+ BeanAttributesImpl<T> beanAttributes,
Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes)
+ Set<InjectionPoint> injectionPoints)
{
- super(webBeansContext, webBeansType, annotatedType, types, qualifiers, Dependent.class, beanClass, stereotypes);
+ super(webBeansContext, webBeansType, annotatedType, beanAttributes, beanClass);
+ setProducer(new InjectionTargetImpl<T>(
+ annotatedType, injectionPoints, webBeansContext, Collections.<AnnotatedMethod<?>>emptyList(), Collections.<AnnotatedMethod<?>>emptyList()));
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerFieldBean.java Thu Jan 24 08:27:26 2013
@@ -19,10 +19,7 @@
package org.apache.webbeans.component;
import java.io.Serializable;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -45,17 +42,9 @@ public class ProducerFieldBean<T> extend
*
* @param returnType type of the field decleration
*/
- public ProducerFieldBean(InjectionTargetBean<?> ownerComponent,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> returnType,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ public ProducerFieldBean(InjectionTargetBean<?> ownerComponent, BeanAttributesImpl<T> beanAttributes, Class<T> returnType)
{
- super(ownerComponent, WebBeansType.PRODUCERFIELD, types, qualifiers, scope, name, nullable, returnType, stereotypes, alternative);
+ super(ownerComponent, WebBeansType.PRODUCERFIELD, beanAttributes, returnType);
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ProducerMethodBean.java Thu Jan 24 08:27:26 2013
@@ -19,10 +19,7 @@
package org.apache.webbeans.component;
import java.io.Serializable;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
@@ -54,16 +51,10 @@ public class ProducerMethodBean<T> exten
* @param returnType producer method return type
*/
public <P> ProducerMethodBean(InjectionTargetBean<P> ownerComponent,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> returnType,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ BeanAttributesImpl<T> beanAttributes,
+ Class<T> returnType)
{
- super(ownerComponent, WebBeansType.PRODUCERMETHOD, types, qualifiers, scope, name, nullable, returnType, stereotypes, alternative);
+ super(ownerComponent, WebBeansType.PRODUCERMETHOD, beanAttributes, returnType);
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ResourceBean.java Thu Jan 24 08:27:26 2013
@@ -19,8 +19,6 @@
package org.apache.webbeans.component;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Set;
import org.apache.webbeans.spi.ResourceInjectionService;
import org.apache.webbeans.spi.api.ResourceReference;
@@ -32,16 +30,10 @@ public class ResourceBean<X, T extends A
public ResourceBean(InjectionTargetBean<?> ownerComponent,
ResourceReference<X, T> resourceReference,
- Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<X> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ BeanAttributesImpl<X> beanAttributes,
+ Class<X> beanClass)
{
- super(ownerComponent, types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative);
+ super(ownerComponent, beanAttributes, beanClass);
this.resourceReference = resourceReference;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/SelfInterceptorBean.java Thu Jan 24 08:27:26 2013
@@ -24,7 +24,6 @@ import javax.enterprise.inject.spi.Inter
import javax.enterprise.inject.spi.Interceptor;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Type;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
@@ -44,11 +43,11 @@ public class SelfInterceptorBean<T> exte
public SelfInterceptorBean(WebBeansContext webBeansContext,
AnnotatedType<T> annotatedType,
- Set<Type> types,
+ BeanAttributesImpl<T> beanAttributes,
Class<T> beanClass,
Map<InterceptionType, Method[]> interceptionMethods)
{
- super(webBeansContext, annotatedType, types, beanClass, interceptionMethods);
+ super(webBeansContext, annotatedType, beanAttributes, beanClass, interceptionMethods);
}
/**
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -20,41 +20,27 @@ package org.apache.webbeans.component.cr
import static org.apache.webbeans.util.InjectionExceptionUtil.throwUnproxyableResolutionException;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.context.NormalScope;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Specializes;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMember;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.util.Nonbinding;
-import javax.inject.Named;
-import javax.inject.Scope;
-
-import org.apache.webbeans.annotation.AnnotationManager;
-import org.apache.webbeans.annotation.AnyLiteral;
-import org.apache.webbeans.annotation.DefaultLiteral;
-import org.apache.webbeans.annotation.NamedLiteral;
+
+import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.OwbBean;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.container.ExternalScope;
import org.apache.webbeans.event.EventUtil;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.exception.helper.ViolationMessageBuilder;
-import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.SecurityUtil;
import org.apache.webbeans.util.WebBeansUtil;
@@ -71,17 +57,9 @@ public abstract class AbstractBeanBuilde
private A annotated;
private WebBeansContext webBeansContext;
-
- private String beanName;
-
- private Class<? extends Annotation> scope;
- private Set<Type> apiTypes = new HashSet<Type>();
-
- private Set<Annotation> qualifiers = new HashSet<Annotation>();
-
- private Set<Class<? extends Annotation>> stereotypes = new HashSet<Class<? extends Annotation>>();
-
+ private BeanAttributesImpl<T> beanAttributes;
+
private Set<AnnotatedMember<? super T>> injectionPoints = new HashSet<AnnotatedMember<? super T>>();
/**
@@ -89,30 +67,19 @@ public abstract class AbstractBeanBuilde
*
* @param annotated
*/
- public AbstractBeanBuilder(WebBeansContext webBeansContext, A annotated)
+ public AbstractBeanBuilder(WebBeansContext webBeansContext, A annotated, BeanAttributesImpl<T> beanAttributes)
{
+ Asserts.assertNotNull(webBeansContext, "webBeansContext may not be null");
+ Asserts.assertNotNull(annotated, "annotated may not be null");
+ Asserts.assertNotNull(beanAttributes, "beanAttributes may not be null");
this.annotated = annotated;
this.webBeansContext = webBeansContext;
+ this.beanAttributes = beanAttributes;
}
- public Class<? extends Annotation> getScope()
- {
- return scope;
- }
-
- public String getName()
- {
- return beanName;
- }
-
- protected Set<Class<? extends Annotation>> getStereotypes()
- {
- return stereotypes;
- }
-
- protected Set<Type> getApiTypes()
+ public BeanAttributesImpl<T> getBeanAttributes()
{
- return apiTypes;
+ return beanAttributes;
}
/**
@@ -191,161 +158,6 @@ public abstract class AbstractBeanBuilde
return false;
}
-
-
- /**
- * {@inheritDoc}
- */
- public void defineApiType()
- {
- if (getBeanType().isArray())
- {
- // 3.3.1
- apiTypes.add(Object.class);
- apiTypes.add(getBeanType());
- }
- else
- {
- Set<Type> types = annotated.getTypeClosure();
- apiTypes.addAll(types);
- Set<String> ignored = webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces();
- for (Iterator<Type> i = apiTypes.iterator(); i.hasNext();)
- {
- Type t = i.next();
- if (t instanceof Class && ignored.contains(((Class<?>)t).getName()))
- {
- i.remove();
- }
- }
- }
- }
-
- protected void defineName(Annotated annotated, String name)
- {
- Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
- Named nameAnnot = null;
- boolean isDefault = false;
- for (Annotation ann : anns)
- {
- if (ann.annotationType().equals(Named.class))
- {
- nameAnnot = (Named) ann;
- break;
- }
- }
-
- if (nameAnnot == null) // no @Named
- {
- // Check for stereottype
- if (webBeansContext.getAnnotationManager().hasNamedOnStereoTypes(stereotypes))
- {
- isDefault = true;
- }
-
- }
- else
- // yes @Named
- {
- if (nameAnnot.value().equals(""))
- {
- isDefault = true;
- }
- else
- {
- beanName = nameAnnot.value();
- }
-
- }
-
- if (isDefault)
- {
- beanName = name;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void defineQualifiers()
- {
- HashSet<Class<? extends Annotation>> qualifiedTypes = new HashSet<Class<? extends Annotation>>();
- if (annotated.isAnnotationPresent(Specializes.class))
- {
- defineQualifiers(getSuperAnnotated(), qualifiedTypes);
- }
- defineQualifiers(annotated, qualifiedTypes);
- }
-
- protected abstract Annotated getSuperAnnotated();
-
- private void defineQualifiers(Annotated annotated, Set<Class<? extends Annotation>> qualifiedTypes)
- {
- Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
- final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
-
- for (Annotation annotation : annotations)
- {
- Class<? extends Annotation> type = annotation.annotationType();
-
- if (annotationManager.isQualifierAnnotation(type))
- {
- Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(type);
-
- for (Method method : methods)
- {
- Class<?> clazz = method.getReturnType();
- if (clazz.isArray() || clazz.isAnnotation())
- {
- if (!AnnotationUtil.hasAnnotation(method.getDeclaredAnnotations(), Nonbinding.class))
- {
- throw new WebBeansConfigurationException("WebBeans definition class : " + method.getDeclaringClass().getName() + " @Qualifier : "
- + annotation.annotationType().getName()
- + " must have @NonBinding valued members for its array-valued and annotation valued members");
- }
- }
- }
-
- if (qualifiedTypes.contains(annotation.annotationType()))
- {
- continue;
- }
- else
- {
- qualifiedTypes.add(annotation.annotationType());
- }
- if (annotation.annotationType().equals(Named.class) && beanName != null)
- {
- qualifiers.add(new NamedLiteral(beanName));
- }
- else
- {
- qualifiers.add(annotation);
- }
- }
- }
-
- // No-binding annotation
- if (qualifiers.size() == 0 )
- {
- qualifiers.add(DefaultLiteral.INSTANCE);
- }
- else if(qualifiers.size() == 1)
- {
- Annotation annot = qualifiers.iterator().next();
- if(annot.annotationType().equals(Named.class))
- {
- qualifiers.add(DefaultLiteral.INSTANCE);
- }
- }
-
- //Add @Any support
- if(!hasAnyQualifier())
- {
- qualifiers.add(new AnyLiteral());
- }
-
- }
-
protected void addInjectionPoint(AnnotatedMember<? super T> member)
{
injectionPoints.add(member);
@@ -360,172 +172,13 @@ public abstract class AbstractBeanBuilde
}
/**
- * Returns true if any binding exist
- *
- * @return true if any binding exist
- */
- private boolean hasAnyQualifier()
- {
- return AnnotationUtil.getAnnotation(qualifiers, Any.class) != null;
- }
-
- public void defineScopeType(String errorMessage)
- {
- defineScopeType(null, errorMessage);
- }
-
- protected void defineScopeType(Class<?> declaringClass, String errorMessage)
- {
- Annotation[] annotations = AnnotationUtil.asArray(annotated.getAnnotations());
- boolean found = false;
-
- List<ExternalScope> additionalScopes = webBeansContext.getBeanManagerImpl().getAdditionalScopes();
-
- for (Annotation annotation : annotations)
- {
- if (declaringClass != null && AnnotationUtil.getDeclaringClass(annotation, declaringClass) != null && !AnnotationUtil.isDeclaringClass(declaringClass, annotation))
- {
- continue;
- }
- Class<? extends Annotation> annotationType = annotation.annotationType();
-
- /*Normal scope*/
- Annotation var = annotationType.getAnnotation(NormalScope.class);
- /*Pseudo scope*/
- Annotation pseudo = annotationType.getAnnotation(Scope.class);
-
- if (var == null && pseudo == null)
- {
- // check for additional scopes registered via a CDI Extension
- for (ExternalScope additionalScope : additionalScopes)
- {
- if (annotationType.equals(additionalScope.getScope()))
- {
- // create a proxy which implements the given annotation
- Annotation scopeAnnotation = additionalScope.getScopeAnnotation();
-
- if (additionalScope.isNormal())
- {
- var = scopeAnnotation;
- }
- else
- {
- pseudo = scopeAnnotation;
- }
- }
- }
- }
-
- if (var != null)
- {
- if(pseudo != null)
- {
- throw new WebBeansConfigurationException("Not to define both @Scope and @NormalScope on bean : " + getBeanType().getName());
- }
-
- if (found)
- {
- throw new WebBeansConfigurationException(errorMessage);
- }
-
- found = true;
- scope = annotation.annotationType();
- }
- else
- {
- if(pseudo != null)
- {
- if (found)
- {
- throw new WebBeansConfigurationException(errorMessage);
- }
-
- found = true;
- scope = annotation.annotationType();
- }
- }
- }
-
- if (!found && declaringClass != null && !hasDeclaredNonInheritedScope(declaringClass))
- {
- defineScopeType(declaringClass.getSuperclass(), errorMessage);
- }
- else if (!found)
- {
- defineDefaultScopeType(errorMessage);
- }
- }
-
- private void defineDefaultScopeType(String exceptionMessage)
- {
- if (scope == null)
- {
- Set<Class<? extends Annotation>> stereos = stereotypes;
- if (stereos.size() == 0)
- {
- scope = Dependent.class;
- }
- else
- {
- Annotation defined = null;
- Set<Class<? extends Annotation>> anns = stereotypes;
- for (Class<? extends Annotation> stero : anns)
- {
- boolean containsNormal = AnnotationUtil.hasMetaAnnotation(stero.getDeclaredAnnotations(), NormalScope.class);
-
- if (AnnotationUtil.hasMetaAnnotation(stero.getDeclaredAnnotations(), NormalScope.class) ||
- AnnotationUtil.hasMetaAnnotation(stero.getDeclaredAnnotations(), Scope.class))
- {
- Annotation next;
-
- if(containsNormal)
- {
- next = AnnotationUtil.getMetaAnnotations(stero.getDeclaredAnnotations(), NormalScope.class)[0];
- }
- else
- {
- next = AnnotationUtil.getMetaAnnotations(stero.getDeclaredAnnotations(), Scope.class)[0];
- }
-
- if (defined == null)
- {
- defined = next;
- }
- else
- {
- if (!defined.equals(next))
- {
- throw new WebBeansConfigurationException(exceptionMessage);
- }
- }
- }
- }
-
- if (defined != null)
- {
- scope = defined.annotationType();
- }
- else
- {
- scope = Dependent.class;
- }
- }
- }
- }
-
- private boolean hasDeclaredNonInheritedScope(Class<?> type)
- {
- return webBeansContext.getAnnotationManager().getDeclaredScopeAnnotation(type) != null;
- }
-
- /**
* Checks the unproxiable condition.
- * @throws WebBeansConfigurationException if bean is not proxied by the container
+ * @throws org.apache.webbeans.exception.WebBeansConfigurationException if bean is not proxied by the container
*/
protected void checkUnproxiableApiType()
{
//Unproxiable test for NormalScoped beans
- if (webBeansContext.getBeanManagerImpl().isNormalScope(scope))
+ if (webBeansContext.getBeanManagerImpl().isNormalScope(beanAttributes.getScope()))
{
ViolationMessageBuilder violationMessage = ViolationMessageBuilder.newViolation();
@@ -582,25 +235,6 @@ public abstract class AbstractBeanBuilde
}
}
- /**
- * {@inheritDoc}
- */
- public void defineStereoTypes()
- {
- Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
- final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
- if (annotationManager.hasStereoTypeMetaAnnotation(anns))
- {
- Annotation[] steroAnns =
- annotationManager.getStereotypeMetaAnnotations(anns);
-
- for (Annotation stereo : steroAnns)
- {
- stereotypes.add(stereo.annotationType());
- }
- }
- }
-
protected <X> void addFieldInjectionPointMetaData(OwbBean<T> bean, AnnotatedField<X> annotField)
{
InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().getFieldInjectionPointData(bean, annotField);
@@ -629,21 +263,14 @@ public abstract class AbstractBeanBuilde
}
}
- protected abstract B createBean(Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> returnType,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative);
+ protected abstract B createBean(Class<T> returnType);
/**
* {@inheritDoc}
*/
public B getBean()
{
- B bean = createBean(apiTypes, qualifiers, getScope(), beanName, false, getBeanType(), stereotypes, false);
+ B bean = createBean(getBeanType());
for (Iterator<AnnotatedMember<? super T>> memberIterator = injectionPoints.iterator(); memberIterator.hasNext();)
{
AnnotatedMember<? super T> member = memberIterator.next();
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1437893&r1=1437892&r2=1437893&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java Thu Jan 24 08:27:26 2013
@@ -54,6 +54,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import org.apache.webbeans.annotation.AnnotationManager;
+import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
@@ -62,7 +63,6 @@ import org.apache.webbeans.component.Res
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.exception.inject.DefinitionException;
import org.apache.webbeans.portable.InjectionTargetImpl;
import org.apache.webbeans.portable.ProducerFieldProducer;
import org.apache.webbeans.portable.ProducerMethodProducer;
@@ -91,9 +91,9 @@ public abstract class AbstractInjectionT
* Creates a new instance.
*
*/
- public AbstractInjectionTargetBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType)
+ public AbstractInjectionTargetBeanBuilder(WebBeansContext webBeansContext, AnnotatedType<T> annotatedType, BeanAttributesImpl<T> beanAttributes)
{
- super(webBeansContext, annotatedType);
+ super(webBeansContext, annotatedType, beanAttributes);
this.webBeansContext = webBeansContext;
}
@@ -107,31 +107,6 @@ public abstract class AbstractInjectionT
return webBeansContext.getAnnotatedElementFactory().getAnnotatedType(superclass);
}
- /**
- * {@inheritDoc}
- */
- public void defineName()
- {
- if (getAnnotated().isAnnotationPresent(Specializes.class))
- {
- AnnotatedType<? super T> superAnnotated = getSuperAnnotated();
- defineName(superAnnotated, WebBeansUtil.getManagedBeanDefaultName(superAnnotated.getJavaClass().getSimpleName()));
- }
- if (getName() == null)
- {
- defineName(getAnnotated(), WebBeansUtil.getManagedBeanDefaultName(getAnnotated().getJavaClass().getSimpleName()));
- }
- else
- {
- // TODO XXX We have to check stereotypes here, too
- if (getAnnotated().getJavaClass().isAnnotationPresent(Named.class))
- {
- throw new DefinitionException("@Specialized Class : " + getAnnotated().getJavaClass().getName()
- + " may not explicitly declare a bean name");
- }
- }
- }
-
protected AnnotatedConstructor<T> getBeanConstructor()
{
Asserts.assertNotNull(getAnnotated(),"Type is null");
@@ -309,11 +284,6 @@ public abstract class AbstractInjectionT
}
}
- public void defineScopeType(String errorMessage)
- {
- defineScopeType(getAnnotated().getJavaClass(), errorMessage);
- }
-
/**
* {@inheritDoc}
*/
@@ -326,7 +296,7 @@ public abstract class AbstractInjectionT
{
if(Modifier.isPublic(annotatedField.getJavaMember().getModifiers()) && !annotatedField.isStatic())
{
- if(webBeansContext.getBeanManagerImpl().isNormalScope(getScope()))
+ if(webBeansContext.getBeanManagerImpl().isNormalScope(getBeanAttributes().getScope()))
{
throw new WebBeansConfigurationException("If bean has a public field, bean scope must be defined as @Scope. Bean is : "
+ getBeanType().getName());
@@ -347,7 +317,7 @@ public abstract class AbstractInjectionT
Annotation[] anns = AnnotationUtil.asArray(annotatedField.getAnnotations());
if(Modifier.isPublic(field.getModifiers()))
{
- if(!getScope().equals(Dependent.class))
+ if(!getBeanAttributes().getScope().equals(Dependent.class))
{
throw new WebBeansConfigurationException("Error in annotated field : " + annotatedField
+" while definining injected field. If bean has a public modifier injection point, bean scope must be defined as @Dependent");
@@ -573,9 +543,9 @@ public abstract class AbstractInjectionT
throw new WebBeansConfigurationException("Resource producer annotated field : " + annotatedField + " can not define EL name");
}
+ BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<T>)annotatedField).build();
ResourceBeanBuilder<T, Annotation> resourceBeanCreator
- = new ResourceBeanBuilder<T, Annotation>(bean, resourceRef, annotatedField);
- resourceBeanCreator.defineQualifiers();
+ = new ResourceBeanBuilder<T, Annotation>(bean, resourceRef, annotatedField, beanAttributes);
ResourceBean<T, Annotation> resourceBean = resourceBeanCreator.getBean();
ResourceProvider<T> resourceProvider = new ResourceProvider<T>(resourceBean.getReference(), webBeansContext);
resourceBean.setProducer(new ProviderBasedProxyProducer<T>(webBeansContext, resourceBean.getReturnType(), resourceProvider));
@@ -588,13 +558,10 @@ public abstract class AbstractInjectionT
}
else
{
- ProducerFieldBeanBuilder<T, ProducerFieldBean<T>> producerFieldBeanCreator = new ProducerFieldBeanBuilder<T, ProducerFieldBean<T>>(bean, annotatedField);
- producerFieldBeanCreator.defineApiType();
- producerFieldBeanCreator.defineStereoTypes();
- producerFieldBeanCreator.defineScopeType("Annotated producer field: " + annotatedField + "must declare default @Scope annotation");
+ BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedField<T>)annotatedField).build();
+ ProducerFieldBeanBuilder<T, ProducerFieldBean<T>> producerFieldBeanCreator
+ = new ProducerFieldBeanBuilder<T, ProducerFieldBean<T>>(bean, annotatedField, beanAttributes);
producerFieldBeanCreator.checkUnproxiableApiType();
- producerFieldBeanCreator.defineQualifiers();
- producerFieldBeanCreator.defineName();
ProducerFieldBean<T> producerFieldBean = producerFieldBeanCreator.getBean();
producerFieldBean.setProducer(new ProducerFieldProducer(bean, annotatedField, producerFieldBean.getInjectionPoints()));
producerFieldBean.setProducerField(field);
@@ -639,17 +606,12 @@ public abstract class AbstractInjectionT
specialize = true;
}
- ProducerMethodBeanBuilder<T> producerMethodBeanCreator = new ProducerMethodBeanBuilder<T>(bean, annotatedMethod);
+ BeanAttributesImpl<T> beanAttributes = BeanAttributesBuilder.forContext(webBeansContext).newBeanAttibutes((AnnotatedMethod<T>)annotatedMethod).build();
+ ProducerMethodBeanBuilder<T> producerMethodBeanCreator = new ProducerMethodBeanBuilder<T>(bean, annotatedMethod, beanAttributes);
- producerMethodBeanCreator.defineStereoTypes();
- producerMethodBeanCreator.defineScopeType("Annotated producer method : " + annotatedMethod
- + "must declare default @Scope annotation");
producerMethodBeanCreator.checkUnproxiableApiType();
- producerMethodBeanCreator.defineQualifiers();
-
+
producerMethodBeanCreator.addInjectionPoint(annotatedMethod);
- producerMethodBeanCreator.defineApiType();
- producerMethodBeanCreator.defineName();
ProducerMethodBean<T> producerMethodBean = producerMethodBeanCreator.getBean();
if(specialize)
@@ -695,9 +657,7 @@ public abstract class AbstractInjectionT
}
}
- protected InjectionTarget<T> buildInjectionTarget(Set<Type> types,
- Set<Annotation> qualifiers,
- AnnotatedType<T> annotatedType,
+ protected InjectionTarget<T> buildInjectionTarget(AnnotatedType<T> annotatedType,
Set<InjectionPoint> points,
WebBeansContext webBeansContext,
List<AnnotatedMethod<?>> postConstructMethods,
@@ -708,31 +668,16 @@ public abstract class AbstractInjectionT
return injectionTarget;
}
- protected abstract I createBean(Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative,
- boolean enabled);
+ protected abstract I createBean(Class<T> beanClass, boolean enabled);
@Override
- protected final I createBean(Set<Type> types,
- Set<Annotation> qualifiers,
- Class<? extends Annotation> scope,
- String name,
- boolean nullable,
- Class<T> beanClass,
- Set<Class<? extends Annotation>> stereotypes,
- boolean alternative)
+ protected final I createBean(Class<T> beanClass)
{
- I bean = createBean(types, qualifiers, scope, name, nullable, beanClass, stereotypes, alternative, enabled);
+ I bean = createBean(beanClass, enabled);
//X TODO hack to set the InjectionTarget
InjectionTarget<T> injectionTarget
- = buildInjectionTarget(types, qualifiers, bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
+ = buildInjectionTarget(bean.getAnnotatedType(), bean.getInjectionPoints(), webBeansContext, getPostConstructMethods(), getPreDestroyMethods());
bean.setProducer(injectionTarget);
return bean;
@@ -795,7 +740,7 @@ public abstract class AbstractInjectionT
public void defineEnabled()
{
- enabled = webBeansContext.getWebBeansUtil().isBeanEnabled(getAnnotated(), getBeanType(), getStereotypes());
+ enabled = webBeansContext.getWebBeansUtil().isBeanEnabled(getAnnotated(), getBeanType(), getBeanAttributes().getStereotypes());
}
@Override