Author: struberg
Date: Fri Jan 18 11:30:35 2013
New Revision: 1435096
URL: http://svn.apache.org/viewvc?rev=1435096&view=rev
Log:
OWB-344 add new Decorator Bean implementation and Builder for it
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
- copied, changed from r1435058,
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/DecoratorBean.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/creation/AbstractBeanBuilder.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
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=1435096&r1=1435095&r2=1435096&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
Fri Jan 18 11:30:35 2013
@@ -21,6 +21,7 @@ package org.apache.webbeans.component;
import javax.enterprise.inject.spi.AnnotatedType;
import javax.enterprise.inject.spi.Decorator;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
import java.util.Set;
@@ -31,27 +32,65 @@ import org.apache.webbeans.config.WebBea
*/
public class DecoratorBean<T> extends InjectionTargetBean<T> implements
Decorator<T>
{
+ /*
+ * Constructor of the Decorator component
+ */
+ private Constructor<T> constructor;
+
+ /**
+ * The Types the decorator itself implements
+ */
+ private Set<Type> decoratedTypes;
+
+ /**
+ * The Type of the @Delegate injection point.
+ */
+ private Type delegateType;
+
+ /**
+ * The Qualifiers of the @Delegate injection point.
+ */
+ 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)
{
super(webBeansContext, webBeansType, annotatedType, types, qualifiers,
scope, beanClass, stereotypes);
}
+ public void setDecoratorInfo(Set<Type> decoratedTypes, Type delegateType,
Set<Annotation> delegateQualifiers)
+ {
+ this.decoratedTypes = decoratedTypes;
+ this.delegateType = delegateType;
+ this.delegateQualifiers = delegateQualifiers;
+ }
+
@Override
public Set<Type> getDecoratedTypes()
{
- return null; //X TODO
+ return decoratedTypes;
}
@Override
public Type getDelegateType()
{
- return null; //X TODO
+ return delegateType;
}
@Override
public Set<Annotation> getDelegateQualifiers()
{
- return null; //X TODO
+ return delegateQualifiers;
+ }
+
+ public void setConstructor(Constructor<T> constructor)
+ {
+ this.constructor = constructor;
+ }
+
+ public Constructor<T> getConstructor()
+ {
+ return constructor;
}
}
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=1435096&r1=1435095&r2=1435096&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
Fri Jan 18 11:30:35 2013
@@ -43,7 +43,7 @@ import org.apache.webbeans.util.Exceptio
public abstract class InterceptorBean<T> extends InjectionTargetBean<T>
implements Interceptor<T>
{
/**
- * Constructor of the web bean component
+ * Constructor of the Interceptor component
*/
private Constructor<T> constructor;
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=1435096&r1=1435095&r2=1435096&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
Fri Jan 18 11:30:35 2013
@@ -109,6 +109,11 @@ public abstract class AbstractBeanBuilde
return stereotypes;
}
+ protected Set<Type> getApiTypes()
+ {
+ return apiTypes;
+ }
+
/**
* {@inheritDoc}
*/
@@ -346,6 +351,14 @@ public abstract class AbstractBeanBuilde
}
/**
+ * @return the AnnotatedMember of all found injection points <i>before</i>
InjectionPoint will be constructed from it.
+ */
+ protected Set<AnnotatedMember<? super T>> getInjectionPointsAnnotated()
+ {
+ return injectionPoints;
+ }
+
+ /**
* Returns true if any binding exist
*
* @return true if any binding exist
@@ -629,7 +642,7 @@ public abstract class AbstractBeanBuilde
*/
public B getBean()
{
- B bean = createBean(apiTypes, qualifiers, scope, beanName, false,
getBeanType(), stereotypes, false);
+ B bean = createBean(apiTypes, qualifiers, getScope(), beanName, false,
getBeanType(), stereotypes, false);
for (Iterator<AnnotatedMember<? super T>> memberIterator =
injectionPoints.iterator(); memberIterator.hasNext();)
{
AnnotatedMember<? super T> member = memberIterator.next();
Copied:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java
(from r1435058,
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/DecoratorBeanBuilder.java?p2=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/DecoratorBeanBuilder.java&p1=openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/InterceptorBeanBuilder.java&r1=1435058&r2=1435096&rev=1435096&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/DecoratorBeanBuilder.java
Fri Jan 18 11:30:35 2013
@@ -18,8 +18,7 @@
*/
package org.apache.webbeans.component.creation;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
+import javax.decorator.Delegate;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -27,54 +26,62 @@ import javax.enterprise.inject.spi.Annot
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;
-
+import javax.inject.Inject;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
+import java.lang.reflect.TypeVariable;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import org.apache.webbeans.component.InterceptorBean;
+import org.apache.webbeans.component.DecoratorBean;
+import org.apache.webbeans.component.WebBeansType;
+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.plugins.OpenWebBeansEjbLCAPlugin;
+import org.apache.webbeans.util.ClassUtil;
/**
* Bean builder for {@link org.apache.webbeans.component.InterceptorBean}s.
*/
-public abstract class InterceptorBeanBuilder<T, B extends InterceptorBean<T>>
extends AbstractInjectionTargetBeanBuilder<T, B>
+public class DecoratorBeanBuilder<T> extends
AbstractInjectionTargetBeanBuilder<T, DecoratorBean<T>>
{
- private final OpenWebBeansEjbLCAPlugin ejbPlugin;
- private final Class<? extends Annotation> prePassivateClass;
- private final Class<? extends Annotation> postActivateClass;
-
private AnnotatedConstructor<T> constructor;
- private Map<InterceptionType, Method[]> interceptionMethods;
-
- protected InterceptorBeanBuilder(WebBeansContext webBeansContext,
AnnotatedType<T> annotatedType)
+ /**
+ * The Types the decorator itself implements
+ */
+ private Set<Type> decoratedTypes;
+
+ /**
+ * The Type of the @Delegate injection point.
+ */
+ private Type delegateType;
+
+ /**
+ * The Qualifiers of the @Delegate injection point.
+ */
+ private Set<Annotation> delegateQualifiers;
+
+ private final Set<String> ignoredDecoratorInterfaces;
+
+
+ public DecoratorBeanBuilder(WebBeansContext webBeansContext,
AnnotatedType<T> annotatedType)
{
super(webBeansContext, annotatedType);
- ejbPlugin = webBeansContext.getPluginLoader().getEjbLCAPlugin();
- if (ejbPlugin != null)
- {
- prePassivateClass = ejbPlugin.getPrePassivateClass();
- postActivateClass = ejbPlugin.getPostActivateClass();
- }
- else
- {
- prePassivateClass = null;
- postActivateClass = null;
- }
+ ignoredDecoratorInterfaces = getIgnoredDecoratorInterfaces();
+ }
+
+ private <T> Set<String> getIgnoredDecoratorInterfaces()
+ {
+ Set<String> result = new
HashSet<String>(webBeansContext.getOpenWebBeansConfiguration().getIgnoredInterfaces());
+ return result;
}
@Override
@@ -90,7 +97,7 @@ public abstract class InterceptorBeanBui
}
- protected void addConstructorInjectionPointMetaData(B bean)
+ protected void addConstructorInjectionPointMetaData(DecoratorBean<T> bean)
{
if (constructor == null)
{
@@ -106,15 +113,20 @@ public abstract class InterceptorBeanBui
bean.setConstructor(constructor.getJavaMember());
}
+
+
/**
* If this method returns <code>false</code> the {@link #getBean()} method
must not get called.
*
- * @return <code>true</code> if the Interceptor is enabled and a Bean
should get created
+ * @return <code>true</code> if the Decorator is enabled and a Bean should
get created
*/
- public abstract boolean isInterceptorEnabled();
+ public boolean isDecoratorEnabled()
+ {
+ return
webBeansContext.getDecoratorsManager().isDecoratorEnabled(getBeanType());
+ }
- protected void checkInterceptorConditions()
+ protected void checkDecoratorConditions()
{
Set<AnnotatedMethod<? super T>> methods = getAnnotated().getMethods();
for(AnnotatedMethod method : methods)
@@ -132,208 +144,130 @@ public abstract class InterceptorBeanBui
}
}
- protected void defineInterceptorRules()
+ public void defineDecoratorRules()
{
+ checkDecoratorConditions();
+
defineApiType();
defineConstructor();
- defineInterceptorMethods();
defineInjectedMethods();
defineInjectedFields();
+
+ defineDecoratedTypes();
}
- /**
- * <p>Grab all methods which act as interceptors for the various
- * {@link javax.enterprise.inject.spi.InterceptionType}s.</p>
- *
- * <p>This method will also check some rules, e.g. that there must not be
- * more than a single {@link javax.interceptor.AroundInvoke} method
- * on a class.</p>
- *
- * <p>For the interceptors where multiple are allowed, the following rules
apply:
- * <ul>
- * <li>Superclass methods first</li>
- * <li>Non-private methods override and derogates their superclass
counterparts.</li>
- * <li>Private methods with the same signature stack (superclass
first).</li>
- * <li>There must only be a single method for each InterceptorType in
the same class.</li>
- * </ul>
- * </p>
- * @return <code>true</code> if we found some interceptor methods
- */
- public boolean defineInterceptorMethods()
+ private void defineDecoratedTypes()
{
- List<Class> classHierarchy =
webBeansContext.getInterceptorUtil().getReverseClassHierarchy(getAnnotated().getJavaClass());
-
- AnnotatedMethod aroundInvokeMethod = null;
- List<AnnotatedMethod> postConstructMethods = new
ArrayList<AnnotatedMethod>();
- List<AnnotatedMethod> preDestroyMethods = new
ArrayList<AnnotatedMethod>();
- List<AnnotatedMethod> aroundTimeoutMethods = new
ArrayList<AnnotatedMethod>();
-
- // EJB related interceptors
- List<AnnotatedMethod> prePassivateMethods = new
ArrayList<AnnotatedMethod>();
- List<AnnotatedMethod> postActivateMethods = new
ArrayList<AnnotatedMethod>();
+ decoratedTypes = new HashSet<Type>(getApiTypes());
+ Class<T> beanClass = getBeanType();
- boolean interceptorFound = false;
-
- Set<AnnotatedMethod<? super T>> methods = getAnnotated().getMethods();
-
- for (Class clazz : classHierarchy)
+ // determine a safe Type for for a later BeanManager.getReference(...)
+ if (ClassUtil.isDefinitionContainsTypeVariables(beanClass))
{
-
- for (AnnotatedMethod m : methods)
+ OwbParametrizedTypeImpl pt = new
OwbParametrizedTypeImpl(beanClass.getDeclaringClass(),beanClass);
+ TypeVariable<?>[] tvs = beanClass.getTypeParameters();
+ for(TypeVariable<?> tv : tvs)
{
- if (clazz == m.getDeclaringType().getJavaClass())
- {
-
- // we only take methods from this very class and not sub-
or superclasses
- if (m.getAnnotation(AroundInvoke.class) != null)
- {
- if (aroundInvokeMethod != null)
- {
- throw new WebBeansConfigurationException("only one
AroundInvoke allowed per Interceptor");
- }
- aroundInvokeMethod = m;
- }
-
- // PostConstruct
- if (m.getAnnotation(PostConstruct.class) != null)
- {
- checkSameClassInterceptors(postConstructMethods, m);
- postConstructMethods.add(m); // add at last position
- }
- removeOverriddenMethod(postConstructMethods, m);
-
- // PreDestroy
- if (m.getAnnotation(PreDestroy.class) != null)
- {
- checkSameClassInterceptors(preDestroyMethods, m);
- preDestroyMethods.add(m); // add at last position
- }
- removeOverriddenMethod(preDestroyMethods, m);
-
- // AroundTimeout
- if (m.getAnnotation(AroundTimeout.class) != null)
- {
- checkSameClassInterceptors(aroundTimeoutMethods, m);
- aroundTimeoutMethods.add(m); // add at last position
- }
- removeOverriddenMethod(aroundTimeoutMethods, m);
-
- // and now the EJB related interceptors
- if (ejbPlugin != null)
- {
- if (m.getAnnotation(prePassivateClass) != null)
- {
- checkSameClassInterceptors(prePassivateMethods, m);
- prePassivateMethods.add(m); // add at last position
- }
- removeOverriddenMethod(prePassivateMethods, m);
-
- // AroundTimeout
- if (m.getAnnotation(AroundTimeout.class) != null)
- {
- checkSameClassInterceptors(aroundTimeoutMethods,
m);
- postActivateMethods.add(m); // add at last position
- }
- removeOverriddenMethod(postActivateMethods, m);
-
- // AroundTimeout
- if (m.getAnnotation(postActivateClass) != null)
- {
- checkSameClassInterceptors(postActivateMethods, m);
- postActivateMethods.add(m); // add at last position
- }
- removeOverriddenMethod(postActivateMethods, m);
- }
- }
+ pt.addTypeArgument(tv);
}
+ decoratedTypes.remove(pt);
+ //X TODO generic support setDecoratorGenericType(pt);
}
-
- // and now for setting the bean info
-
- interceptionMethods = new HashMap<InterceptionType, Method[]>();
-
- if (aroundInvokeMethod != null)
+ else
{
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.AROUND_INVOKE, new
Method[]{aroundInvokeMethod.getJavaMember()});
+ decoratedTypes.remove(beanClass);
+ //X TODO generic support setDecoratorGenericType(beanClass);
}
- if (postConstructMethods.size() > 0)
+ /* drop any non-interface bean types */
+ Type superClass = beanClass.getGenericSuperclass();
+ while (superClass != Object.class)
{
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.POST_CONSTRUCT,
getMethodArray(postConstructMethods));
- }
- if (preDestroyMethods.size() > 0)
- {
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.PRE_DESTROY,
getMethodArray(preDestroyMethods));
- }
- if (aroundTimeoutMethods.size() > 0)
- {
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.AROUND_TIMEOUT,
getMethodArray(aroundTimeoutMethods));
+ decoratedTypes.remove(superClass);
+ superClass = superClass.getClass().getGenericSuperclass();
}
+ decoratedTypes.remove(Object.class);
+ decoratedTypes.remove(java.io.Serializable.class); /* 8.1 */
- if (prePassivateMethods.size() > 0)
- {
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.PRE_PASSIVATE,
getMethodArray(prePassivateMethods));
- }
- if (postActivateMethods.size() > 0)
+
+ for (Iterator<Type> i = decoratedTypes.iterator(); i.hasNext(); )
{
- interceptorFound = true;
- interceptionMethods.put(InterceptionType.POST_ACTIVATE,
getMethodArray(postActivateMethods));
+ Type t = i.next();
+ if (t instanceof Class<?> &&
ignoredDecoratorInterfaces.contains(((Class) t).getName()))
+ {
+ i.remove();
+ }
}
- return interceptorFound;
}
- /**
- * @return the a Method array with the native members of the
AnnotatedMethod list
- */
- private Method[] getMethodArray(List<AnnotatedMethod> methodList)
+ private void defineDelegate(Set<InjectionPoint> injectionPoints)
{
- Method[] methods = new Method[methodList.size()];
- int i=0;
- for (AnnotatedMethod am : methodList)
+ boolean found = false;
+ InjectionPoint ipFound = null;
+ for(InjectionPoint ip : injectionPoints)
{
- methods[i++] = am.getJavaMember();
+ if(ip.getAnnotated().isAnnotationPresent(Delegate.class))
+ {
+ if(!found)
+ {
+ found = true;
+ ipFound = ip;
+ }
+ else
+ {
+ throw new WebBeansConfigurationException("Decorators must
have a one @Delegate injection point. " +
+ "But the decorator bean : " + toString() + " has
more than one");
+ }
+ }
}
- return methods;
- }
- /**
- *
- * @return
- */
- private void checkSameClassInterceptors(List<AnnotatedMethod>
alreadyDefinedMethods, AnnotatedMethod annotatedMethod)
- {
- Class clazz = null;
- for (AnnotatedMethod alreadyDefined : alreadyDefinedMethods)
+
+ if(ipFound == null)
+ {
+ throw new WebBeansConfigurationException("Decorators must have a
one @Delegate injection point." +
+ "But the decorator bean : " + toString() + " has none");
+ }
+
+ if(!(ipFound.getMember() instanceof Constructor))
{
- if (clazz == null)
+ AnnotatedElement element = (AnnotatedElement)ipFound.getMember();
+ if(!element.isAnnotationPresent(Inject.class))
{
- clazz = annotatedMethod.getDeclaringType().getJavaClass();
+ String message = "Error in decorator : "+ toString() + ". The
delegate injection point must be an injected field, " +
+ "initializer method parameter or bean constructor
method parameter.";
+
+ throw new WebBeansConfigurationException(message);
}
+ }
+
+ delegateType = ipFound.getType();
+ delegateQualifiers = ipFound.getQualifiers();
- // check for same class -> Exception
- if (alreadyDefined.getDeclaringType().getJavaClass() == clazz)
+ for (Type decType : decoratedTypes)
+ {
+ if
(!(ClassUtil.getClass(decType)).isAssignableFrom(ClassUtil.getClass(delegateType)))
{
- throw new WebBeansConfigurationException("Only one Interceptor
of a certain type is allowed per class, but multiple found in class "
- +
annotatedMethod.getDeclaringType().getJavaClass().getName()
- + " methods: " +
annotatedMethod.getJavaMember().toString()
- + " and " + alreadyDefined.getJavaMember().toString());
+ throw new WebBeansConfigurationException("Decorator : " +
toString() + " delegate attribute must implement all of the decorator decorated
types" +
+ ", but decorator type " + decType + " is not
assignable from delegate type of " + delegateType);
+ }
+ else
+ {
+ if(ClassUtil.isParametrizedType(decType) &&
ClassUtil.isParametrizedType(delegateType))
+ {
+ if(!delegateType.equals(decType))
+ {
+ throw new WebBeansConfigurationException("Decorator :
" + toString() + " generic delegate attribute must be same with decorated type
: " + decType);
+ }
+ }
}
}
}
- protected abstract B createBean(Set<Type> types,
- Class<T> beanClass,
- boolean enabled,
- Map<InterceptionType, Method[]>
interceptionMethods);
+
@Override
- protected B createBean(Set<Type> types,
+ protected DecoratorBean<T> createBean(Set<Type> types,
Set<Annotation> qualifiers,
Class<? extends Annotation> scope,
String name,
@@ -343,8 +277,23 @@ public abstract class InterceptorBeanBui
boolean alternative,
boolean enabled)
{
- B bean = createBean(types, beanClass, enabled, interceptionMethods);
- addConstructorInjectionPointMetaData(bean);
- return bean;
+ DecoratorBean<T> decorator = new DecoratorBean<T>(webBeansContext,
WebBeansType.MANAGED, getAnnotated(), types, qualifiers,
+ scope, beanClass,
stereotypes);
+ addConstructorInjectionPointMetaData(decorator);
+
+ decorator.setEnabled(enabled);
+ return decorator;
+ }
+
+ @Override
+ public DecoratorBean<T> getBean()
+ {
+ DecoratorBean<T> decorator = super.getBean();
+
+ // we can only do this after the bean injection points got scanned
+ defineDelegate(decorator.getInjectionPoints());
+ decorator.setDecoratorInfo(decoratedTypes, delegateType,
delegateQualifiers);
+
+ return decorator;
}
}
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=1435096&r1=1435095&r2=1435096&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
Fri Jan 18 11:30:35 2013
@@ -49,6 +49,7 @@ import javax.enterprise.inject.spi.Proce
import javax.enterprise.inject.spi.Producer;
import org.apache.webbeans.annotation.AnnotationManager;
+import org.apache.webbeans.component.DecoratorBean;
import org.apache.webbeans.component.InjectionTargetBean;
import org.apache.webbeans.component.AbstractProducerBean;
import org.apache.webbeans.component.CdiInterceptorBean;
@@ -60,6 +61,7 @@ import org.apache.webbeans.component.Owb
import org.apache.webbeans.component.ProducerFieldBean;
import org.apache.webbeans.component.ProducerMethodBean;
import org.apache.webbeans.component.creation.CdiInterceptorBeanBuilder;
+import org.apache.webbeans.component.creation.DecoratorBeanBuilder;
import org.apache.webbeans.component.creation.ManagedBeanBuilder;
import org.apache.webbeans.container.BeanManagerImpl;
import org.apache.webbeans.container.InjectableBeanManager;
@@ -740,10 +742,6 @@ public class BeansDeployer
throw new WebBeansConfigurationException("Passivation
scoped defined bean must be passivation capable, " +
"but bean : " + beanObj.toString() + " is not
passivation capable");
}
- else
- {
- validate = true;
- }
}
validate = true;
@@ -841,12 +839,6 @@ public class BeansDeployer
ManagedBeanBuilder<T, ManagedBean<T>> managedBeanCreator = new
ManagedBeanBuilder<T, ManagedBean<T>>(webBeansContext, annotatedType);
- boolean annotationTypeSet = false;
- if(processAnnotatedEvent.isModifiedAnnotatedType())
- {
- annotationTypeSet = true;
- }
-
InjectionTargetBean<T> bean;
GProcessInjectionTarget processInjectionTarget = null;
if(WebBeansUtil.isDecorator(annotatedType))
@@ -855,13 +847,17 @@ public class BeansDeployer
{
logger.log(Level.FINE, "Found Managed Bean Decorator with
class name : [{0}]", annotatedType.getJavaClass().getName());
}
- if(annotationTypeSet)
+ DecoratorBeanBuilder<T> dbb = new
DecoratorBeanBuilder<T>(webBeansContext, annotatedType);
+ if (dbb.isDecoratorEnabled())
{
- bean =
webBeansContext.getWebBeansUtil().defineDecorator(annotatedType);
+ dbb.defineDecoratorRules();
+ DecoratorBean<T> decorator = dbb.getBean();
+
webBeansContext.getDecoratorsManager().addDecorator(decorator);
+ bean = decorator;
}
else
{
- bean = managedBeanCreator.defineDecorator(annotatedType);
+ bean = null;
}
}
else if(WebBeansUtil.isCdiInterceptor(annotatedType))
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=1435096&r1=1435095&r2=1435096&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
Fri Jan 18 11:30:35 2013
@@ -30,17 +30,16 @@ import org.apache.webbeans.proxy.Interce
import org.apache.webbeans.util.AnnotationUtil;
import javax.enterprise.context.Dependent;
import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.Decorator;
import javax.enterprise.inject.spi.InterceptionType;
import javax.enterprise.inject.spi.Interceptor;
import javax.interceptor.AroundInvoke;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -113,18 +112,25 @@ public final class WebBeansInterceptorCo
activeInterceptors.add(interceptorInfo.getSelfInterceptorBean());
}
}
-
+
+/*X TODO remove
if (mii.getMethodDecorators() != null)
{
LinkedHashMap<Decorator<?>, Method> methodDecorators=
mii.getMethodDecorators();
+
//X TODO fill an own DecoratorDelegateInterceptor and add
it to the activeInterceptors.
//X TODO or find some alternative handling
}
+*/
if (activeInterceptors.size() > 0)
{
methodInterceptors.put(interceptedMethod,
activeInterceptors);
}
+ else if (mii.getMethodDecorators() != null)
+ {
+ methodInterceptors.put(interceptedMethod,
Collections.EMPTY_LIST);
+ }
// empty InterceptionType -> AROUND_INVOKE
if (!mii.getInterceptionTypes().isEmpty())