[webbeans-commits] Webbeans SVN: r2307 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean.
by webbeans-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-04-05 18:49:01 -0400 (Sun, 05 Apr 2009)
New Revision: 2307
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
Log:
Disposal Methods oops...
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-05 22:01:20 UTC (rev 2306)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-05 22:49:01 UTC (rev 2307)
@@ -14,7 +14,6 @@
import javax.inject.Disposes;
import javax.inject.Initializer;
import javax.inject.Produces;
-import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
import org.jboss.webbeans.ManagerImpl;
@@ -22,7 +21,6 @@
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
-import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -38,8 +36,8 @@
initInjectionPoints();
initType();
initTypes();
- this.id = createId("DisposalMethod-" + declaringBean.getName() + "-"+ disposalMethod.getSignature().toString());
-
+ this.id = createId("DisposalMethod-" + declaringBean.getName() + "-" + disposalMethod.getSignature().toString());
+
}
protected AbstractClassBean<?> declaringBean;
@@ -53,10 +51,11 @@
this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getRawType();
}
- public AnnotatedMethod<T> getAnnotatedItem() {
- return disposalMethodInjectionPoint;
+ public AnnotatedMethod<T> getAnnotatedItem()
+ {
+ return disposalMethodInjectionPoint;
}
-
+
public static <T> DisposalMethodBean<T> of(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, AbstractClassBean<?> declaringBean)
{
return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
@@ -95,6 +94,20 @@
return declaringBean.getDeploymentType();
}
+ /**
+ * Initializes the API types
+ */
+ @Override
+ protected void initTypes()
+ {
+ Set<Type> types = new HashSet<Type>();
+ types = new HashSet<Type>();
+ types.addAll(disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getFlattenedTypeHierarchy());
+ types.add(getType());
+ types.add(Object.class);
+ super.types = types;
+ }
+
public Set<AnnotatedInjectionPoint<?, ?>> getInjectionPoints()
{
return injectionPoints;
@@ -143,7 +156,7 @@
public void invokeDisposeMethod(Object instance)
{
-
+
List<Object> parameters = new LinkedList<Object>();
parameters.add(instance);
@@ -158,11 +171,11 @@
try
{
- disposalMethodInjectionPoint.invoke(beanInstance, parameters.toArray());
+ disposalMethodInjectionPoint.invoke(beanInstance, parameters.toArray());
}
catch (Exception e)
{
- // TODO:
+ // TODO:
}
}
@@ -234,8 +247,8 @@
throw new IllegalStateException(toString() + " does not specialize a bean");
}
this.specializedBean = environment.getProducerMethod(superClassMethod);
- }
-
+ }
+
@Override
public Class<T> getType()
{
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2306 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: bootstrap and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: danielc.roth
Date: 2009-04-05 18:01:20 -0400 (Sun, 05 Apr 2009)
New Revision: 2306
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
Log:
Disposal Methods update
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-05 20:16:46 UTC (rev 2305)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-05 22:01:20 UTC (rev 2306)
@@ -29,10 +29,10 @@
public class DisposalMethodBean<T> extends AbstractBean<T, Method>
{
- protected DisposalMethodBean(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
+ protected DisposalMethodBean(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, AbstractClassBean<?> declaringBean)
{
super(manager);
- this.disposalMethod = disposalMethod;
+ this.disposalMethodInjectionPoint = MethodInjectionPoint.of(this, disposalMethod);
this.declaringBean = declaringBean;
checkDisposalMethod();
initInjectionPoints();
@@ -42,27 +42,22 @@
}
- protected Bean<?> declaringBean;
- protected AnnotatedMethod<T> disposalMethod;
+ protected AbstractClassBean<?> declaringBean;
+ private ProducerMethodBean<?> specializedBean;
+ protected MethodInjectionPoint<T> disposalMethodInjectionPoint;
protected Set<AnnotatedInjectionPoint<?, ?>> disposalInjectionPoints;
private String id;
- @Override
- protected void initTypes()
+ protected void initType()
{
- Set<Type> types = new HashSet<Type>();
- types = new HashSet<Type>();
- types.add(getType());
- types.add(Object.class); // FODO: Maybe not?
- super.types = types;
+ this.type = (Class<T>) disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).get(0).getRawType();
}
- protected void initType()
- {
- this.type = (Class<T>) disposalMethod.getAnnotatedParameters(Disposes.class).get(0).getRawType();
+ public AnnotatedMethod<T> getAnnotatedItem() {
+ return disposalMethodInjectionPoint;
}
-
- public static <T> DisposalMethodBean<T> of(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
+
+ public static <T> DisposalMethodBean<T> of(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, AbstractClassBean<?> declaringBean)
{
return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
}
@@ -71,7 +66,7 @@
{
disposalInjectionPoints = new HashSet<AnnotatedInjectionPoint<?, ?>>();
- List<? extends AnnotatedParameter<?>> disposalMethodParameters = disposalMethod.getParameters();
+ List<? extends AnnotatedParameter<?>> disposalMethodParameters = disposalMethodInjectionPoint.getParameters();
// First one must be @Disposes, if more, register injectionpoints
if (disposalMethodParameters.size() > 1)
@@ -83,7 +78,7 @@
}
}
- injectionPoints.add(MethodInjectionPoint.of(declaringBean, disposalMethod));
+ injectionPoints.add(MethodInjectionPoint.of(declaringBean, disposalMethodInjectionPoint));
}
@@ -91,7 +86,7 @@
public Set<Annotation> getBindings()
{
// At least 1 parameter exists, already checked in constructor
- return disposalMethod.getParameters().get(0).getBindings();
+ return disposalMethodInjectionPoint.getParameters().get(0).getBindings();
}
@Override
@@ -108,7 +103,7 @@
@Override
public String getName()
{
- return disposalMethod.getPropertyName();
+ return disposalMethodInjectionPoint.getPropertyName();
}
@Override
@@ -126,7 +121,7 @@
@Override
public String toString()
{
- return disposalMethod.toString();
+ return disposalMethodInjectionPoint.toString();
}
@Override
@@ -148,6 +143,7 @@
public void invokeDisposeMethod(Object instance)
{
+
List<Object> parameters = new LinkedList<Object>();
parameters.add(instance);
@@ -158,11 +154,11 @@
parameters.add(injectionObject);
}
- Object beanInstance = disposalMethod.isStatic() ? declaringBean : getManager().getInstance(declaringBean);
+ Object beanInstance = disposalMethodInjectionPoint.isStatic() ? declaringBean : getManager().getInstance(declaringBean);
try
{
- disposalMethod.invoke(beanInstance, parameters.toArray());
+ disposalMethodInjectionPoint.invoke(beanInstance, parameters.toArray());
}
catch (Exception e)
{
@@ -173,25 +169,25 @@
private void checkDisposalMethod()
{
- if (!disposalMethod.getParameters().get(0).isAnnotationPresent(Disposes.class))
+ if (!disposalMethodInjectionPoint.getParameters().get(0).isAnnotationPresent(Disposes.class))
{
- throw new DefinitionException(disposalMethod.toString() + " doesn't have @Dispose as first parameter");
+ throw new DefinitionException(disposalMethodInjectionPoint.toString() + " doesn't have @Dispose as first parameter");
}
- if (disposalMethod.getAnnotatedParameters(Disposes.class).size() > 1)
+ if (disposalMethodInjectionPoint.getAnnotatedParameters(Disposes.class).size() > 1)
{
- throw new DefinitionException(disposalMethod.toString() + " has more than one @Dispose parameters");
+ throw new DefinitionException(disposalMethodInjectionPoint.toString() + " has more than one @Dispose parameters");
}
- if (disposalMethod.getAnnotatedParameters(Observes.class).size() > 0)
+ if (disposalMethodInjectionPoint.getAnnotatedParameters(Observes.class).size() > 0)
{
- throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethod.toString());
+ throw new DefinitionException("@Observes is not allowed on disposal method, see " + disposalMethodInjectionPoint.toString());
}
- if (disposalMethod.getAnnotation(Initializer.class) != null)
+ if (disposalMethodInjectionPoint.getAnnotation(Initializer.class) != null)
{
- throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethod.toString());
+ throw new DefinitionException("@Intitializer is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
}
- if (disposalMethod.getAnnotation(Produces.class) != null)
+ if (disposalMethodInjectionPoint.getAnnotation(Produces.class) != null)
{
- throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethod.toString());
+ throw new DefinitionException("@Produces is not allowed on a disposal method, see " + disposalMethodInjectionPoint.toString());
}
if (declaringBean instanceof EnterpriseBean)
{
@@ -204,7 +200,7 @@
Class<?> clazz = (Class<?>) type;
try
{
- clazz.getDeclaredMethod(disposalMethod.getName(), disposalMethod.getParameterTypesAsArray());
+ clazz.getDeclaredMethod(disposalMethodInjectionPoint.getName(), disposalMethodInjectionPoint.getParameterTypesAsArray());
methodDeclaredOnTypes = true;
}
catch (NoSuchMethodException nsme)
@@ -221,6 +217,26 @@
}
@Override
+ protected void preSpecialize(BeanDeployerEnvironment environment)
+ {
+ if (declaringBean.getAnnotatedItem().getSuperclass().getDeclaredMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+ {
+ throw new DefinitionException("Specialized disposal method does not override a method on the direct superclass");
+ }
+ }
+
+ @Override
+ protected void specialize(BeanDeployerEnvironment environment)
+ {
+ AnnotatedMethod<?> superClassMethod = declaringBean.getAnnotatedItem().getSuperclass().getMethod(getAnnotatedItem().getAnnotatedMethod());
+ if (environment.getProducerMethod(superClassMethod) == null)
+ {
+ throw new IllegalStateException(toString() + " does not specialize a bean");
+ }
+ this.specializedBean = environment.getProducerMethod(superClassMethod);
+ }
+
+ @Override
public Class<T> getType()
{
return type;
@@ -251,12 +267,6 @@
}
@Override
- protected AnnotatedItem<T, Method> getAnnotatedItem()
- {
- return disposalMethod;
- }
-
- @Override
protected Class<? extends Annotation> getDefaultDeploymentType()
{
return declaringBean.getDeploymentType();
@@ -265,7 +275,7 @@
@Override
protected String getDefaultName()
{
- return disposalMethod.getPropertyName();
+ return disposalMethodInjectionPoint.getPropertyName();
}
@Override
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-05 20:16:46 UTC (rev 2305)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-05 22:01:20 UTC (rev 2306)
@@ -75,7 +75,7 @@
initType();
initTypes();
initBindings();
- this.id = createId("ProducerField-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
+ this.id = createId("ProducerMethod-" + declaringBean.getType().getName() + "-" + method.getSignature().toString());
}
protected T produceInstance(CreationalContext<T> creationalContext)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-05 20:16:46 UTC (rev 2305)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployerEnvironment.java 2009-04-05 22:01:20 UTC (rev 2306)
@@ -25,7 +25,8 @@
private static final AnnotatedItem<?, ?> OTHER_BEANS_ANNOTATED_ITEM = ResolvableAnnotatedClass.of(BeanDeployerEnvironment.class, new Annotation[0]);
private final Map<AnnotatedClass<?>, AbstractClassBean<?>> classBeanMap;
- private final Map<AnnotatedMethod<?>, ProducerMethodBean<?>> methodBeanMap;
+ private final Map<AnnotatedMethod<?>, ProducerMethodBean<?>> producerMethodBeanMap;
+ private final Map<AnnotatedMethod<?>, DisposalMethodBean<?>> disposalMethodBeanMap;
private final Set<RIBean<?>> beans;
private final Set<ObserverImpl<?>> observers;
private final Set<DisposalMethodBean<?>> allDisposalBeans;
@@ -35,7 +36,8 @@
public BeanDeployerEnvironment(EjbDescriptorCache ejbDescriptors)
{
this.classBeanMap = new HashMap<AnnotatedClass<?>, AbstractClassBean<?>>();
- this.methodBeanMap = new HashMap<AnnotatedMethod<?>, ProducerMethodBean<?>>();
+ this.producerMethodBeanMap = new HashMap<AnnotatedMethod<?>, ProducerMethodBean<?>>();
+ this.disposalMethodBeanMap = new HashMap<AnnotatedMethod<?>, DisposalMethodBean<?>>();
this.allDisposalBeans = new HashSet<DisposalMethodBean<?>>();
this.resolvedDisposalBeans = new HashSet<DisposalMethodBean<?>>();
this.beans = new HashSet<RIBean<?>>();
@@ -45,13 +47,13 @@
public ProducerMethodBean<?> getProducerMethod(AnnotatedMethod<?> method)
{
- if (!methodBeanMap.containsKey(method))
+ if (!producerMethodBeanMap.containsKey(method))
{
return null;
}
else
{
- ProducerMethodBean<?> bean = methodBeanMap.get(method);
+ ProducerMethodBean<?> bean = producerMethodBeanMap.get(method);
bean.initialize(this);
return bean;
}
@@ -81,8 +83,11 @@
}
else if (value instanceof ProducerMethodBean)
{
- ProducerMethodBean<?> bean = (ProducerMethodBean<?>) value;
- methodBeanMap.put(bean.getAnnotatedItem(), bean);
+ ProducerMethodBean<?> bean = (ProducerMethodBean<?>) value;
+ producerMethodBeanMap.put(bean.getAnnotatedItem(), bean);
+ } else if (value instanceof DisposalMethodBean) {
+ DisposalMethodBean<?> bean = (DisposalMethodBean<?>) value;
+ disposalMethodBeanMap.put(bean.getAnnotatedItem(), bean);
}
beans.add(value);
}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2305 - ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 16:16:46 -0400 (Sun, 05 Apr 2009)
New Revision: 2305
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
Log:
Do a deep copy on observers
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -188,7 +188,7 @@
beans.addAll(parentManager.getBeans());
ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers = new ConcurrentSetHashMultiMap<Type, EventObserver<?>>();
- registeredObservers.putAll(parentManager.getRegisteredObservers());
+ registeredObservers.deepPutAll(parentManager.getRegisteredObservers());
Namespace rootNamespace = new Namespace(parentManager.getRootNamespace());
return new ManagerImpl(
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.util.collections;
+import java.util.Collection;
import java.util.concurrent.CopyOnWriteArrayList;
/**
@@ -38,5 +39,22 @@
}
private static final long serialVersionUID = -7489797765014324457L;
+
+ public ConcurrentList()
+ {
+ super();
+ }
+
+ public ConcurrentList(Collection<? extends E> collection)
+ {
+ super(collection);
+ }
+
+ public ConcurrentList(E[] array)
+ {
+ super(array);
+ }
+
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.util.collections.multi;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -49,6 +50,14 @@
{
return delegate;
}
+
+ public void deepPutAll(Map<? extends K, ? extends ConcurrentList<V>> map)
+ {
+ for (Entry<? extends K, ? extends ConcurrentList<V>> entry : map.entrySet())
+ {
+ put(entry.getKey(), new ConcurrentList<V>(entry.getValue()));
+ }
+ }
/**
* Gets the list of values for a given key
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.util.collections.multi;
+import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import org.jboss.webbeans.util.collections.ConcurrentList;
@@ -37,4 +38,12 @@
*/
public void put(K key, V value);
+ /**
+ * Put all the data in the map into this map, copying each multi-value, not
+ * just attaching the existing multi-value
+ *
+ * @param map the map to copy
+ */
+ public void deepPutAll(Map<? extends K, ? extends ConcurrentList<V>> map);
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -16,6 +16,7 @@
* limitations under the License.
*/
import java.util.Collections;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
@@ -44,6 +45,14 @@
{
delegate = new ConcurrentHashMap<K, Set<V>>();
}
+
+ public void deepPutAll(Map<? extends K, ? extends Set<V>> map)
+ {
+ for (Entry<? extends K, ? extends Set<V>> entry : map.entrySet())
+ {
+ put(entry.getKey(), new CopyOnWriteArraySet<V>(entry.getValue()));
+ }
+ }
@Override
protected ConcurrentMap<K, Set<V>> delegate()
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -16,6 +16,7 @@
*/
package org.jboss.webbeans.util.collections.multi;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentMap;
@@ -37,5 +38,13 @@
* @param value the value to add
*/
public void put(K key, V value);
+
+ /**
+ * Put all the data in the map into this map, copying each multi-value, not
+ * just attaching the existing multi-value
+ *
+ * @param map the map to copy
+ */
+ public void deepPutAll(Map<? extends K, ? extends Set<V>> map);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -50,6 +50,14 @@
{
return delegate;
}
+
+ public void deepPutAll(Map<? extends K, ? extends List<V>> map)
+ {
+ for (Entry<? extends K, ? extends List<V>> entry : map.entrySet())
+ {
+ put(entry.getKey(), new ArrayList<V>(entry.getValue()));
+ }
+ }
/**
* Gets the list of values for a given key
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -35,4 +35,12 @@
*/
public void put(K key, V value);
+ /**
+ * Put all the data in the map into this map, copying each multi-value, not
+ * just attaching the existing multi-value
+ *
+ * @param map the map to copy
+ */
+ public void deepPutAll(Map<? extends K, ? extends List<V>> map);
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -50,6 +50,14 @@
{
return delegate;
}
+
+ public void deepPutAll(Map<? extends K, ? extends Set<V>> map)
+ {
+ for (Entry<? extends K, ? extends Set<V>> entry : map.entrySet())
+ {
+ put(entry.getKey(), new HashSet<V>(entry.getValue()));
+ }
+ }
/**
* Gets the list of values for a given key
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -37,4 +37,12 @@
*/
public void put(K key, V value);
+ /**
+ * Put all the data in the map into this map, copying each multi-value, not
+ * just attaching the existing multi-value
+ *
+ * @param map the map to copy
+ */
+ public void deepPutAll(Map<? extends K, ? extends Set<V>> map);
+
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-05 20:04:15 UTC (rev 2304)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-05 20:16:46 UTC (rev 2305)
@@ -284,7 +284,7 @@
getCurrentManager().getInstanceByType(Field.class).get();
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertion(section="11.6", id="s")
public void testObserverBelongingToChildDoesNotFireForParentActivity()
{
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2304 - ri/trunk/impl/src/main/java/org/jboss/webbeans.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 16:04:15 -0400 (Sun, 05 Apr 2009)
New Revision: 2304
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java
Log:
oops
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java 2009-04-05 20:03:03 UTC (rev 2303)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java 2009-04-05 20:04:15 UTC (rev 2304)
@@ -1,26 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jboss.webbeans;
-
-/**
- * @author Pete Muir
- *
- */
-public class Test
-{
-
-}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2303 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/bean/proxy and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 16:03:03 -0400 (Sun, 05 Apr 2009)
New Revision: 2303
Added:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Foo.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
ri/trunk/jboss-tck-runner/pom.xml
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
ri/trunk/tests/unit-tests.xml
Log:
up memory for running tests, fix serialization for child managers, use correct manager in client proxy
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -17,7 +17,10 @@
package org.jboss.webbeans;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* Access point for getting/setting current Managager
*
@@ -25,8 +28,11 @@
*/
public class CurrentManager
{
+
// The root manager instance
- protected static ManagerImpl managerImpl;
+ private static Integer rootManagerId;
+
+ private final static Map<Integer, ManagerImpl> managers = new ConcurrentHashMap<Integer, ManagerImpl>();
/**
* Gets the root manager
@@ -35,7 +41,7 @@
*/
public static ManagerImpl rootManager()
{
- return managerImpl;
+ return managers.get(rootManagerId);
}
/**
@@ -45,7 +51,26 @@
*/
public static void setRootManager(ManagerImpl managerImpl)
{
- CurrentManager.managerImpl = managerImpl;
+ if (managerImpl == null)
+ {
+ rootManagerId = null;
+ }
+ else
+ {
+ rootManagerId = add(managerImpl);
+ }
}
+ public static ManagerImpl get(Integer key)
+ {
+ return managers.get(key);
+ }
+
+ public static Integer add(ManagerImpl manager)
+ {
+ Integer id = manager.getId();
+ managers.put(id, manager);
+ return id;
+ }
+
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -34,9 +34,11 @@
import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.context.Context;
import javax.context.ContextNotActiveException;
@@ -82,9 +84,9 @@
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.collections.multi.ConcurrentSetHashMultiMap;
import org.jboss.webbeans.util.collections.multi.ConcurrentListHashMultiMap;
import org.jboss.webbeans.util.collections.multi.ConcurrentListMultiMap;
+import org.jboss.webbeans.util.collections.multi.ConcurrentSetHashMultiMap;
import org.jboss.webbeans.util.collections.multi.ConcurrentSetMultiMap;
/**
@@ -123,6 +125,7 @@
private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans;
private transient final Map<String, RIBean<?>> riBeans;
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
+ private final transient AtomicInteger ids;
/*
@@ -141,7 +144,9 @@
private transient final ThreadLocal<Stack<InjectionPoint>> currentInjectionPoint;
private transient List<Bean<?>> beans;
private final transient Namespace rootNamespace;
- private final ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers;
+ private final transient ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers;
+ private final transient Set<ManagerImpl> childActivities;
+ private final Integer id;
/**
@@ -166,8 +171,9 @@
new ClientProxyProvider(),
new ConcurrentListHashMultiMap<Class<? extends Annotation>, Context>(),
new HashMap<Bean<?>, Bean<?>>(),
-
- defaultEnabledDeploymentTypes);
+ defaultEnabledDeploymentTypes,
+ new AtomicInteger()
+ );
}
/**
@@ -195,7 +201,9 @@
parentManager.getClientProxyProvider(),
parentManager.getContexts(),
parentManager.getSpecializedBeans(),
- parentManager.getEnabledDeploymentTypes());
+ parentManager.getEnabledDeploymentTypes(),
+ parentManager.getIds()
+ );
}
/**
@@ -213,7 +221,8 @@
ClientProxyProvider clientProxyProvider,
ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts,
Map<Bean<?>, Bean<?>> specializedBeans,
- List<Class<? extends Annotation>> enabledDeploymentTypes
+ List<Class<? extends Annotation>> enabledDeploymentTypes,
+ AtomicInteger ids
)
{
this.services = serviceRegistry;
@@ -226,10 +235,13 @@
this.registeredObservers = registeredObservers;
setEnabledDeploymentTypes(enabledDeploymentTypes);
this.rootNamespace = rootNamespace;
+ this.ids = ids;
+ this.id = ids.incrementAndGet();
this.resolver = new Resolver(this);
this.eventManager = new EventManager(this);
this.nonContextualInjector = new NonContextualInjector(this);
+ this.childActivities = new CopyOnWriteArraySet<ManagerImpl>();
this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
{
@Override
@@ -280,6 +292,10 @@
resolver.clear();
beans.add(bean);
registerBeanNamespace(bean);
+ for (ManagerImpl childActivity : childActivities)
+ {
+ childActivity.addBean(bean);
+ }
return this;
}
@@ -557,43 +573,44 @@
throw new UnsupportedOperationException("Not yet implemented");
}
+ public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
+ {
+ return _addObserver(observer, eventType, bindings);
+ }
+
/**
- * Registers an observer for a given event type and binding types
+ * Shortcut to register an ObserverImpl
*
- * @param observer The observer to register
- * @param eventType The event type to match
- * @param bindings The bindings to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
- * java.lang.Class, java.lang.annotation.Annotation[])
+ * @param <T>
+ * @param observer
+ * @return
*/
- public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
+ public <T> Manager addObserver(ObserverImpl<T> observer)
{
- this.eventManager.addObserver(observer, eventType, bindings);
- return this;
+ return _addObserver(observer, observer.getEventType(), observer.getBindingsAsArray());
}
- public <T> Manager addObserver(ObserverImpl<T> observer)
+ public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
{
- this.eventManager.addObserver(observer, observer.getEventType(), observer.getBindingsAsArray());
- return this;
+ return _addObserver(observer, eventType.getType(), bindings);
}
-
+
/**
- * Registers an observer for a given event type literal and binding types
- *
- * @param observer The observer to register
- * @param eventType The event type literal to match
- * @param bindings The bindings to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
- * javax.inject.TypeLiteral, java.lang.annotation.Annotation[])
+ * Does the actual observer registration
+ *
+ * @param <T>
+ * @param observer
+ * @param eventType
+ * @param bindings
+ * @return
*/
- public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
+ protected <T> Manager _addObserver(Observer<T> observer, Type eventType, Annotation... bindings)
{
- eventManager.addObserver(observer, eventType.getType(), bindings);
+ this.eventManager.addObserver(observer, eventType, bindings);
+ for (ManagerImpl childActivity : childActivities)
+ {
+ childActivity._addObserver(observer, eventType, bindings);
+ }
return this;
}
@@ -704,7 +721,7 @@
{
if (creationalContext != null || (creationalContext == null && getContext(bean.getScopeType()).get(bean) != null))
{
- return (T) clientProxyProvider.getClientProxy(bean);
+ return (T) clientProxyProvider.getClientProxy(this, bean);
}
else
{
@@ -968,9 +985,12 @@
throw new UnsupportedOperationException();
}
- public Manager createActivity()
+ public ManagerImpl createActivity()
{
- return newChildManager(this);
+ ManagerImpl childActivity = newChildManager(this);
+ childActivities.add(childActivity);
+ CurrentManager.add(childActivity);
+ return childActivity;
}
public Manager setCurrent(Class<? extends Annotation> scopeType)
@@ -1015,7 +1035,7 @@
protected Object readResolve()
{
- return CurrentManager.rootManager();
+ return CurrentManager.get(id);
}
/**
@@ -1076,6 +1096,16 @@
return contexts;
}
+ protected AtomicInteger getIds()
+ {
+ return ids;
+ }
+
+ public Integer getId()
+ {
+ return id;
+ }
+
public ConcurrentSetMultiMap<Type, EventObserver<?>> getRegisteredObservers()
{
return registeredObservers;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyMethodHandler.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -25,7 +25,7 @@
import javax.context.Context;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -48,8 +48,10 @@
// The bean
private transient Bean<?> bean;
// The bean index in the manager
- private int beanIndex;
+ private final int beanIndex;
+ private final ManagerImpl manager;
+
private static final ThreadLocal<CreationalContextImpl<?>> currentCreationalContext = new ThreadLocal<CreationalContextImpl<?>>();
/**
@@ -58,10 +60,11 @@
* @param bean The bean to proxy
* @param beanIndex The index to the bean in the manager bean list
*/
- public ClientProxyMethodHandler(Bean<?> bean, int beanIndex)
+ public ClientProxyMethodHandler(Bean<?> bean, ManagerImpl manager, int beanIndex)
{
this.bean = bean;
this.beanIndex = beanIndex;
+ this.manager = manager;
log.trace("Created method handler for bean " + bean + " indexed as " + beanIndex);
}
@@ -88,7 +91,7 @@
{
if (bean == null)
{
- bean = CurrentManager.rootManager().getBeans().get(beanIndex);
+ bean = manager.getBeans().get(beanIndex);
}
Object proxiedInstance = getProxiedInstance(bean);
Object returnValue = Reflections.lookupMethod(proxiedMethod, proxiedInstance).invoke(proxiedInstance, args);
@@ -110,7 +113,7 @@
}
try
{
- Context context = CurrentManager.rootManager().getContext(bean.getScopeType());
+ Context context = manager.getContext(bean.getScopeType());
return context.get(bean, creationalContext);
}
finally
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/ClientProxyProvider.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -28,7 +28,7 @@
import javax.inject.DefinitionException;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.collections.ConcurrentCache;
@@ -71,12 +71,12 @@
* @throws InstantiationException When the proxy couldn't be created
* @throws IllegalAccessException When the proxy couldn't be created
*/
- private static <T> T createClientProxy(Bean<T> bean, int beanIndex) throws RuntimeException
+ private static <T> T createClientProxy(Bean<T> bean, ManagerImpl manager, int beanIndex) throws RuntimeException
{
try
{
- ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, beanIndex);
+ ClientProxyMethodHandler proxyMethodHandler = new ClientProxyMethodHandler(bean, manager, beanIndex);
Set<Type> classes = new LinkedHashSet<Type>(bean.getTypes());
classes.add(Serializable.class);
ProxyFactory proxyFactory = Proxies.getProxyFactory(classes);
@@ -110,19 +110,19 @@
* @return the client proxy for the bean
*/
// TODO: What is this create parameter? Something obsolete?
- public <T> T getClientProxy(final Bean<T> bean)
+ public <T> T getClientProxy(final ManagerImpl manager, final Bean<T> bean)
{
return pool.putIfAbsent(bean, new Callable<T>()
{
public T call() throws Exception
{
- int beanIndex = CurrentManager.rootManager().getBeans().indexOf(bean);
+ int beanIndex = manager.getBeans().indexOf(bean);
if (beanIndex < 0)
{
throw new DefinitionException(bean + " is not known to the manager");
}
- return createClientProxy(bean, beanIndex);
+ return createClientProxy(bean, manager, beanIndex);
}
});
Modified: ri/trunk/jboss-tck-runner/pom.xml
===================================================================
--- ri/trunk/jboss-tck-runner/pom.xml 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/jboss-tck-runner/pom.xml 2009-04-05 20:03:03 UTC (rev 2303)
@@ -92,6 +92,8 @@
<suiteXmlFiles>
<suiteXmlFile>${project.build.directory}/dependency/jsr299-tck-impl-suite.xml</suiteXmlFile>
</suiteXmlFiles>
+ <argLine>-Xmx128m</argLine>
+ <forkMode>once</forkMode>
</configuration>
</plugin>
<plugin>
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -1,6 +1,10 @@
package org.jboss.webbeans.test.unit;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.Arrays;
@@ -114,4 +118,18 @@
}
}
+ protected byte[] serialize(Object instance) throws IOException
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(bytes);
+ out.writeObject(instance);
+ return bytes.toByteArray();
+ }
+
+ protected Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException
+ {
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
+ return in.readObject();
+ }
+
}
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Foo.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Foo.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Foo.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.unit.manager;
+
+public class Foo
+{
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/Foo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java 2009-04-05 20:03:03 UTC (rev 2303)
@@ -0,0 +1,140 @@
+package org.jboss.webbeans.test.unit.manager;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.CreationalContext;
+import javax.context.Dependent;
+import javax.inject.Production;
+import javax.inject.manager.Bean;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.Manager;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.literal.CurrentLiteral;
+import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+@Artifact
+@Packaging
+public class ManagerTest extends AbstractWebBeansTest
+{
+
+ private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>();
+
+ static
+ {
+ DEFAULT_BINDINGS.add(new CurrentLiteral());
+ }
+
+ private static interface Dummy {}
+
+ private static class DummyBean extends Bean<Dummy>
+ {
+
+ private static final Set<Type> TYPES = new HashSet<Type>();
+
+ static
+ {
+ TYPES.add(Dummy.class);
+ TYPES.add(Object.class);
+ }
+
+ protected DummyBean(Manager manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return DEFAULT_BINDINGS;
+ }
+
+ @Override
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return Production.class;
+ }
+
+ @Override
+ public Set<? extends InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @Override
+ public Set<? extends Type> getTypes()
+ {
+ return TYPES;
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isSerializable()
+ {
+ return false;
+ }
+
+ public Dummy create(CreationalContext<Dummy> creationalContext)
+ {
+ return null;
+ }
+
+ public void destroy(Dummy instance)
+ {
+
+ }
+
+ }
+
+ @Test
+ public void testRootManagerSerializability() throws Exception
+ {
+ Integer rootManagerId = manager.getId();
+ ManagerImpl deserializedRootManager = (ManagerImpl) deserialize(serialize(manager));
+ assert deserializedRootManager.getId().equals(rootManagerId);
+ assert manager.resolveByType(Foo.class).size() == 1;
+ assert deserializedRootManager.resolveByType(Foo.class).size() == 1;
+ assert manager.resolveByType(Foo.class).iterator().next().equals(deserializedRootManager.resolveByType(Foo.class).iterator().next());
+ }
+
+ @Test
+ public void testChildManagerSerializability() throws Exception
+ {
+ ManagerImpl childManager = manager.createActivity();
+ Bean<?> dummyBean = new DummyBean(childManager);
+ childManager.addBean(dummyBean);
+ Integer childManagerId = childManager.getId();
+ ManagerImpl deserializedChildManager = (ManagerImpl) deserialize(serialize(childManager));
+ assert deserializedChildManager.getId().equals(childManagerId);
+ assert childManager.resolveByType(Dummy.class).size() == 1;
+ assert deserializedChildManager.resolveByType(Dummy.class).size() == 1;
+ assert childManager.resolveByType(Dummy.class).iterator().next().equals(deserializedChildManager.resolveByType(Dummy.class).iterator().next());
+ }
+
+
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/manager/ManagerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml 2009-04-05 13:14:58 UTC (rev 2302)
+++ ri/trunk/tests/unit-tests.xml 2009-04-05 20:03:03 UTC (rev 2303)
@@ -64,6 +64,7 @@
<package name="org.jboss.webbeans.test.unit.implementation.proxy" />
<package name="org.jboss.webbeans.test.unit.implementation.proxy.enterprise" />
<package name="org.jboss.webbeans.test.unit.lookup" />
+ <package name="org.jboss.webbeans.test.unit.manager" />
<package name="org.jboss.webbeans.test.unit.lookup.circular" />
<package name="org.jboss.webbeans.test.unit.xml.deploy" />
<package name="org.jboss.webbeans.test.unit.xml.parser" />
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2302 - in ri/trunk/impl/src/main/java/org/jboss/webbeans: introspector and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 09:14:58 -0400 (Sun, 05 Apr 2009)
New Revision: 2302
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
Log:
A bit more clean up
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-05 13:03:52 UTC (rev 2301)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-05 13:14:58 UTC (rev 2302)
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.annotation.Named;
@@ -42,7 +43,6 @@
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
import org.jboss.webbeans.literal.CurrentLiteral;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -79,7 +79,7 @@
* @param possibleDeploymentTypes The possible deployment types
* @return The deployment type
*/
- public static Class<? extends Annotation> getDeploymentType(List<Class<? extends Annotation>> enabledDeploymentTypes, AnnotationMap possibleDeploymentTypes)
+ public static Class<? extends Annotation> getDeploymentType(List<Class<? extends Annotation>> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
{
for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
{
@@ -199,7 +199,7 @@
protected void initDeploymentTypeFromStereotype()
{
- AnnotationMap possibleDeploymentTypes = getMergedStereotypes().getPossibleDeploymentTypes();
+ Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes = getMergedStereotypes().getPossibleDeploymentTypes();
if (possibleDeploymentTypes.size() > 0)
{
this.deploymentType = getDeploymentType(manager.getEnabledDeploymentTypes(), possibleDeploymentTypes);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-04-05 13:03:52 UTC (rev 2301)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/AnnotationStore.java 2009-04-05 13:14:58 UTC (rev 2302)
@@ -14,8 +14,8 @@
import javax.inject.BindingType;
import org.jboss.webbeans.literal.CurrentLiteral;
-import org.jboss.webbeans.util.Strings;
-import org.jboss.webbeans.util.collections.ForwardingMap;
+import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.SetMultiMap;
public class AnnotationStore
{
@@ -26,112 +26,16 @@
private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
- /**
- * Represents a mapping from a annotation type to an annotation
- * implementation
- */
- public static class AnnotationMap extends ForwardingMap<Class<? extends Annotation>, Annotation>
- {
- private final Map<Class<? extends Annotation>, Annotation> delegate;
- public AnnotationMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Annotation>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Annotation> delegate()
- {
- return delegate;
- }
-
- /**
- * Gets a string representation of the map
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotationMap (annotation type -> annotation): ", delegate);
- }
-
- }
-
/**
- * Represents a mapping from a annotation (meta-annotation) to a set of
- * annotations
- *
- */
- private static class MetaAnnotationMap extends ForwardingMap<Class<? extends Annotation>, Set<Annotation>>
- {
- private final Map<Class<? extends Annotation>, Set<Annotation>> delegate;
-
- public MetaAnnotationMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<Annotation>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<Annotation>> delegate()
- {
- return delegate;
- }
-
- /**
- * Gets the set of annotations matching the given annotation type
- *
- * @param key The meta-annotation to match
- * @returns The set of matching annotations containing this
- * meta-annotation
- */
- @Override
- public Set<Annotation> get(Object key)
- {
- Set<Annotation> annotations = super.get(key);
- return annotations != null ? annotations : new HashSet<Annotation>();
- }
-
- /**
- * Adds an annotation under the meta-annotation type key
- *
- * @param key The meta-annotation type
- * @param value The annotation
- */
- public void put(Class<? extends Annotation> key, Annotation value)
- {
- Set<Annotation> annotations = super.get(key);
- if (annotations == null)
- {
- annotations = new HashSet<Annotation>();
- super.put(key, annotations);
- }
- annotations.add(value);
- }
-
- /**
- * Gets a string representation of the map
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return Strings.mapToString("MetaAnnotationMap (annotation type -> annotation set: ", delegate);
- }
-
- }
-
- /**
* Builds the annotation map (annotation type -> annotation)
*
* @param annotations The array of annotations to map
* @return The annotation map
*/
- protected static AnnotationMap buildAnnotationMap(Annotation[] annotations)
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Annotation[] annotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : annotations)
{
annotationMap.put(annotation.annotationType(), annotation);
@@ -145,9 +49,9 @@
* @param annotations The array of annotations to map
* @return The annotation map
*/
- protected static AnnotationMap buildAnnotationMap(Iterable<Annotation> annotations)
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Iterable<Annotation> annotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : annotations)
{
annotationMap.put(annotation.annotationType(), annotation);
@@ -173,11 +77,11 @@
public static AnnotationStore wrap(AnnotationStore annotationStore, Set<Annotation> annotations, Set<Annotation> declaredAnnotations)
{
- AnnotationMap annotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
annotationMap.putAll(buildAnnotationMap(annotations));
annotationMap.putAll(annotationStore.getAnnotationMap());
- AnnotationMap declaredAnnotationMap = new AnnotationMap();
+ Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
declaredAnnotationMap.putAll(buildAnnotationMap(declaredAnnotations));
declaredAnnotationMap.putAll(annotationStore.getDeclaredAnnotationMap());
@@ -185,18 +89,18 @@
}
// The annotation map (annotation type -> annotation) of the item
- private final AnnotationMap annotationMap;
+ private final Map<Class<? extends Annotation>, Annotation> annotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final MetaAnnotationMap metaAnnotationMap;
+ private final SetMultiMap<Class<? extends Annotation>, Annotation> metaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> annotationSet;
// The annotation map (annotation type -> annotation) of the item
- private final AnnotationMap declaredAnnotationMap;
+ private final Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap;
// The meta-annotation map (annotation type -> set of annotations containing
// meta-annotation) of the item
- private final MetaAnnotationMap declaredMetaAnnotationMap;
+ private final SetMultiMap<Class<? extends Annotation>, Annotation> declaredMetaAnnotationMap;
// The set of all annotations on the item
private final Set<Annotation> declaredAnnotationSet;
@@ -209,7 +113,7 @@
* @param annotationMap A map of annotation to register
*
*/
- protected AnnotationStore(AnnotationMap annotationMap, AnnotationMap declaredAnnotationMap)
+ protected AnnotationStore(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap)
{
if (annotationMap == null)
{
@@ -217,7 +121,7 @@
}
this.annotationMap = annotationMap;
this.annotationSet = new HashSet<Annotation>();
- this.metaAnnotationMap = new MetaAnnotationMap();
+ this.metaAnnotationMap = new SetHashMultiMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : annotationMap.values())
{
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
@@ -237,7 +141,7 @@
}
this.declaredAnnotationMap = declaredAnnotationMap;
this.declaredAnnotationSet = new HashSet<Annotation>();
- this.declaredMetaAnnotationMap = new MetaAnnotationMap();
+ this.declaredMetaAnnotationMap = new SetHashMultiMap<Class<? extends Annotation>, Annotation>();
for (Annotation annotation : declaredAnnotationMap.values())
{
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
@@ -306,12 +210,12 @@
return declaredAnnotationMap.containsKey(annotationType);
}
- AnnotationMap getAnnotationMap()
+ Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
{
return annotationMap;
}
- AnnotationMap getDeclaredAnnotationMap()
+ Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap()
{
return declaredAnnotationMap;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-05 13:03:52 UTC (rev 2301)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-05 13:14:58 UTC (rev 2302)
@@ -18,11 +18,12 @@
package org.jboss.webbeans.metadata;
import java.lang.annotation.Annotation;
+import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
/**
* Meta model for the merged stereotype for a bean
@@ -32,7 +33,7 @@
public class MergedStereotypes<T, E>
{
// The possible deployment types
- private final AnnotationMap possibleDeploymentTypes;
+ private final Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
// The possible scope types
private final Set<Annotation> possibleScopeTypes;
// Is the bean name defaulted?
@@ -51,7 +52,7 @@
*/
public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
{
- this.possibleDeploymentTypes = new AnnotationMap();
+ this.possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
this.possibleScopeTypes = new HashSet<Annotation>();
this.requiredTypes = new HashSet<Class<?>>();
this.supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -96,7 +97,7 @@
*
* @return The deployment types
*/
- public AnnotationMap getPossibleDeploymentTypes()
+ public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
{
return possibleDeploymentTypes;
}
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2301 - ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 09:03:52 -0400 (Sun, 05 Apr 2009)
New Revision: 2301
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
Log:
Stronger Set semantics
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java 2009-04-05 13:03:52 UTC (rev 2301)
@@ -15,37 +15,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+import java.util.Collections;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArraySet;
-import org.jboss.webbeans.util.collections.ConcurrentCollection;
-import org.jboss.webbeans.util.collections.ConcurrentList;
import org.jboss.webbeans.util.collections.ForwardingConcurrentMap;
/**
* An concurrent multimap which is internally backed by a a ConcurrentHashMap
- * and a CopyOnWriteArrayList
+ * and a CopyOnWriteArraySet
*
* @author Pete Muir
*/
-public class ConcurrentSetHashMultiMap<K, V> extends ForwardingConcurrentMap<K, ConcurrentCollection<V>> implements ConcurrentSetMultiMap<K, V>
+public class ConcurrentSetHashMultiMap<K, V> extends ForwardingConcurrentMap<K, Set<V>> implements ConcurrentSetMultiMap<K, V>
{
- private final ConcurrentCollection<V> EMPTY_COLLECTION = ConcurrentList.emptyList();
+ private final Set<V> EMPTY_COLLECTION = Collections.emptySet();
// The map delegate
- private ConcurrentMap<K, ConcurrentCollection<V>> delegate;
+ private ConcurrentMap<K, Set<V>> delegate;
/**
* Constructor.
*/
public ConcurrentSetHashMultiMap()
{
- delegate = new ConcurrentHashMap<K, ConcurrentCollection<V>>();
+ delegate = new ConcurrentHashMap<K, Set<V>>();
}
@Override
- protected ConcurrentMap<K, ConcurrentCollection<V>> delegate()
+ protected ConcurrentMap<K, Set<V>> delegate()
{
return delegate;
}
@@ -59,16 +60,16 @@
* matches.
*/
@Override
- public ConcurrentCollection<V> get(Object key)
+ public Set<V> get(Object key)
{
- ConcurrentCollection<V> values = super.get(key);
+ Set<V> values = super.get(key);
return values != null ? values : EMPTY_COLLECTION;
}
public void put(K key, V value)
{
- delegate().putIfAbsent(key, new ConcurrentList<V>());
- get(key).addIfAbsent(value);
+ delegate().putIfAbsent(key, new CopyOnWriteArraySet<V>());
+ get(key).add(value);
}
}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java 2009-04-05 13:03:52 UTC (rev 2301)
@@ -16,18 +16,17 @@
*/
package org.jboss.webbeans.util.collections.multi;
+import java.util.Set;
import java.util.concurrent.ConcurrentMap;
-import org.jboss.webbeans.util.collections.ConcurrentCollection;
-
/**
- * A concurrent multimap, in which the multi-values are stored with Set
- * semantics for {@link #put(Object, Object)} operations
+ * A concurrent multimap, in which the multi-values are stored in a concurrent
+ * Set
*
* @author Pete Muir
*
*/
-public interface ConcurrentSetMultiMap<K, V> extends ConcurrentMap<K, ConcurrentCollection<V>>
+public interface ConcurrentSetMultiMap<K, V> extends ConcurrentMap<K, Set<V>>
{
/**
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java 2009-04-05 13:03:52 UTC (rev 2301)
@@ -20,8 +20,7 @@
import java.util.Set;
/**
- * A concurrent multimap, in which the multi-values are stored with Set
- * semantics for {@link #put(Object, Object)} operations
+ * A concurrent multimap, in which the multi-values are stored in a Set
*
* @author Pete Muir
*
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2300 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard and 7 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-05 08:54:49 -0400 (Sun, 05 Apr 2009)
New Revision: 2300
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextMap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
Log:
Big tidy up to concurrent multi-value data structures
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -65,11 +65,10 @@
import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
import org.jboss.webbeans.context.ApplicationContext;
-import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.el.Namespace;
-import org.jboss.webbeans.el.NamespaceManager;
import org.jboss.webbeans.event.EventManager;
+import org.jboss.webbeans.event.EventObserver;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.NonContextualInjector;
import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
@@ -83,6 +82,10 @@
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Proxies;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.collections.multi.ConcurrentSetHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.ConcurrentListHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.ConcurrentListMultiMap;
+import org.jboss.webbeans.util.collections.multi.ConcurrentSetMultiMap;
/**
* Implementation of the Web Beans Manager.
@@ -95,54 +98,52 @@
*/
public class ManagerImpl implements WebBeansManager, Serializable
{
-
-
-
private static final Log log = Logging.getLog(ManagerImpl.class);
private static final long serialVersionUID = 3021562879133838561L;
// The JNDI key to place the manager under
public static final String JNDI_KEY = "java:app/Manager";
-
- // The enabled deployment types from web-beans.xml
- private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
- // The Web Beans event manager
- private transient final EventManager eventManager;
-
- // An executor service for asynchronous tasks
+ /*
+ * Application scoped services
+ * ****************************
+ */
private transient final ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
-
- // An injection point metadata beans factory
- private transient final ThreadLocal<Stack<InjectionPoint>> currentInjectionPoint;
-
- // The bean resolver
- private transient final Resolver resolver;
-
- // The registered contexts
- private transient final ContextMap contexts;
+ private transient final ServiceRegistry services;
- // The client proxy pool
+ /*
+ * Application scoped data structures
+ * ***********************************
+ */
+ private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
+ private transient final ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts;
private transient final ClientProxyProvider clientProxyProvider;
-
- // The registered beans
- private transient List<Bean<?>> beans;
-
- // The registered beans, mapped by implementation class
private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans;
-
private transient final Map<String, RIBean<?>> riBeans;
+ private final transient Map<Bean<?>, Bean<?>> specializedBeans;
- private transient final ServiceRegistry services;
-
- private final transient Map<Bean<?>, Bean<?>> specializedBeans;
-
+
+ /*
+ * Activity scoped services
+ * *************************
+ */
+ private transient final EventManager eventManager;
+ private transient final Resolver resolver;
private final transient NonContextualInjector nonContextualInjector;
- private final transient NamespaceManager namespaceManager;
+ /*
+ * Activity scoped data structures
+ * ********************************
+ */
+ private transient final ThreadLocal<Stack<InjectionPoint>> currentInjectionPoint;
+ private transient List<Bean<?>> beans;
+ private final transient Namespace rootNamespace;
+ private final ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers;
+
+
/**
* Create a new, root, manager
*
@@ -158,12 +159,14 @@
return new ManagerImpl(
serviceRegistry,
new CopyOnWriteArrayList<Bean<?>>(),
+ new ConcurrentSetHashMultiMap<Type, EventObserver<?>>(),
+ new Namespace(),
new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>(),
new ConcurrentHashMap<String, RIBean<?>>(),
new ClientProxyProvider(),
- new ContextMap(),
+ new ConcurrentListHashMultiMap<Class<? extends Annotation>, Context>(),
new HashMap<Bean<?>, Bean<?>>(),
- new NamespaceManager(new Namespace()),
+
defaultEnabledDeploymentTypes);
}
@@ -178,17 +181,20 @@
List<Bean<?>> beans = new CopyOnWriteArrayList<Bean<?>>();
beans.addAll(parentManager.getBeans());
- NamespaceManager namespaceManager = new NamespaceManager(new Namespace(parentManager.getNamespaceManager().getRoot()));
+ ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers = new ConcurrentSetHashMultiMap<Type, EventObserver<?>>();
+ registeredObservers.putAll(parentManager.getRegisteredObservers());
+ Namespace rootNamespace = new Namespace(parentManager.getRootNamespace());
return new ManagerImpl(
parentManager.getServices(),
- beans,
+ beans,
+ registeredObservers,
+ rootNamespace,
parentManager.getNewEnterpriseBeanMap(),
- parentManager.getRiBeans(),
+ parentManager.getRiBeans(),
parentManager.getClientProxyProvider(),
parentManager.getContexts(),
parentManager.getSpecializedBeans(),
- namespaceManager,
parentManager.getEnabledDeploymentTypes());
}
@@ -199,13 +205,14 @@
*/
private ManagerImpl(
ServiceRegistry serviceRegistry,
- List<Bean<?>> beans,
+ List<Bean<?>> beans,
+ ConcurrentSetMultiMap<Type, EventObserver<?>> registeredObservers,
+ Namespace rootNamespace,
Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans,
Map<String, RIBean<?>> riBeans,
ClientProxyProvider clientProxyProvider,
- ContextMap contexts,
+ ConcurrentListMultiMap<Class<? extends Annotation>, Context> contexts,
Map<Bean<?>, Bean<?>> specializedBeans,
- NamespaceManager namespaceManager,
List<Class<? extends Annotation>> enabledDeploymentTypes
)
{
@@ -213,13 +220,12 @@
this.beans = beans;
this.newEnterpriseBeans = newEnterpriseBeans;
this.riBeans = riBeans;
-
this.clientProxyProvider = clientProxyProvider;
this.contexts = contexts;
this.specializedBeans = specializedBeans;
-
- this.namespaceManager = namespaceManager;
+ this.registeredObservers = registeredObservers;
setEnabledDeploymentTypes(enabledDeploymentTypes);
+ this.rootNamespace = rootNamespace;
this.resolver = new Resolver(this);
this.eventManager = new EventManager(this);
@@ -273,7 +279,7 @@
}
resolver.clear();
beans.add(bean);
- namespaceManager.register(bean);
+ registerBeanNamespace(bean);
return this;
}
@@ -466,11 +472,25 @@
newEnterpriseBeans.put(bean.getType(), (EnterpriseBean<?>) bean);
}
riBeans.put(bean.getId(), bean);
- namespaceManager.register(bean);
+ registerBeanNamespace(bean);
}
resolver.clear();
}
}
+
+ protected void registerBeanNamespace(Bean<?> bean)
+ {
+ if (bean.getName() != null && bean.getName().indexOf('.') > 0)
+ {
+ String name = bean.getName().substring(0, bean.getName().lastIndexOf('.'));
+ String[] hierarchy = name.split("\\.");
+ Namespace namespace = getRootNamespace();
+ for (String s : hierarchy)
+ {
+ namespace = namespace.putIfAbsent(s);
+ }
+ }
+ }
/**
* Gets the class-mapped beans. For internal use.
@@ -507,7 +527,7 @@
*/
public Manager addContext(Context context)
{
- contexts.add(context);
+ contexts.put(context.getScopeType(), context);
return this;
}
@@ -622,7 +642,7 @@
public Context getContext(Class<? extends Annotation> scopeType)
{
List<Context> activeContexts = new ArrayList<Context>();
- for (Context context : contexts.getContext(scopeType))
+ for (Context context : contexts.get(scopeType))
{
if (context.isActive())
{
@@ -641,17 +661,6 @@
}
/**
- * Direct access to built in contexts. For internal use.
- *
- * @param scopeType The scope type of the context
- * @return The context
- */
- public Context getBuiltInContext(Class<? extends Annotation> scopeType)
- {
- return contexts.getBuiltInContext(scopeType);
- }
-
- /**
* Returns an instance of a bean
*
* @param bean The bean to instantiate
@@ -936,11 +945,6 @@
{
return resolver;
}
-
- public NamespaceManager getNamespaceManager()
- {
- return namespaceManager;
- }
/**
* Gets a string representation
@@ -1067,9 +1071,19 @@
return clientProxyProvider;
}
- protected ContextMap getContexts()
+ protected ConcurrentListMultiMap<Class<? extends Annotation>, Context> getContexts()
{
return contexts;
}
+
+ public ConcurrentSetMultiMap<Type, EventObserver<?>> getRegisteredObservers()
+ {
+ return registeredObservers;
+ }
+
+ public Namespace getRootNamespace()
+ {
+ return rootNamespace;
+ }
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans;
+
+/**
+ * @author Pete Muir
+ *
+ */
+public class Test
+{
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/Test.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -12,6 +12,12 @@
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
+/**
+ * AnnotatedItem transformer which can be used for FacadeBeans
+ *
+ * @author Pete Muir
+ *
+ */
public class FacadeBeanAnnotatedItemTransformer implements AnnotatedItemTransformer
{
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextMap.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/context/ContextMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -1,113 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans.context;
-
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import javax.context.Context;
-
-import org.jboss.webbeans.util.collections.ForwardingMap;
-
-/**
- * A map from a scope to a list of contexts
- *
- * @author Nicklas Karlsson
- * @author Pete Muir
- *
- */
-public class ContextMap extends ForwardingMap<Class<? extends Annotation>, List<Context>>
-{
- private Map<Class<? extends Annotation>, List<Context>> delegate;
-
- public ContextMap() {
- delegate = new ConcurrentHashMap<Class<? extends Annotation>, List<Context>>();
- }
-
- /**
- * Gets the dependent context
- *
- * @param scopeType The scope type to get
- * @return The dependent context
- */
- public AbstractContext getBuiltInContext(Class<? extends Annotation> scopeType)
- {
- if (getContext(scopeType) != null)
- {
- return (AbstractContext) getContext(scopeType).get(0);
- }
- else
- {
- return null;
- }
- }
-
- /**
- * Gets the list of context with the given scope type
- *
- * @param scopeType The scope type to match
- * @return A list of matching contexts. An empty list is returned if there
- * are no matches
- */
- public List<Context> getContext(Class<? extends Annotation> scopeType)
- {
- List<Context> contexts = get(scopeType);
- if (contexts == null)
- {
- return Collections.emptyList();
- }
- else
- {
- return contexts;
- }
- }
-
- /**
- * Adds a context under a scope type
- *
- * Creates the list of contexts if it doesn't exist
- *
- * @param context The new context
- */
- public void add(Context context)
- {
- List<Context> contexts = get(context.getScopeType());
- if (contexts == null) {
- contexts = new CopyOnWriteArrayList<Context>();
- put(context.getScopeType(), contexts);
- }
- contexts.add(context);
- }
-
- @Override
- protected Map<Class<? extends Annotation>, List<Context>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return "ContextMap holding " + delegate().size() + " contexts: " + delegate().keySet();
- }
-
-}
\ No newline at end of file
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -1,34 +0,0 @@
-package org.jboss.webbeans.el;
-
-import javax.inject.manager.Bean;
-
-public class NamespaceManager
-{
-
- private final Namespace root;
-
- public NamespaceManager(Namespace root)
- {
- this.root = root;
- }
-
- public void register(Bean<?> bean)
- {
- if (bean.getName() != null && bean.getName().indexOf('.') > 0)
- {
- String name = bean.getName().substring(0, bean.getName().lastIndexOf('.'));
- String[] hierarchy = name.split("\\.");
- Namespace namespace = root;
- for (String s : hierarchy)
- {
- namespace = namespace.putIfAbsent(s);
- }
- }
- }
-
- public Namespace getRoot()
- {
- return root;
- }
-
-}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -90,10 +90,10 @@
Namespace namespace = null;
if (base == null)
{
- if (CurrentManager.rootManager().getNamespaceManager().getRoot().contains(propertyString))
+ if (CurrentManager.rootManager().getRootNamespace().contains(propertyString))
{
context.setPropertyResolved(true);
- return CurrentManager.rootManager().getNamespaceManager().getRoot().get(propertyString);
+ return CurrentManager.rootManager().getRootNamespace().get(propertyString);
}
}
else if (base instanceof Namespace)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -19,12 +19,9 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
+import java.util.Collection;
import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
import javax.event.Observer;
@@ -32,9 +29,7 @@
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.util.Strings;
import org.jboss.webbeans.util.Reflections.HierarchyDiscovery;
-import org.jboss.webbeans.util.collections.ForwardingMap;
/**
* The event bus is where observers are registered and events are fired.
@@ -46,86 +41,6 @@
{
private static Log log = Logging.getLog(EventManager.class);
- /**
- * An event type -> observer list map
- */
- private class RegisteredObserversMap extends ForwardingMap<Type, List<EventObserver<?>>>
- {
-
- // The map delegate
- private ConcurrentHashMap<Type, List<EventObserver<?>>> delegate;
-
- /**
- * Constructor. Initializes the delegate
- */
- public RegisteredObserversMap()
- {
- delegate = new ConcurrentHashMap<Type, List<EventObserver<?>>>();
- }
-
- /**
- * Returns the delegate for the ForwardingMap
- *
- * @return The delegate
- */
- @Override
- protected Map<Type, List<EventObserver<?>>> delegate()
- {
- return delegate;
- }
-
- /**
- * Gets the list of observers for a given event type
- *
- * @param eventType The event type
- * @return The list of interested observers. An empty list is returned if
- * there are no matches.
- */
- @Override
- public CopyOnWriteArrayList<EventObserver<?>> get(Object eventType)
- {
- CopyOnWriteArrayList<EventObserver<?>> observers = (CopyOnWriteArrayList<EventObserver<?>>) super.get(eventType);
- return observers != null ? observers : new CopyOnWriteArrayList<EventObserver<?>>();
- }
-
- /**
- * Adds an observer for a given event type
- *
- * Implicitly creates a new list if there is none for the event type. Only adds the observer if
- * it is not already present
- *
- * @param eventType The event type
- * @param observer The observer to add
- */
- public void put(Type eventType, EventObserver<?> observer)
- {
- List<EventObserver<?>> observers = super.get(eventType);
- if (observers == null)
- {
- observers = new CopyOnWriteArrayList<EventObserver<?>>();
- super.put(eventType, observers);
- }
- if (!observers.contains(observer))
- {
- observers.add(observer);
- }
- }
-
- /**
- * Gets a string representation of the map
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return Strings.mapToString("RegisteredObserversMap (event type -> observers list): ", delegate);
- }
-
- }
-
- // The map of registered observers for a give
- private final RegisteredObserversMap registeredObservers;
private final ManagerImpl manager;
@@ -134,7 +49,6 @@
*/
public EventManager(ManagerImpl manager)
{
- registeredObservers = new RegisteredObserversMap();
this.manager = manager;
}
@@ -148,7 +62,7 @@
public <T> void addObserver(Observer<T> observer, Type eventType, Annotation... bindings)
{
EventObserver<T> eventObserver = new EventObserver<T>(observer, eventType, manager, bindings);
- registeredObservers.put(eventType, eventObserver);
+ manager.getRegisteredObservers().put(eventType, eventObserver);
log.debug("Added observer " + observer + " observing event type " + eventType);
}
@@ -167,7 +81,7 @@
Set<Type> types = new HierarchyDiscovery(event.getClass()).getFlattenedTypes();
for (Type type : types)
{
- for (EventObserver<?> observer : registeredObservers.get(type))
+ for (EventObserver<?> observer : manager.getRegisteredObservers().get(type))
{
log.debug("Checking observer " + observer + " to see if it is interested in event [" + event + "]");
if (observer.isObserverInterested(bindings))
@@ -215,7 +129,7 @@
*/
public <T> void removeObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
{
- List<EventObserver<?>> observers = registeredObservers.get(eventType);
+ Collection<EventObserver<?>> observers = manager.getRegisteredObservers().get(eventType);
EventObserver<T> eventObserver = new EventObserver<T>(observer, eventType, manager, bindings);
observers.remove(eventObserver);
}
@@ -225,7 +139,7 @@
{
StringBuilder buffer = new StringBuilder();
buffer.append("Event manager\n");
- buffer.append(registeredObservers.toString());
+ buffer.append(manager.getRegisteredObservers().toString());
return buffer.toString();
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AbstractAnnotatedMember.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -17,25 +17,17 @@
package org.jboss.webbeans.introspector.jlr;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import javax.inject.BindingType;
import javax.inject.manager.Manager;
import org.jboss.webbeans.introspector.AnnotatedMember;
-import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.introspector.ForwardingAnnotatedMember;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
-import org.jboss.webbeans.util.collections.ForwardingMap;
/**
* Represents an abstract annotated memeber (field, method or constructor)
@@ -54,50 +46,7 @@
{
}
-
- /**
- * An annotation type -> list of annotations map
- */
- protected class AnnotatedParameterMap extends ForwardingMap<Class<? extends Annotation>, List<AnnotatedParameter<?>>>
- {
- private Map<Class<? extends Annotation>, List<AnnotatedParameter<?>>> delegate;
- public AnnotatedParameterMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, List<AnnotatedParameter<?>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, List<AnnotatedParameter<?>>> delegate()
- {
- return delegate;
- }
-
- public void put(Class<? extends Annotation> key, AnnotatedParameter<?> value)
- {
- List<AnnotatedParameter<?>> parameters = super.get(key);
- if (parameters == null)
- {
- parameters = new ArrayList<AnnotatedParameter<?>>();
- super.put(key, parameters);
- }
- parameters.add(value);
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotatedParameterMap (annotation type -> parameter abstraction list): ", delegate);
- }
-
- @Override
- public List<AnnotatedParameter<?>> get(Object key)
- {
- List<AnnotatedParameter<?>> parameters = super.get(key);
- return parameters != null ? parameters : new ArrayList<AnnotatedParameter<?>>();
- }
- }
-
// The name of the member
private final String name;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedAnnotationImpl.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -30,8 +30,8 @@
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.resources.ClassTransformer;
-import org.jboss.webbeans.util.Strings;
-import org.jboss.webbeans.util.collections.ForwardingMap;
+import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.SetMultiMap;
/**
* Represents an annotated annotation
@@ -44,52 +44,9 @@
*/
public class AnnotatedAnnotationImpl<T extends Annotation> extends AbstractAnnotatedType<T> implements AnnotatedAnnotation<T>
{
-
- /**
- * A (annotation type -> set of method abstractions with annotation) map
- */
- private class AnnotatedMemberMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>
- {
- private Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate;
- public AnnotatedMemberMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotatedMemberMap (annotation type -> set of member abstractions: ", delegate);
- }
-
- @Override
- public Set<AnnotatedMethod<?>> get(Object key)
- {
- Set<AnnotatedMethod<?>> methods = super.get(key);
- return methods != null ? methods : new HashSet<AnnotatedMethod<?>>();
- }
-
- public void put(Class<? extends Annotation> key, AnnotatedMethod<?> value)
- {
- Set<AnnotatedMethod<?>> members = super.get(key);
- if (members == null)
- {
- members = new HashSet<AnnotatedMethod<?>>();
- super.put(key, members);
- }
- members.add(value);
- }
- }
-
// The annotated members map (annotation -> member with annotation)
- private final AnnotatedMemberMap annotatedMembers;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>> annotatedMembers;
// The implementation class of the annotation
private final Class<T> clazz;
// The set of abstracted members
@@ -117,7 +74,7 @@
super(AnnotationStore.of(annotationType), annotationType, annotationType, classTransformer);
this.clazz = annotationType;
members = new HashSet<AnnotatedMethod<?>>();
- annotatedMembers = new AnnotatedMemberMap();
+ annotatedMembers = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>>();
this.namedMembers = new HashMap<String, AnnotatedMethod<?>>();
for (Method member : clazz.getDeclaredMethods())
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedClassImpl.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -40,8 +40,8 @@
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
-import org.jboss.webbeans.util.Strings;
-import org.jboss.webbeans.util.collections.ForwardingMap;
+import org.jboss.webbeans.util.collections.multi.SetHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.SetMultiMap;
/**
* Represents an annotated class
@@ -57,203 +57,43 @@
private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
- /**
- * A (annotation type -> set of field abstractions with annotation/meta
- * annotation) map
- */
- private static class AnnotatedFieldMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedField<?>>>
- {
- private Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> delegate;
-
- public AnnotatedFieldMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedField<?>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<AnnotatedField<?>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotatedFieldMap (annotation type -> field abstraction set): ", delegate);
- }
-
- @Override
- public Set<AnnotatedField<?>> get(Object key)
- {
- Set<AnnotatedField<?>> fields = super.get(key);
- return fields != null ? fields : new HashSet<AnnotatedField<?>>();
- }
-
- public void put(Class<? extends Annotation> key, AnnotatedField<?> value)
- {
- Set<AnnotatedField<?>> fields = super.get(key);
- if (fields == null)
- {
- fields = new HashSet<AnnotatedField<?>>();
- super.put(key, fields);
- }
- fields.add(value);
- }
-
- }
-
- /**
- * A (annotation type -> set of method abstractions with annotation) map
- */
- private class AnnotatedMethodMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>
- {
- private Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate;
-
- public AnnotatedMethodMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedMethod<?>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<AnnotatedMethod<?>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotatedMethodMap (annotation type -> method abstraction set): ", delegate);
- }
-
- @Override
- public Set<AnnotatedMethod<?>> get(Object key)
- {
- Set<AnnotatedMethod<?>> methods = super.get(key);
- return methods != null ? methods : new HashSet<AnnotatedMethod<?>>();
- }
-
- public void put(Class<? extends Annotation> key, AnnotatedMethod<?> value)
- {
- Set<AnnotatedMethod<?>> methods = super.get(key);
- if (methods == null)
- {
- methods = new HashSet<AnnotatedMethod<?>>();
- super.put(key, methods);
- }
- methods.add(value);
- }
-
- }
-
- /**
- * A (annotation type -> set of constructor abstractions with annotation) map
- */
- private class AnnotatedConstructorMap extends ForwardingMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>
- {
- private Map<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> delegate;
-
- public AnnotatedConstructorMap()
- {
- delegate = new HashMap<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>>();
- }
-
- @Override
- protected Map<Class<? extends Annotation>, Set<AnnotatedConstructor<T>>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("AnnotatedConstructorMap (annotation type -> constructor abstraction set): ", delegate);
- }
-
- @Override
- public Set<AnnotatedConstructor<T>> get(Object key)
- {
- Set<AnnotatedConstructor<T>> constructors = super.get(key);
- return constructors != null ? constructors : new HashSet<AnnotatedConstructor<T>>();
- }
-
- public void add(Class<? extends Annotation> key, AnnotatedConstructor<T> value)
- {
- Set<AnnotatedConstructor<T>> constructors = super.get(key);
- if (constructors == null)
- {
- constructors = new HashSet<AnnotatedConstructor<T>>();
- super.put(key, constructors);
- }
- constructors.add(value);
- }
- }
-
- /**
- * A (class list -> set of constructor abstractions with matching parameters)
- * map
- */
- private class ConstructorsByArgumentMap extends ForwardingMap<List<Class<?>>, AnnotatedConstructor<T>>
- {
- private Map<List<Class<?>>, AnnotatedConstructor<T>> delegate;
-
- public ConstructorsByArgumentMap()
- {
- delegate = new HashMap<List<Class<?>>, AnnotatedConstructor<T>>();
- }
-
- @Override
- protected Map<List<Class<?>>, AnnotatedConstructor<T>> delegate()
- {
- return delegate;
- }
-
- @Override
- public String toString()
- {
- return Strings.mapToString("Annotation type -> constructor by arguments mappings: ", delegate);
- }
- }
-
-
-
// The set of abstracted fields
private final Set<AnnotatedField<?>> fields;
// The map from annotation type to abstracted field with annotation
- private final AnnotatedFieldMap annotatedFields;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedField<?>> annotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private final AnnotatedFieldMap metaAnnotatedFields;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedField<?>> metaAnnotatedFields;
// The set of abstracted fields
private final Set<AnnotatedField<?>> declaredFields;
private final Map<String, AnnotatedField<?>> declaredFieldsByName;
// The map from annotation type to abstracted field with annotation
- private final AnnotatedFieldMap declaredAnnotatedFields;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedField<?>> declaredAnnotatedFields;
// The map from annotation type to abstracted field with meta-annotation
- private final AnnotatedFieldMap declaredMetaAnnotatedFields;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedField<?>> declaredMetaAnnotatedFields;
// The set of abstracted methods
private final Set<AnnotatedMethod<?>> methods;
private final Map<MethodSignature, AnnotatedMethod<?>> declaredMethodsBySignature;
// The map from annotation type to abstracted method with annotation
- private final AnnotatedMethodMap annotatedMethods;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>> annotatedMethods;
// The map from annotation type to method with a parameter with annotation
- private final AnnotatedMethodMap methodsByAnnotatedParameters;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>> methodsByAnnotatedParameters;
// The set of abstracted methods
private final Set<AnnotatedMethod<?>> declaredMethods;
// The map from annotation type to abstracted method with annotation
- private final AnnotatedMethodMap declaredAnnotatedMethods;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>> declaredAnnotatedMethods;
// The map from annotation type to method with a parameter with annotation
- private final AnnotatedMethodMap declaredMethodsByAnnotatedParameters;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>> declaredMethodsByAnnotatedParameters;
// The set of abstracted constructors
private final Set<AnnotatedConstructor<T>> constructors;
private final Map<ConstructorSignature, AnnotatedConstructor<?>> declaredConstructorsBySignature;
// The map from annotation type to abstracted constructor with annotation
- private final AnnotatedConstructorMap annotatedConstructors;
+ private final SetMultiMap<Class<? extends Annotation>, AnnotatedConstructor<T>> annotatedConstructors;
// The map from class list to abstracted constructor
- private final ConstructorsByArgumentMap constructorsByArgumentMap;
+ private final Map<List<Class<?>>, AnnotatedConstructor<T>> constructorsByArgumentMap;
// Cached string representation
private String toString;
@@ -273,12 +113,12 @@
super(AnnotationStore.of(annotations, declaredAnnotations), rawType, type, classTransformer);
this.fields = new HashSet<AnnotatedField<?>>();
- this.annotatedFields = new AnnotatedFieldMap();
- this.metaAnnotatedFields = new AnnotatedFieldMap();
+ this.annotatedFields = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedField<?>>();
+ this.metaAnnotatedFields = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedField<?>>();
this.declaredFields = new HashSet<AnnotatedField<?>>();
this.declaredFieldsByName = new HashMap<String, AnnotatedField<?>>();
- this.declaredAnnotatedFields = new AnnotatedFieldMap();
- this.declaredMetaAnnotatedFields = new AnnotatedFieldMap();
+ this.declaredAnnotatedFields = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedField<?>>();
+ this.declaredMetaAnnotatedFields = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedField<?>>();
this._nonStaticMemberClass = Reflections.isNonMemberInnerClass(rawType);
this._abstract = Reflections.isAbstract(rawType);
this._enum = rawType.isEnum();
@@ -318,8 +158,8 @@
}
this.constructors = new HashSet<AnnotatedConstructor<T>>();
- this.constructorsByArgumentMap = new ConstructorsByArgumentMap();
- this.annotatedConstructors = new AnnotatedConstructorMap();
+ this.constructorsByArgumentMap = new HashMap<List<Class<?>>, AnnotatedConstructor<T>>();
+ this.annotatedConstructors = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedConstructor<T>>();
this.declaredConstructorsBySignature = new HashMap<ConstructorSignature, AnnotatedConstructor<?>>();
for (Constructor<?> constructor : rawType.getDeclaredConstructors())
{
@@ -346,11 +186,11 @@
}
this.methods = new HashSet<AnnotatedMethod<?>>();
- this.annotatedMethods = new AnnotatedMethodMap();
- this.methodsByAnnotatedParameters = new AnnotatedMethodMap();
+ this.annotatedMethods = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>>();
+ this.methodsByAnnotatedParameters = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>>();
this.declaredMethods = new HashSet<AnnotatedMethod<?>>();
- this.declaredAnnotatedMethods = new AnnotatedMethodMap();
- this.declaredMethodsByAnnotatedParameters = new AnnotatedMethodMap();
+ this.declaredAnnotatedMethods = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>>();
+ this.declaredMethodsByAnnotatedParameters = new SetHashMultiMap<Class<? extends Annotation>, AnnotatedMethod<?>>();
this.declaredMethodsBySignature = new HashMap<MethodSignature, AnnotatedMethod<?>>();
for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -32,6 +32,8 @@
import org.jboss.webbeans.introspector.AnnotationStore;
import org.jboss.webbeans.introspector.ConstructorSignature;
import org.jboss.webbeans.util.Names;
+import org.jboss.webbeans.util.collections.multi.ListHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.ListMultiMap;
/**
* Represents an annotated constructor
@@ -51,7 +53,7 @@
// The list of parameter abstractions
private final List<AnnotatedParameter<?>> parameters;
// The mapping of annotation -> parameter abstraction
- private final AnnotatedParameterMap annotatedParameters;
+ private final ListMultiMap<Class<? extends Annotation>, AnnotatedParameter<?>> annotatedParameters;
// The declaring class abstraction
private final AnnotatedType<T> declaringClass;
@@ -81,7 +83,7 @@
this.declaringClass = declaringClass;
this.parameters = new ArrayList<AnnotatedParameter<?>>();
- annotatedParameters = new AnnotatedParameterMap();
+ annotatedParameters = new ListHashMultiMap<Class<? extends Annotation>, AnnotatedParameter<?>>();
for (int i = 0; i < constructor.getParameterTypes().length; i++)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedMethodImpl.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -33,6 +33,8 @@
import org.jboss.webbeans.introspector.MethodSignature;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.util.collections.multi.ListHashMultiMap;
+import org.jboss.webbeans.util.collections.multi.ListMultiMap;
/**
* Represents an annotated method
@@ -53,7 +55,7 @@
private final List<AnnotatedParameter<?>> parameters;
// A mapping from annotation type to parameter abstraction with that
// annotation present
- private final AnnotatedParameterMap annotatedParameters;
+ private final ListMultiMap<Class<? extends Annotation>, AnnotatedParameter<?>> annotatedParameters;
// The property name
private final String propertyName;
@@ -88,7 +90,7 @@
this.method.setAccessible(true);
this.declaringClass = declaringClass;
this.parameters = new ArrayList<AnnotatedParameter<?>>();
- this.annotatedParameters = new AnnotatedParameterMap();
+ this.annotatedParameters = new ListHashMultiMap<Class<? extends Annotation>, AnnotatedParameter<?>>();
for (int i = 0; i < method.getParameterTypes().length; i++)
{
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
+e @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+import java.util.Collection;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Adds concurrent add operations to the collection interface. Signatures and
+ * javadoc taken from {@link CopyOnWriteArrayList}.
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ConcurrentCollection<E> extends Collection<E>
+{
+ /**
+ * Appends all of the elements in the specified collection that are not
+ * already contained in this list, to the end of this list, in the order that
+ * they are returned by the specified collection's iterator.
+ *
+ * @param c
+ * collection containing elements to be added to this list
+ * @return the number of elements added
+ * @throws NullPointerException
+ * if the specified collection is null
+ */
+ public int addAllAbsent(Collection<? extends E> c);
+
+ /**
+ * Append the element if not present.
+ *
+ * @param e
+ * element to be added to this list, if absent
+ * @return true if the element was added
+ */
+ public boolean addIfAbsent(E e);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentCollection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections;
+
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Implementation of {@link ConcurrentCollection} using a
+ * {@link CopyOnWriteArrayList}
+ *
+ * @author Pete Muir
+ *
+ */
+public class ConcurrentList<E> extends CopyOnWriteArrayList<E> implements ConcurrentCollection<E>
+{
+
+ @SuppressWarnings("unchecked")
+ private static final ConcurrentList EMPTY_LIST = new ConcurrentList();
+
+ @SuppressWarnings("unchecked")
+ public static <E> ConcurrentList<E> emptyList()
+ {
+ return EMPTY_LIST;
+ }
+
+ private static final long serialVersionUID = -7489797765014324457L;
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ConcurrentList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.util.collections;
+
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ * A concurrent map which forwards all its method calls to another concurrent
+ * map. Subclasses should override one or more methods to modify the behavior of
+ * the backing map as desired per the <a
+ * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>.
+ *
+ * @see ForwardingObject
+ * @author Charles Fry
+ */
+public abstract class ForwardingConcurrentMap<K, V> extends ForwardingMap<K, V> implements ConcurrentMap<K, V>
+{
+
+ @Override
+ protected abstract ConcurrentMap<K, V> delegate();
+
+ public V putIfAbsent(K key, V value)
+ {
+ return delegate().putIfAbsent(key, value);
+ }
+
+ public boolean remove(Object key, Object value)
+ {
+ return delegate().remove(key, value);
+ }
+
+ public V replace(K key, V value)
+ {
+ return delegate().replace(key, value);
+ }
+
+ public boolean replace(K key, V oldValue, V newValue)
+ {
+ return delegate().replace(key, oldValue, newValue);
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/ForwardingConcurrentMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.webbeans.util.collections.ConcurrentList;
+import org.jboss.webbeans.util.collections.ForwardingConcurrentMap;
+
+/**
+ * An concurrent multimap which is internally backed by a a ConcurrentHashMap
+ * and a CopyOnWriteArrayList
+ *
+ * @author Pete Muir
+ */
+public class ConcurrentListHashMultiMap<K, V> extends ForwardingConcurrentMap<K, ConcurrentList<V>> implements ConcurrentListMultiMap<K, V>
+{
+
+ private final ConcurrentList<V> EMPTY_LIST = ConcurrentList.emptyList();
+
+ // The map delegate
+ private ConcurrentHashMap<K, ConcurrentList<V>> delegate;
+
+ /**
+ * Constructor.
+ */
+ public ConcurrentListHashMultiMap()
+ {
+ delegate = new ConcurrentHashMap<K, ConcurrentList<V>>();
+ }
+
+ @Override
+ protected ConcurrentMap<K, ConcurrentList<V>> delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Gets the list of values for a given key
+ *
+ * @param key
+ * the key
+ * @return The list of values. An empty list is returned if there are no
+ * matches.
+ */
+ @Override
+ public ConcurrentList<V> get(Object key)
+ {
+ ConcurrentList<V> values = super.get(key);
+ return values != null ? values : EMPTY_LIST;
+ }
+
+ public void put(K key, V value)
+ {
+ delegate.putIfAbsent(key, new ConcurrentList<V>());
+ get(key).add(value);
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListHashMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.webbeans.util.collections.ConcurrentList;
+
+/**
+ * A concurrent multimap, in which the multi-values are stored in a list
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ConcurrentListMultiMap<K, V> extends ConcurrentMap<K, ConcurrentList<V>>
+{
+
+ /**
+ * Add a value, creating the list if it doesn't exist
+ *
+ * @param key the key to store the value under
+ * @param value the value to add
+ */
+ public void put(K key, V value);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentListMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,74 @@
+package org.jboss.webbeans.util.collections.multi;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.webbeans.util.collections.ConcurrentCollection;
+import org.jboss.webbeans.util.collections.ConcurrentList;
+import org.jboss.webbeans.util.collections.ForwardingConcurrentMap;
+
+/**
+ * An concurrent multimap which is internally backed by a a ConcurrentHashMap
+ * and a CopyOnWriteArrayList
+ *
+ * @author Pete Muir
+ */
+public class ConcurrentSetHashMultiMap<K, V> extends ForwardingConcurrentMap<K, ConcurrentCollection<V>> implements ConcurrentSetMultiMap<K, V>
+{
+
+ private final ConcurrentCollection<V> EMPTY_COLLECTION = ConcurrentList.emptyList();
+
+ // The map delegate
+ private ConcurrentMap<K, ConcurrentCollection<V>> delegate;
+
+ /**
+ * Constructor.
+ */
+ public ConcurrentSetHashMultiMap()
+ {
+ delegate = new ConcurrentHashMap<K, ConcurrentCollection<V>>();
+ }
+
+ @Override
+ protected ConcurrentMap<K, ConcurrentCollection<V>> delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Gets the list of values for a given key
+ *
+ * @param key
+ * the key
+ * @return The list of values. An empty list is returned if there are no
+ * matches.
+ */
+ @Override
+ public ConcurrentCollection<V> get(Object key)
+ {
+ ConcurrentCollection<V> values = super.get(key);
+ return values != null ? values : EMPTY_COLLECTION;
+ }
+
+ public void put(K key, V value)
+ {
+ delegate().putIfAbsent(key, new ConcurrentList<V>());
+ get(key).addIfAbsent(value);
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetHashMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.webbeans.util.collections.ConcurrentCollection;
+
+/**
+ * A concurrent multimap, in which the multi-values are stored with Set
+ * semantics for {@link #put(Object, Object)} operations
+ *
+ * @author Pete Muir
+ *
+ */
+public interface ConcurrentSetMultiMap<K, V> extends ConcurrentMap<K, ConcurrentCollection<V>>
+{
+
+ /**
+ * Add a value. The collection is automatically created. If the value already
+ * exists, it isn't added
+ *
+ * @param key the key to add the value to
+ * @param value the value to add
+ */
+ public void put(K key, V value);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ConcurrentSetMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.webbeans.util.collections.ForwardingMap;
+
+/**
+ * An multimap which is internally backed by a HashMap and a ArrayList
+ *
+ * @author Pete Muir
+ */
+public class ListHashMultiMap<K, V> extends ForwardingMap<K, List<V>> implements ListMultiMap<K, V>
+{
+
+ private final List<V> EMPTY_COLLECTION = Collections.emptyList();
+
+ // The map delegate
+ private Map<K, List<V>> delegate;
+
+ /**
+ * Constructor.
+ */
+ public ListHashMultiMap()
+ {
+ delegate = new HashMap<K, List<V>>();
+ }
+
+ @Override
+ protected Map<K, List<V>> delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Gets the list of values for a given key
+ *
+ * @param key
+ * the key
+ * @return The list of values. An empty list is returned if there are no
+ * matches.
+ */
+ @Override
+ public List<V> get(Object key)
+ {
+ List<V> values = super.get(key);
+ return values != null ? values : EMPTY_COLLECTION;
+ }
+
+ /**
+ * Adds an value for a given key
+ *
+ * Implicitly creates a new list if there is none for the key. Only adds
+ * the value if it is not already present
+ *
+ * @param key the key
+ * @param value the value
+ */
+ public void put(K key, V value)
+ {
+ if (!containsKey(key))
+ {
+ put(key, new ArrayList<V>());
+ }
+ get(key).add(value);
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListHashMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A concurrent multimap, in which the multi-values are stored in a list
+ * @author Pete Muir
+ *
+ */
+public interface ListMultiMap<K, V> extends Map<K, List<V>>
+{
+
+ /**
+ * Add a value, creating the list if it doesn't exist
+ *
+ * @param key the key to store the value under
+ * @param value the value to add
+ */
+ public void put(K key, V value);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/ListMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.webbeans.util.collections.ForwardingMap;
+
+/**
+ * An multimap which is internally backed by a HashMap and a HashSet
+ *
+ * @author Pete Muir
+ */
+public class SetHashMultiMap<K, V> extends ForwardingMap<K, Set<V>> implements SetMultiMap<K, V>
+{
+
+ private final Set<V> EMPTY_COLLECTION = Collections.emptySet();
+
+ // The map delegate
+ private Map<K, Set<V>> delegate;
+
+ /**
+ * Constructor.
+ */
+ public SetHashMultiMap()
+ {
+ delegate = new HashMap<K, Set<V>>();
+ }
+
+ @Override
+ protected Map<K, Set<V>> delegate()
+ {
+ return delegate;
+ }
+
+ /**
+ * Gets the list of values for a given key
+ *
+ * @param key
+ * the key
+ * @return The list of values. An empty list is returned if there are no
+ * matches.
+ */
+ @Override
+ public Set<V> get(Object key)
+ {
+ Set<V> values = super.get(key);
+ return values != null ? values : EMPTY_COLLECTION;
+ }
+
+ public void put(K key, V value)
+ {
+ if (!containsKey(key))
+ {
+ put(key, new HashSet<V>());
+ }
+ Set<V> values = get(key);
+ if (!values.contains(value))
+ {
+ values.add(value);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetHashMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.webbeans.util.collections.multi;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * A concurrent multimap, in which the multi-values are stored with Set
+ * semantics for {@link #put(Object, Object)} operations
+ *
+ * @author Pete Muir
+ *
+ */
+public interface SetMultiMap<K, V> extends Map<K, Set<V>>
+{
+
+ /**
+ * Add a value. The collection is automatically created. If the value already
+ * exists, it isn't added
+ *
+ * @param key the key to add the value to
+ * @param value the value to add
+ */
+ public void put(K key, V value);
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/collections/multi/SetMultiMap.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-04 18:25:00 UTC (rev 2299)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-05 12:54:49 UTC (rev 2300)
@@ -200,7 +200,7 @@
assert childActivity.getInstanceToInject(dummyBean.getInjectionPoints().iterator().next()) != null;
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section="11.6", id="j"),
@SpecAssertion(section="11.6", id="n")
15 years, 8 months
[webbeans-commits] Webbeans SVN: r2299 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean and 14 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-04 14:25:00 -0400 (Sat, 04 Apr 2009)
New Revision: 2299
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/ChildManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
Log:
Enable createActivity
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -63,9 +63,9 @@
public class BeanValidator
{
- private final RootManager manager;
+ private final ManagerImpl manager;
- public BeanValidator(RootManager manager)
+ public BeanValidator(ManagerImpl manager)
{
this.manager = manager;
}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/ChildManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ChildManager.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ChildManager.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -1,169 +0,0 @@
-package org.jboss.webbeans;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Set;
-
-import javax.context.Context;
-import javax.context.CreationalContext;
-import javax.event.Observer;
-import javax.inject.TypeLiteral;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Decorator;
-import javax.inject.manager.InjectionPoint;
-import javax.inject.manager.InterceptionType;
-import javax.inject.manager.Interceptor;
-import javax.inject.manager.Manager;
-
-import org.jboss.webbeans.manager.api.WebBeansManager;
-
-public class ChildManager implements WebBeansManager, Serializable
-{
-
- private final WebBeansManager parentManager;
-
- public ChildManager(WebBeansManager manager)
- {
- this.parentManager = manager;
- }
-
- public void injectNonContextualInstance(Object instance)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public void shutdown()
- {
- throw new UnsupportedOperationException("Must call shutdown() on root manager");
- }
-
- public Manager addBean(Bean<?> bean)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Manager addContext(Context context)
- {
- throw new UnsupportedOperationException("Must add contexts to root manager");
- }
-
- public Manager addDecorator(Decorator decorator)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Manager addInterceptor(Interceptor interceptor)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Manager createActivity()
- {
- return new ChildManager(this);
- }
-
- public void fireEvent(Object event, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Context getContext(Class<? extends Annotation> scopeType)
- {
- return parentManager.getContext(scopeType);
- }
-
- public <T> T getInstance(Bean<T> bean)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Object getInstanceByName(String name)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> T getInstanceByType(Class<T> type, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> T getInstanceByType(TypeLiteral<T> type, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> T getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> T getInstanceToInject(InjectionPoint injectionPoint)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Manager parse(InputStream xmlStream)
- {
- throw new UnsupportedOperationException("Can only add XML metadata to root manager");
- }
-
- public <T> Manager removeObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Manager removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Set<Bean<?>> resolveByName(String name)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Set<Bean<T>> resolveByType(Class<T> type, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Set<Bean<T>> resolveByType(TypeLiteral<T> type, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public List<Decorator> resolveDecorators(Set<Type> types, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public List<Interceptor> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public Manager setCurrent(Class<? extends Annotation> scopeType)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/CurrentManager.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -26,26 +26,26 @@
public class CurrentManager
{
// The root manager instance
- protected static RootManager rootManager;
+ protected static ManagerImpl managerImpl;
/**
* Gets the root manager
*
* @return The root manager
*/
- public static RootManager rootManager()
+ public static ManagerImpl rootManager()
{
- return rootManager;
+ return managerImpl;
}
/**
* Sets the root manager
*
- * @param rootManager The root manager
+ * @param managerImpl The root manager
*/
- public static void setRootManager(RootManager rootManager)
+ public static void setRootManager(ManagerImpl managerImpl)
{
- CurrentManager.rootManager = rootManager;
+ CurrentManager.managerImpl = managerImpl;
}
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -41,7 +41,7 @@
// The binding types the helper operates on
protected final Set<? extends Annotation> bindings;
// The Web Beans manager
- protected final RootManager manager;
+ protected final ManagerImpl manager;
// The type of the operation
protected final Class<T> type;
@@ -52,7 +52,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- protected FacadeImpl(Class<T> type, RootManager manager, Set<? extends Annotation> bindings)
+ protected FacadeImpl(Class<T> type, ManagerImpl manager, Set<? extends Annotation> bindings)
{
this.manager = manager;
this.type = type;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -35,7 +35,7 @@
{
- public static <I> Instance<I> of(Class<I> clazz, RootManager manager, Set<Annotation> annotations)
+ public static <I> Instance<I> of(Class<I> clazz, ManagerImpl manager, Set<Annotation> annotations)
{
return new InstanceImpl<I>(clazz, manager, annotations);
}
@@ -47,7 +47,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- private InstanceImpl(Class<T> type, RootManager manager, Set<Annotation> bindings)
+ private InstanceImpl(Class<T> type, ManagerImpl manager, Set<Annotation> bindings)
{
super(type, manager, bindings);
}
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java (from rev 2298, ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -0,0 +1,1075 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
+
+import javax.context.Context;
+import javax.context.ContextNotActiveException;
+import javax.context.CreationalContext;
+import javax.event.Observer;
+import javax.inject.AmbiguousDependencyException;
+import javax.inject.BindingType;
+import javax.inject.DeploymentException;
+import javax.inject.DuplicateBindingTypeException;
+import javax.inject.Production;
+import javax.inject.Standard;
+import javax.inject.TypeLiteral;
+import javax.inject.UnproxyableDependencyException;
+import javax.inject.UnsatisfiedDependencyException;
+import javax.inject.manager.Bean;
+import javax.inject.manager.Decorator;
+import javax.inject.manager.InjectionPoint;
+import javax.inject.manager.InterceptionType;
+import javax.inject.manager.Interceptor;
+import javax.inject.manager.Manager;
+
+import org.jboss.webbeans.bean.DisposalMethodBean;
+import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.bean.NewEnterpriseBean;
+import org.jboss.webbeans.bean.RIBean;
+import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
+import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
+import org.jboss.webbeans.context.ApplicationContext;
+import org.jboss.webbeans.context.ContextMap;
+import org.jboss.webbeans.context.CreationalContextImpl;
+import org.jboss.webbeans.el.Namespace;
+import org.jboss.webbeans.el.NamespaceManager;
+import org.jboss.webbeans.event.EventManager;
+import org.jboss.webbeans.event.ObserverImpl;
+import org.jboss.webbeans.injection.NonContextualInjector;
+import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
+import org.jboss.webbeans.injection.resolution.Resolver;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.log.Log;
+import org.jboss.webbeans.log.Logging;
+import org.jboss.webbeans.manager.api.WebBeansManager;
+import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.resources.spi.NamingContext;
+import org.jboss.webbeans.util.Beans;
+import org.jboss.webbeans.util.Proxies;
+import org.jboss.webbeans.util.Reflections;
+
+/**
+ * Implementation of the Web Beans Manager.
+ *
+ * Essentially a singleton for registering Beans, Contexts, Observers,
+ * Interceptors etc. as well as providing resolution
+ *
+ * @author Pete Muir
+ *
+ */
+public class ManagerImpl implements WebBeansManager, Serializable
+{
+
+
+
+
+ private static final Log log = Logging.getLog(ManagerImpl.class);
+
+ private static final long serialVersionUID = 3021562879133838561L;
+
+ // The JNDI key to place the manager under
+ public static final String JNDI_KEY = "java:app/Manager";
+
+ // The enabled deployment types from web-beans.xml
+ private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
+
+ // The Web Beans event manager
+ private transient final EventManager eventManager;
+
+ // An executor service for asynchronous tasks
+ private transient final ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
+
+ // An injection point metadata beans factory
+ private transient final ThreadLocal<Stack<InjectionPoint>> currentInjectionPoint;
+
+ // The bean resolver
+ private transient final Resolver resolver;
+
+ // The registered contexts
+ private transient final ContextMap contexts;
+
+ // The client proxy pool
+ private transient final ClientProxyProvider clientProxyProvider;
+
+ // The registered beans
+ private transient List<Bean<?>> beans;
+
+ // The registered beans, mapped by implementation class
+ private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans;
+
+ private transient final Map<String, RIBean<?>> riBeans;
+
+ private transient final ServiceRegistry services;
+
+ private final transient Map<Bean<?>, Bean<?>> specializedBeans;
+
+ private final transient NonContextualInjector nonContextualInjector;
+
+ private final transient NamespaceManager namespaceManager;
+
+ /**
+ * Create a new, root, manager
+ *
+ * @param serviceRegistry
+ * @return
+ */
+ public static ManagerImpl newRootManager(ServiceRegistry serviceRegistry)
+ {
+ List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
+ defaultEnabledDeploymentTypes.add(0, Standard.class);
+ defaultEnabledDeploymentTypes.add(1, Production.class);
+
+ return new ManagerImpl(
+ serviceRegistry,
+ new CopyOnWriteArrayList<Bean<?>>(),
+ new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>(),
+ new ConcurrentHashMap<String, RIBean<?>>(),
+ new ClientProxyProvider(),
+ new ContextMap(),
+ new HashMap<Bean<?>, Bean<?>>(),
+ new NamespaceManager(new Namespace()),
+ defaultEnabledDeploymentTypes);
+ }
+
+ /**
+ * Create a new child manager
+ *
+ * @param parentManager
+ * @return
+ */
+ public static ManagerImpl newChildManager(ManagerImpl parentManager)
+ {
+ List<Bean<?>> beans = new CopyOnWriteArrayList<Bean<?>>();
+ beans.addAll(parentManager.getBeans());
+
+ NamespaceManager namespaceManager = new NamespaceManager(new Namespace(parentManager.getNamespaceManager().getRoot()));
+
+ return new ManagerImpl(
+ parentManager.getServices(),
+ beans,
+ parentManager.getNewEnterpriseBeanMap(),
+ parentManager.getRiBeans(),
+ parentManager.getClientProxyProvider(),
+ parentManager.getContexts(),
+ parentManager.getSpecializedBeans(),
+ namespaceManager,
+ parentManager.getEnabledDeploymentTypes());
+ }
+
+ /**
+ * Create a new manager
+ *
+ * @param ejbServices the ejbResolver to use
+ */
+ private ManagerImpl(
+ ServiceRegistry serviceRegistry,
+ List<Bean<?>> beans,
+ Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeans,
+ Map<String, RIBean<?>> riBeans,
+ ClientProxyProvider clientProxyProvider,
+ ContextMap contexts,
+ Map<Bean<?>, Bean<?>> specializedBeans,
+ NamespaceManager namespaceManager,
+ List<Class<? extends Annotation>> enabledDeploymentTypes
+ )
+ {
+ this.services = serviceRegistry;
+ this.beans = beans;
+ this.newEnterpriseBeans = newEnterpriseBeans;
+ this.riBeans = riBeans;
+
+ this.clientProxyProvider = clientProxyProvider;
+ this.contexts = contexts;
+ this.specializedBeans = specializedBeans;
+
+ this.namespaceManager = namespaceManager;
+ setEnabledDeploymentTypes(enabledDeploymentTypes);
+
+ this.resolver = new Resolver(this);
+ this.eventManager = new EventManager(this);
+ this.nonContextualInjector = new NonContextualInjector(this);
+ this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
+ {
+ @Override
+ protected Stack<InjectionPoint> initialValue()
+ {
+ return new Stack<InjectionPoint>();
+ }
+ };
+ }
+
+ /**
+ * Set up the enabled deployment types, if none are specified by the user,
+ * the default @Production and @Standard are used. For internal use.
+ *
+ * @param enabledDeploymentTypes The enabled deployment types from
+ * web-beans.xml
+ */
+ protected void checkEnabledDeploymentTypes()
+ {
+ if (!this.enabledDeploymentTypes.get(0).equals(Standard.class))
+ {
+ throw new DeploymentException("@Standard must be the lowest precedence deployment type");
+ }
+ }
+
+ protected void addWebBeansDeploymentTypes()
+ {
+ if (!this.enabledDeploymentTypes.contains(WebBean.class))
+ {
+ this.enabledDeploymentTypes.add(1, WebBean.class);
+ }
+ }
+
+ /**
+ * Registers a bean with the manager
+ *
+ * @param bean The bean to register
+ * @return A reference to manager
+ *
+ * @see javax.inject.manager.Manager#addBean(javax.inject.manager.Bean)
+ */
+ public Manager addBean(Bean<?> bean)
+ {
+ if (beans.contains(bean))
+ {
+ return this;
+ }
+ resolver.clear();
+ beans.add(bean);
+ namespaceManager.register(bean);
+ return this;
+ }
+
+ /**
+ * Resolve the disposal method for the given producer method. For internal
+ * use.
+ *
+ * @param apiType The API type to match
+ * @param bindings The binding types to match
+ * @return The set of matching disposal methods
+ */
+ public <T> Set<DisposalMethodBean<T>> resolveDisposalBeans(Class<T> apiType, Annotation... bindings)
+ {
+ // Correct?
+ Set<Bean<T>> beans = resolveByType(apiType, bindings);
+ Set<DisposalMethodBean<T>> disposalBeans = new HashSet<DisposalMethodBean<T>>();
+ for (Bean<T> bean : beans)
+ if (bean instanceof DisposalMethodBean)
+ disposalBeans.add((DisposalMethodBean<T>) bean);
+ return disposalBeans;
+ }
+
+ /**
+ * Resolves observers for given event and bindings
+ *
+ * @param event The event to match
+ * @param bindings The binding types to match
+ * @return The set of matching observers
+ *
+ * @see javax.inject.manager.Manager#resolveObservers(java.lang.Object,
+ * java.lang.annotation.Annotation[])
+ */
+ @SuppressWarnings("unchecked")
+ public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
+ {
+ Class<?> clazz = event.getClass();
+ for (Annotation annotation : bindings)
+ {
+ if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
+ {
+ throw new IllegalArgumentException("Not a binding type " + annotation);
+ }
+ }
+ HashSet<Annotation> bindingAnnotations = new HashSet<Annotation>(Arrays.asList(bindings));
+ if (bindingAnnotations.size() < bindings.length)
+ {
+ throw new DuplicateBindingTypeException("Duplicate binding types: " + bindings);
+ }
+ Type t = new Reflections.HierarchyDiscovery(clazz).getResolvedType();
+ for (Type type : Reflections.getActualTypeArguments(clazz))
+ {
+ if (type instanceof WildcardType)
+ {
+ throw new IllegalArgumentException("Cannot resolve an event type parameterized with a wildcard " + clazz);
+ }
+ if (type instanceof TypeVariable)
+ {
+ throw new IllegalArgumentException("Cannot resolve an event type parameterized with a type parameter " + clazz);
+ }
+ }
+ return eventManager.getObservers(event, bindings);
+ }
+
+ /**
+ * A strongly ordered, unmodifiable list of enabled deployment types
+ *
+ * @return The ordered enabled deployment types known to the manager
+ */
+ public List<Class<? extends Annotation>> getEnabledDeploymentTypes()
+ {
+ return Collections.unmodifiableList(enabledDeploymentTypes);
+ }
+
+ /**
+ * Set the enabled deployment types
+ *
+ * @param enabledDeploymentTypes
+ */
+ public void setEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
+ {
+ this.enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>(enabledDeploymentTypes);
+ checkEnabledDeploymentTypes();
+ addWebBeansDeploymentTypes();
+ }
+
+ /**
+ * Resolves beans by API type and binding types
+ *
+ * @param type The API type to match
+ * @param bindings The binding types to match
+ * @return The set of matching beans
+ *
+ * @see javax.inject.manager.Manager#resolveByType(java.lang.Class,
+ * java.lang.annotation.Annotation[])
+ */
+ public <T> Set<Bean<T>> resolveByType(Class<T> type, Annotation... bindings)
+ {
+ return resolveByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
+ }
+
+ /**
+ * Resolves beans by API type literal and binding types
+ *
+ * @param type The API type literal to match
+ * @param bindings The binding types to match
+ * @return The set of matching beans
+ *
+ * @see javax.inject.manager.Manager#resolveByType(javax.inject.TypeLiteral,
+ * java.lang.annotation.Annotation[])
+ */
+ public <T> Set<Bean<T>> resolveByType(TypeLiteral<T> type, Annotation... bindings)
+ {
+ return resolveByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
+ }
+
+ public <T> Set<Bean<T>> resolveByType(AnnotatedItem<T, ?> element, InjectionPoint injectionPoint, Annotation... bindings)
+ {
+ boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
+ try
+ {
+ if (registerInjectionPoint)
+ {
+ currentInjectionPoint.get().push(injectionPoint);
+ }
+ return resolveByType(element, bindings);
+ }
+ finally
+ {
+ if (registerInjectionPoint)
+ {
+ currentInjectionPoint.get().pop();
+ }
+ }
+ }
+
+ /**
+ * Check the resolution request is valid, and then ask the resolver to
+ * perform the resolution. For internal use.
+ *
+ * @param element The item to resolve
+ * @param bindings The binding types to match
+ * @return The set of matching beans
+ */
+ public <T> Set<Bean<T>> resolveByType(AnnotatedItem<T, ?> element, Annotation... bindings)
+ {
+ for (Annotation annotation : element.getAnnotationsAsSet())
+ {
+ if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
+ {
+ throw new IllegalArgumentException("Not a binding type " + annotation);
+ }
+ }
+ for (Type type : element.getActualTypeArguments())
+ {
+ if (type instanceof WildcardType)
+ {
+ throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
+ }
+ if (type instanceof TypeVariable)
+ {
+ throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
+ }
+ }
+ if (bindings.length > element.getMetaAnnotations(BindingType.class).size())
+ {
+ throw new DuplicateBindingTypeException("Duplicate bindings (" + Arrays.asList(bindings) + ") type passed " + element.toString());
+ }
+ return resolver.get(element);
+ }
+
+ /**
+ * Wraps a collection of beans into a thread safe list. Since this overwrites
+ * any existing list of beans in the manager, this should only be done on
+ * startup and other controlled situations. Also maps the beans by
+ * implementation class. For internal use.
+ *
+ * @param beans The set of beans to add
+ * @return A reference to the manager
+ */
+ // TODO Build maps in the deployer :-)
+ public void setBeans(Set<RIBean<?>> beans)
+ {
+ synchronized (beans)
+ {
+ this.beans = new CopyOnWriteArrayList<Bean<?>>(beans);
+ for (RIBean<?> bean : beans)
+ {
+ if (bean instanceof NewEnterpriseBean)
+ {
+ newEnterpriseBeans.put(bean.getType(), (EnterpriseBean<?>) bean);
+ }
+ riBeans.put(bean.getId(), bean);
+ namespaceManager.register(bean);
+ }
+ resolver.clear();
+ }
+ }
+
+ /**
+ * Gets the class-mapped beans. For internal use.
+ *
+ * @return The bean map
+ */
+ public Map<Class<?>, EnterpriseBean<?>> getNewEnterpriseBeanMap()
+ {
+ return newEnterpriseBeans;
+ }
+
+ /**
+ * The beans registered with the Web Bean manager. For internal use
+ *
+ * @return The list of known beans
+ */
+ public List<Bean<?>> getBeans()
+ {
+ return Collections.unmodifiableList(beans);
+ }
+
+ public Map<String, RIBean<?>> getRiBeans()
+ {
+ return Collections.unmodifiableMap(riBeans);
+ }
+
+ /**
+ * Registers a context with the manager
+ *
+ * @param context The context to add
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#addContext(javax.context.Context)
+ */
+ public Manager addContext(Context context)
+ {
+ contexts.add(context);
+ return this;
+ }
+
+ /**
+ * Registers a decorator with the manager
+ *
+ * @param decorator The decorator to register
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#addDecorator(javax.inject.manager.Decorator)
+ */
+ public Manager addDecorator(Decorator decorator)
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Registers an interceptor with the manager
+ *
+ * @param interceptor The interceptor to register
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#addInterceptor(javax.inject.manager.Interceptor)
+ */
+ public Manager addInterceptor(Interceptor interceptor)
+ {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ /**
+ * Registers an observer for a given event type and binding types
+ *
+ * @param observer The observer to register
+ * @param eventType The event type to match
+ * @param bindings The bindings to match
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
+ * java.lang.Class, java.lang.annotation.Annotation[])
+ */
+ public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
+ {
+ this.eventManager.addObserver(observer, eventType, bindings);
+ return this;
+ }
+
+ public <T> Manager addObserver(ObserverImpl<T> observer)
+ {
+ this.eventManager.addObserver(observer, observer.getEventType(), observer.getBindingsAsArray());
+ return this;
+ }
+
+ /**
+ * Registers an observer for a given event type literal and binding types
+ *
+ * @param observer The observer to register
+ * @param eventType The event type literal to match
+ * @param bindings The bindings to match
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
+ * javax.inject.TypeLiteral, java.lang.annotation.Annotation[])
+ */
+ public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
+ {
+ eventManager.addObserver(observer, eventType.getType(), bindings);
+ return this;
+ }
+
+ /**
+ * Fires an event object with given event object for given bindings
+ *
+ * @param event The event object to pass along
+ * @param bindings The binding types to match
+ *
+ * @see javax.inject.manager.Manager#fireEvent(java.lang.Object,
+ * java.lang.annotation.Annotation[])
+ */
+ public void fireEvent(Object event, Annotation... bindings)
+ {
+ // Check the event object for template parameters which are not allowed by
+ // the spec.
+ if (Reflections.isParameterizedType(event.getClass()))
+ {
+ throw new IllegalArgumentException("Event type " + event.getClass().getName() + " is not allowed because it is a generic");
+ }
+ // Also check that the binding types are truly binding types
+ for (Annotation binding : bindings)
+ {
+ if (!Reflections.isBindings(binding))
+ {
+ throw new IllegalArgumentException("Event type " + event.getClass().getName() + " cannot be fired with non-binding type " + binding.getClass().getName() + " specified");
+ }
+ }
+
+ // Get the observers for this event. Although resolveObservers is
+ // parameterized, this method is not, so we have to use
+ // Observer<Object> for observers.
+ Set<Observer<Object>> observers = resolveObservers(event, bindings);
+ eventManager.notifyObservers(observers, event);
+ }
+
+ /**
+ * Gets an active context of the given scope. Throws an exception if there
+ * are no active contexts found or if there are too many matches
+ *
+ * @param scopeType The scope to match
+ * @return A single active context of the given scope
+ *
+ * @see javax.inject.manager.Manager#getContext(java.lang.Class)
+ */
+ public Context getContext(Class<? extends Annotation> scopeType)
+ {
+ List<Context> activeContexts = new ArrayList<Context>();
+ for (Context context : contexts.getContext(scopeType))
+ {
+ if (context.isActive())
+ {
+ activeContexts.add(context);
+ }
+ }
+ if (activeContexts.isEmpty())
+ {
+ throw new ContextNotActiveException("No active contexts for scope type " + scopeType.getName());
+ }
+ if (activeContexts.size() > 1)
+ {
+ throw new IllegalStateException("More than one context active for scope type " + scopeType.getName());
+ }
+ return activeContexts.iterator().next();
+ }
+
+ /**
+ * Direct access to built in contexts. For internal use.
+ *
+ * @param scopeType The scope type of the context
+ * @return The context
+ */
+ public Context getBuiltInContext(Class<? extends Annotation> scopeType)
+ {
+ return contexts.getBuiltInContext(scopeType);
+ }
+
+ /**
+ * Returns an instance of a bean
+ *
+ * @param bean The bean to instantiate
+ * @return An instance of the bean
+ *
+ * @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
+ */
+ public <T> T getInstance(Bean<T> bean)
+ {
+ return getInstance(bean, true);
+ }
+
+ public <T> T getInstance(Bean<T> bean, boolean create)
+ {
+ if (create)
+ {
+ return getInstance(bean, new CreationalContextImpl<T>(bean));
+ }
+ else
+ {
+ return getInstance(bean, null);
+ }
+ }
+
+ /**
+ * Returns an instance of a bean
+ *
+ * @param bean The bean to instantiate
+ * @return An instance of the bean
+ *
+ * @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
+ */
+ @SuppressWarnings("unchecked")
+ private <T> T getInstance(Bean<T> bean, CreationalContextImpl<T> creationalContext)
+ {
+ if (specializedBeans.containsKey(bean))
+ {
+ return getInstance((Bean<T>) specializedBeans.get(bean), creationalContext);
+ }
+ else if (getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal())
+ {
+ if (creationalContext != null || (creationalContext == null && getContext(bean.getScopeType()).get(bean) != null))
+ {
+ return (T) clientProxyProvider.getClientProxy(bean);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return getContext(bean.getScopeType()).get(bean, creationalContext);
+ }
+ }
+
+ public <T> T getInstanceToInject(InjectionPoint injectionPoint)
+ {
+ return this.<T> getInstanceToInject(injectionPoint, null);
+ }
+
+ public void injectNonContextualInstance(Object instance)
+ {
+ nonContextualInjector.inject(instance);
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
+ {
+ boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
+ try
+ {
+ if (registerInjectionPoint)
+ {
+ currentInjectionPoint.get().push(injectionPoint);
+ }
+ AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of(injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
+ Bean<T> resolvedBean = getBeanByType(element, element.getBindingsAsArray());
+ if (getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
+ {
+ throw new UnproxyableDependencyException("Attempting to inject an unproxyable normal scoped bean " + resolvedBean + " into " + injectionPoint);
+ }
+ if (creationalContext instanceof CreationalContextImpl)
+ {
+ CreationalContextImpl<?> ctx = (CreationalContextImpl<?>) creationalContext;
+ if (ctx.containsIncompleteInstance(resolvedBean))
+ {
+ return ctx.getIncompleteInstance(resolvedBean);
+ }
+ else
+ {
+ return getInstance(resolvedBean, ctx.getCreationalContext(resolvedBean));
+ }
+ }
+ else
+ {
+ return getInstance(resolvedBean);
+ }
+ }
+ finally
+ {
+ if (registerInjectionPoint)
+ {
+ currentInjectionPoint.get().pop();
+ }
+ }
+ }
+
+ /**
+ * Gets an instance by name, returning null if none is found and throwing an
+ * exception if too many beans match
+ *
+ * @param name The name to match
+ * @return An instance of the bean
+ *
+ * @see javax.inject.manager.Manager#getInstanceByName(java.lang.String)
+ */
+ public Object getInstanceByName(String name)
+ {
+ Set<Bean<?>> beans = resolveByName(name);
+ if (beans.size() == 0)
+ {
+ return null;
+ }
+ else if (beans.size() > 1)
+ {
+ throw new AmbiguousDependencyException("Resolved multiple Web Beans with " + name);
+ }
+ else
+ {
+ return getInstance(beans.iterator().next());
+ }
+ }
+
+ /**
+ * Returns an instance by API type and binding types
+ *
+ * @param type The API type to match
+ * @param bindings The binding types to match
+ * @return An instance of the bean
+ *
+ * @see javax.inject.manager.Manager#getInstanceByType(java.lang.Class,
+ * java.lang.annotation.Annotation[])
+ */
+ public <T> T getInstanceByType(Class<T> type, Annotation... bindings)
+ {
+ return getInstanceByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
+ }
+
+ /**
+ * Returns an instance by type literal and binding types
+ *
+ * @param type The type to match
+ * @param bindings The binding types to match
+ * @return An instance of the bean
+ *
+ * @see javax.inject.manager.Manager#getInstanceByType(javax.inject.TypeLiteral,
+ * java.lang.annotation.Annotation[])
+ */
+ public <T> T getInstanceByType(TypeLiteral<T> type, Annotation... bindings)
+ {
+ return getInstanceByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
+ }
+
+ /**
+ * Resolve an instance, verify that the resolved bean can be instantiated,
+ * and return
+ *
+ * @param element The annotated item to match
+ * @param bindings The binding types to match
+ * @return An instance of the bean
+ */
+ private <T> T getInstanceByType(AnnotatedItem<T, ?> element, Annotation... bindings)
+ {
+ return getInstance(getBeanByType(element, bindings));
+ }
+
+ public <T> Bean<T> getBeanByType(AnnotatedItem<T, ?> element, Annotation... bindings)
+ {
+ Set<Bean<T>> beans = resolveByType(element, bindings);
+ if (beans.size() == 0)
+ {
+ throw new UnsatisfiedDependencyException(element + "Unable to resolve any Web Beans");
+ }
+ else if (beans.size() > 1)
+ {
+ throw new AmbiguousDependencyException(element + "Resolved multiple Web Beans");
+ }
+ Bean<T> bean = beans.iterator().next();
+ boolean normalScoped = getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
+ if (normalScoped && !Beans.isBeanProxyable(bean))
+ {
+ throw new UnproxyableDependencyException("Normal scoped bean " + bean + " is not proxyable");
+ }
+ return bean;
+ }
+
+ /**
+ * Removes an observer
+ *
+ * @param observer The observer to remove
+ * @param eventType The event type to match
+ * @param bindings the binding types to match
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#removeObserver(javax.event.Observer,
+ * java.lang.Class, java.lang.annotation.Annotation[])
+ */
+ public <T> Manager removeObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
+ {
+ this.eventManager.removeObserver(observer, eventType, bindings);
+ return this;
+ }
+
+ /**
+ * Removes an observer
+ *
+ * @param observer The observer to remove
+ * @param eventType The event type to match
+ * @param bindings the binding types to match
+ * @return A reference to the manager
+ *
+ * @see javax.inject.manager.Manager#removeObserver(javax.event.Observer,
+ * javax.inject.TypeLiteral, java.lang.annotation.Annotation[])
+ */
+ public <T> Manager removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
+ {
+ this.eventManager.removeObserver(observer, eventType.getRawType(), bindings);
+ return this;
+ }
+
+ /**
+ * Resolves a set of beans based on their name
+ *
+ * @param The name to match
+ * @return The set of matching beans
+ *
+ * @see javax.inject.manager.Manager#resolveByName(java.lang.String)
+ */
+ public Set<Bean<?>> resolveByName(String name)
+ {
+ return resolver.get(name);
+ }
+
+ /**
+ * Resolves a list of decorators based on API types and binding types Os
+ *
+ * @param types The set of API types to match
+ * @param bindings The binding types to match
+ * @return A list of matching decorators
+ *
+ * @see javax.inject.manager.Manager#resolveDecorators(java.util.Set,
+ * java.lang.annotation.Annotation[])
+ */
+ public List<Decorator> resolveDecorators(Set<Type> types, Annotation... bindings)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Resolves a list of interceptors based on interception type and interceptor
+ * bindings
+ *
+ * @param type The interception type to resolve
+ * @param interceptorBindings The binding types to match
+ * @return A list of matching interceptors
+ *
+ * @see javax.inject.manager.Manager#resolveInterceptors(javax.inject.manager.InterceptionType,
+ * java.lang.annotation.Annotation[])
+ */
+ public List<Interceptor> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Get the web bean resolver. For internal use
+ *
+ * @return The resolver
+ */
+ public Resolver getResolver()
+ {
+ return resolver;
+ }
+
+ public NamespaceManager getNamespaceManager()
+ {
+ return namespaceManager;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Manager\n");
+ buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n");
+ buffer.append("Registered contexts: " + contexts.keySet() + "\n");
+ buffer.append("Registered beans: " + getBeans().size() + "\n");
+ buffer.append("Specialized beans: " + specializedBeans.size() + "\n");
+ return buffer.toString();
+ }
+
+ public Manager parse(InputStream xmlStream)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Manager createActivity()
+ {
+ return newChildManager(this);
+ }
+
+ public Manager setCurrent(Class<? extends Annotation> scopeType)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return services;
+ }
+
+ /**
+ * Accesses the factory used to create each instance of InjectionPoint that
+ * is injected into web beans.
+ *
+ * @return the factory
+ */
+ public InjectionPoint getInjectionPoint()
+ {
+ if (!currentInjectionPoint.get().empty())
+ {
+ return currentInjectionPoint.get().peek();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Map<Bean<?>, Bean<?>> getSpecializedBeans()
+ {
+ // TODO make this unmodifiable after deploy!
+ return specializedBeans;
+ }
+
+ // Serialization
+
+ protected Object readResolve()
+ {
+ return CurrentManager.rootManager();
+ }
+
+ /**
+ * Provides access to the executor service used for asynchronous tasks.
+ *
+ * @return the ExecutorService for this manager
+ */
+ public ExecutorService getTaskExecutor()
+ {
+ return taskExecutor;
+ }
+
+ public void shutdown()
+ {
+ log.trace("Ending application");
+ shutdownExecutors();
+ ApplicationContext.INSTANCE.destroy();
+ ApplicationContext.INSTANCE.setActive(false);
+ ApplicationContext.INSTANCE.setBeanStore(null);
+ getServices().get(NamingContext.class).unbind(ManagerImpl.JNDI_KEY);
+ }
+
+ /**
+ * Shuts down any executor services in the manager.
+ */
+ protected void shutdownExecutors()
+ {
+ taskExecutor.shutdown();
+ try
+ {
+ // Wait a while for existing tasks to terminate
+ if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
+ {
+ taskExecutor.shutdownNow(); // Cancel currently executing tasks
+ // Wait a while for tasks to respond to being cancelled
+ if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
+ {
+ // Log the error here
+ }
+ }
+ }
+ catch (InterruptedException ie)
+ {
+ // (Re-)Cancel if current thread also interrupted
+ taskExecutor.shutdownNow();
+ // Preserve interrupt status
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ protected ClientProxyProvider getClientProxyProvider()
+ {
+ return clientProxyProvider;
+ }
+
+ protected ContextMap getContexts()
+ {
+ return contexts;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -1,1002 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans;
-
-import java.io.InputStream;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import javax.context.Context;
-import javax.context.ContextNotActiveException;
-import javax.context.CreationalContext;
-import javax.event.Observer;
-import javax.inject.AmbiguousDependencyException;
-import javax.inject.BindingType;
-import javax.inject.DeploymentException;
-import javax.inject.DuplicateBindingTypeException;
-import javax.inject.Production;
-import javax.inject.Standard;
-import javax.inject.TypeLiteral;
-import javax.inject.UnproxyableDependencyException;
-import javax.inject.UnsatisfiedDependencyException;
-import javax.inject.manager.Bean;
-import javax.inject.manager.Decorator;
-import javax.inject.manager.InjectionPoint;
-import javax.inject.manager.InterceptionType;
-import javax.inject.manager.Interceptor;
-import javax.inject.manager.Manager;
-
-import org.jboss.webbeans.bean.DisposalMethodBean;
-import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.NewEnterpriseBean;
-import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.bean.proxy.ClientProxyProvider;
-import org.jboss.webbeans.bootstrap.api.ServiceRegistry;
-import org.jboss.webbeans.context.ApplicationContext;
-import org.jboss.webbeans.context.ContextMap;
-import org.jboss.webbeans.context.CreationalContextImpl;
-import org.jboss.webbeans.el.NamespaceManager;
-import org.jboss.webbeans.event.EventManager;
-import org.jboss.webbeans.event.ObserverImpl;
-import org.jboss.webbeans.injection.NonContextualInjector;
-import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
-import org.jboss.webbeans.injection.resolution.Resolver;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.log.Log;
-import org.jboss.webbeans.log.Logging;
-import org.jboss.webbeans.manager.api.WebBeansManager;
-import org.jboss.webbeans.metadata.MetaDataCache;
-import org.jboss.webbeans.resources.spi.NamingContext;
-import org.jboss.webbeans.util.Beans;
-import org.jboss.webbeans.util.Proxies;
-import org.jboss.webbeans.util.Reflections;
-
-/**
- * Implementation of the Web Beans Manager.
- *
- * Essentially a singleton for registering Beans, Contexts, Observers,
- * Interceptors etc. as well as providing resolution
- *
- * @author Pete Muir
- *
- */
-public class RootManager implements WebBeansManager, Serializable
-{
-
- private static final Log log = Logging.getLog(RootManager.class);
-
- private static final long serialVersionUID = 3021562879133838561L;
-
- // The JNDI key to place the manager under
- public static final String JNDI_KEY = "java:app/Manager";
-
- // The enabled deployment types from web-beans.xml
- private transient List<Class<? extends Annotation>> enabledDeploymentTypes;
-
- // The Web Beans event manager
- private transient final EventManager eventManager;
-
- // An executor service for asynchronous tasks
- private transient final ExecutorService taskExecutor = Executors.newSingleThreadExecutor();
-
- // An injection point metadata beans factory
- private transient final ThreadLocal<Stack<InjectionPoint>> currentInjectionPoint;
-
- // The bean resolver
- private transient final Resolver resolver;
-
- // The registered contexts
- private transient final ContextMap contextMap;
-
- // The client proxy pool
- private transient final ClientProxyProvider clientProxyProvider;
-
- // The registered beans
- private transient List<Bean<?>> beans;
-
- // The registered beans, mapped by implementation class
- private transient final Map<Class<?>, EnterpriseBean<?>> newEnterpriseBeanMap;
-
- private transient final Map<String, RIBean<?>> riBeans;
-
- private transient final ServiceRegistry services;
-
- private final transient Map<Bean<?>, Bean<?>> specializedBeans;
-
- private final transient NonContextualInjector nonContextualInjector;
-
- private final transient NamespaceManager namespaceManager;
-
- /**
- * Create a new manager
- *
- * @param ejbServices the ejbResolver to use
- */
- public RootManager(ServiceRegistry simpleServiceRegistry)
- {
- this.services = simpleServiceRegistry;
- this.beans = new CopyOnWriteArrayList<Bean<?>>();
- this.newEnterpriseBeanMap = new ConcurrentHashMap<Class<?>, EnterpriseBean<?>>();
- this.riBeans = new ConcurrentHashMap<String, RIBean<?>>();
- this.resolver = new Resolver(this);
- this.clientProxyProvider = new ClientProxyProvider();
- this.contextMap = new ContextMap();
- this.eventManager = new EventManager(this);
- this.currentInjectionPoint = new ThreadLocal<Stack<InjectionPoint>>()
- {
- @Override
- protected Stack<InjectionPoint> initialValue()
- {
- return new Stack<InjectionPoint>();
- }
- };
- this.specializedBeans = new HashMap<Bean<?>, Bean<?>>();
- this.nonContextualInjector = new NonContextualInjector(this);
- this.namespaceManager = new NamespaceManager();
- List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
- defaultEnabledDeploymentTypes.add(0, Standard.class);
- defaultEnabledDeploymentTypes.add(1, Production.class);
- setEnabledDeploymentTypes(defaultEnabledDeploymentTypes);
- }
-
- /**
- * Set up the enabled deployment types, if none are specified by the user,
- * the default @Production and @Standard are used. For internal use.
- *
- * @param enabledDeploymentTypes The enabled deployment types from
- * web-beans.xml
- */
- protected void checkEnabledDeploymentTypes()
- {
- if (!this.enabledDeploymentTypes.get(0).equals(Standard.class))
- {
- throw new DeploymentException("@Standard must be the lowest precedence deployment type");
- }
- }
-
- protected void addWebBeansDeploymentTypes()
- {
- if (!this.enabledDeploymentTypes.contains(WebBean.class))
- {
- this.enabledDeploymentTypes.add(1, WebBean.class);
- }
- }
-
- /**
- * Registers a bean with the manager
- *
- * @param bean The bean to register
- * @return A reference to manager
- *
- * @see javax.inject.manager.Manager#addBean(javax.inject.manager.Bean)
- */
- public Manager addBean(Bean<?> bean)
- {
- if (beans.contains(bean))
- {
- return this;
- }
- resolver.clear();
- beans.add(bean);
- namespaceManager.register(bean);
- return this;
- }
-
- /**
- * Resolve the disposal method for the given producer method. For internal
- * use.
- *
- * @param apiType The API type to match
- * @param bindings The binding types to match
- * @return The set of matching disposal methods
- */
- public <T> Set<DisposalMethodBean<T>> resolveDisposalBeans(Class<T> apiType, Annotation... bindings)
- {
- // Correct?
- Set<Bean<T>> beans = resolveByType(apiType, bindings);
- Set<DisposalMethodBean<T>> disposalBeans = new HashSet<DisposalMethodBean<T>>();
- for (Bean<T> bean : beans)
- if (bean instanceof DisposalMethodBean)
- disposalBeans.add((DisposalMethodBean<T>) bean);
- return disposalBeans;
- }
-
- /**
- * Resolves observers for given event and bindings
- *
- * @param event The event to match
- * @param bindings The binding types to match
- * @return The set of matching observers
- *
- * @see javax.inject.manager.Manager#resolveObservers(java.lang.Object,
- * java.lang.annotation.Annotation[])
- */
- @SuppressWarnings("unchecked")
- public <T> Set<Observer<T>> resolveObservers(T event, Annotation... bindings)
- {
- Class<?> clazz = event.getClass();
- for (Annotation annotation : bindings)
- {
- if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
- {
- throw new IllegalArgumentException("Not a binding type " + annotation);
- }
- }
- HashSet<Annotation> bindingAnnotations = new HashSet<Annotation>(Arrays.asList(bindings));
- if (bindingAnnotations.size() < bindings.length)
- {
- throw new DuplicateBindingTypeException("Duplicate binding types: " + bindings);
- }
- Type t = new Reflections.HierarchyDiscovery(clazz).getResolvedType();
- for (Type type : Reflections.getActualTypeArguments(clazz))
- {
- if (type instanceof WildcardType)
- {
- throw new IllegalArgumentException("Cannot resolve an event type parameterized with a wildcard " + clazz);
- }
- if (type instanceof TypeVariable)
- {
- throw new IllegalArgumentException("Cannot resolve an event type parameterized with a type parameter " + clazz);
- }
- }
- return eventManager.getObservers(event, bindings);
- }
-
- /**
- * A strongly ordered, unmodifiable list of enabled deployment types
- *
- * @return The ordered enabled deployment types known to the manager
- */
- public List<Class<? extends Annotation>> getEnabledDeploymentTypes()
- {
- return Collections.unmodifiableList(enabledDeploymentTypes);
- }
-
- /**
- * Set the enabled deployment types
- *
- * @param enabledDeploymentTypes
- */
- public void setEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
- {
- this.enabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>(enabledDeploymentTypes);
- checkEnabledDeploymentTypes();
- addWebBeansDeploymentTypes();
- }
-
- /**
- * Resolves beans by API type and binding types
- *
- * @param type The API type to match
- * @param bindings The binding types to match
- * @return The set of matching beans
- *
- * @see javax.inject.manager.Manager#resolveByType(java.lang.Class,
- * java.lang.annotation.Annotation[])
- */
- public <T> Set<Bean<T>> resolveByType(Class<T> type, Annotation... bindings)
- {
- return resolveByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
- }
-
- /**
- * Resolves beans by API type literal and binding types
- *
- * @param type The API type literal to match
- * @param bindings The binding types to match
- * @return The set of matching beans
- *
- * @see javax.inject.manager.Manager#resolveByType(javax.inject.TypeLiteral,
- * java.lang.annotation.Annotation[])
- */
- public <T> Set<Bean<T>> resolveByType(TypeLiteral<T> type, Annotation... bindings)
- {
- return resolveByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
- }
-
- public <T> Set<Bean<T>> resolveByType(AnnotatedItem<T, ?> element, InjectionPoint injectionPoint, Annotation... bindings)
- {
- boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
- try
- {
- if (registerInjectionPoint)
- {
- currentInjectionPoint.get().push(injectionPoint);
- }
- return resolveByType(element, bindings);
- }
- finally
- {
- if (registerInjectionPoint)
- {
- currentInjectionPoint.get().pop();
- }
- }
- }
-
- /**
- * Check the resolution request is valid, and then ask the resolver to
- * perform the resolution. For internal use.
- *
- * @param element The item to resolve
- * @param bindings The binding types to match
- * @return The set of matching beans
- */
- public <T> Set<Bean<T>> resolveByType(AnnotatedItem<T, ?> element, Annotation... bindings)
- {
- for (Annotation annotation : element.getAnnotationsAsSet())
- {
- if (!getServices().get(MetaDataCache.class).getBindingTypeModel(annotation.annotationType()).isValid())
- {
- throw new IllegalArgumentException("Not a binding type " + annotation);
- }
- }
- for (Type type : element.getActualTypeArguments())
- {
- if (type instanceof WildcardType)
- {
- throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
- }
- if (type instanceof TypeVariable)
- {
- throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
- }
- }
- if (bindings.length > element.getMetaAnnotations(BindingType.class).size())
- {
- throw new DuplicateBindingTypeException("Duplicate bindings (" + Arrays.asList(bindings) + ") type passed " + element.toString());
- }
- return resolver.get(element);
- }
-
- /**
- * Wraps a collection of beans into a thread safe list. Since this overwrites
- * any existing list of beans in the manager, this should only be done on
- * startup and other controlled situations. Also maps the beans by
- * implementation class. For internal use.
- *
- * @param beans The set of beans to add
- * @return A reference to the manager
- */
- // TODO Build maps in the deployer :-)
- public void setBeans(Set<RIBean<?>> beans)
- {
- synchronized (beans)
- {
- this.beans = new CopyOnWriteArrayList<Bean<?>>(beans);
- for (RIBean<?> bean : beans)
- {
- if (bean instanceof NewEnterpriseBean)
- {
- newEnterpriseBeanMap.put(bean.getType(), (EnterpriseBean<?>) bean);
- }
- riBeans.put(bean.getId(), bean);
- namespaceManager.register(bean);
- }
- resolver.clear();
- }
- }
-
- /**
- * Gets the class-mapped beans. For internal use.
- *
- * @return The bean map
- */
- public Map<Class<?>, EnterpriseBean<?>> getNewEnterpriseBeanMap()
- {
- return newEnterpriseBeanMap;
- }
-
- /**
- * The beans registered with the Web Bean manager. For internal use
- *
- * @return The list of known beans
- */
- public List<Bean<?>> getBeans()
- {
- return Collections.unmodifiableList(beans);
- }
-
- public Map<String, RIBean<?>> getRiBeans()
- {
- return Collections.unmodifiableMap(riBeans);
- }
-
- /**
- * Registers a context with the manager
- *
- * @param context The context to add
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addContext(javax.context.Context)
- */
- public Manager addContext(Context context)
- {
- contextMap.add(context);
- return this;
- }
-
- /**
- * Registers a decorator with the manager
- *
- * @param decorator The decorator to register
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addDecorator(javax.inject.manager.Decorator)
- */
- public Manager addDecorator(Decorator decorator)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /**
- * Registers an interceptor with the manager
- *
- * @param interceptor The interceptor to register
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addInterceptor(javax.inject.manager.Interceptor)
- */
- public Manager addInterceptor(Interceptor interceptor)
- {
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- /**
- * Registers an observer for a given event type and binding types
- *
- * @param observer The observer to register
- * @param eventType The event type to match
- * @param bindings The bindings to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
- * java.lang.Class, java.lang.annotation.Annotation[])
- */
- public <T> Manager addObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
- {
- this.eventManager.addObserver(observer, eventType, bindings);
- return this;
- }
-
- public <T> Manager addObserver(ObserverImpl<T> observer)
- {
- this.eventManager.addObserver(observer, observer.getEventType(), observer.getBindingsAsArray());
- return this;
- }
-
- /**
- * Registers an observer for a given event type literal and binding types
- *
- * @param observer The observer to register
- * @param eventType The event type literal to match
- * @param bindings The bindings to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#addObserver(javax.event.Observer,
- * javax.inject.TypeLiteral, java.lang.annotation.Annotation[])
- */
- public <T> Manager addObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
- {
- eventManager.addObserver(observer, eventType.getType(), bindings);
- return this;
- }
-
- /**
- * Fires an event object with given event object for given bindings
- *
- * @param event The event object to pass along
- * @param bindings The binding types to match
- *
- * @see javax.inject.manager.Manager#fireEvent(java.lang.Object,
- * java.lang.annotation.Annotation[])
- */
- public void fireEvent(Object event, Annotation... bindings)
- {
- // Check the event object for template parameters which are not allowed by
- // the spec.
- if (Reflections.isParameterizedType(event.getClass()))
- {
- throw new IllegalArgumentException("Event type " + event.getClass().getName() + " is not allowed because it is a generic");
- }
- // Also check that the binding types are truly binding types
- for (Annotation binding : bindings)
- {
- if (!Reflections.isBindings(binding))
- {
- throw new IllegalArgumentException("Event type " + event.getClass().getName() + " cannot be fired with non-binding type " + binding.getClass().getName() + " specified");
- }
- }
-
- // Get the observers for this event. Although resolveObservers is
- // parameterized, this method is not, so we have to use
- // Observer<Object> for observers.
- Set<Observer<Object>> observers = resolveObservers(event, bindings);
- eventManager.notifyObservers(observers, event);
- }
-
- /**
- * Gets an active context of the given scope. Throws an exception if there
- * are no active contexts found or if there are too many matches
- *
- * @param scopeType The scope to match
- * @return A single active context of the given scope
- *
- * @see javax.inject.manager.Manager#getContext(java.lang.Class)
- */
- public Context getContext(Class<? extends Annotation> scopeType)
- {
- List<Context> activeContexts = new ArrayList<Context>();
- for (Context context : contextMap.getContext(scopeType))
- {
- if (context.isActive())
- {
- activeContexts.add(context);
- }
- }
- if (activeContexts.isEmpty())
- {
- throw new ContextNotActiveException("No active contexts for scope type " + scopeType.getName());
- }
- if (activeContexts.size() > 1)
- {
- throw new IllegalStateException("More than one context active for scope type " + scopeType.getName());
- }
- return activeContexts.iterator().next();
- }
-
- /**
- * Direct access to built in contexts. For internal use.
- *
- * @param scopeType The scope type of the context
- * @return The context
- */
- public Context getBuiltInContext(Class<? extends Annotation> scopeType)
- {
- return contextMap.getBuiltInContext(scopeType);
- }
-
- /**
- * Returns an instance of a bean
- *
- * @param bean The bean to instantiate
- * @return An instance of the bean
- *
- * @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
- */
- public <T> T getInstance(Bean<T> bean)
- {
- return getInstance(bean, true);
- }
-
- public <T> T getInstance(Bean<T> bean, boolean create)
- {
- if (create)
- {
- return getInstance(bean, new CreationalContextImpl<T>(bean));
- }
- else
- {
- return getInstance(bean, null);
- }
- }
-
- /**
- * Returns an instance of a bean
- *
- * @param bean The bean to instantiate
- * @return An instance of the bean
- *
- * @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
- */
- @SuppressWarnings("unchecked")
- private <T> T getInstance(Bean<T> bean, CreationalContextImpl<T> creationalContext)
- {
- if (specializedBeans.containsKey(bean))
- {
- return getInstance((Bean<T>) specializedBeans.get(bean), creationalContext);
- }
- else if (getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal())
- {
- if (creationalContext != null || (creationalContext == null && getContext(bean.getScopeType()).get(bean) != null))
- {
- return (T) clientProxyProvider.getClientProxy(bean);
- }
- else
- {
- return null;
- }
- }
- else
- {
- return getContext(bean.getScopeType()).get(bean, creationalContext);
- }
- }
-
- public <T> T getInstanceToInject(InjectionPoint injectionPoint)
- {
- return this.<T> getInstanceToInject(injectionPoint, null);
- }
-
- public void injectNonContextualInstance(Object instance)
- {
- nonContextualInjector.inject(instance);
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getInstanceToInject(InjectionPoint injectionPoint, CreationalContext<?> creationalContext)
- {
- boolean registerInjectionPoint = !injectionPoint.getType().equals(InjectionPoint.class);
- try
- {
- if (registerInjectionPoint)
- {
- currentInjectionPoint.get().push(injectionPoint);
- }
- AnnotatedItem<T, ?> element = ResolvableAnnotatedClass.of(injectionPoint.getType(), injectionPoint.getBindings().toArray(new Annotation[0]));
- Bean<T> resolvedBean = getBeanByType(element, element.getBindingsAsArray());
- if (getServices().get(MetaDataCache.class).getScopeModel(resolvedBean.getScopeType()).isNormal() && !Proxies.isTypeProxyable(injectionPoint.getType()))
- {
- throw new UnproxyableDependencyException("Attempting to inject an unproxyable normal scoped bean " + resolvedBean + " into " + injectionPoint);
- }
- if (creationalContext instanceof CreationalContextImpl)
- {
- CreationalContextImpl<?> ctx = (CreationalContextImpl<?>) creationalContext;
- if (ctx.containsIncompleteInstance(resolvedBean))
- {
- return ctx.getIncompleteInstance(resolvedBean);
- }
- else
- {
- return getInstance(resolvedBean, ctx.getCreationalContext(resolvedBean));
- }
- }
- else
- {
- return getInstance(resolvedBean);
- }
- }
- finally
- {
- if (registerInjectionPoint)
- {
- currentInjectionPoint.get().pop();
- }
- }
- }
-
- /**
- * Gets an instance by name, returning null if none is found and throwing an
- * exception if too many beans match
- *
- * @param name The name to match
- * @return An instance of the bean
- *
- * @see javax.inject.manager.Manager#getInstanceByName(java.lang.String)
- */
- public Object getInstanceByName(String name)
- {
- Set<Bean<?>> beans = resolveByName(name);
- if (beans.size() == 0)
- {
- return null;
- }
- else if (beans.size() > 1)
- {
- throw new AmbiguousDependencyException("Resolved multiple Web Beans with " + name);
- }
- else
- {
- return getInstance(beans.iterator().next());
- }
- }
-
- /**
- * Returns an instance by API type and binding types
- *
- * @param type The API type to match
- * @param bindings The binding types to match
- * @return An instance of the bean
- *
- * @see javax.inject.manager.Manager#getInstanceByType(java.lang.Class,
- * java.lang.annotation.Annotation[])
- */
- public <T> T getInstanceByType(Class<T> type, Annotation... bindings)
- {
- return getInstanceByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
- }
-
- /**
- * Returns an instance by type literal and binding types
- *
- * @param type The type to match
- * @param bindings The binding types to match
- * @return An instance of the bean
- *
- * @see javax.inject.manager.Manager#getInstanceByType(javax.inject.TypeLiteral,
- * java.lang.annotation.Annotation[])
- */
- public <T> T getInstanceByType(TypeLiteral<T> type, Annotation... bindings)
- {
- return getInstanceByType(ResolvableAnnotatedClass.of(type, bindings), bindings);
- }
-
- /**
- * Resolve an instance, verify that the resolved bean can be instantiated,
- * and return
- *
- * @param element The annotated item to match
- * @param bindings The binding types to match
- * @return An instance of the bean
- */
- private <T> T getInstanceByType(AnnotatedItem<T, ?> element, Annotation... bindings)
- {
- return getInstance(getBeanByType(element, bindings));
- }
-
- public <T> Bean<T> getBeanByType(AnnotatedItem<T, ?> element, Annotation... bindings)
- {
- Set<Bean<T>> beans = resolveByType(element, bindings);
- if (beans.size() == 0)
- {
- throw new UnsatisfiedDependencyException(element + "Unable to resolve any Web Beans");
- }
- else if (beans.size() > 1)
- {
- throw new AmbiguousDependencyException(element + "Resolved multiple Web Beans");
- }
- Bean<T> bean = beans.iterator().next();
- boolean normalScoped = getServices().get(MetaDataCache.class).getScopeModel(bean.getScopeType()).isNormal();
- if (normalScoped && !Beans.isBeanProxyable(bean))
- {
- throw new UnproxyableDependencyException("Normal scoped bean " + bean + " is not proxyable");
- }
- return bean;
- }
-
- /**
- * Removes an observer
- *
- * @param observer The observer to remove
- * @param eventType The event type to match
- * @param bindings the binding types to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#removeObserver(javax.event.Observer,
- * java.lang.Class, java.lang.annotation.Annotation[])
- */
- public <T> Manager removeObserver(Observer<T> observer, Class<T> eventType, Annotation... bindings)
- {
- this.eventManager.removeObserver(observer, eventType, bindings);
- return this;
- }
-
- /**
- * Removes an observer
- *
- * @param observer The observer to remove
- * @param eventType The event type to match
- * @param bindings the binding types to match
- * @return A reference to the manager
- *
- * @see javax.inject.manager.Manager#removeObserver(javax.event.Observer,
- * javax.inject.TypeLiteral, java.lang.annotation.Annotation[])
- */
- public <T> Manager removeObserver(Observer<T> observer, TypeLiteral<T> eventType, Annotation... bindings)
- {
- this.eventManager.removeObserver(observer, eventType.getRawType(), bindings);
- return this;
- }
-
- /**
- * Resolves a set of beans based on their name
- *
- * @param The name to match
- * @return The set of matching beans
- *
- * @see javax.inject.manager.Manager#resolveByName(java.lang.String)
- */
- public Set<Bean<?>> resolveByName(String name)
- {
- return resolver.get(name);
- }
-
- /**
- * Resolves a list of decorators based on API types and binding types Os
- *
- * @param types The set of API types to match
- * @param bindings The binding types to match
- * @return A list of matching decorators
- *
- * @see javax.inject.manager.Manager#resolveDecorators(java.util.Set,
- * java.lang.annotation.Annotation[])
- */
- public List<Decorator> resolveDecorators(Set<Type> types, Annotation... bindings)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Resolves a list of interceptors based on interception type and interceptor
- * bindings
- *
- * @param type The interception type to resolve
- * @param interceptorBindings The binding types to match
- * @return A list of matching interceptors
- *
- * @see javax.inject.manager.Manager#resolveInterceptors(javax.inject.manager.InterceptionType,
- * java.lang.annotation.Annotation[])
- */
- public List<Interceptor> resolveInterceptors(InterceptionType type, Annotation... interceptorBindings)
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Get the web bean resolver. For internal use
- *
- * @return The resolver
- */
- public Resolver getResolver()
- {
- return resolver;
- }
-
- public NamespaceManager getNamespaceManager()
- {
- return namespaceManager;
- }
-
- /**
- * Gets a string representation
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append("Manager\n");
- buffer.append("Enabled deployment types: " + getEnabledDeploymentTypes() + "\n");
- buffer.append("Registered contexts: " + contextMap.keySet() + "\n");
- buffer.append("Registered beans: " + getBeans().size() + "\n");
- buffer.append("Specialized beans: " + specializedBeans.size() + "\n");
- return buffer.toString();
- }
-
- public Manager parse(InputStream xmlStream)
- {
- throw new UnsupportedOperationException();
- }
-
- public Manager createActivity()
- {
- return new ChildManager(this);
- }
-
- public Manager setCurrent(Class<? extends Annotation> scopeType)
- {
- throw new UnsupportedOperationException();
- }
-
- public ServiceRegistry getServices()
- {
- return services;
- }
-
- /**
- * Accesses the factory used to create each instance of InjectionPoint that
- * is injected into web beans.
- *
- * @return the factory
- */
- public InjectionPoint getInjectionPoint()
- {
- if (!currentInjectionPoint.get().empty())
- {
- return currentInjectionPoint.get().peek();
- }
- else
- {
- return null;
- }
- }
-
- /**
- *
- * @return
- */
- public Map<Bean<?>, Bean<?>> getSpecializedBeans()
- {
- // TODO make this unmodifiable after deploy!
- return specializedBeans;
- }
-
- // Serialization
-
- protected Object readResolve()
- {
- return CurrentManager.rootManager();
- }
-
- /**
- * Provides access to the executor service used for asynchronous tasks.
- *
- * @return the ExecutorService for this manager
- */
- public ExecutorService getTaskExecutor()
- {
- return taskExecutor;
- }
-
- public void shutdown()
- {
- log.trace("Ending application");
- shutdownExecutors();
- ApplicationContext.INSTANCE.destroy();
- ApplicationContext.INSTANCE.setActive(false);
- ApplicationContext.INSTANCE.setBeanStore(null);
- getServices().get(NamingContext.class).unbind(RootManager.JNDI_KEY);
- }
-
- /**
- * Shuts down any executor services in the manager.
- */
- protected void shutdownExecutors()
- {
- taskExecutor.shutdown();
- try
- {
- // Wait a while for existing tasks to terminate
- if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
- {
- taskExecutor.shutdownNow(); // Cancel currently executing tasks
- // Wait a while for tasks to respond to being cancelled
- if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
- {
- // Log the error here
- }
- }
- }
- catch (InterruptedException ie)
- {
- // (Re-)Cancel if current thread also interrupted
- taskExecutor.shutdownNow();
- // Preserve interrupt status
- Thread.currentThread().interrupt();
- }
- }
-
-}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -34,7 +34,7 @@
import javax.inject.Standard;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentInstancesStore;
import org.jboss.webbeans.conversation.ConversationImpl;
@@ -62,7 +62,7 @@
{
@SuppressWarnings("unchecked")
- private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, RootManager.class, ConversationImpl.class));
+ private static Set<Class<?>> STANDARD_WEB_BEAN_CLASSES = new HashSet<Class<?>>(Arrays.asList(Event.class, ManagerImpl.class, ConversationImpl.class));
private boolean proxyable;
@@ -112,7 +112,7 @@
// If the type a primitive?
private boolean primitive;
// The Web Beans manager
- protected RootManager manager;
+ protected ManagerImpl manager;
protected boolean _serializable;
@@ -128,7 +128,7 @@
*
* @param manager The Web Beans manager
*/
- public AbstractBean(RootManager manager)
+ public AbstractBean(ManagerImpl manager)
{
super(manager);
this.manager = manager;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractClassBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -33,7 +33,7 @@
import javax.inject.Produces;
import javax.inject.Production;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.FieldInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
@@ -75,7 +75,7 @@
* @param type The type
* @param manager The Web Beans manager
*/
- protected AbstractClassBean(AnnotatedClass<T> type, RootManager manager)
+ protected AbstractClassBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(manager);
this.annotatedItem = type;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractProducerBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -37,7 +37,7 @@
import javax.inject.Produces;
import javax.inject.manager.InjectionPoint;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.CreationalContextImpl;
import org.jboss.webbeans.context.DependentContext;
@@ -71,7 +71,7 @@
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- public AbstractProducerBean(AbstractClassBean<?> declaringBean, RootManager manager)
+ public AbstractProducerBean(AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
super(manager);
this.declaringBean = declaringBean;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/DisposalMethodBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -17,7 +17,7 @@
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
import org.jboss.webbeans.injection.MethodInjectionPoint;
@@ -29,7 +29,7 @@
public class DisposalMethodBean<T> extends AbstractBean<T, Method>
{
- protected DisposalMethodBean(RootManager manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
+ protected DisposalMethodBean(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
{
super(manager);
this.disposalMethod = disposalMethod;
@@ -62,7 +62,7 @@
this.type = (Class<T>) disposalMethod.getAnnotatedParameters(Disposes.class).get(0).getRawType();
}
- public static <T> DisposalMethodBean<T> of(RootManager manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
+ public static <T> DisposalMethodBean<T> of(ManagerImpl manager, AnnotatedMethod<T> disposalMethod, Bean<?> declaringBean)
{
return new DisposalMethodBean<T>(manager, disposalMethod, declaringBean);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -36,7 +36,7 @@
import javax.inject.DefinitionException;
import javax.interceptor.Interceptor;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
import org.jboss.webbeans.bean.proxy.EnterpriseBeanProxyMethodHandler;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
@@ -79,7 +79,7 @@
* @param manager the current manager
* @return An Enterprise Web Bean
*/
- public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager, BeanDeployerEnvironment environment)
+ public static <T> EnterpriseBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager, BeanDeployerEnvironment environment)
{
return new EnterpriseBean<T>(clazz, manager, environment);
}
@@ -90,7 +90,7 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected EnterpriseBean(AnnotatedClass<T> type, RootManager manager, BeanDeployerEnvironment environment)
+ protected EnterpriseBean(AnnotatedClass<T> type, ManagerImpl manager, BeanDeployerEnvironment environment)
{
super(type, manager);
initType();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewEnterpriseBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -24,7 +24,7 @@
import javax.context.Dependent;
import javax.inject.Standard;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.literal.NewLiteral;
@@ -45,7 +45,7 @@
* @param manager The Web Beans manager
* @return a new NewEnterpriseBean instance
*/
- public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz, RootManager manager, BeanDeployerEnvironment environment)
+ public static <T> NewEnterpriseBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager, BeanDeployerEnvironment environment)
{
return new NewEnterpriseBean<T>(clazz, manager, environment);
}
@@ -56,7 +56,7 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewEnterpriseBean(AnnotatedClass<T> type, RootManager manager, BeanDeployerEnvironment environment)
+ protected NewEnterpriseBean(AnnotatedClass<T> type, ManagerImpl manager, BeanDeployerEnvironment environment)
{
super(type, manager, environment);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/NewSimpleBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import javax.context.Dependent;
import javax.inject.Standard;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.literal.NewLiteral;
@@ -45,7 +45,7 @@
* @param manager The Web Beans manager
* @return a new NewSimpleBean instance
*/
- public static <T> NewSimpleBean<T> of(AnnotatedClass<T> clazz, RootManager manager)
+ public static <T> NewSimpleBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager)
{
return new NewSimpleBean<T>(clazz, manager);
}
@@ -56,7 +56,7 @@
* @param type An annotated class
* @param manager The Web Beans manager
*/
- protected NewSimpleBean(AnnotatedClass<T> type, RootManager manager)
+ protected NewSimpleBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -21,7 +21,7 @@
import javax.context.CreationalContext;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.util.Names;
@@ -47,7 +47,7 @@
* @param manager the current manager
* @return A producer Web Bean
*/
- public static <T> ProducerFieldBean<T> of(AnnotatedField<T> field, AbstractClassBean<?> declaringBean, RootManager manager)
+ public static <T> ProducerFieldBean<T> of(AnnotatedField<T> field, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
return new ProducerFieldBean<T>(field, declaringBean, manager);
}
@@ -59,7 +59,7 @@
* @param declaringBean The declaring bean
* @param manager The Web Beans manager
*/
- protected ProducerFieldBean(AnnotatedField<T> field, AbstractClassBean<?> declaringBean, RootManager manager)
+ protected ProducerFieldBean(AnnotatedField<T> field, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
super(declaringBean, manager);
this.field = field;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerMethodBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -29,7 +29,7 @@
import javax.inject.Disposes;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.MethodInjectionPoint;
import org.jboss.webbeans.injection.ParameterInjectionPoint;
@@ -63,12 +63,12 @@
* @param manager the current manager
* @return A producer Web Bean
*/
- public static <T> ProducerMethodBean<T> of(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, RootManager manager)
+ public static <T> ProducerMethodBean<T> of(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
return new ProducerMethodBean<T>(method, declaringBean, manager);
}
- protected ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, RootManager manager)
+ protected ProducerMethodBean(AnnotatedMethod<T> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
super(declaringBean, manager);
this.method = MethodInjectionPoint.of(this, method);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -24,7 +24,7 @@
import javax.context.Dependent;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
@@ -38,9 +38,9 @@
private static final ConcurrentMap<String, AtomicInteger> ids = new ConcurrentHashMap<String, AtomicInteger>();
- private final RootManager manager;
+ private final ManagerImpl manager;
- protected RIBean(RootManager manager)
+ protected RIBean(ManagerImpl manager)
{
super(manager);
this.manager = manager;
@@ -54,7 +54,7 @@
}
@Override
- protected RootManager getManager()
+ protected ManagerImpl getManager()
{
return manager;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -27,7 +27,7 @@
import javax.inject.DefinitionException;
import javax.inject.Initializer;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentStorageRequest;
@@ -83,7 +83,7 @@
* @param manager the current manager
* @return A Web Bean
*/
- public static <T> SimpleBean<T> of(AnnotatedClass<T> clazz, RootManager manager)
+ public static <T> SimpleBean<T> of(AnnotatedClass<T> clazz, ManagerImpl manager)
{
return new SimpleBean<T>(clazz, manager);
}
@@ -94,7 +94,7 @@
* @param type The type of the bean
* @param manager The Web Beans manager
*/
- protected SimpleBean(AnnotatedClass<T> type, RootManager manager)
+ protected SimpleBean(AnnotatedClass<T> type, ManagerImpl manager)
{
super(type, manager);
initType();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -9,13 +9,13 @@
import javax.context.CreationalContext;
import javax.inject.manager.InjectionPoint;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
public abstract class AbstractFacadeBean<T> extends AbstractStandardBean<T>
{
- protected AbstractFacadeBean(RootManager manager)
+ protected AbstractFacadeBean(ManagerImpl manager)
{
super(manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractStandardBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -9,7 +9,7 @@
import javax.context.Dependent;
import javax.inject.Standard;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.injection.AnnotatedInjectionPoint;
@@ -23,7 +23,7 @@
private final String id;
- protected AbstractStandardBean(RootManager manager)
+ protected AbstractStandardBean(ManagerImpl manager)
{
super(manager);
this.id = getClass().getSimpleName();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -11,7 +11,7 @@
import javax.inject.Obtains;
import javax.inject.TypeLiteral;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.event.EventImpl;
import org.jboss.webbeans.injection.resolution.AnnotatedItemTransformer;
import org.jboss.webbeans.literal.FiresLiteral;
@@ -27,12 +27,12 @@
private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends Annotation>>(Arrays.asList(Obtains.class));
- public static AbstractFacadeBean<Event<?>> of(RootManager manager)
+ public static AbstractFacadeBean<Event<?>> of(ManagerImpl manager)
{
return new EventBean(manager);
}
- protected EventBean(RootManager manager)
+ protected EventBean(ManagerImpl manager)
{
super(manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import javax.context.CreationalContext;
import javax.inject.manager.InjectionPoint;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
/**
* Bean for InjectionPoint metadata
@@ -48,12 +48,12 @@
* @param manager The RI manager implementation
* @return a new bean for this injection point
*/
- public static InjectionPointBean of(RootManager manager)
+ public static InjectionPointBean of(ManagerImpl manager)
{
return new InjectionPointBean(manager);
}
- protected InjectionPointBean(RootManager manager)
+ protected InjectionPointBean(ManagerImpl manager)
{
super(manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -11,7 +11,7 @@
import javax.inject.TypeLiteral;
import org.jboss.webbeans.InstanceImpl;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.injection.resolution.AnnotatedItemTransformer;
import org.jboss.webbeans.literal.ObtainsLiteral;
@@ -26,12 +26,12 @@
public static final AnnotatedItemTransformer TRANSFORMER = new FacadeBeanAnnotatedItemTransformer(TYPE, OBTAINS);
- public static AbstractFacadeBean<Instance<?>> of(RootManager manager)
+ public static AbstractFacadeBean<Instance<?>> of(ManagerImpl manager)
{
return new InstanceBean(manager);
}
- protected InstanceBean(RootManager manager)
+ protected InstanceBean(ManagerImpl manager)
{
super(manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/ManagerBean.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -11,32 +11,32 @@
import javax.context.CreationalContext;
import javax.inject.manager.Manager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
-public class ManagerBean extends AbstractStandardBean<RootManager>
+public class ManagerBean extends AbstractStandardBean<ManagerImpl>
{
- private static final Set<Type> TYPES = new HashSet<Type>(Arrays.asList(RootManager.class, Manager.class));
+ private static final Set<Type> TYPES = new HashSet<Type>(Arrays.asList(ManagerImpl.class, Manager.class));
- public static final ManagerBean of(RootManager manager)
+ public static final ManagerBean of(ManagerImpl manager)
{
return new ManagerBean(manager);
}
- protected ManagerBean(RootManager manager)
+ protected ManagerBean(ManagerImpl manager)
{
super(manager);
}
- public RootManager create(CreationalContext<RootManager> creationalContext)
+ public ManagerImpl create(CreationalContext<ManagerImpl> creationalContext)
{
return getManager();
}
@Override
- public Class<RootManager> getType()
+ public Class<ManagerImpl> getType()
{
- return RootManager.class;
+ return ManagerImpl.class;
}
@Override
@@ -45,7 +45,7 @@
return TYPES;
}
- public void destroy(RootManager instance)
+ public void destroy(ManagerImpl instance)
{
// No-op
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -14,7 +14,7 @@
import javax.inject.Realizes;
import javax.inject.UnsatisfiedDependencyException;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.DisposalMethodBean;
import org.jboss.webbeans.bean.EnterpriseBean;
@@ -50,11 +50,11 @@
private final BeanDeployerEnvironment environment;
private final Set<AnnotatedClass<?>> classes;
- private final RootManager manager;
+ private final ManagerImpl manager;
private final ClassTransformer classTransformer;
- public BeanDeployer(RootManager manager, EjbDescriptorCache ejbDescriptors)
+ public BeanDeployer(ManagerImpl manager, EjbDescriptorCache ejbDescriptors)
{
this.manager = manager;
this.environment = new BeanDeployerEnvironment(ejbDescriptors);
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.standard.EventBean;
import org.jboss.webbeans.bean.standard.InjectionPointBean;
import org.jboss.webbeans.bean.standard.InstanceBean;
@@ -80,7 +80,7 @@
private static Log log = Logging.getLog(WebBeansBootstrap.class);
// The Web Beans manager
- private RootManager manager;
+ private ManagerImpl manager;
public WebBeansBootstrap()
{
// initialize default services
@@ -100,17 +100,17 @@
log.info("EJB services not available. Session beans will be simple beans, injection into non-contextual EJBs, injection of @Resource, @PersistenceContext and @EJB in simple beans, injection of Java EE resources and JMS resources will not be available.");
}
addImplementationServices();
- this.manager = new RootManager(ServiceRegistries.unmodifiableServiceRegistry(getServices()));
+ this.manager = ManagerImpl.newRootManager(ServiceRegistries.unmodifiableServiceRegistry(getServices()));
try
{
- getServices().get(NamingContext.class).unbind(RootManager.JNDI_KEY);
+ getServices().get(NamingContext.class).unbind(ManagerImpl.JNDI_KEY);
}
catch (ExecutionException e)
{
}
finally
{
- getServices().get(NamingContext.class).bind(RootManager.JNDI_KEY, getManager());
+ getServices().get(NamingContext.class).bind(ManagerImpl.JNDI_KEY, getManager());
}
CurrentManager.setRootManager(manager);
initializeContexts();
@@ -130,7 +130,7 @@
}
- public RootManager getManager()
+ public ManagerImpl getManager()
{
return manager;
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -2,6 +2,7 @@
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
/**
* A namespace for bean names
@@ -13,12 +14,37 @@
{
private final String qualifiedName;
private final String name;
- private final Map<String, Namespace> children = new HashMap<String, Namespace>();
+ private final Map<String, Namespace> children;
- public Namespace(String name, String qualifiedName)
+ /**
+ * Create a new namespace hierarchy, creating copies of all children as
+ * children of this node
+ *
+ * @param namespace
+ */
+ public Namespace(Namespace namespace)
{
+ this(namespace.getName(), namespace.getQualifiedName());
+ for (Entry<String, Namespace> entry : namespace.getChildren().entrySet())
+ {
+ children.put(entry.getKey(), new Namespace(entry.getValue()));
+ }
+ }
+
+ /**
+ * Create a new, root, namespace
+ *
+ */
+ public Namespace()
+ {
+ this(null, null);
+ }
+
+ protected Namespace(String name, String qualifiedName)
+ {
this.name = name;
this.qualifiedName = qualifiedName;
+ this.children = new HashMap<String, Namespace>();
}
public Namespace putIfAbsent(String key)
@@ -47,6 +73,16 @@
return qualifiedName;
}
+ protected Map<String, Namespace> getChildren()
+ {
+ return children;
+ }
+
+ protected String getName()
+ {
+ return name;
+ }
+
public String qualifyName(String suffix)
{
return qualifiedName == null ? suffix : qualifiedName + "." + suffix;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -7,11 +7,11 @@
private final Namespace root;
- public NamespaceManager()
+ public NamespaceManager(Namespace root)
{
- root = new Namespace(null, null);
+ this.root = root;
}
-
+
public void register(Bean<?> bean)
{
if (bean.getName() != null && bean.getName().indexOf('.') > 0)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import javax.event.Observer;
import org.jboss.webbeans.FacadeImpl;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.util.Strings;
/**
@@ -41,7 +41,7 @@
private static final long serialVersionUID = 8130060821283091287L;
- public static <E> Event<E> of(Class<E> eventType, RootManager manager, Set<Annotation> bindings)
+ public static <E> Event<E> of(Class<E> eventType, ManagerImpl manager, Set<Annotation> bindings)
{
return new EventImpl<E>(eventType, manager, bindings);
}
@@ -54,7 +54,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- public EventImpl(Class<T> eventType, RootManager manager, Set<Annotation> bindings)
+ public EventImpl(Class<T> eventType, ManagerImpl manager, Set<Annotation> bindings)
{
super(eventType, manager, bindings);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventManager.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -28,7 +28,7 @@
import javax.event.Observer;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.log.Log;
import org.jboss.webbeans.log.Logging;
@@ -126,13 +126,13 @@
// The map of registered observers for a give
private final RegisteredObserversMap registeredObservers;
- private final RootManager manager;
+ private final ManagerImpl manager;
/**
* Initializes a new instance of the EventManager.
*/
- public EventManager(RootManager manager)
+ public EventManager(ManagerImpl manager)
{
registeredObservers = new RegisteredObserversMap();
this.manager = manager;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventObserver.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -26,7 +26,7 @@
import javax.inject.Current;
import javax.inject.DuplicateBindingTypeException;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Reflections;
import org.jboss.webbeans.util.Strings;
@@ -50,7 +50,7 @@
private final Type eventType;
private final List<Annotation> eventBindings;
private final Observer<T> observer;
- private final RootManager manager;
+ private final ManagerImpl manager;
/**
* Constructs a new wrapper for an observer.
@@ -59,7 +59,7 @@
* @param eventType The class of event being observed
* @param eventBindings The array of annotation event bindings, if any
*/
- public EventObserver(final Observer<T> observer, final Type eventType, RootManager manager, final Annotation... eventBindings)
+ public EventObserver(final Observer<T> observer, final Type eventType, ManagerImpl manager, final Annotation... eventBindings)
{
this.observer = observer;
this.eventType = eventType;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverFactory.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -17,7 +17,7 @@
package org.jboss.webbeans.event;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -38,7 +38,7 @@
* @param manager The Web Beans manager
* @return An observer implementation built from the method abstraction
*/
- public static <T> ObserverImpl<T> create(AnnotatedMethod<?> method, AbstractClassBean<?> declaringBean, RootManager manager)
+ public static <T> ObserverImpl<T> create(AnnotatedMethod<?> method, AbstractClassBean<?> declaringBean, ManagerImpl manager)
{
ObserverImpl<T> result = null;
if (manager.getServices().contains(TransactionServices.class) && TransactionalObserverImpl.isObserverMethodTransactional(method))
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/ObserverImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -35,7 +35,7 @@
import javax.inject.Produces;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.context.DependentInstancesStore;
@@ -61,7 +61,7 @@
protected final MethodInjectionPoint<?> observerMethod;
private final boolean conditional;
private final boolean asynchronous;
- protected RootManager manager;
+ protected ManagerImpl manager;
private final Type eventType;
private final Annotation[] bindings;
@@ -73,7 +73,7 @@
* @param observerBean The observer bean
* @param manager The Web Beans manager
*/
- protected ObserverImpl(final AnnotatedMethod<?> observer, final Bean<?> observerBean, final RootManager manager)
+ protected ObserverImpl(final AnnotatedMethod<?> observer, final Bean<?> observerBean, final ManagerImpl manager)
{
this.manager = manager;
this.observerBean = observerBean;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/TransactionalObserverImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -29,7 +29,7 @@
import javax.inject.manager.Bean;
import javax.transaction.Synchronization;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.transaction.spi.TransactionServices;
@@ -73,7 +73,7 @@
* @param observerBean The bean declaring the observer method
* @param manager The JCDI manager in use
*/
- protected TransactionalObserverImpl(AnnotatedMethod<?> observer, Bean<?> observerBean, RootManager manager)
+ protected TransactionalObserverImpl(AnnotatedMethod<?> observer, Bean<?> observerBean, ManagerImpl manager)
{
super(observer, observerBean, manager);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ConstructorInjectionPoint.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -30,7 +30,7 @@
import javax.context.CreationalContext;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.ForwardingAnnotatedConstructor;
@@ -96,7 +96,7 @@
return delegate().getBindings();
}
- public T newInstance(RootManager manager, CreationalContext<?> creationalContext)
+ public T newInstance(ManagerImpl manager, CreationalContext<?> creationalContext)
{
try
{
@@ -156,7 +156,7 @@
* @param manager The Web Beans manager
* @return The object array of looked up values
*/
- protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Object specialVal, Class<? extends Annotation> specialParam, RootManager manager, CreationalContext<?> creationalContext)
+ protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Object specialVal, Class<? extends Annotation> specialParam, ManagerImpl manager, CreationalContext<?> creationalContext)
{
Object[] parameterValues = new Object[parameters.size()];
Iterator<ParameterInjectionPoint<?>> iterator = parameters.iterator();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/FieldInjectionPoint.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import javax.context.CreationalContext;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.ForwardingAnnotatedField;
@@ -69,7 +69,7 @@
return delegate().getAnnotationStore().getBindings();
}
- public void inject(Object declaringInstance, RootManager manager, CreationalContext<?> creationalContext)
+ public void inject(Object declaringInstance, ManagerImpl manager, CreationalContext<?> creationalContext)
{
try
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/MethodInjectionPoint.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -29,7 +29,7 @@
import javax.context.CreationalContext;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.ForwardingAnnotatedMethod;
@@ -95,7 +95,7 @@
return delegate().getBindings();
}
- public T invoke(Object declaringInstance, RootManager manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
+ public T invoke(Object declaringInstance, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
{
try
{
@@ -117,7 +117,7 @@
}
@SuppressWarnings("unchecked")
- public T invokeWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, RootManager manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
+ public T invokeWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
{
try
{
@@ -138,7 +138,7 @@
return null;
}
- public T invokeOnInstance(Object declaringInstance, RootManager manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
+ public T invokeOnInstance(Object declaringInstance, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
{
try
{
@@ -168,7 +168,7 @@
}
@SuppressWarnings("unchecked")
- public T invokeOnInstanceWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, RootManager manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
+ public T invokeOnInstanceWithSpecialValue(Object declaringInstance, Class<? extends Annotation> annotatedParameter, Object parameter, ManagerImpl manager, CreationalContext<?> creationalContext, Class<? extends RuntimeException> exceptionTypeToThrow)
{
try
{
@@ -247,7 +247,7 @@
* @param manager The Web Beans manager
* @return The object array of looked up values
*/
- protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Class<? extends Annotation> specialParam, Object specialVal, RootManager manager, CreationalContext<?> creationalContext)
+ protected Object[] getParameterValues(List<ParameterInjectionPoint<?>> parameters, Class<? extends Annotation> specialParam, Object specialVal, ManagerImpl manager, CreationalContext<?> creationalContext)
{
Object[] parameterValues = new Object[parameters.size()];
Iterator<ParameterInjectionPoint<?>> iterator = parameters.iterator();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/NonContextualInjector.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -3,8 +3,7 @@
import java.util.Set;
import java.util.concurrent.Callable;
-import org.jboss.webbeans.RootManager;
-import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.resources.ClassTransformer;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.collections.ConcurrentCache;
@@ -13,12 +12,12 @@
{
private final ConcurrentCache<Class<?>, Set<FieldInjectionPoint<?>>> instances;
- private final RootManager manager;
+ private final ManagerImpl manager;
- public NonContextualInjector(RootManager manager)
+ public NonContextualInjector(ManagerImpl manager)
{
- this.manager = manager;
this.instances = new ConcurrentCache<Class<?>, Set<FieldInjectionPoint<?>>>();
+ this.manager = manager;
}
public void inject(final Object instance)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ParameterInjectionPoint.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -23,7 +23,7 @@
import javax.context.CreationalContext;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.ForwardingAnnotatedParameter;
@@ -77,7 +77,7 @@
throw new UnsupportedOperationException();
}
- public T getValueToInject(RootManager manager, CreationalContext<?> creationalContext)
+ public T getValueToInject(ManagerImpl manager, CreationalContext<?> creationalContext)
{
return manager.<T>getInstanceToInject(this, creationalContext);
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -30,7 +30,7 @@
import javax.inject.TypeLiteral;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.standard.EventBean;
import org.jboss.webbeans.bean.standard.InstanceBean;
import org.jboss.webbeans.introspector.AnnotatedItem;
@@ -59,25 +59,23 @@
// The resolved names
private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
// The Web Beans manager
- private RootManager manager;
+ private final ManagerImpl manager;
private final Set<AnnotatedItemTransformer> transformers;
/**
* Constructor
*
- * @param manager The Web Beans manager
*/
- public Resolver(RootManager manager)
+ public Resolver(ManagerImpl manager)
{
+ this.manager = manager;
this.injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?, ?>, Set<Bean<?>>>();
this.resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
this.transformers = new HashSet<AnnotatedItemTransformer>();
transformers.add(EventBean.TRANSFORMER);
transformers.add(InstanceBean.TRANSFORMER);
- this.manager = manager;
}
-
/**
* Add multiple injection points for later resolving using
* {@link #registerInjectionPoint(AnnotatedItem)}. Useful during bootstrap.
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/introspector/jlr/AnnotatedConstructorImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -25,7 +25,7 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotatedConstructor;
import org.jboss.webbeans.introspector.AnnotatedParameter;
import org.jboss.webbeans.introspector.AnnotatedType;
@@ -181,7 +181,7 @@
* @throws InstantiationException
* @throws IllegalArgumentException
*
- * @see org.jboss.webbeans.introspector.AnnotatedConstructor#newInstance(RootManager)
+ * @see org.jboss.webbeans.introspector.AnnotatedConstructor#newInstance(ManagerImpl)
*/
public T newInstance(Object... parameters) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/metadata/MergedStereotypes.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -21,7 +21,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.introspector.AnnotationStore.AnnotationMap;
/**
@@ -42,14 +42,14 @@
// The supported scopes
private final Set<Class<? extends Annotation>> supportedScopes;
- private final RootManager manager;
+ private final ManagerImpl manager;
/**
* Constructor
*
* @param stereotypeAnnotations The stereotypes to merge
*/
- public MergedStereotypes(Set<Annotation> stereotypeAnnotations, RootManager manager)
+ public MergedStereotypes(Set<Annotation> stereotypeAnnotations, ManagerImpl manager)
{
this.possibleDeploymentTypes = new AnnotationMap();
this.possibleScopeTypes = new HashSet<Annotation>();
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/util/Beans.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -24,7 +24,7 @@
import javax.inject.Produces;
import javax.inject.manager.Bean;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.EnterpriseBean;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.injection.FieldInjectionPoint;
@@ -47,7 +47,7 @@
* @param bean The bean to inspect
* @return True if passivating, false otherwise
*/
- public static boolean isPassivatingBean(Bean<?> bean, RootManager manager)
+ public static boolean isPassivatingBean(Bean<?> bean, ManagerImpl manager)
{
if (bean instanceof EnterpriseBean)
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SessionBeanElementChecker.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -2,7 +2,7 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.XmlConstants;
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/checker/bean/ext/SimpleBeanElementChecker.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -6,7 +6,7 @@
import org.dom4j.Element;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.xml.ParseXmlHelper;
Modified: ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java
===================================================================
--- ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/porting-package/src/main/java/org/jboss/webbeans/tck/StandaloneContainersImpl.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -7,7 +7,7 @@
import org.jboss.testharness.api.DeploymentException;
import org.jboss.testharness.spi.StandaloneContainers;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.MockWebBeanDiscovery;
@@ -27,7 +27,7 @@
lifecycle.initialize();
try
{
- RootManager manager = lifecycle.getBootstrap().getManager();
+ ManagerImpl manager = lifecycle.getBootstrap().getManager();
if (enabledDeploymentTypes != null)
{
manager.setEnabledDeploymentTypes(enabledDeploymentTypes);
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/AbstractWebBeansTest.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -11,7 +11,7 @@
import org.jboss.testharness.AbstractTest;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.context.DependentContext;
import org.jboss.webbeans.util.EnumerationIterable;
import org.testng.ITestContext;
@@ -54,7 +54,7 @@
protected static final int BUILT_IN_BEANS = 3;
- protected RootManager manager;
+ protected ManagerImpl manager;
public static boolean visited = false;
Modified: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -9,7 +9,7 @@
import javax.inject.manager.Bean;
import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.RootManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
import org.jboss.webbeans.mock.MockServletLifecycle;
@@ -22,7 +22,7 @@
{
private MockServletLifecycle lifecycle;
- private RootManager manager;
+ private ManagerImpl manager;
@BeforeClass
public void beforeClass() throws Throwable
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-04 15:54:52 UTC (rev 2298)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/activities/ActivitiesTest.java 2009-04-04 18:25:00 UTC (rev 2299)
@@ -3,7 +3,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -14,6 +13,7 @@
import javax.event.Observer;
import javax.inject.AnnotationLiteral;
import javax.inject.Production;
+import javax.inject.UnsatisfiedDependencyException;
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
import javax.inject.manager.Manager;
@@ -22,6 +22,7 @@
import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.jsr299.tck.ForwardingBean;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -29,6 +30,13 @@
public class ActivitiesTest extends AbstractJSR299Test
{
+ private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>();
+
+ static
+ {
+ DEFAULT_BINDINGS.add(new CurrentLiteral());
+ }
+
private Bean<?> createDummyBean(Manager manager, final Type injectionPointType)
{
final Set<InjectionPoint> injectionPoints = new HashSet<InjectionPoint>();
@@ -38,8 +46,6 @@
types.add(Object.class);
final Bean<?> bean = new Bean<Object>(manager)
{
-
-
@Override
public Set<Annotation> getBindings()
@@ -120,7 +126,7 @@
public Set<Annotation> getBindings()
{
- return Collections.emptySet();
+ return DEFAULT_BINDINGS;
}
public Member getMember()
@@ -168,7 +174,7 @@
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section="11.6", id="b"),
@SpecAssertion(section="11.6", id="m")
@@ -182,7 +188,7 @@
assert childActivity.resolveByType(Cow.class).iterator().next().equals(bean);
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertion(section="11.6", id="c")
public void testBeanBelongingToParentActivityCanBeInjectedIntoChildActivityBean()
{
@@ -218,16 +224,26 @@
assert Fox.isObserved();
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertion(section="11.6", id="l")
public void testContextObjectBelongingToParentBelongsToChild()
{
- getCurrentManager().addContext(new DummyContext());
+ Context context = new DummyContext()
+ {
+
+ @Override
+ public boolean isActive()
+ {
+ return true;
+ }
+
+ };
+ getCurrentManager().addContext(context);
Manager childActivity = getCurrentManager().createActivity();
assert childActivity.getContext(Dummy.class) != null;
}
- @Test(groups="ri-broken")
+ @Test
@SpecAssertion(section="11.6", id="o")
public void testBeanBelongingToChildActivityCannotBeInjectedIntoParentActivityBean()
{
@@ -238,9 +254,9 @@
assert getCurrentManager().resolveByType(Object.class, new AnnotationLiteral<Tame>() {}).size() == 0;
}
- @Test(groups="ri-broken")
- @SpecAssertion(section="11.6", id="p")
- public void testInstanceProcessedByCurrentActivity()
+ @Test(expectedExceptions=UnsatisfiedDependencyException.class)
+ @SpecAssertion(section="11.6", id="r")
+ public void testInstanceProcessedByParentActivity()
{
Context dummyContext = new DummyContext();
getCurrentManager().addContext(dummyContext);
@@ -265,7 +281,7 @@
}
});
- assert getCurrentManager().getInstanceByType(Field.class).get() == null;
+ getCurrentManager().getInstanceByType(Field.class).get();
}
@Test(groups="ri-broken")
15 years, 9 months
[webbeans-commits] Webbeans SVN: r2298 - in ri/trunk: impl/src/main/java/org/jboss/webbeans/el and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-04-04 11:54:52 -0400 (Sat, 04 Apr 2009)
New Revision: 2298
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
ri/trunk/tests/pom.xml
Log:
WBRI-218
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-04 13:53:33 UTC (rev 2297)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/RootManager.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -67,6 +67,7 @@
import org.jboss.webbeans.context.ApplicationContext;
import org.jboss.webbeans.context.ContextMap;
import org.jboss.webbeans.context.CreationalContextImpl;
+import org.jboss.webbeans.el.NamespaceManager;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.NonContextualInjector;
@@ -135,6 +136,8 @@
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
private final transient NonContextualInjector nonContextualInjector;
+
+ private final transient NamespaceManager namespaceManager;
/**
* Create a new manager
@@ -161,6 +164,7 @@
};
this.specializedBeans = new HashMap<Bean<?>, Bean<?>>();
this.nonContextualInjector = new NonContextualInjector(this);
+ this.namespaceManager = new NamespaceManager();
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
defaultEnabledDeploymentTypes.add(0, Standard.class);
defaultEnabledDeploymentTypes.add(1, Production.class);
@@ -206,6 +210,7 @@
}
resolver.clear();
beans.add(bean);
+ namespaceManager.register(bean);
return this;
}
@@ -398,6 +403,7 @@
newEnterpriseBeanMap.put(bean.getType(), (EnterpriseBean<?>) bean);
}
riBeans.put(bean.getId(), bean);
+ namespaceManager.register(bean);
}
resolver.clear();
}
@@ -867,6 +873,11 @@
{
return resolver;
}
+
+ public NamespaceManager getNamespaceManager()
+ {
+ return namespaceManager;
+ }
/**
* Gets a string representation
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-04-04 13:53:33 UTC (rev 2297)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/Namespace.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -11,31 +11,47 @@
*/
public class Namespace
{
+ private final String qualifiedName;
+ private final String name;
+ private final Map<String, Namespace> children = new HashMap<String, Namespace>();
- private String name;
- private Map<String, Namespace> children = new HashMap<String, Namespace>();
-
- public Namespace(String name)
+ public Namespace(String name, String qualifiedName)
{
this.name = name;
+ this.qualifiedName = qualifiedName;
}
- public Namespace getChild(String key)
+ public Namespace putIfAbsent(String key)
{
Namespace result = children.get(key);
if (result==null)
{
- result = new Namespace( getQualifiedName(key) + '.' );
- children.put(name, result);
+ result = new Namespace( key, qualifyName(key) );
+ children.put(key, result);
}
return result;
}
+
+ public Namespace get(String key)
+ {
+ return children.get(key);
+ }
+
+ public boolean contains(String key)
+ {
+ return children.containsKey(key);
+ }
- public String getQualifiedName(String key)
+ public String getQualifiedName()
{
- return name==null ? key : name + key;
+ return qualifiedName;
}
+ public String qualifyName(String suffix)
+ {
+ return qualifiedName == null ? suffix : qualifiedName + "." + suffix;
+ }
+
@Override
public int hashCode()
{
@@ -45,15 +61,14 @@
@Override
public boolean equals(Object other)
{
- if ( !(other instanceof Namespace) )
+ if (other instanceof Namespace)
{
- return false;
+ Namespace that = (Namespace) other;
+ return this.getQualifiedName().equals(that.getQualifiedName());
}
else
{
- Namespace ns = (Namespace) other;
- return this.name==ns.name ||
- ( this.name!=null && this.name.equals(ns.name) );
+ return false;
}
}
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -0,0 +1,34 @@
+package org.jboss.webbeans.el;
+
+import javax.inject.manager.Bean;
+
+public class NamespaceManager
+{
+
+ private final Namespace root;
+
+ public NamespaceManager()
+ {
+ root = new Namespace(null, null);
+ }
+
+ public void register(Bean<?> bean)
+ {
+ if (bean.getName() != null && bean.getName().indexOf('.') > 0)
+ {
+ String name = bean.getName().substring(0, bean.getName().lastIndexOf('.'));
+ String[] hierarchy = name.split("\\.");
+ Namespace namespace = root;
+ for (String s : hierarchy)
+ {
+ namespace = namespace.putIfAbsent(s);
+ }
+ }
+ }
+
+ public Namespace getRoot()
+ {
+ return root;
+ }
+
+}
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespaceManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java 2009-04-04 13:53:33 UTC (rev 2297)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/NamespacedResolver.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -1,110 +0,0 @@
-package org.jboss.webbeans.el;
-
-
-import javax.el.ELContext;
-import javax.inject.ExecutionException;
-
-import org.jboss.webbeans.CurrentManager;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.context.DependentInstancesStore;
-import org.jboss.webbeans.context.DependentStorageRequest;
-
-class NamespacedResolver
-{
-
- private final ELContext context;
- private final String property;
- private final Namespace namespace;
- private Object value;
-
- public NamespacedResolver(ELContext context, Namespace namespace, String property)
- {
- this.context = context;
- this.property = property;
- this.namespace = namespace;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public NamespacedResolver run()
- {
-
- try
- {
- new RunInDependentContext()
- {
-
- @Override
- protected void execute() throws Exception
- {
- value = CurrentManager.rootManager().getInstanceByName(namespace.getQualifiedName(property));
- if (value != null)
- {
- context.setPropertyResolved(true);
- }
- }
-
- }.run();
- }
- catch (Exception e)
- {
- throw new ExecutionException("Error resolving EL " + property, e);
- }
-
- if (!context.isPropertyResolved())
- {
- // look for a namespace
- value = namespace.getChild(property);
- if (value != null)
- {
- context.setPropertyResolved(true);
- }
- }
- return this;
- }
-
- static abstract class RunInDependentContext
- {
-
- private final DependentStorageRequest dependentStorageRequest;
-
- public RunInDependentContext()
- {
- dependentStorageRequest = DependentStorageRequest.of(new DependentInstancesStore(), new Object());
- }
-
- private void setup()
- {
- DependentContext.INSTANCE.setActive(true);
- DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
- }
-
- private void cleanup()
- {
- DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
- // TODO kinky
- dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
- DependentContext.INSTANCE.setActive(false);
- }
-
- protected abstract void execute() throws Exception;
-
- public final void run() throws Exception
- {
- try
- {
- setup();
- execute();
- }
- finally
- {
- cleanup();
- }
- }
-
- }
-
-}
\ No newline at end of file
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -0,0 +1,49 @@
+/**
+ *
+ */
+package org.jboss.webbeans.el;
+
+import org.jboss.webbeans.context.DependentContext;
+import org.jboss.webbeans.context.DependentInstancesStore;
+import org.jboss.webbeans.context.DependentStorageRequest;
+
+abstract class RunInDependentContext
+{
+
+ private final DependentStorageRequest dependentStorageRequest;
+
+ public RunInDependentContext()
+ {
+ dependentStorageRequest = DependentStorageRequest.of(new DependentInstancesStore(), new Object());
+ }
+
+ private void setup()
+ {
+ DependentContext.INSTANCE.setActive(true);
+ DependentContext.INSTANCE.startCollectingDependents(dependentStorageRequest);
+ }
+
+ private void cleanup()
+ {
+ DependentContext.INSTANCE.stopCollectingDependents(dependentStorageRequest);
+ // TODO kinky
+ dependentStorageRequest.getDependentInstancesStore().destroyDependentInstances(dependentStorageRequest.getKey());
+ DependentContext.INSTANCE.setActive(false);
+ }
+
+ protected abstract void execute() throws Exception;
+
+ public final void run() throws Exception
+ {
+ try
+ {
+ setup();
+ execute();
+ }
+ finally
+ {
+ cleanup();
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/RunInDependentContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-04 13:53:33 UTC (rev 2297)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/el/WebBeansELResolver.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -22,7 +22,10 @@
import javax.el.ELContext;
import javax.el.ELResolver;
+import javax.inject.ExecutionException;
+import org.jboss.webbeans.CurrentManager;
+
/**
* An EL-resolver against the named beans
*
@@ -30,9 +33,24 @@
*/
public class WebBeansELResolver extends ELResolver
{
-
- private static final Namespace ROOT = new Namespace(null);
+ private static final class ValueHolder<T>
+ {
+
+ private T value;
+
+ public T getValue()
+ {
+ return value;
+ }
+
+ public void setValue(T value)
+ {
+ this.value = value;
+ }
+
+ }
+
/**
* @see javax.el.ELResolver#getCommonPropertyType(ELContext, Object)
*/
@@ -68,14 +86,60 @@
{
if (property != null)
{
+ String propertyString = property.toString();
+ Namespace namespace = null;
if (base == null)
{
- return new NamespacedResolver(context, ROOT, property.toString()).run().getValue();
+ if (CurrentManager.rootManager().getNamespaceManager().getRoot().contains(propertyString))
+ {
+ context.setPropertyResolved(true);
+ return CurrentManager.rootManager().getNamespaceManager().getRoot().get(propertyString);
+ }
}
- else if (base instanceof Namespace)
+ else if (base instanceof Namespace)
{
- return new NamespacedResolver(context, (Namespace) base, property.toString()).run().getValue();
+ namespace = (Namespace) base;
+ // We're definitely the responsible party
+ context.setPropertyResolved(true);
+ if (namespace.contains(propertyString))
+ {
+ // There is a child namespace
+ return namespace.get(propertyString);
+ }
}
+ final String name;
+ if (namespace != null)
+ {
+ // Try looking in the manager for a bean
+ name = namespace.qualifyName(propertyString);
+ }
+ else
+ {
+ name = propertyString;
+ }
+ final ValueHolder<Object> holder = new ValueHolder<Object>();
+ try
+ {
+ new RunInDependentContext()
+ {
+
+ @Override
+ protected void execute() throws Exception
+ {
+ holder.setValue(CurrentManager.rootManager().getInstanceByName(name));
+ }
+
+ }.run();
+ }
+ catch (Exception e)
+ {
+ throw new ExecutionException("Error resolving property " + propertyString + " against base " + base, e);
+ }
+ if (holder.getValue() != null)
+ {
+ context.setPropertyResolved(true);
+ return holder.getValue();
+ }
}
return null;
}
Modified: ri/trunk/tests/pom.xml
===================================================================
--- ri/trunk/tests/pom.xml 2009-04-04 13:53:33 UTC (rev 2297)
+++ ri/trunk/tests/pom.xml 2009-04-04 15:54:52 UTC (rev 2298)
@@ -42,6 +42,16 @@
</dependency>
<dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-ri</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-api</artifactId>
<optional>true</optional>
Added: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java
===================================================================
--- ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java (rev 0)
+++ ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java 2009-04-04 15:54:52 UTC (rev 2298)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.unit.definition;
+
+import javax.el.ELContext;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.webbeans.mock.el.EL;
+import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
+import org.testng.annotations.Test;
+
+@Artifact
+public class ELResolverTest extends AbstractWebBeansTest
+{
+
+ @Test
+ public void testNonBeanDoesntResolveToNamespace()
+ {
+ ELContext elContext = EL.createELContext();
+ assert EL.EXPRESSION_FACTORY.createValueExpression(elContext, "#{foo.bar}", Object.class).getValue(elContext) == null;
+ }
+
+}
Property changes on: ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/definition/ELResolverTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 9 months