You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2009/03/07 14:54:12 UTC
svn commit: r751267 - in
/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans:
component/ config/ config/inheritance/ container/ container/activity/
context/ deployment/ intercept/ intercept/webbeans/ lifecycle/ util/ xml/
Author: gerdogdu
Date: Sat Mar 7 13:54:11 2009
New Revision: 751267
URL: http://svn.apache.org/viewvc?rev=751267&view=rev
Log:
Updating for TCK tests.Adding simple activity for managers.
Added:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java (with props)
Modified:
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/AbstractBeanInheritedMetaData.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/BeanInheritedMetaData.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomContextImpl.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/AbstractComponent.java Sat Mar 7 13:54:11 2009
@@ -24,6 +24,7 @@
import java.util.Set;
import java.util.WeakHashMap;
+import javax.context.Context;
import javax.context.Contextual;
import javax.context.CreationalContext;
import javax.context.Dependent;
@@ -31,6 +32,7 @@
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
+import org.apache.webbeans.config.inheritance.BeanInheritedMetaData;
import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
import org.apache.webbeans.container.ManagerImpl;
import org.apache.webbeans.context.ContextFactory;
@@ -119,6 +121,17 @@
this.webBeansType = webBeansType;
this.returnType = returnType;
}
+
+
+ public IBeanInheritedMetaData getInheritedMetaData()
+ {
+ return this.inheritedMetaData;
+ }
+
+ protected void setInheritedMetaData()
+ {
+ this.inheritedMetaData = new BeanInheritedMetaData<T>(this);
+ }
/*
* (non-Javadoc)
@@ -196,9 +209,14 @@
}
if(WebBeansUtil.isScopeTypeNormal(getScopeType()))
- {
- WebBeansContext context = (WebBeansContext)getManager().getContext(getScopeType());
- context.remove(this);
+ {
+ Context context = getManager().getContext(getScopeType());
+
+ if(context instanceof WebBeansContext)
+ {
+ WebBeansContext webBeansContext = (WebBeansContext) context;
+ webBeansContext.remove(this);
+ }
}
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/Component.java Sat Mar 7 13:54:11 2009
@@ -21,6 +21,7 @@
import javax.inject.manager.InjectionPoint;
import javax.inject.manager.Manager;
+import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
import org.apache.webbeans.intercept.InterceptorData;
/**
@@ -41,6 +42,8 @@
super(manager);
}
+ abstract public IBeanInheritedMetaData getInheritedMetaData();
+
abstract public Annotation getType();
abstract public void setType(Annotation type);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/ComponentImpl.java Sat Mar 7 13:54:11 2009
@@ -59,6 +59,9 @@
public ComponentImpl(Class<T> returnType, WebBeansType type)
{
super(type, returnType);
+
+ //Setting inherited meta data instance
+ setInheritedMetaData();
}
/*
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java Sat Mar 7 13:54:11 2009
@@ -43,6 +43,7 @@
import org.apache.webbeans.annotation.CurrentLiteral;
import org.apache.webbeans.annotation.DependentScopeLiteral;
+import org.apache.webbeans.annotation.ProductionLiteral;
import org.apache.webbeans.component.AbstractComponent;
import org.apache.webbeans.component.Component;
import org.apache.webbeans.component.ComponentImpl;
@@ -50,6 +51,7 @@
import org.apache.webbeans.component.ObservesMethodsOwner;
import org.apache.webbeans.component.ProducerComponentImpl;
import org.apache.webbeans.component.ProducerFieldComponent;
+import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
import org.apache.webbeans.container.InjectionResolver;
import org.apache.webbeans.decorator.WebBeansDecoratorConfig;
import org.apache.webbeans.deployment.DeploymentTypeManager;
@@ -103,12 +105,34 @@
IComponentHasParent child = (IComponentHasParent) component;
component.setType(child.getParent().getType());
found = true;
- }
+ }
+
+ if (!found)
+ {
+ // Look inherited meta-data deplyment type
+ IBeanInheritedMetaData metadata = component.getInheritedMetaData();
+ if (metadata != null)
+ {
+ if (metadata.getInheritedDeploymentType() != null)
+ {
+ component.setType(metadata.getInheritedDeploymentType());
+ found = true;
+ }
+ }
+ }
+ // Still not set
if (!found)
{
+ // Look stereotype
+ Annotation result = WebBeansUtil.getMaxPrecedenceSteroTypeDeploymentType(component);
+
+ // Default @Production
+ if (result == null)
+ {
+ component.setType(new ProductionLiteral());
- component.setType(WebBeansUtil.getMaxPrecedenceSteroTypeDeploymentType(component));
+ }
}
return component.getDeploymentType();
@@ -136,25 +160,25 @@
public static <T> void defineProducerMethodApiTypes(AbstractComponent<T> component, Class<T> clazz)
{
Set<Type> types = component.getTypes();
-
+
if (clazz.isPrimitive() || clazz.isArray())
{
types.add(clazz);
types.add(Object.class);
-
- if(clazz.isPrimitive())
+
+ if (clazz.isPrimitive())
{
- types.add(ClassUtil.getPrimitiveWrapper(clazz));
+ types.add(ClassUtil.getPrimitiveWrapper(clazz));
}
-
+
}
else
{
- if(ClassUtil.isPrimitiveWrapper(clazz))
+ if (ClassUtil.isPrimitiveWrapper(clazz))
{
types.add(ClassUtil.getWrapperPrimitive(clazz));
}
-
+
ClassUtil.setTypeHierarchy(component.getTypes(), clazz);
}
}
@@ -181,7 +205,7 @@
Class<?> clazz = method.getReturnType();
if (clazz.isArray() || clazz.isAnnotation())
{
- if (!AnnotationUtil.isAnnotationExist(method.getAnnotations(), NonBinding.class))
+ if (!AnnotationUtil.isAnnotationExist(method.getDeclaredAnnotations(), NonBinding.class))
{
throw new WebBeansConfigurationException("WebBeans definition class : " + component.getReturnType().getName() + " @BindingType : " + annotation.annotationType().getName() + " must have @NonBinding valued members for its array-valued and annotation valued members");
}
@@ -196,12 +220,38 @@
component.addBindingType(annotation);
}
}
+
+ // Adding inherited binding types
+ IBeanInheritedMetaData inheritedMetaData = component.getInheritedMetaData();
+ if (inheritedMetaData != null)
+ {
+ Set<Annotation> inheritedTypes = inheritedMetaData.getInheritedBindingTypes();
+ for (Annotation inherited : inheritedTypes)
+ {
+ Set<Annotation> bindings = component.getBindings();
+ boolean found = false;
+ for (Annotation existBinding : bindings)
+ {
+ if (existBinding.annotationType().equals(inherited.annotationType()))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ component.addBindingType(inherited);
+ }
+ }
+ }
+
// No-binding annotation
- if (!find)
+ if (component.getBindings().size() == 0)
{
component.addBindingType(new CurrentLiteral());
}
+
}
/**
@@ -241,7 +291,7 @@
public static <T> void defineStereoTypes(Component<?> component, Class<T> clazz)
{
- Annotation[] anns = clazz.getAnnotations();
+ Annotation[] anns = clazz.getDeclaredAnnotations();
if (AnnotationUtil.isStereoTypeMetaAnnotationExist(anns))
{
@@ -252,46 +302,87 @@
component.addStereoType(stereo);
}
}
+
+ // Adding inherited binding types
+ IBeanInheritedMetaData inheritedMetaData = component.getInheritedMetaData();
+ if (inheritedMetaData != null)
+ {
+ Set<Annotation> inheritedTypes = inheritedMetaData.getInheritedStereoTypes();
+ for (Annotation inherited : inheritedTypes)
+ {
+ Set<Annotation> bindings = component.getStereotypes();
+ boolean found = false;
+ for (Annotation existBinding : bindings)
+ {
+ if (existBinding.annotationType().equals(inherited.annotationType()))
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ component.addStereoType(inherited);
+ }
+ }
+ }
+
}
public static void defineDefaultScopeType(Component<?> component, String exceptionMessage)
{
- Set<Annotation> stereos = component.getStereotypes();
- if (stereos.size() == 0)
+ // Frist look for inherited scope
+ IBeanInheritedMetaData metaData = component.getInheritedMetaData();
+ boolean found = false;
+ if (metaData != null)
{
- component.setImplScopeType(new DependentScopeLiteral());
+ Annotation inheritedScope = metaData.getInheritedScopeType();
+ if (inheritedScope != null)
+ {
+ found = true;
+ component.setImplScopeType(inheritedScope);
+ }
}
- else
+
+ if (!found)
{
- Annotation defined = null;
- Set<Annotation> anns = component.getStereotypes();
- for (Annotation stero : anns)
+ Set<Annotation> stereos = component.getStereotypes();
+ if (stereos.size() == 0)
{
- if (AnnotationUtil.isMetaAnnotationExist(stero.annotationType().getAnnotations(), ScopeType.class))
+ component.setImplScopeType(new DependentScopeLiteral());
+ }
+ else
+ {
+ Annotation defined = null;
+ Set<Annotation> anns = component.getStereotypes();
+ for (Annotation stero : anns)
{
- Annotation next = AnnotationUtil.getMetaAnnotations(stero.annotationType().getAnnotations(), ScopeType.class)[0];
-
- if (defined == null)
- {
- defined = next;
- }
- else
+ if (AnnotationUtil.isMetaAnnotationExist(stero.annotationType().getDeclaredAnnotations(), ScopeType.class))
{
- if (!defined.equals(next))
+ Annotation next = AnnotationUtil.getMetaAnnotations(stero.annotationType().getDeclaredAnnotations(), ScopeType.class)[0];
+
+ if (defined == null)
{
- throw new WebBeansConfigurationException(exceptionMessage);
+ defined = next;
+ }
+ else
+ {
+ if (!defined.equals(next))
+ {
+ throw new WebBeansConfigurationException(exceptionMessage);
+ }
}
}
}
- }
- if (defined != null)
- {
- component.setImplScopeType(defined);
- }
- else
- {
- component.setImplScopeType(new DependentScopeLiteral());
+ if (defined != null)
+ {
+ component.setImplScopeType(defined);
+ }
+ else
+ {
+ component.setImplScopeType(new DependentScopeLiteral());
+ }
}
}
@@ -345,7 +436,7 @@
}
}
-
+
/**
* Defines the set of {@link ProducerFieldComponent} components.
*
@@ -356,82 +447,81 @@
{
Set<ProducerFieldComponent<?>> producerFields = new HashSet<ProducerFieldComponent<?>>();
Field[] fields = component.getReturnType().getDeclaredFields();
-
- //From normal class
+
+ // From normal class
createProducerFieldWithRealizations(component, producerFields, fields, false);
-
- //From @Realizations
- fields = new Field[0];
-
- if(component.getReturnType().getAnnotation(Realizes.class) != null)
+
+ // From @Realizations
+ fields = new Field[0];
+
+ if (component.getReturnType().getAnnotation(Realizes.class) != null)
{
fields = AnnotationUtil.getClazzFieldsWithGivenAnnotation(component.getReturnType().getSuperclass(), Produces.class);
-
- //from @Realizations
+
+ // from @Realizations
createProducerFieldWithRealizations(component, producerFields, fields, true);
}
-
-
+
return producerFields;
}
-
- private static void createProducerFieldWithRealizations(AbstractComponent<?> component,Set<ProducerFieldComponent<?>> producerFields, Field[] fields, boolean isRealizes)
+
+ private static void createProducerFieldWithRealizations(AbstractComponent<?> component, Set<ProducerFieldComponent<?>> producerFields, Field[] fields, boolean isRealizes)
{
- for(Field field : fields)
+ for (Field field : fields)
{
- if(isRealizes)
+ if (isRealizes)
{
int modifiers = field.getModifiers();
- if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+ if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
{
continue;
}
}
-
- //Producer field
- if(AnnotationUtil.isAnnotationExist(field.getAnnotations(), Produces.class))
+
+ // Producer field
+ if (AnnotationUtil.isAnnotationExist(field.getDeclaredAnnotations(), Produces.class))
{
ProducerFieldComponent<?> newComponent = createProducerFieldComponent(field.getType(), field, component);
-
+
if (newComponent != null)
{
- if(isRealizes)
+ if (isRealizes)
{
- //Add Binding types from the parent and removes from the generic super class via @Realizes
+ // Add Binding types from the parent and removes from
+ // the generic super class via @Realizes
Set<Annotation> fromParents = component.getBindings();
- for(Annotation fromParent : fromParents)
+ for (Annotation fromParent : fromParents)
{
newComponent.addBindingType(fromParent);
}
-
- //Removes the @BindingTypes from @Realizes
+
+ // Removes the @BindingTypes from @Realizes
Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
- for(Annotation fromGeneric : fromGenerics)
+ for (Annotation fromGeneric : fromGenerics)
{
newComponent.getBindings().remove(fromGeneric);
}
-
- //Deployment type is the same as parent
+
+ // Deployment type is the same as parent
newComponent.setType(component.getType());
-
+
}
}
-
-
+
if (newComponent != null)
{
- producerFields.add(newComponent);
+ producerFields.add(newComponent);
}
-
+
}
-
+
}
-
+
}
-
+
/**
- * Defines the {@link Bean} producer methods. Moreover,
- * it configures the producer methods with using the {@link Realizes} annotations.
+ * Defines the {@link Bean} producer methods. Moreover, it configures the
+ * producer methods with using the {@link Realizes} annotations.
*
* @param component
* @return the set of producer components
@@ -440,45 +530,44 @@
public static Set<ProducerComponentImpl<?>> defineProducerMethods(AbstractComponent<?> component)
{
Asserts.assertNotNull(component, "component parameter can not be null");
-
+
Set<ProducerComponentImpl<?>> producerComponents = new HashSet<ProducerComponentImpl<?>>();
Class<?> clazz = component.getReturnType();
Method[] declaredMethods = clazz.getDeclaredMethods();
-
- //From @Realizations
+
+ // From @Realizations
Method[] realizedProducers = new Method[0];
-
- if(clazz.getAnnotation(Realizes.class) != null)
+
+ if (clazz.getAnnotation(Realizes.class) != null)
{
realizedProducers = AnnotationUtil.getMethodsWithAnnotation(clazz.getSuperclass(), Produces.class);
-
+
}
-
+
boolean isSpecializes = false;
-
- //This methods defined in the class
+
+ // This methods defined in the class
for (Method declaredMethod : declaredMethods)
{
- createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz, isSpecializes,false);
+ createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz, isSpecializes, false);
}
- //This methods defined in the @Realizations generic class
+ // This methods defined in the @Realizations generic class
for (Method declaredMethod : realizedProducers)
{
int modifiers = declaredMethod.getModifiers();
- if(!Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers))
+ if (!Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers))
{
- createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz.getSuperclass(), isSpecializes,true);
+ createProducerComponentsWithReliazes(component, producerComponents, declaredMethod, clazz.getSuperclass(), isSpecializes, true);
}
}
return producerComponents;
}
-
-
- private static <T> void createProducerComponentsWithReliazes(AbstractComponent<T> component, Set<ProducerComponentImpl<?>> producerComponents, Method declaredMethod, Class<?> clazz,boolean isSpecializes,boolean isRealizes)
+
+ private static <T> void createProducerComponentsWithReliazes(AbstractComponent<T> component, Set<ProducerComponentImpl<?>> producerComponents, Method declaredMethod, Class<?> clazz, boolean isSpecializes, boolean isRealizes)
{
// Producer Method
if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Produces.class))
@@ -501,34 +590,35 @@
ProducerComponentImpl<?> newComponent = createProducerComponent(declaredMethod.getReturnType(), declaredMethod, component, isSpecializes);
if (newComponent != null)
{
- if(isRealizes)
+ if (isRealizes)
{
newComponent.setFromRealizes(true);
-
- //Add Binding types from the parent and removes from the generic super class via @Realizes
+
+ // Add Binding types from the parent and removes from the
+ // generic super class via @Realizes
Set<Annotation> fromParents = component.getBindings();
- for(Annotation fromParent : fromParents)
+ for (Annotation fromParent : fromParents)
{
newComponent.addBindingType(fromParent);
}
-
- //Removes the @BindingTypes from @Realizes
+
+ // Removes the @BindingTypes from @Realizes
Annotation[] fromGenerics = AnnotationUtil.getBindingAnnotations(component.getReturnType().getSuperclass().getDeclaredAnnotations());
- for(Annotation fromGeneric : fromGenerics)
+ for (Annotation fromGeneric : fromGenerics)
{
newComponent.getBindings().remove(fromGeneric);
}
-
- //Deployment type is the same as parent
+
+ // Deployment type is the same as parent
newComponent.setType(component.getType());
-
+
}
-
+
producerComponents.add(newComponent);
- addMethodInjectionPointMetaData(newComponent, declaredMethod);
+ addMethodInjectionPointMetaData(newComponent, declaredMethod);
}
}
-
+
}
private static <T> ProducerComponentImpl<T> createProducerComponent(Class<T> returnType, Method method, AbstractComponent<?> parent, boolean isSpecializes)
@@ -556,7 +646,7 @@
return null;
}
- Annotation[] methodAnns = method.getAnnotations();
+ Annotation[] methodAnns = method.getDeclaredAnnotations();
DefinitionUtil.defineProducerMethodApiTypes(component, returnType);
DefinitionUtil.defineScopeType(component, methodAnns, "WebBeans producer method : " + method.getName() + " in class " + parent.getReturnType().getName() + " must declare default @ScopeType annotation");
@@ -567,13 +657,12 @@
return component;
}
-
+
private static <T> ProducerFieldComponent<T> createProducerFieldComponent(Class<T> returnType, Field field, AbstractComponent<?> parent)
{
ProducerFieldComponent<T> component = new ProducerFieldComponent<T>(parent, returnType);
component.setProducerField(field);
-
if (returnType.isPrimitive())
{
component.setNullable(false);
@@ -581,7 +670,7 @@
defineSerializable(component);
- Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component, field.getAnnotations(), "There are more than one @DeploymentType annotation in the component class : " + component.getReturnType().getName());
+ Class<? extends Annotation> deploymentType = DefinitionUtil.defineDeploymentType(component, field.getDeclaredAnnotations(), "There are more than one @DeploymentType annotation in the component class : " + component.getReturnType().getName());
// Check if the deployment type is enabled.
if (!DeploymentTypeManager.getInstance().isDeploymentTypeEnabled(deploymentType))
@@ -589,74 +678,75 @@
return null;
}
- Annotation[] fieldAnns = field.getAnnotations();
+ Annotation[] fieldAnns = field.getDeclaredAnnotations();
DefinitionUtil.defineProducerMethodApiTypes(component, returnType);
DefinitionUtil.defineScopeType(component, fieldAnns, "WebBeans producer method : " + field.getName() + " in class " + parent.getReturnType().getName() + " must declare default @ScopeType annotation");
DefinitionUtil.defineBindingTypes(component, fieldAnns);
- DefinitionUtil.defineName(component, fieldAnns,field.getName());
+ DefinitionUtil.defineName(component, fieldAnns, field.getName());
- //WebBeansUtil.checkSteroTypeRequirements(component, fieldAnns, "WebBeans producer method : " + method.getName() + " in class : " + parent.getReturnType().getName());
+ // WebBeansUtil.checkSteroTypeRequirements(component, fieldAnns,
+ // "WebBeans producer method : " + method.getName() + " in class : " +
+ // parent.getReturnType().getName());
return component;
- }
+ }
public static <T> void defineDisposalMethods(AbstractComponent<T> component)
{
Class<?> clazz = component.getReturnType();
- Method[] methods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Disposes.class);
+ Method[] methods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Disposes.class);
Method[] genericMethods = new Method[0];
- if(clazz.getAnnotation(Realizes.class) != null)
+ if (clazz.getAnnotation(Realizes.class) != null)
{
genericMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz.getSuperclass(), Disposes.class);
- }
-
- //From Normal
- createDisposalMethodsWithRealizations(component, methods, clazz,false);
-
- //From @Realizations
- createDisposalMethodsWithRealizations(component, genericMethods, clazz.getSuperclass(),true);
- }
-
-
- private static <T> void createDisposalMethodsWithRealizations(AbstractComponent<T> component,Method[] methods, Class<?> clazz, boolean isRealizes)
+ }
+
+ // From Normal
+ createDisposalMethodsWithRealizations(component, methods, clazz, false);
+
+ // From @Realizations
+ createDisposalMethodsWithRealizations(component, genericMethods, clazz.getSuperclass(), true);
+ }
+
+ private static <T> void createDisposalMethodsWithRealizations(AbstractComponent<T> component, Method[] methods, Class<?> clazz, boolean isRealizes)
{
ProducerComponentImpl<?> previous = null;
for (Method declaredMethod : methods)
{
- if(isRealizes)
+ if (isRealizes)
{
int modifiers = declaredMethod.getModifiers();
- if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+ if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
{
continue;
}
}
-
+
WebBeansUtil.checkProducerMethodDisposal(declaredMethod, clazz.getName());
Type type = AnnotationUtil.getMethodFirstParameterWithAnnotation(declaredMethod, Disposes.class);
Annotation[] annot = AnnotationUtil.getMethodFirstParameterBindingTypesWithGivenAnnotation(declaredMethod, Disposes.class);
-
- if(isRealizes)
+
+ if (isRealizes)
{
annot = AnnotationUtil.getRealizesGenericAnnotations(component.getReturnType(), annot);
}
-
+
Set<Bean<T>> set = InjectionResolver.getInstance().implResolveByType(ClassUtil.getFirstRawType(type), ClassUtil.getActualTypeArguements(type), annot);
- Bean<T> bean = set.iterator().next();
+ Bean<T> bean = set.iterator().next();
ProducerComponentImpl<?> pr = null;
-
+
if (bean == null || !(bean instanceof ProducerComponentImpl))
{
throw new UnsatisfiedDependencyException("Producer method component of the disposal method : " + declaredMethod.getName() + " in class : " + clazz.getName() + "is not found");
}
-
+
else
{
- pr = (ProducerComponentImpl<?>)bean;
+ pr = (ProducerComponentImpl<?>) bean;
}
if (previous == null)
@@ -673,45 +763,45 @@
}
pr.setDisposalMethod(declaredMethod);
-
+
addMethodInjectionPointMetaData(component, declaredMethod);
-
+
}
}
public static <T> void defineInjectedFields(ComponentImpl<T> component)
{
Class<T> clazz = component.getReturnType();
-
- //From component
+
+ // From component
defineInternalInjectedFields(component, clazz, false);
-
- //From inherited super class
+
+ // From inherited super class
defineInternalInjectedFieldsRecursively(component, clazz);
}
-
+
@SuppressWarnings("unchecked")
private static <T> void defineInternalInjectedFieldsRecursively(ComponentImpl<T> component, Class<T> clazz)
{
- //From inheritance
+ // From inheritance
Class<?> superClazz = clazz.getSuperclass();
- if(!superClazz.equals(Object.class))
+ if (!superClazz.equals(Object.class))
{
- //From super class
- defineInternalInjectedFields(component, (Class<T>)superClazz, true);
-
- //From super class type hierarchy
- defineInternalInjectedFieldsRecursively(component, (Class<T>)superClazz);
+ // From super class
+ defineInternalInjectedFields(component, (Class<T>) superClazz, true);
+
+ // From super class type hierarchy
+ defineInternalInjectedFieldsRecursively(component, (Class<T>) superClazz);
}
-
+
}
-
- private static <T> void defineInternalInjectedFields(ComponentImpl<T> component,Class<T> clazz, boolean fromSuperClazz)
+
+ private static <T> void defineInternalInjectedFields(ComponentImpl<T> component, Class<T> clazz, boolean fromSuperClazz)
{
- if(!WebBeansUtil.checkObservableFieldsConditions(clazz))
+ if (!WebBeansUtil.checkObservableFieldsConditions(clazz))
{
- WebBeansUtil.checkObtainsFieldConditions(clazz);
+ WebBeansUtil.checkObtainsFieldConditions(clazz);
}
Field[] fields = clazz.getDeclaredFields();
@@ -719,26 +809,26 @@
{
for (Field field : fields)
{
- Annotation[] anns = field.getAnnotations();
+ Annotation[] anns = field.getDeclaredAnnotations();
- //Injected fields can not be @Decorates or @Produces
- if(AnnotationUtil.isAnnotationExist(anns, Produces.class) ||
- AnnotationUtil.isAnnotationExist(anns, Decorates.class))
+ // Injected fields can not be @Decorates or @Produces
+ if (AnnotationUtil.isAnnotationExist(anns, Produces.class) || AnnotationUtil.isAnnotationExist(anns, Decorates.class))
{
return;
}
-
+
Annotation[] bindingAnns = AnnotationUtil.getBindingAnnotations(anns);
Annotation[] resourceAnns = AnnotationUtil.getResourceAnnotations(anns);
-
- // bindingAnns and resourceAnns are not allowed at the same time!
+
+ // bindingAnns and resourceAnns are not allowed at the same
+ // time!
if (bindingAnns.length > 0 && resourceAnns.length > 0)
{
- throw new WebBeansConfigurationException("Found binding and resource injection at the same time for the field : "
- + field.getName() + " in class : " + clazz.getName());
+ throw new WebBeansConfigurationException("Found binding and resource injection at the same time for the field : " + field.getName() + " in class : " + clazz.getName());
}
-
- // injected fields must either be resources or define binding types,
+
+ // injected fields must either be resources or define binding
+ // types,
// otherwise it's binding @Current.
if (bindingAnns.length > 0 || resourceAnns.length > 0)
{
@@ -750,38 +840,38 @@
{
WebBeansUtil.checkForValidResources(field.getGenericType(), clazz, field.getName(), anns);
}
-
+
int mod = field.getModifiers();
if (!Modifier.isStatic(mod) && !Modifier.isFinal(mod))
{
- if(!fromSuperClazz)
+ if (!fromSuperClazz)
{
- component.addInjectedField(field);
- addFieldInjectionPointMetaData(component, field);
+ component.addInjectedField(field);
+ addFieldInjectionPointMetaData(component, field);
}
else
{
- //Check that field is already exist
+ // Check that field is already exist
Set<Field> definedInjectedFields = component.getInjectedFields();
- for(Field defineInjectedField : definedInjectedFields)
+ for (Field defineInjectedField : definedInjectedFields)
{
- if(defineInjectedField.getName().equals(field.getName()) && defineInjectedField.getType().equals(field.getType()))
+ if (defineInjectedField.getName().equals(field.getName()) && defineInjectedField.getType().equals(field.getType()))
{
break;
}
else
{
- component.addInjectedField(field);
- addFieldInjectionPointMetaData(component, field);
+ component.addInjectedField(field);
+ addFieldInjectionPointMetaData(component, field);
}
}
- }
+ }
}
}
-
+
}
}
-
+
}
public static <T> void defineInjectedMethods(ComponentImpl<T> component)
@@ -789,45 +879,44 @@
Asserts.assertNotNull(component, "component parameter can not be null");
Class<T> clazz = component.getReturnType();
-
- //From component class definition
+
+ // From component class definition
defineInternalInjectedMethods(component, clazz, false);
-
- //From inheritance hierarchy
+
+ // From inheritance hierarchy
defineInternalInjectedMethodsRecursively(component, clazz);
}
-
+
@SuppressWarnings("unchecked")
private static <T> void defineInternalInjectedMethodsRecursively(ComponentImpl<T> component, Class<T> clazz)
{
- //From inheritance
+ // From inheritance
Class<?> superClazz = clazz.getSuperclass();
- if(!superClazz.equals(Object.class))
+ if (!superClazz.equals(Object.class))
{
- //From super class
- defineInternalInjectedMethods(component, (Class<T>)superClazz, true);
-
- //From super class type hierarchy
- defineInternalInjectedMethodsRecursively(component, (Class<T>)superClazz);
+ // From super class
+ defineInternalInjectedMethods(component, (Class<T>) superClazz, true);
+
+ // From super class type hierarchy
+ defineInternalInjectedMethodsRecursively(component, (Class<T>) superClazz);
}
}
-
+
private static <T> void defineInternalInjectedMethods(ComponentImpl<T> component, Class<T> clazz, boolean fromInherited)
{
-
+
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods)
{
boolean isInitializer = AnnotationUtil.isMethodHasAnnotation(method, Initializer.class);
- boolean isResource = AnnotationUtil.isMethodHasResourceAnnotation(method);
-
+ boolean isResource = AnnotationUtil.isMethodHasResourceAnnotation(method);
+
if (isInitializer && isResource)
{
- throw new WebBeansConfigurationException("Found Initializer and resource injection at the same time for the method : "
- + method.getName() + " in class : " + clazz.getName());
+ throw new WebBeansConfigurationException("Found Initializer and resource injection at the same time for the method : " + method.getName() + " in class : " + clazz.getName());
}
-
+
if (isInitializer)
{
checkForInjectedInitializerMethod(component, clazz, method);
@@ -840,36 +929,35 @@
{
continue;
}
-
+
if (!Modifier.isStatic(method.getModifiers()))
{
- if(!fromInherited)
+ if (!fromInherited)
{
component.addInjectedMethod(method);
- addMethodInjectionPointMetaData(component, method);
+ addMethodInjectionPointMetaData(component, method);
}
else
{
Set<Method> injectedMethods = component.getInjectedMethods();
- for(Method definedInjectedMethod : injectedMethods)
+ for (Method definedInjectedMethod : injectedMethods)
{
- if(definedInjectedMethod.getName().equals(method.getName()) &&
- Arrays.equals(definedInjectedMethod.getParameterTypes(), method.getParameterTypes()))
+ if (definedInjectedMethod.getName().equals(method.getName()) && Arrays.equals(definedInjectedMethod.getParameterTypes(), method.getParameterTypes()))
{
break;
}
else
{
component.addInjectedMethod(method);
- addMethodInjectionPointMetaData(component, method);
+ addMethodInjectionPointMetaData(component, method);
}
}
}
-
+
}
}
-
+
}
/**
@@ -892,8 +980,7 @@
}
else
{
- throw new WebBeansConfigurationException("Initializer method : " + method.getName() + " in class : " + clazz.getName()
- + " can not be annotated with @Produces");
+ throw new WebBeansConfigurationException("Initializer method : " + method.getName() + " in class : " + clazz.getName() + " can not be annotated with @Produces");
}
}
@@ -905,15 +992,13 @@
Class<?>[] parameterTypes = method.getParameterTypes();
if (parameterTypes == null || parameterTypes.length != 1)
{
- throw new WebBeansConfigurationException("Resource method : " + method.getName() + " in class : " + clazz.getName()
- + " must only have exactly 1 parameter with a valid resource type");
+ throw new WebBeansConfigurationException("Resource method : " + method.getName() + " in class : " + clazz.getName() + " must only have exactly 1 parameter with a valid resource type");
}
-
- Annotation[] anns = method.getAnnotations();
+
+ Annotation[] anns = method.getDeclaredAnnotations();
WebBeansUtil.checkForValidResources(parameterTypes[0], clazz, method.getName(), anns);
}
-
public static void defineSimpleWebBeanInterceptorStack(AbstractComponent<?> component)
{
Asserts.assertNotNull(component, "component parameter can no be null");
@@ -922,7 +1007,7 @@
EJBInterceptorConfig.configure(component.getReturnType(), component.getInterceptorStack());
// @javax.webbeans.Interceptor
- WebBeansInterceptorConfig.configure(component.getReturnType(), component.getInterceptorStack());
+ WebBeansInterceptorConfig.configure(component, component.getInterceptorStack());
}
public static void defineWebBeanDecoratorStack(AbstractComponent<?> component, Object object)
@@ -936,48 +1021,48 @@
Asserts.nullCheckForClass(clazz);
NotificationManager manager = NotificationManager.getInstance();
-
+
Method[] candidateMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz, Observes.class);
- //From @Relizations
+ // From @Relizations
Method[] genericMethods = new Method[0];
- if(clazz.getAnnotation(Realizes.class) != null)
+ if (clazz.getAnnotation(Realizes.class) != null)
{
genericMethods = AnnotationUtil.getMethodsWithParameterAnnotation(clazz.getSuperclass(), Observes.class);
- }
-
- //From normal
+ }
+
+ // From normal
createObserverMethodsWithRealizes(component, clazz, candidateMethods, false);
-
- //From @Realizations
+
+ // From @Realizations
createObserverMethodsWithRealizes(component, clazz.getSuperclass(), genericMethods, true);
-
+
manager.addObservableComponentMethods(component);
}
-
+
@SuppressWarnings("unchecked")
- private static <T> void createObserverMethodsWithRealizes(ObservesMethodsOwner<T> component,Class<?> clazz, Method[] candidateMethods, boolean isRealizes)
+ private static <T> void createObserverMethodsWithRealizes(ObservesMethodsOwner<T> component, Class<?> clazz, Method[] candidateMethods, boolean isRealizes)
{
-
+
for (Method candidateMethod : candidateMethods)
{
- if(isRealizes)
+ if (isRealizes)
{
int modifiers = candidateMethod.getModifiers();
- if(Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
+ if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers))
{
continue;
}
}
-
+
EventUtil.checkObserverMethodConditions(candidateMethod, clazz);
component.addObservableMethod(candidateMethod);
component.setFromRealizes(isRealizes);
-
- addMethodInjectionPointMetaData((AbstractComponent<T>)component, candidateMethod);
+
+ addMethodInjectionPointMetaData((AbstractComponent<T>) component, candidateMethod);
}
-
+
}
public static <T> void defineSerializable(AbstractComponent<T> component)
@@ -988,29 +1073,29 @@
component.setSerializable(true);
}
}
-
+
public static <T> void addFieldInjectionPointMetaData(AbstractComponent<T> owner, Field field)
{
InjectionPoint injectionPoint = InjectionPointFactory.getFieldInjectionPointData(owner, field);
- if(injectionPoint != null)
+ if (injectionPoint != null)
{
- owner.addInjectionPoint(injectionPoint);
+ owner.addInjectionPoint(injectionPoint);
}
}
-
+
public static <T> void addMethodInjectionPointMetaData(AbstractComponent<T> owner, Method method)
{
List<InjectionPoint> injectionPoints = InjectionPointFactory.getMethodInjectionPointData(owner, method);
- for(InjectionPoint injectionPoint : injectionPoints)
+ for (InjectionPoint injectionPoint : injectionPoints)
{
owner.addInjectionPoint(injectionPoint);
}
}
-
+
public static <T> void addConstructorInjectionPointMetaData(AbstractComponent<T> owner, Constructor<T> constructor)
{
List<InjectionPoint> injectionPoints = InjectionPointFactory.getConstructorInjectionPointData(owner, constructor);
- for(InjectionPoint injectionPoint : injectionPoints)
+ for (InjectionPoint injectionPoint : injectionPoints)
{
owner.addInjectionPoint(injectionPoint);
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/SimpleWebBeansConfigurator.java Sat Mar 7 13:54:11 2009
@@ -115,7 +115,7 @@
checkSimpleWebBeanCondition(clazz);
ComponentImpl<T> component = new ComponentImpl<T>(clazz, type);
-
+
DefinitionUtil.defineSerializable(component);
DefinitionUtil.defineStereoTypes(component, clazz);
@@ -127,19 +127,19 @@
return null;
}
- Annotation[] clazzAnns = clazz.getAnnotations();
+ Annotation[] clazzAnns = clazz.getDeclaredAnnotations();
DefinitionUtil.defineApiTypes(component, clazz);
DefinitionUtil.defineScopeType(component, clazzAnns, "WebBeans component implementation class : " + clazz.getName() + " must declare default @ScopeType annotation");
WebBeansUtil.checkPassivationScope(component, component.getScopeType().getAnnotation(ScopeType.class));
DefinitionUtil.defineBindingTypes(component, clazzAnns);
- DefinitionUtil.defineName(component, clazzAnns, WebBeansUtil.getSimpleWebBeanDefaultName(clazz.getSimpleName()));
-
+ DefinitionUtil.defineName(component, clazzAnns, WebBeansUtil.getSimpleWebBeanDefaultName(clazz.getSimpleName()));
+
Constructor<T> constructor = WebBeansUtil.defineConstructor(clazz);
component.setConstructor(constructor);
DefinitionUtil.addConstructorInjectionPointMetaData(component, constructor);
- WebBeansUtil.checkSteroTypeRequirements(component, clazz.getAnnotations(), "WebBeans component class : " + clazz.getName());
+ WebBeansUtil.checkSteroTypeRequirements(component, clazz.getDeclaredAnnotations(), "WebBeans component class : " + clazz.getName());
Set<ProducerComponentImpl<?>> producerComponents = DefinitionUtil.defineProducerMethods(component);
manager.getBeans().addAll(producerComponents);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/AbstractBeanInheritedMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/AbstractBeanInheritedMetaData.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/AbstractBeanInheritedMetaData.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/AbstractBeanInheritedMetaData.java Sat Mar 7 13:54:11 2009
@@ -56,6 +56,7 @@
setInheritedScopeType();
setInheritedStereoTypes();
}
+
public Set<Annotation> getInheritedBindingTypes()
{
@@ -91,6 +92,7 @@
{
return this.inheritedClazz;
}
+
/**
* @param inheritedBindingTypes the inheritedBindingTypes to set
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/BeanInheritedMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/BeanInheritedMetaData.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/BeanInheritedMetaData.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/inheritance/BeanInheritedMetaData.java Sat Mar 7 13:54:11 2009
@@ -86,10 +86,12 @@
private void setInheritedType(Class<?> inheritedClass, Class<? extends Annotation> annotationType)
{
- Annotation annotation = AnnotationUtil.getMetaAnnotations(inheritedClass.getAnnotations(), annotationType)[0];
+ Annotation[] inheritedAnnotations = AnnotationUtil.getMetaAnnotations(inheritedClass.getDeclaredAnnotations(), annotationType);
- if(annotation != null && annotation.annotationType().isAnnotationPresent(Inherited.class))
+ if(inheritedAnnotations.length >0 && inheritedAnnotations[0].annotationType().isAnnotationPresent(Inherited.class))
{
+ Annotation annotation = inheritedAnnotations[0];
+
if(annotationType.equals(ScopeType.class))
{
this.inheritedScopeType = annotation;
@@ -111,7 +113,7 @@
private void setInheritedTypes(Set<Annotation> types, Class<?> inheritedClass, Class<? extends Annotation> annotationType)
{
- Annotation[] annotations = AnnotationUtil.getMetaAnnotations(inheritedClass.getAnnotations(), annotationType);
+ Annotation[] annotations = AnnotationUtil.getMetaAnnotations(inheritedClass.getDeclaredAnnotations(), annotationType);
for(Annotation annotation : annotations)
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/ManagerImpl.java Sat Mar 7 13:54:11 2009
@@ -46,7 +46,7 @@
import javax.naming.StringRefAddr;
import org.apache.webbeans.component.AbstractComponent;
-import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.container.activity.ActivityManager;
import org.apache.webbeans.context.ContextFactory;
import org.apache.webbeans.context.creational.CreationalContextFactory;
import org.apache.webbeans.context.creational.CreationalContextImpl;
@@ -98,9 +98,8 @@
public static ManagerImpl getManager()
{
- ManagerImpl instance = (ManagerImpl) WebBeansFinder.getSingletonInstance(WebBeansFinder.SINGLETON_MANAGER);
-
- return instance;
+ ActivityManager activityManager = ActivityManager.getInstance();
+ return activityManager.getRootActivity();
}
public void setXMLConfigurator(WebBeansXMLConfigurator xmlConfigurator)
@@ -452,10 +451,11 @@
}
else
{
- if (context.isActive() && containsActiveContext(contextList))
- {
- throw new IllegalStateException("There is already an active Context registered for this scope! Context=" + context);
- }
+ //Mark , this brokes the TCK tests!!!!
+// if (context.isActive() && containsActiveContext(contextList))
+// {
+// throw new IllegalStateException("There is already an active Context registered for this scope! Context=" + context.getScopeType());
+// }
contextList.add(context);
}
@@ -479,22 +479,22 @@
return this;
}
- /**
- * Check if the given contextList contains an active Context
- * @param contextList
- * @return <code>true</code> if the given contextList contains an active Context, <code>false</code> otherwise
- */
- private boolean containsActiveContext(List<Context> contextList)
- {
- for (Context c : contextList)
- {
- if (c.isActive())
- {
- return true;
- }
- }
- return false;
- }
+// /**
+// * Check if the given contextList contains an active Context
+// * @param contextList
+// * @return <code>true</code> if the given contextList contains an active Context, <code>false</code> otherwise
+// */
+// private boolean containsActiveContext(List<Context> contextList)
+// {
+// for (Context c : contextList)
+// {
+// if (c.isActive())
+// {
+// return true;
+// }
+// }
+// return false;
+// }
public Manager createActivity()
{
@@ -506,15 +506,5 @@
{
// TODO Auto-generated method stub
return null;
- }
-
-
- public void clear()
- {
- this.components.clear();
- this.contextMap.clear();
- this.proxyMap.clear();
- this.webBeansDecorators.clear();
- this.webBeansInterceptors.clear();
- }
+ }
}
\ No newline at end of file
Added: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java?rev=751267&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java (added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java Sat Mar 7 13:54:11 2009
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.webbeans.container.activity;
+
+
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.container.ManagerImpl;
+
+public class ActivityManager
+{
+ private ManagerImpl rootActivity = null;
+
+ public ActivityManager()
+ {
+
+ }
+
+ public static ActivityManager getInstance()
+ {
+ ActivityManager currentActivityManager = (ActivityManager)WebBeansFinder.getSingletonInstance(ActivityManager.class.getName());
+
+ return currentActivityManager;
+ }
+
+ public void setRootActivity(ManagerImpl rootActivity)
+ {
+ this.rootActivity = rootActivity;
+ }
+
+ public ManagerImpl getRootActivity()
+ {
+ return this.rootActivity;
+ }
+
+}
Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/activity/ActivityManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomContextImpl.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomContextImpl.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/context/CustomContextImpl.java Sat Mar 7 13:54:11 2009
@@ -17,20 +17,18 @@
package org.apache.webbeans.context;
import java.lang.annotation.Annotation;
-import java.util.concurrent.ConcurrentHashMap;
import javax.context.Context;
import javax.context.Contextual;
import javax.context.CreationalContext;
-class CustomContextImpl extends AbstractContext
+class CustomContextImpl implements Context
{
private Context context;
CustomContextImpl(Context context)
{
this.context = context;
- setComponentInstanceMap();
}
public Class<? extends Annotation> getScopeType()
@@ -53,13 +51,4 @@
return this.context.isActive();
}
-
- @Override
- public void setComponentInstanceMap()
- {
- this.componentInstanceMap = new ConcurrentHashMap<Contextual<?>, Object>();
-
-
- }
-
}
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/deployment/StereoTypeModel.java Sat Mar 7 13:54:11 2009
@@ -52,28 +52,28 @@
{
this.name = clazz.getName();
- if (AnnotationUtil.isMetaAnnotationExist(clazz.getAnnotations(), DeploymentType.class))
+ if (AnnotationUtil.isMetaAnnotationExist(clazz.getDeclaredAnnotations(), DeploymentType.class))
{
- this.defaultDeploymentType = AnnotationUtil.getMetaAnnotations(clazz.getAnnotations(), DeploymentType.class)[0];
+ this.defaultDeploymentType = AnnotationUtil.getMetaAnnotations(clazz.getDeclaredAnnotations(), DeploymentType.class)[0];
}
- if (AnnotationUtil.isMetaAnnotationExist(clazz.getAnnotations(), ScopeType.class))
+ if (AnnotationUtil.isMetaAnnotationExist(clazz.getDeclaredAnnotations(), ScopeType.class))
{
- this.defaultScopeType = AnnotationUtil.getMetaAnnotations(clazz.getAnnotations(), ScopeType.class)[0];
+ this.defaultScopeType = AnnotationUtil.getMetaAnnotations(clazz.getDeclaredAnnotations(), ScopeType.class)[0];
}
- if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(clazz.getAnnotations()))
+ if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(clazz.getDeclaredAnnotations()))
{
- Annotation[] ibs = AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getAnnotations());
+ Annotation[] ibs = AnnotationUtil.getInterceptorBindingMetaAnnotations(clazz.getDeclaredAnnotations());
for (Annotation ann : ibs)
{
this.interceptorBindingTypes.add(ann);
}
}
- if (AnnotationUtil.isStereoTypeMetaAnnotationExist(clazz.getAnnotations()))
+ if (AnnotationUtil.isStereoTypeMetaAnnotationExist(clazz.getDeclaredAnnotations()))
{
- Annotation[] isy = AnnotationUtil.getStereotypeMetaAnnotations(clazz.getAnnotations());
+ Annotation[] isy = AnnotationUtil.getStereotypeMetaAnnotations(clazz.getDeclaredAnnotations());
Target outerStereo = clazz.getAnnotation(Target.class);
for (Annotation is : isy)
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java Sat Mar 7 13:54:11 2009
@@ -209,7 +209,7 @@
}
else
{
- Annotation[] stereoTypes = AnnotationUtil.getStereotypeMetaAnnotations(clazz.getAnnotations());
+ Annotation[] stereoTypes = AnnotationUtil.getStereotypeMetaAnnotations(clazz.getDeclaredAnnotations());
for (Annotation stero : stereoTypes)
{
if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(stero.annotationType().getDeclaredAnnotations()))
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/WebBeansInterceptorConfig.java Sat Mar 7 13:54:11 2009
@@ -28,6 +28,8 @@
import javax.interceptor.AroundInvoke;
import org.apache.webbeans.component.AbstractComponent;
+import org.apache.webbeans.component.Component;
+import org.apache.webbeans.config.inheritance.IBeanInheritedMetaData;
import org.apache.webbeans.container.ManagerImpl;
import org.apache.webbeans.intercept.webbeans.WebBeansInterceptor;
import org.apache.webbeans.logger.WebBeansLogger;
@@ -81,8 +83,10 @@
*
* @param clazz configuration interceptors for this
*/
- public static void configure(Class<?> clazz, List<InterceptorData> stack)
+ public static void configure(Component<?> component, List<InterceptorData> stack)
{
+ Class<?> clazz = component.getReturnType();
+
if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(clazz.getDeclaredAnnotations()))
{
@@ -108,6 +112,17 @@
}
}
}
+
+ //Look for inherited binding types
+ IBeanInheritedMetaData metadata = component.getInheritedMetaData();
+ if(metadata != null)
+ {
+ Set<Annotation> inheritedBindingTypes = metadata.getInheritedInterceptorBindingTypes();
+ if(!inheritedBindingTypes.isEmpty())
+ {
+ bindingTypeSet.addAll(inheritedBindingTypes);
+ }
+ }
anns = new Annotation[bindingTypeSet.size()];
anns = bindingTypeSet.toArray(anns);
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/webbeans/WebBeansInterceptor.java Sat Mar 7 13:54:11 2009
@@ -179,9 +179,9 @@
anns = declared.toArray(anns);
}
- else if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(clazzAnnot.getAnnotations()))
+ else if (AnnotationUtil.isInterceptorBindingMetaAnnotationExist(clazzAnnot.getDeclaredAnnotations()))
{
- anns = AnnotationUtil.getInterceptorBindingMetaAnnotations(clazzAnnot.getAnnotations());
+ anns = AnnotationUtil.getInterceptorBindingMetaAnnotations(clazzAnnot.getDeclaredAnnotations());
}
/*
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/lifecycle/WebBeansLifeCycle.java Sat Mar 7 13:54:11 2009
@@ -31,6 +31,7 @@
import org.apache.webbeans.config.WebBeansContainerDeployer;
import org.apache.webbeans.config.WebBeansFinder;
import org.apache.webbeans.container.ManagerImpl;
+import org.apache.webbeans.container.activity.ActivityManager;
import org.apache.webbeans.context.ContextFactory;
import org.apache.webbeans.el.WebBeansELResolver;
import org.apache.webbeans.exception.WebBeansException;
@@ -54,14 +55,19 @@
private WebBeansXMLConfigurator xmlDeployer = null;
private JNDIService jndiService = null;
+
+ private ManagerImpl rootManager = null;
public WebBeansLifeCycle()
{
+ this.rootManager = new ManagerImpl();
this.xmlDeployer = new WebBeansXMLConfigurator();
this.deployer = new WebBeansContainerDeployer(xmlDeployer);
this.jndiService = ServiceLoader.getService(JNDIService.class);
- ManagerImpl.getManager().setXMLConfigurator(this.xmlDeployer);
+ rootManager.setXMLConfigurator(this.xmlDeployer);
+
+ ActivityManager.getInstance().setRootActivity(this.rootManager);
}
public void requestStarted(ServletRequestEvent event)
@@ -166,6 +172,7 @@
this.discovery = null;
this.service = null;
this.xmlDeployer = null;
+ this.rootManager = null;
WebBeansFinder.clearInstances();
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java Sat Mar 7 13:54:11 2009
@@ -347,7 +347,7 @@
{
for (Annotation param : parameters)
{
- Annotation[] btype = param.annotationType().getAnnotations();
+ Annotation[] btype = param.annotationType().getDeclaredAnnotations();
for (Annotation b : btype)
{
@@ -950,14 +950,14 @@
setAnnots.add(definedAnn);
}
- Annotation[] genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getSuperclass().getAnnotations());
+ Annotation[] genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getSuperclass().getDeclaredAnnotations());
for(Annotation generic : genericReliazesAnns)
{
setAnnots.remove(generic);
}
- genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getAnnotations());
+ genericReliazesAnns = AnnotationUtil.getBindingAnnotations(clazz.getDeclaredAnnotations());
for(Annotation generic : genericReliazesAnns)
{
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Mar 7 13:54:11 2009
@@ -1030,9 +1030,9 @@
{
for (Annotation dt : deploymentTypes)
{
- if (AnnotationUtil.isMetaAnnotationExist(dt.annotationType().getAnnotations(), DeploymentType.class))
+ if (AnnotationUtil.isMetaAnnotationExist(dt.annotationType().getDeclaredAnnotations(), DeploymentType.class))
{
- Annotation result2[] = AnnotationUtil.getMetaAnnotations(dt.annotationType().getAnnotations(), DeploymentType.class);
+ Annotation result2[] = AnnotationUtil.getMetaAnnotations(dt.annotationType().getDeclaredAnnotations(), DeploymentType.class);
Class<? extends Annotation> dtAnnot = result2[0].annotationType();
if (maxPrecedDeploymentType == null)
@@ -1053,12 +1053,7 @@
}
}
- if (result == null)
- {
- return new ProductionLiteral();
-
- }
-
+
return result;
}
@@ -1091,7 +1086,7 @@
{
Asserts.nullCheckForClass(clazz);
- Annotation[] annotations = clazz.getAnnotations();
+ Annotation[] annotations = clazz.getDeclaredAnnotations();
boolean deploymentTypeFound = false;
boolean scopeTypeFound = false;
@@ -1470,7 +1465,7 @@
{
if (old.annotationType().equals(bindingType.annotationType()))
{
- throw new DuplicateBindingTypeException("Manager.resolveDecorators() method parameter binding types array argument can not define duplicate binding annotation with name : @" + old.getClass().getName());
+ throw new DuplicateBindingTypeException("Manager.resolveDecorators() method parameter binding types array argument can not define duplicate binding annotation with name : @" + old.annotationType().getName());
}
if (!AnnotationUtil.isBindingAnnotation(bindingType.annotationType()))
Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=751267&r1=751266&r2=751267&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java (original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java Sat Mar 7 13:54:11 2009
@@ -1447,7 +1447,7 @@
}
else
{
- DefinitionUtil.defineName(component, component.getReturnType().getAnnotations(), WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getSimpleName()));
+ DefinitionUtil.defineName(component, component.getReturnType().getDeclaredAnnotations(), WebBeansUtil.getSimpleWebBeanDefaultName(component.getReturnType().getSimpleName()));
}
}