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 22:20:12 UTC
svn commit: r1438200 - in /openwebbeans/trunk:
webbeans-ejb/src/main/java/org/apache/webbeans/ejb/common/util/
webbeans-impl/src/main/java/org/apache/webbeans/component/
webbeans-impl/src/main/java/org/apache/webbeans/component/creation/
webbeans-impl/...
Author: arne
Date: Thu Jan 24 21:20:11 2013
New Revision: 1438200
URL: http://svn.apache.org/viewvc?rev=1438200&view=rev
Log:
OWB-770: Moved creation of InjectionPoints to InjectionPointFactory
Modified:
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/BeanAttributesImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.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/BeanAttributesBuilder.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/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/ProducerMethodProducerBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
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=1438200&r1=1438199&r2=1438200&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 21:20:11 2013
@@ -172,7 +172,6 @@ public final class EjbUtility
// Let the plugin handle adding the new bean instance as it knows more about its EJB Bean
manager.getBeans().addAll(producerMethodBeans);
- ejbBeanCreator.validateDisposalMethods(ejbBean);
manager.getBeans().addAll(producerFieldBeans);
}
@@ -251,8 +250,6 @@ public final class EjbUtility
manager.getBeans().addAll(producerMethodBeans);
manager.getBeans().addAll(producerFieldBeans);
-
- ejbBeanCreator.validateDisposalMethods(ejbBean);
}
private static void checkProducerMethods(Set<ProducerMethodBean<?>> producerMethodBeans, BaseEjbBean<?> bean)
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=1438200&r1=1438199&r2=1438200&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 21:20:11 2013
@@ -68,9 +68,6 @@ public abstract class AbstractOwbBean<T>
/**This bean is enabled or disabled*/
protected boolean enabled = true;
- /** The bean allows nullable object */
- protected boolean nullable = true;
-
/**Beans injection points*/
protected Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
@@ -285,22 +282,6 @@ public abstract class AbstractOwbBean<T>
{
return (Class<T>) getBeanClass();
}
-
- /**
- * {@inheritDoc}
- */
- public void setNullable(boolean nullable)
- {
- this.nullable = nullable;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isNullable()
- {
- return nullable;
- }
/**
* {@inheritDoc}
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=1438200&r1=1438199&r2=1438200&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 21:20:11 2013
@@ -39,6 +39,9 @@ public class BeanAttributesImpl<T>
private final Set<Class<? extends Annotation>> stereotypes;
private final boolean alternative;
+ /**
+ * TODO This constructor can be removed, when we move to CDI 1.1 since {@link Bean} extends BeanAttributes.
+ */
public BeanAttributesImpl(Bean<T> bean)
{
this(bean.getTypes(),
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/OwbBean.java Thu Jan 24 21:20:11 2013
@@ -82,12 +82,6 @@ public interface OwbBean<T> extends Bean
public Class<T> getReturnType();
/**
- * Set nullable flag.
- * @param nullable flag
- */
- public void setNullable(boolean nullable);
-
- /**
* Set specialized flag.
* @param specialized flag
*/
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=1438200&r1=1438199&r2=1438200&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 21:20:11 2013
@@ -29,20 +29,15 @@ import java.util.List;
import java.util.Set;
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 org.apache.webbeans.component.BeanAttributesImpl;
-import org.apache.webbeans.component.OwbBean;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.event.EventUtil;
import org.apache.webbeans.exception.helper.ViolationMessageBuilder;
import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.SecurityUtil;
-import org.apache.webbeans.util.WebBeansUtil;
/**
* Abstract implementation.
@@ -235,34 +230,6 @@ public abstract class AbstractBeanBuilde
}
}
- protected <X> void addFieldInjectionPointMetaData(OwbBean<T> bean, AnnotatedField<X> annotField)
- {
- InjectionPoint injectionPoint = webBeansContext.getInjectionPointFactory().getFieldInjectionPointData(bean, annotField);
- if (injectionPoint != null)
- {
- addImplicitComponentForInjectionPoint(injectionPoint);
- bean.addInjectionPoint(injectionPoint);
- }
- }
-
- protected <X> void addMethodInjectionPointMetaData(OwbBean<T> bean, AnnotatedMethod<X> method)
- {
- List<InjectionPoint> methodInjectionPoints = webBeansContext.getInjectionPointFactory().getMethodInjectionPointData(bean, method);
- for (InjectionPoint injectionPoint : methodInjectionPoints)
- {
- addImplicitComponentForInjectionPoint(injectionPoint);
- bean.addInjectionPoint(injectionPoint);
- }
- }
-
- protected void addImplicitComponentForInjectionPoint(InjectionPoint injectionPoint)
- {
- if(!WebBeansUtil.checkObtainsInjectionPointConditions(injectionPoint))
- {
- EventUtil.checkObservableInjectionPointConditions(injectionPoint);
- }
- }
-
protected abstract B createBean(Class<T> returnType);
/**
@@ -270,21 +237,7 @@ public abstract class AbstractBeanBuilde
*/
public B getBean()
{
- B bean = createBean(getBeanType());
- for (Iterator<AnnotatedMember<? super T>> memberIterator = injectionPoints.iterator(); memberIterator.hasNext();)
- {
- AnnotatedMember<? super T> member = memberIterator.next();
- if (member instanceof AnnotatedField)
- {
- addFieldInjectionPointMetaData((OwbBean<T>)bean, (AnnotatedField<?>) member);
- }
- else if (member instanceof AnnotatedMethod)
- {
- addMethodInjectionPointMetaData((OwbBean<T>)bean, (AnnotatedMethod<?>) member);
- }
- }
-
- return bean;
+ return createBean(getBeanType());
}
protected A getAnnotated()
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=1438200&r1=1438199&r2=1438200&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 21:20:11 2013
@@ -18,8 +18,6 @@
*/
package org.apache.webbeans.component.creation;
-import static org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException;
-
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -45,11 +43,9 @@ import javax.enterprise.inject.spi.Annot
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InjectionTarget;
import javax.enterprise.inject.spi.ObserverMethod;
-import javax.enterprise.inject.spi.Producer;
import javax.inject.Inject;
import javax.inject.Named;
@@ -61,11 +57,9 @@ import org.apache.webbeans.component.Pro
import org.apache.webbeans.component.ResourceBean;
import org.apache.webbeans.component.ResourceProvider;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.portable.InjectionTargetImpl;
import org.apache.webbeans.portable.ProducerFieldProducer;
-import org.apache.webbeans.portable.ProducerMethodProducer;
import org.apache.webbeans.portable.ProviderBasedProxyProducer;
import org.apache.webbeans.spi.api.ResourceReference;
import org.apache.webbeans.util.AnnotationUtil;
@@ -188,105 +182,6 @@ public abstract class AbstractInjectionT
/**
* {@inheritDoc}
*/
- public void validateDisposalMethods(InjectionTargetBean<T> bean)
- {
- final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
- Set<AnnotatedMethod<? super T>> annotatedMethods = getAnnotated().getMethods();
- ProducerMethodBean<?> previous = null;
- for (InjectionPoint injectionPoint : bean.getInjectionPoints())
- {
- if (injectionPoint.getAnnotated().isAnnotationPresent(Disposes.class))
- {
- AnnotatedParameter<T> annotatedParameter = (AnnotatedParameter<T>) injectionPoint.getAnnotated();
- AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>) annotatedParameter.getDeclaringCallable();
- Method declaredMethod = annotatedMethod.getJavaMember();
- checkProducerMethodDisposal(annotatedMethod);
- Type type = AnnotationUtil.getAnnotatedMethodFirstParameterWithAnnotation(annotatedMethod, Disposes.class);
- Annotation[] annot = annotationManager.getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(annotatedMethod, Disposes.class);
-
- InjectionResolver injectionResolver = webBeansContext.getBeanManagerImpl().getInjectionResolver();
-
- Set<Bean<?>> set = injectionResolver.implResolveByType(type, annot);
- if (set.isEmpty())
- {
- throwUnsatisfiedResolutionException(type, declaredMethod, annot);
- }
-
- Bean<?> foundBean = set.iterator().next();
- ProducerMethodBean<?> pr = null;
-
- if (foundBean == null || !(foundBean instanceof ProducerMethodBean))
- {
- throwUnsatisfiedResolutionException(annotatedMethod.getDeclaringType().getJavaClass(), declaredMethod, annot);
- }
-
- pr = (ProducerMethodBean<?>) foundBean;
-
- if (previous == null)
- {
- previous = pr;
- }
- else
- {
- // multiple same producer
- if (previous.equals(pr))
- {
- throw new WebBeansConfigurationException("There are multiple disposal method for the producer method : " + pr.getCreatorMethod().getName() + " in class : "
- + annotatedMethod.getDeclaringType().getJavaClass());
- }
- }
-
- Method producerMethod = pr.getCreatorMethod();
- //Disposer methods and producer methods must be in the same class
- if(!producerMethod.getDeclaringClass().getName().equals(declaredMethod.getDeclaringClass().getName()))
- {
- throw new WebBeansConfigurationException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : "
- + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
- }
-
- pr.setDisposalMethod(declaredMethod);
- Producer<?> producer = pr.getProducer();
- if (producer instanceof ProducerMethodProducer)
- {
- ((ProducerMethodProducer)producer).setDisposalMethod(annotatedMethod);
- }
- }
- }
- }
-
- /**
- * CheckProducerMethodDisposal.
- * @param annotatedMethod disposal method
- */
- private void checkProducerMethodDisposal(AnnotatedMethod<T> annotatedMethod)
- {
- List<AnnotatedParameter<T>> parameters = annotatedMethod.getParameters();
- boolean found = false;
- for(AnnotatedParameter<T> parameter : parameters)
- {
- if(parameter.isAnnotationPresent(Disposes.class))
- {
- if(found)
- {
- throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
- + ". Multiple disposes annotation.");
- }
- found = true;
- }
- }
-
- if(annotatedMethod.isAnnotationPresent(Inject.class)
- || AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Observes.class)
- || annotatedMethod.isAnnotationPresent(Produces.class))
- {
- throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
- + ". Disposal methods can not be annotated with" + " @Initializer/@Destructor/@Produces annotation or has a parameter annotated with @Observes.");
- }
- }
-
- /**
- * {@inheritDoc}
- */
public void defineInjectedFields()
{
AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
@@ -565,11 +460,6 @@ public abstract class AbstractInjectionT
ProducerFieldBean<T> producerFieldBean = producerFieldBeanCreator.getBean();
producerFieldBean.setProducer(new ProducerFieldProducer(bean, annotatedField, producerFieldBean.getInjectionPoints()));
producerFieldBean.setProducerField(field);
-
- if (producerFieldBean.getReturnType().isPrimitive())
- {
- producerFieldBean.setNullable(false);
- }
webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean, producerFieldBean, anns);
WebBeansUtil.checkProducerGenericType(producerFieldBean, annotatedField.getJavaMember());
@@ -621,10 +511,6 @@ public abstract class AbstractInjectionT
ProducerMethodProducerBuilder producerBuilder = new ProducerMethodProducerBuilder(producerMethodBean);
producerMethodBean.setProducer(producerBuilder.build(annotatedMethod));
producerMethodBean.setCreatorMethod(annotatedMethod.getJavaMember());
- if (ClassUtil.getClass(annotatedMethod.getBaseType()).isPrimitive())
- {
- producerMethodBean.setNullable(false);
- }
webBeansContext.getWebBeansUtil().setBeanEnableFlagForProducerBean(bean,
producerMethodBean,
@@ -748,4 +634,15 @@ public abstract class AbstractInjectionT
{
return getAnnotated().getJavaClass();
}
+
+ @Override
+ public I getBean()
+ {
+ I bean = super.getBean();
+ for (InjectionPoint injectionPoint: webBeansContext.getInjectionPointFactory().buildInjectionPoints(bean, getAnnotated()))
+ {
+ bean.addInjectionPoint(injectionPoint);
+ }
+ return bean;
+ }
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractProducerBeanBuilder.java Thu Jan 24 21:20:11 2013
@@ -47,6 +47,7 @@ public abstract class AbstractProducerBe
}
protected abstract P createBean(InjectionTargetBean<?> parent, Class<T> beanClass);
+
@Override
protected P createBean(Class<T> beanClass)
{
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/BeanAttributesBuilder.java Thu Jan 24 21:20:11 2013
@@ -119,7 +119,7 @@ public abstract class BeanAttributesBuil
/**
* {@inheritDoc}
*/
- public void defineTypes()
+ protected void defineTypes()
{
Class<?> baseType = ClassUtil.getClass(annotated.getBaseType());
if (baseType.isArray())
@@ -147,7 +147,7 @@ public abstract class BeanAttributesBuil
/**
* {@inheritDoc}
*/
- public void defineQualifiers()
+ protected void defineQualifiers()
{
HashSet<Class<? extends Annotation>> qualifiedTypes = new HashSet<Class<? extends Annotation>>();
if (annotated.isAnnotationPresent(Specializes.class))
@@ -434,15 +434,17 @@ public abstract class BeanAttributesBuil
protected abstract Annotated getSuperAnnotated();
- public void defineNullable()
+ protected abstract void defineNullable();
+
+ protected void defineNullable(boolean nullable)
{
- nullable = false;
+ this.nullable = nullable;
}
/**
* {@inheritDoc}
*/
- public void defineStereotypes()
+ protected void defineStereotypes()
{
Annotation[] anns = AnnotationUtil.asArray(annotated.getAnnotations());
final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
@@ -458,7 +460,7 @@ public abstract class BeanAttributesBuil
}
}
- public void defineAlternative()
+ protected void defineAlternative()
{
alternative = false;
}
@@ -526,6 +528,12 @@ public abstract class BeanAttributesBuil
}
}
}
+
+ @Override
+ protected void defineNullable()
+ {
+ defineNullable(false);
+ }
@Override
protected AnnotatedType<? super C> getSuperAnnotated()
@@ -558,6 +566,12 @@ public abstract class BeanAttributesBuil
{
defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
}
+
+ @Override
+ protected void defineNullable()
+ {
+ defineNullable(!getAnnotated().getJavaMember().getType().isPrimitive());
+ }
@Override
protected AnnotatedField<? super M> getSuperAnnotated()
@@ -611,6 +625,12 @@ public abstract class BeanAttributesBuil
}
}
}
+
+ @Override
+ protected void defineNullable()
+ {
+ defineNullable(!getAnnotated().getJavaMember().getReturnType().isPrimitive());
+ }
@Override
protected AnnotatedMethod<? super M> getSuperAnnotated()
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java Thu Jan 24 21:20:11 2013
@@ -48,7 +48,6 @@ import org.apache.webbeans.config.OWBLog
import org.apache.webbeans.config.OwbParametrizedTypeImpl;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.inject.impl.InjectionPointFactory;
import org.apache.webbeans.logger.WebBeansLoggerFacade;
import org.apache.webbeans.portable.AnnotatedConstructorImpl;
import org.apache.webbeans.portable.InjectionTargetImpl;
@@ -88,7 +87,7 @@ public class DecoratorBeanBuilder<T> ext
ignoredDecoratorInterfaces = getIgnoredDecoratorInterfaces();
}
- private <T> Set<String> getIgnoredDecoratorInterfaces()
+ private Set<String> getIgnoredDecoratorInterfaces()
{
Set<String> result = new HashSet<String>(webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces());
return result;
@@ -100,23 +99,6 @@ public class DecoratorBeanBuilder<T> ext
constructor = getBeanConstructor();
}
-
- protected void addConstructorInjectionPointMetaData(DecoratorBean<T> bean)
- {
- if (constructor == null)
- {
- return;
- }
- InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
- List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(bean, constructor);
- for (InjectionPoint injectionPoint : injectionPoints)
- {
- addImplicitComponentForInjectionPoint(injectionPoint);
- bean.addInjectionPoint(injectionPoint);
- }
- bean.setConstructor(constructor.getJavaMember());
- }
-
/**
* If this method returns <code>false</code> the {@link #getBean()} method must not get called.
*
@@ -127,7 +109,6 @@ public class DecoratorBeanBuilder<T> ext
return webBeansContext.getDecoratorsManager().isDecoratorEnabled(getBeanType());
}
-
protected void checkDecoratorConditions()
{
if(getBeanAttributes().getScope() != Dependent.class)
@@ -313,8 +294,6 @@ public class DecoratorBeanBuilder<T> ext
protected DecoratorBean<T> createBean(Class<T> beanClass, boolean enabled)
{
DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext, WebBeansType.MANAGED, getAnnotated(), getBeanAttributes(), beanClass);
- addConstructorInjectionPointMetaData(decorator);
-
decorator.setEnabled(enabled);
return decorator;
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java Thu Jan 24 21:20:11 2013
@@ -25,7 +25,6 @@ import javax.enterprise.inject.spi.Annot
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.InterceptionType;
import javax.interceptor.AroundInvoke;
import javax.interceptor.AroundTimeout;
@@ -44,7 +43,6 @@ import org.apache.webbeans.component.Bea
import org.apache.webbeans.component.InterceptorBean;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.inject.impl.InjectionPointFactory;
import org.apache.webbeans.plugins.OpenWebBeansEjbLCAPlugin;
import org.apache.webbeans.util.ClassUtil;
@@ -91,13 +89,6 @@ public abstract class InterceptorBeanBui
{
return;
}
- InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
- List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(bean, constructor);
- for (InjectionPoint injectionPoint : injectionPoints)
- {
- addImplicitComponentForInjectionPoint(injectionPoint);
- bean.addInjectionPoint(injectionPoint);
- }
bean.setConstructor(constructor.getJavaMember());
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ManagedBeanBuilder.java Thu Jan 24 21:20:11 2013
@@ -25,13 +25,11 @@ import javax.annotation.PreDestroy;
import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.component.BeanAttributesImpl;
import org.apache.webbeans.component.ManagedBean;
import org.apache.webbeans.component.WebBeansType;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.inject.impl.InjectionPointFactory;
import org.apache.webbeans.util.WebBeansUtil;
/**
@@ -116,13 +114,6 @@ public class ManagedBeanBuilder<T, M ext
{
return;
}
- InjectionPointFactory injectionPointFactory = webBeansContext.getInjectionPointFactory();
- List<InjectionPoint> injectionPoints = injectionPointFactory.getConstructorInjectionPointData(bean, constructor);
- for (InjectionPoint injectionPoint : injectionPoints)
- {
- addImplicitComponentForInjectionPoint(injectionPoint);
- bean.addInjectionPoint(injectionPoint);
- }
bean.setConstructor(constructor.getJavaMember());
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodProducerBuilder.java Thu Jan 24 21:20:11 2013
@@ -23,15 +23,19 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import javax.enterprise.event.Observes;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Inject;
import javax.inject.Named;
import org.apache.webbeans.component.OwbBean;
import org.apache.webbeans.component.ProducerMethodBean;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
import org.apache.webbeans.portable.ProducerMethodProducer;
import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.Asserts;
@@ -119,20 +123,57 @@ public class ProducerMethodProducerBuild
{
continue;
}
+ if (disposalMethod != null)
+ {
+ throw new WebBeansConfigurationException("There are multiple disposal method for the producer method : "
+ + disposalMethod.getJavaMember().getName() + " in class : "
+ + annotatedMethod.getDeclaringType().getJavaClass());
+ }
+ if (!annotatedMethod.getDeclaringType().equals(producerMethod.getDeclaringType()))
+ {
+ throw new WebBeansConfigurationException("Producer method component of the disposal method : "
+ + annotatedMethod.getJavaMember().getName() + " in class : "
+ + annotatedMethod.getDeclaringType().getJavaClass() + " must be in the same class!");
+ }
+ checkDisposalMethod(annotatedMethod);
disposalMethod = (AnnotatedMethod<P>)annotatedMethod;
- break;
}
}
}
}
}
+ private void checkDisposalMethod(AnnotatedMethod<? super P> annotatedMethod)
+ {
+ boolean found = false;
+ for (AnnotatedParameter<?> parameter : annotatedMethod.getParameters())
+ {
+ if(parameter.isAnnotationPresent(Disposes.class))
+ {
+ if(found)
+ {
+ throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
+ + ". Multiple disposes annotation.");
+ }
+ found = true;
+ }
+ }
+
+ if(annotatedMethod.isAnnotationPresent(Inject.class)
+ || AnnotationUtil.hasAnnotatedMethodParameterAnnotation(annotatedMethod, Observes.class)
+ || annotatedMethod.isAnnotationPresent(Produces.class))
+ {
+ throw new WebBeansConfigurationException("Error in definining disposal method of annotated method : " + annotatedMethod
+ + ". Disposal methods can not be annotated with" + " @Initializer/@Destructor/@Produces annotation or has a parameter annotated with @Observes.");
+ }
+ }
+
private void defineInjectionPoints()
{
- injectionPoints = new HashSet<InjectionPoint>(bean.getWebBeansContext().getInjectionPointFactory().getMethodInjectionPointData(bean, producerMethod));
+ injectionPoints = new HashSet<InjectionPoint>(bean.getWebBeansContext().getInjectionPointFactory().buildInjectionPoints(bean, producerMethod));
if (disposalMethod != null)
{
- injectionPoints.addAll(bean.getWebBeansContext().getInjectionPointFactory().getMethodInjectionPointData(bean, disposalMethod));
+ injectionPoints.addAll(bean.getWebBeansContext().getInjectionPointFactory().buildInjectionPoints(bean, disposalMethod));
}
}
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java Thu Jan 24 21:20:11 2013
@@ -975,7 +975,6 @@ public class BeansDeployer
// add them one after the other to enable serialization handling et al
beanManager.addBean(producerMethod);
}
- managedBeanCreator.validateDisposalMethods(bean);//Define disposal method after adding producers
for (ProducerFieldBean<?> producerField : producerFields)
{
// add them one after the other to enable serialization handling et al
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/ObserverMethodImpl.java Thu Jan 24 21:20:11 2013
@@ -390,7 +390,7 @@ public class ObserverMethodImpl<T> imple
AnnotatedParameter<T> annotatedParameter = newAnnotatedMethod.getParameters().get(i);
//Creating injection point
- InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, type, observerMethod, annotatedParameter, bindingTypes);
+ InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, type, annotatedParameter, bindingTypes);
//Injected Bean
Bean<Object> injectedBean = (Bean<Object>)getWebBeansContext().getBeanManagerImpl().getInjectionResolver().getInjectionPointBean(point);
@@ -461,8 +461,7 @@ public class ObserverMethodImpl<T> imple
annotationManager.getQualifierAnnotations(AnnotationUtil.
asArray(parameter.getAnnotations()));
- InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, parameter.getBaseType(),
- parameter.getDeclaringCallable().getJavaMember(), parameter, bindingTypes);
+ InjectionPoint point = InjectionPointFactory.getPartialInjectionPoint(bean, parameter.getBaseType(), parameter, bindingTypes);
//Get observer parameter instance
@SuppressWarnings("unchecked")
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Thu Jan 24 21:20:11 2013
@@ -19,17 +19,16 @@
package org.apache.webbeans.inject.impl;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
-import javax.decorator.Delegate;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedCallable;
import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMethod;
@@ -37,11 +36,11 @@ import javax.enterprise.inject.spi.Annot
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Inject;
import javax.inject.Named;
import org.apache.webbeans.annotation.NamedLiteral;
import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.portable.AnnotatedElementFactory;
import org.apache.webbeans.util.AnnotationUtil;
import org.apache.webbeans.util.Asserts;
@@ -54,182 +53,90 @@ public class InjectionPointFactory
this.webBeansContext = webBeansContext;
}
- public InjectionPoint getFieldInjectionPointData(Bean<?> owner, Field member)
+ public <X> Set<InjectionPoint> buildInjectionPoints(Bean<X> owner, AnnotatedType<X> annotatedType)
{
- Asserts.assertNotNull(owner, "owner parameter can not be null");
- Asserts.assertNotNull(member, "member parameter can not be null");
-
- Annotation[] annots = null;
- annots = member.getAnnotations();
-
- AnnotatedElementFactory annotatedElementFactory = webBeansContext.getAnnotatedElementFactory();
-
- AnnotatedType<?> annotated = annotatedElementFactory.newAnnotatedType(member.getDeclaringClass());
- return getGenericInjectionPoint(owner, annots, member.getGenericType(), member, annotatedElementFactory.newAnnotatedField(member, annotated));
- }
-
- public <X> InjectionPoint getFieldInjectionPointData(Bean<?> owner, AnnotatedField<X> annotField)
- {
- Asserts.assertNotNull(owner, "owner parameter can not be null");
- Asserts.assertNotNull(annotField, "annotField parameter can not be null");
- Field member = annotField.getJavaMember();
-
- Annotation[] annots = AnnotationUtil.asArray(annotField.getAnnotations());
-
- return getGenericInjectionPoint(owner, annots, annotField.getBaseType(), member, annotField);
- }
-
- /**
- * Gets injected point instance.
- * @param owner owner of the injection point
- * @param annots annotations of the injection point
- * @param type type of the injection point
- * @param member member of the injection point
- * @param annotated annotated instance of injection point
- * @return injection point instance
- */
- private InjectionPoint getGenericInjectionPoint(Bean<?> owner, Annotation[] annots, Type type, Member member,Annotated annotated)
- {
- InjectionPointImpl injectionPoint;
-
- Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(annots);
-
- //@Named update for injection fields!
- if(member instanceof Field)
+ Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
+ for (AnnotatedConstructor<X> constructor: annotatedType.getConstructors())
{
- for(int i=0; i < qualifierAnnots.length; i++)
+ if (constructor.isAnnotationPresent(Inject.class))
{
- Annotation qualifier = qualifierAnnots[i];
- if(qualifier.annotationType().equals(Named.class))
- {
- Named named = (Named)qualifier;
- String value = named.value();
-
- if(value == null || value.equals(""))
- {
- NamedLiteral namedLiteral = new NamedLiteral();
- namedLiteral.setValue(member.getName());
- qualifierAnnots[i] = namedLiteral;
- }
-
- break;
- }
+ buildInjectionPoints(owner, constructor, injectionPoints);
}
}
-
-
- injectionPoint = new InjectionPointImpl(owner, type, member, annotated);
-
- if(AnnotationUtil.hasAnnotation(annots, Delegate.class))
+ for (AnnotatedField<? super X> field: annotatedType.getFields())
{
- injectionPoint.setDelegate(true);
+ if (field.isAnnotationPresent(Inject.class))
+ {
+ injectionPoints.add(buildInjectionPoint(owner, field));
+ }
}
-
- if(Modifier.isTransient(member.getModifiers()))
+ for (AnnotatedMethod<? super X> method: annotatedType.getMethods())
{
- injectionPoint.setTransient(true);
+ if (method.isAnnotationPresent(Inject.class))
+ {
+ buildInjectionPoints(owner, method, injectionPoints);
+ }
}
-
- addAnnotation(injectionPoint, qualifierAnnots, true);
-
- return injectionPoint;
-
+ return injectionPoints;
}
- public <X> List<InjectionPoint> getMethodInjectionPointData(Bean<?> owner, AnnotatedMethod<X> method)
+ public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedField<X> annotField)
{
- Asserts.assertNotNull(owner, "owner parameter can not be null");
- Asserts.assertNotNull(method, "method parameter can not be null");
-
- List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
-
- List<AnnotatedParameter<X>> parameters = method.getParameters();
+ Asserts.assertNotNull(annotField, "annotField parameter can not be null");
- InjectionPoint point;
+ Annotation[] annots = AnnotationUtil.asArray(annotField.getAnnotations());
+ Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(annots);
- for(AnnotatedParameter<?> parameter : parameters)
+ //@Named update for injection fields!
+ for (int i=0; i < qualifierAnnots.length; i++)
{
- //@Observes is not injection point type for method parameters
- if(parameter.getAnnotation(Observes.class) == null)
+ Annotation qualifier = qualifierAnnots[i];
+ if (qualifier.annotationType().equals(Named.class))
{
- point = getGenericInjectionPoint(owner, parameter.getAnnotations().toArray(new Annotation[parameter.getAnnotations().size()]),
- parameter.getBaseType(), method.getJavaMember() , parameter);
- lists.add(point);
- }
- }
-
- return lists;
- }
-
- public static InjectionPoint getPartialInjectionPoint(Bean<?> owner,Type type, Member member, Annotated annotated, Annotation...bindings)
- {
- InjectionPointImpl impl = new InjectionPointImpl(owner,type,member,annotated);
+ Named named = (Named)qualifier;
+ String value = named.value();
+ if (value == null || value.equals(""))
+ {
+ NamedLiteral namedLiteral = new NamedLiteral();
+ namedLiteral.setValue(annotField.getJavaMember().getName());
+ qualifierAnnots[i] = namedLiteral;
+ }
- for(Annotation annot : bindings)
- {
- impl.addBindingAnnotation(annot);
+ break;
+ }
}
- return impl;
-
+ return new InjectionPointImpl(owner, annotField.getBaseType(), Arrays.asList(qualifierAnnots), annotField);
}
- public <T> List<InjectionPoint> getConstructorInjectionPointData(Bean<T> owner, AnnotatedConstructor<T> constructor)
+ public <X> List<InjectionPoint> buildInjectionPoints(Bean<?> owner, AnnotatedCallable<X> callable)
{
- Asserts.assertNotNull(owner, "owner parameter can not be null");
- Asserts.assertNotNull(constructor, "constructor parameter can not be null");
-
List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
-
- List<AnnotatedParameter<T>> parameters = constructor.getParameters();
-
- InjectionPoint point;
-
- for(AnnotatedParameter<?> parameter : parameters)
- {
- point = getGenericInjectionPoint(owner, parameter.getAnnotations().toArray(new Annotation[parameter.getAnnotations().size()]),
- parameter.getBaseType(), constructor.getJavaMember() , parameter);
- lists.add(point);
- }
-
+ buildInjectionPoints(owner, callable, lists);
return lists;
}
-
- @SuppressWarnings("unchecked")
- public List<InjectionPoint> getConstructorInjectionPointData(Bean<?> owner, Constructor<?> member)
+ private <X> void buildInjectionPoints(Bean<?> owner, AnnotatedCallable<X> callable, Collection<InjectionPoint> lists)
{
- Asserts.assertNotNull(owner, "owner parameter can not be null");
- Asserts.assertNotNull(member, "member parameter can not be null");
-
- List<InjectionPoint> lists = new ArrayList<InjectionPoint>();
-
- AnnotatedType<Object> annotated = (AnnotatedType<Object>) webBeansContext.getAnnotatedElementFactory().newAnnotatedType(member.getDeclaringClass());
- AnnotatedConstructor constructor = webBeansContext.getAnnotatedElementFactory().newAnnotatedConstructor((Constructor<Object>)member,annotated);
- List<AnnotatedParameter<?>> parameters = constructor.getParameters();
-
- InjectionPoint point;
-
- for(AnnotatedParameter<?> parameter : parameters)
- {
- point = getGenericInjectionPoint(owner, parameter.getAnnotations().toArray(new Annotation[parameter.getAnnotations().size()]),
- parameter.getBaseType(), member , parameter);
- lists.add(point);
- }
+ Asserts.assertNotNull(callable, "callable parameter can not be null");
- return lists;
- }
+ List<AnnotatedParameter<X>> parameters = callable.getParameters();
- private static void addAnnotation(InjectionPointImpl impl, Annotation[] annots, boolean isBinding)
- {
- for (Annotation ann : annots)
+ for (AnnotatedParameter<?> parameter : parameters)
{
- if (isBinding)
+ //@Observes is not injection point type for method parameters
+ if (parameter.getAnnotation(Observes.class) == null)
{
- impl.addBindingAnnotation(ann);
+ Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(parameter.getAnnotations().toArray(new Annotation[0]));
+ InjectionPoint point = new InjectionPointImpl(owner, parameter.getBaseType(), Arrays.asList(qualifierAnnots), parameter);
+ lists.add(point);
}
}
}
+ public static InjectionPoint getPartialInjectionPoint(Bean<?> owner,Type type, AnnotatedParameter<?> parameter, Annotation...bindings)
+ {
+ return new InjectionPointImpl(owner, type, Arrays.asList(bindings), parameter);
+ }
}
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointImpl.java Thu Jan 24 21:20:11 2013
@@ -29,13 +29,18 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.decorator.Delegate;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
@@ -43,7 +48,9 @@ import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.event.EventUtil;
import org.apache.webbeans.portable.AnnotatedElementFactory;
+import org.apache.webbeans.util.Asserts;
import org.apache.webbeans.util.WebBeansUtil;
class InjectionPointImpl implements InjectionPoint, Serializable
@@ -64,22 +71,38 @@ class InjectionPointImpl implements Inje
private boolean delegate;
- InjectionPointImpl(Bean<?> ownerBean, Type type, Member member, Annotated annotated)
+ InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, AnnotatedField<?> annotatedField)
{
- this.ownerBean = ownerBean;
- injectionMember = member;
- injectionType = type;
- this.annotated = annotated;
+ this(ownerBean, type, qualifiers, annotatedField,
+ annotatedField.getJavaMember(), annotatedField.isAnnotationPresent(Delegate.class), Modifier.isTransient(annotatedField.getJavaMember().getModifiers()));
+ }
+
+ InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, AnnotatedParameter<?> parameter)
+ {
+ this(ownerBean, type, qualifiers, parameter, parameter.getDeclaringCallable().getJavaMember(), parameter.isAnnotationPresent(Delegate.class), false);
}
- void addBindingAnnotation(Annotation qualifierAnnotations)
+ private InjectionPointImpl(Bean<?> ownerBean, Type type, Collection<Annotation> qualifiers, Annotated annotated, Member member, boolean delegate, boolean isTransient)
{
- this.qualifierAnnotations.add(qualifierAnnotations);
+ Asserts.assertNotNull(type, "required type may not be null");
+ Asserts.assertNotNull(qualifiers, "qualifiers may not be null");
+ Asserts.assertNotNull(annotated, "annotated may not be null");
+ Asserts.assertNotNull(member, "member may not be null");
+ this.ownerBean = ownerBean;
+ this.injectionType = type;
+ this.qualifierAnnotations = Collections.unmodifiableSet(new HashSet<Annotation>(qualifiers));
+ this.annotated = annotated;
+ this.injectionMember = member;
+ this.delegate = delegate;
+ this.transientt = isTransient;
+ if(!WebBeansUtil.checkObtainsInjectionPointConditions(this))
+ {
+ EventUtil.checkObservableInjectionPointConditions(this);
+ }
}
public Bean<?> getBean()
{
-
return ownerBean;
}
@@ -116,16 +139,6 @@ class InjectionPointImpl implements Inje
return transientt;
}
- void setDelegate(boolean delegate)
- {
- this.delegate = delegate;
- }
-
- void setTransient(boolean transientt)
- {
- this.transientt = transientt;
- }
-
private void writeObject(java.io.ObjectOutputStream op) throws IOException
{
ObjectOutputStream out = new ObjectOutputStream(op);
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Thu Jan 24 21:20:11 2013
@@ -1616,8 +1616,6 @@ public final class WebBeansUtil
((InjectionTargetBean) managedBean).defineBeanInterceptorStack();
}
- managedBeanCreator.validateDisposalMethods(managedBean);//Define disposal method after adding producers
-
return managedBean;
}
@@ -1752,9 +1750,6 @@ public final class WebBeansUtil
{
((InjectionTargetBean) managedBean).defineBeanInterceptorStack();
}
-
- managedBeanCreator.validateDisposalMethods(managedBean); //Define disposal method after adding producers
-
return managedBean;
}
Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/TestContext.java Thu Jan 24 21:20:11 2013
@@ -557,7 +557,6 @@ public abstract class TestContext implem
manager.addBean(producerField);
}
- managedBeanCreator.validateDisposalMethods(component);
managedBeanCreator.defineObserverMethods(component);
return component;
Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java?rev=1438200&r1=1438199&r2=1438200&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/inject/named/NamedTests.java Thu Jan 24 21:20:11 2013
@@ -23,12 +23,16 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.Set;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Named;
import org.apache.webbeans.config.WebBeansContext;
import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.portable.AnnotatedElementFactory;
import org.apache.webbeans.test.TestContext;
import org.apache.webbeans.test.component.IPayment;
import org.apache.webbeans.test.component.inject.named.NamedFieldWithNamedValue;
@@ -60,8 +64,11 @@ public class NamedTests extends TestCont
Bean<NamedFieldWithNamedValue> bean = defineManagedBean(NamedFieldWithNamedValue.class);
Field field = NamedFieldWithNamedValue.class.getDeclaredField("paymentProcessor");
+ AnnotatedElementFactory annotatedElementFactory = WebBeansContext.getInstance().getAnnotatedElementFactory();
+ AnnotatedType<NamedFieldWithNamedValue> annotatedType = (AnnotatedType<NamedFieldWithNamedValue>) annotatedElementFactory.getAnnotatedType(field.getDeclaringClass());
+ AnnotatedField<NamedFieldWithNamedValue> annotatedField = annotatedElementFactory.newAnnotatedField(field, annotatedType);
InjectionPoint point =
- WebBeansContext.getInstance().getInjectionPointFactory().getFieldInjectionPointData(bean, field);
+ WebBeansContext.getInstance().getInjectionPointFactory().buildInjectionPoint(bean, annotatedField);
WebBeansUtil.checkInjectionPointNamedQualifier(point);
@@ -76,8 +83,11 @@ public class NamedTests extends TestCont
Bean<NamedFieldWithoutNamedValue> bean = defineManagedBean(NamedFieldWithoutNamedValue.class);
Field field = NamedFieldWithoutNamedValue.class.getDeclaredField("paymentProcessor");
+ AnnotatedElementFactory annotatedElementFactory = WebBeansContext.getInstance().getAnnotatedElementFactory();
+ AnnotatedType<NamedFieldWithNamedValue> annotatedType = (AnnotatedType<NamedFieldWithNamedValue>) annotatedElementFactory.getAnnotatedType(field.getDeclaringClass());
+ AnnotatedField<NamedFieldWithNamedValue> annotatedField = annotatedElementFactory.newAnnotatedField(field, annotatedType);
InjectionPoint point =
- WebBeansContext.getInstance().getInjectionPointFactory().getFieldInjectionPointData(bean, field);
+ WebBeansContext.getInstance().getInjectionPointFactory().buildInjectionPoint(bean, annotatedField);
WebBeansUtil.checkInjectionPointNamedQualifier(point);
@@ -91,11 +101,13 @@ public class NamedTests extends TestCont
public void testOtherWithNamedValue() throws Exception
{
Bean<NamedOtherWithNamedValue> bean = defineManagedBean(NamedOtherWithNamedValue.class);
- Constructor<?> constructor = NamedOtherWithNamedValue.class.getDeclaredConstructor(new Class<?>[]{IPayment.class});
+ Constructor<NamedOtherWithNamedValue> constructor = NamedOtherWithNamedValue.class.getDeclaredConstructor(new Class<?>[]{IPayment.class});
+ AnnotatedElementFactory annotatedElementFactory = WebBeansContext.getInstance().getAnnotatedElementFactory();
+ AnnotatedType<NamedOtherWithNamedValue> annotatedType = annotatedElementFactory.getAnnotatedType(constructor.getDeclaringClass());
+ AnnotatedConstructor<NamedOtherWithNamedValue> annotatedConstructor = annotatedElementFactory.newAnnotatedConstructor(constructor, annotatedType);
InjectionPoint point =
- WebBeansContext.getInstance().getInjectionPointFactory().getConstructorInjectionPointData(bean,
- constructor).get(0);
+ WebBeansContext.getInstance().getInjectionPointFactory().buildInjectionPoints(bean, annotatedConstructor).get(0);
WebBeansUtil.checkInjectionPointNamedQualifier(point);
@@ -109,11 +121,13 @@ public class NamedTests extends TestCont
public void testOtherWithoutNamedValue() throws Exception
{
Bean<NamedOtherWithoutNamedValue> bean = defineManagedBean(NamedOtherWithoutNamedValue.class);
- Constructor<?> constructor = NamedOtherWithoutNamedValue.class.getDeclaredConstructor(new Class<?>[]{IPayment.class});
+ Constructor<NamedOtherWithoutNamedValue> constructor = NamedOtherWithoutNamedValue.class.getDeclaredConstructor(new Class<?>[]{IPayment.class});
+ AnnotatedElementFactory annotatedElementFactory = WebBeansContext.getInstance().getAnnotatedElementFactory();
+ AnnotatedType<NamedOtherWithoutNamedValue> annotatedType = annotatedElementFactory.getAnnotatedType(constructor.getDeclaringClass());
+ AnnotatedConstructor<NamedOtherWithoutNamedValue> annotatedConstructor = annotatedElementFactory.newAnnotatedConstructor(constructor, annotatedType);
InjectionPoint point =
- WebBeansContext.getInstance().getInjectionPointFactory().getConstructorInjectionPointData(bean,
- constructor).get(0);
+ WebBeansContext.getInstance().getInjectionPointFactory().buildInjectionPoints(bean, annotatedConstructor).get(0);
String value = qulifier(point);