Author: pete.muir(a)jboss.org
Date: 2009-03-19 20:05:31 -0400 (Thu, 19 Mar 2009)
New Revision: 2118
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.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/FacadeBeanAnnotatedItemTransformer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/AnnotatedItemTransformer.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedItem.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/FiresLiteral.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
Removed:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EventBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/InstanceBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/Resolver.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/Foo.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.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/ManagerImpl.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/InjectionPointBean.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/event/EventImpl.java
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/implementation/enterprise/sbi/SessionBeanInterceptorTest.java
ri/trunk/tests/unit-tests.xml
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/event4/JavaSparrow_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/noninstance/NonInstanceTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/notypeparam/NoTypeParameterSpecifiedTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableBean_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/wildcard/NoWildcardTest.java
Log:
WBRI-156, WBRI-173
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-19 23:05:24
UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanValidator.java 2009-03-20 00:05:31
UTC (rev 2118)
@@ -17,16 +17,23 @@
package org.jboss.webbeans;
import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
+import javax.event.Event;
+import javax.event.Fires;
import javax.inject.AmbiguousDependencyException;
import javax.inject.DefinitionException;
import javax.inject.InconsistentSpecializationException;
+import javax.inject.Instance;
import javax.inject.New;
import javax.inject.NullableDependencyException;
+import javax.inject.Obtains;
import javax.inject.UnproxyableDependencyException;
import javax.inject.UnsatisfiedDependencyException;
import javax.inject.UnserializableDependencyException;
@@ -36,7 +43,7 @@
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.RIBean;
-import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
+import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
@@ -78,9 +85,11 @@
{
throw new DefinitionException("The injection point " +
injectionPoint + " is annotated with @New which cannot be combined with other binding
types");
}
+ checkFacadeInjectionPoint(injectionPoint, Obtains.class, Instance.class);
+ checkFacadeInjectionPoint(injectionPoint, Fires.class, Event.class);
Annotation[] bindings = injectionPoint.getBindings().toArray(new
Annotation[0]);
AnnotatedItem<?, ?> annotatedItem =
ResolvableAnnotatedClass.of(injectionPoint.getType(), bindings);
- Set<?> resolvedBeans = manager.resolveByType(annotatedItem, bindings);
+ Set<?> resolvedBeans = manager.resolveByType(annotatedItem,
injectionPoint, bindings);
if (resolvedBeans.isEmpty())
{
throw new UnsatisfiedDependencyException("The injection point "
+ injectionPoint + " with binding types " +
Names.annotationsToString(injectionPoint.getBindings()) + " in " + bean + "
has unsatisfied dependencies with binding types ");
@@ -133,5 +142,33 @@
Comparator<Class<? extends Annotation>> comparator = new
ListComparator<Class<? extends
Annotation>>(manager.getEnabledDeploymentTypes());
return comparator.compare(deploymentType, otherDeploymentType) > 0;
}
+
+ private void checkFacadeInjectionPoint(InjectionPoint injectionPoint, Class<?
extends Annotation> annotationType, Class<?> type)
+ {
+ if (injectionPoint.isAnnotationPresent(annotationType))
+ {
+ if (injectionPoint.getType() instanceof ParameterizedType)
+ {
+ ParameterizedType parameterizedType = (ParameterizedType)
injectionPoint.getType();
+ if (!type.isAssignableFrom((Class<?>) parameterizedType.getRawType()))
+ {
+ throw new DefinitionException("An injection point annotated " +
annotationType + " must have type " + type + " " + injectionPoint);
+ }
+ if (parameterizedType.getActualTypeArguments()[0] instanceof TypeVariable)
+ {
+ throw new DefinitionException("An injection point annotated " +
annotationType + " cannot have a type variable type parameter " +
injectionPoint);
+ }
+ if (parameterizedType.getActualTypeArguments()[0] instanceof WildcardType)
+ {
+ throw new DefinitionException("An injection point annotated " +
annotationType + " cannot have a wildcard type parameter " + injectionPoint);
+ }
+ }
+ else
+ {
+ throw new DefinitionException("An injection point annotated " +
annotationType + " must have a type parameter " + injectionPoint);
+ }
+ }
+
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-03-19 23:05:24 UTC
(rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java 2009-03-20 00:05:31 UTC
(rev 2118)
@@ -24,7 +24,7 @@
import javax.inject.DuplicateBindingTypeException;
import javax.inject.manager.Manager;
-import org.jboss.webbeans.util.Reflections;
+import org.jboss.webbeans.metadata.MetaDataCache;
/**
* Common implementation for binding-type-based helpers
@@ -35,6 +35,9 @@
*/
public abstract class FacadeImpl<T>
{
+
+ private static final Annotation[] EMPTY_BINDINGS = new Annotation[0];
+
// The binding types the helper operates on
protected final Set<? extends Annotation> bindings;
// The Web Beans manager
@@ -49,29 +52,31 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- protected FacadeImpl(Class<T> type, Manager manager, Annotation... bindings)
+ protected FacadeImpl(Class<T> type, Manager manager, Set<? extends
Annotation> bindings)
{
this.manager = manager;
this.type = type;
- this.bindings = mergeBindings(new HashSet<Annotation>(), bindings);
+ this.bindings = bindings;
}
/**
- * Merges and validates the current and new bindings
+ * Gets a string representation
*
- * Checks with an abstract method for annotations to exclude
- *
- * @param currentBindings Existing bindings
- * @param newBindings New bindings
- * @return The union of the bindings
+ * @return A string representation
*/
- protected Set<Annotation> mergeBindings(Set<? extends Annotation>
currentBindings, Annotation... newBindings)
+ @Override
+ public String toString()
{
+ return "Abstract facade implmentation";
+ }
+
+ protected Annotation[] mergeInBindings(Annotation... newBindings)
+ {
Set<Annotation> result = new HashSet<Annotation>();
- result.addAll(currentBindings);
+ result.addAll(bindings);
for (Annotation newAnnotation : newBindings)
{
- if (!Reflections.isBindings(newAnnotation))
+ if
(!MetaDataCache.instance().getBindingTypeModel(newAnnotation.annotationType()).isValid())
{
throw new IllegalArgumentException(newAnnotation + " is not a binding
for " + this);
}
@@ -79,42 +84,8 @@
{
throw new DuplicateBindingTypeException(newAnnotation + " is already
present in the bindings list for " + this);
}
- if (!getFilteredAnnotations().contains(newAnnotation.annotationType()))
- {
- result.add(newAnnotation);
- }
}
- return result;
+ return result.toArray(EMPTY_BINDINGS);
}
- /**
- * Gets a set of annotation classes to ignore
- *
- * @return A set of annotation classes to ignore
- */
- protected abstract Set<Class<? extends Annotation>>
getFilteredAnnotations();
-
- /**
- * Merges the binding this helper operates upon with the parameters
- *
- * @param bindings The bindings to merge
- *
- * @return The union of the binding types
- */
- protected Annotation[] mergeBindings(Annotation... newBindings)
- {
- return mergeBindings(bindings, newBindings).toArray(new Annotation[0]);
- }
-
- /**
- * Gets a string representation
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- return "Abstract facade implmentation";
- }
-
}
\ No newline at end of file
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-03-19 23:05:24
UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java 2009-03-20 00:05:31
UTC (rev 2118)
@@ -18,7 +18,6 @@
package org.jboss.webbeans;
import java.lang.annotation.Annotation;
-import java.util.Collections;
import java.util.Set;
import javax.inject.Instance;
@@ -34,6 +33,13 @@
*/
public class InstanceImpl<T> extends FacadeImpl<T> implements
Instance<T>
{
+
+
+ public static <I> Instance<I> of(Class<I> clazz, ManagerImpl
manager, Set<Annotation> annotations)
+ {
+ return new InstanceImpl<I>(clazz, manager, annotations);
+ }
+
/**
* Constructor
*
@@ -41,7 +47,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- public InstanceImpl(Class<T> type, Manager manager, Annotation... bindings)
+ private InstanceImpl(Class<T> type, Manager manager, Set<Annotation>
bindings)
{
super(type, manager, bindings);
}
@@ -57,7 +63,7 @@
*/
public T get(Annotation... bindings)
{
- return manager.getInstanceByType(type, mergeBindings(bindings));
+ return manager.getInstanceByType(type, mergeInBindings(bindings));
}
/**
@@ -71,19 +77,4 @@
return "Obtainable instance for type " + type + " and binding types
" + bindings;
}
- /**
- * Filters annotations from the binding type or parameter lists
- *
- * This implementation filters no annotations
- *
- * @return A set of annotations to filter
- *
- * @see org.jboss.webbeans.FacadeImpl#getFilteredAnnotations
- */
- @Override
- protected Set<Class<? extends Annotation>> getFilteredAnnotations()
- {
- return Collections.emptySet();
- }
-
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-19 23:05:24
UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/ManagerImpl.java 2009-03-20 00:05:31
UTC (rev 2118)
@@ -69,13 +69,12 @@
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.injection.NonContextualInjector;
-import org.jboss.webbeans.injection.ResolvableAnnotatedClass;
-import org.jboss.webbeans.injection.Resolver;
+import org.jboss.webbeans.injection.resolution.ResolvableAnnotatedClass;
+import org.jboss.webbeans.injection.resolution.Resolver;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.jlr.AnnotatedClassImpl;
-import org.jboss.webbeans.literal.NewLiteral;
import org.jboss.webbeans.manager.api.WebBeansManager;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
@@ -93,13 +92,11 @@
public class ManagerImpl implements WebBeansManager, Serializable
{
- private static final Annotation[] NEW_BINDING_ARRAY = {new NewLiteral()};
-
private static final long serialVersionUID = 3021562879133838561L;
// The JNDI key to place the manager under
public static final String JNDI_KEY = "java:comp/Manager";
-
+
// The enabled deployment types from web-beans.xml
private transient List<Class<? extends Annotation>>
enabledDeploymentTypes;
// The Web Beans event manager
@@ -110,10 +107,10 @@
// 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
@@ -129,20 +126,21 @@
private transient final Set<Decorator> decorators;
// The registered interceptors
private transient final Set<Interceptor> interceptors;
-
+
// The EJB resolver provided by the container
private transient final ServiceRegistry simpleServiceRegistry;
-
+
private transient final EjbDescriptorCache ejbDescriptorCache;
private final transient Map<Bean<?>, Bean<?>> specializedBeans;
private final transient NonContextualInjector nonContextualInjector;
-
+
/**
* Create a new manager
*
- * @param ejbServices the ejbResolver to use
+ * @param ejbServices
+ * the ejbResolver to use
*/
public ManagerImpl(ServiceRegistry simpleServiceRegistry)
{
@@ -172,13 +170,13 @@
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
+ * @param enabledDeploymentTypes
+ * The enabled deployment types from web-beans.xml
*/
protected void checkEnabledDeploymentTypes()
{
@@ -195,11 +193,12 @@
this.enabledDeploymentTypes.add(1, WebBean.class);
}
}
-
+
/**
* Registers a bean with the manager
*
- * @param bean The bean to register
+ * @param bean
+ * The bean to register
* @return A reference to manager
*
* @see javax.inject.manager.Manager#addBean(javax.inject.manager.Bean)
@@ -214,25 +213,29 @@
beans.add(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
+ * @param apiType
+ * The API type to match
+ * @param bindings
+ * The binding types to match
* @return The set of matching disposal methods
*/
public <T> Set<AnnotatedMethod<?>>
resolveDisposalMethods(Class<T> apiType, Annotation... bindings)
{
return Collections.emptySet();
}
-
+
/**
* Resolves observers for given event and bindings
*
- * @param event The event to match
- * @param bindings The binding types to match
+ * @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,
@@ -241,7 +244,7 @@
@SuppressWarnings("unchecked")
public <T> Set<Observer<T>> resolveObservers(T event, Annotation...
bindings)
{
- AnnotatedClass<T> element =
AnnotatedClassImpl.of((Class<T>)event.getClass());
+ AnnotatedClass<T> element = AnnotatedClassImpl.of((Class<T>)
event.getClass());
for (Annotation annotation : bindings)
{
if
(!MetaDataCache.instance().getBindingTypeModel(annotation.annotationType()).isValid())
@@ -267,7 +270,7 @@
}
return eventManager.getObservers(event, bindings);
}
-
+
/**
* A strongly ordered, unmodifiable list of enabled deployment types
*
@@ -277,7 +280,7 @@
{
return Collections.unmodifiableList(enabledDeploymentTypes);
}
-
+
/**
* Set the enabled deployment types
*
@@ -289,12 +292,14 @@
checkEnabledDeploymentTypes();
addWebBeansDeploymentTypes();
}
-
+
/**
* Resolves beans by API type and binding types
*
- * @param type The API type to match
- * @param bindings The binding types to match
+ * @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,
@@ -304,12 +309,14 @@
{
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
+ * @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,
@@ -319,13 +326,35 @@
{
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
+ * @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)
@@ -354,14 +383,15 @@
}
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
+ * @param beans
+ * The set of beans to add
* @return A reference to the manager
*/
// TODO Build maps in the deployer :-)
@@ -381,7 +411,7 @@
resolver.clear();
}
}
-
+
/**
* Gets the class-mapped beans. For internal use.
*
@@ -391,7 +421,7 @@
{
return newEnterpriseBeanMap;
}
-
+
/**
* The beans registered with the Web Bean manager. For internal use
*
@@ -406,11 +436,12 @@
{
return Collections.unmodifiableMap(riBeans);
}
-
+
/**
* Registers a context with the manager
*
- * @param context The context to add
+ * @param context
+ * The context to add
* @return A reference to the manager
*
* @see javax.inject.manager.Manager#addContext(javax.context.Context)
@@ -420,11 +451,12 @@
contextMap.add(context);
return this;
}
-
+
/**
* Registers a decorator with the manager
*
- * @param decorator The decorator to register
+ * @param decorator
+ * The decorator to register
* @return A reference to the manager
*
* @see javax.inject.manager.Manager#addDecorator(javax.inject.manager.Decorator)
@@ -434,11 +466,12 @@
decorators.add(decorator);
return this;
}
-
+
/**
* Registers an interceptor with the manager
*
- * @param interceptor The interceptor to register
+ * @param interceptor
+ * The interceptor to register
* @return A reference to the manager
*
* @see javax.inject.manager.Manager#addInterceptor(javax.inject.manager.Interceptor)
@@ -448,13 +481,16 @@
interceptors.add(interceptor);
return this;
}
-
+
/**
* 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
+ * @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,
@@ -471,13 +507,16 @@
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
+ * @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,
@@ -488,12 +527,14 @@
eventManager.addObserver(observer, eventType.getRawType(), 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
+ * @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[])
@@ -514,19 +555,20 @@
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
+ * @param scopeType
+ * The scope to match
* @return A single active context of the given scope
*
* @see javax.inject.manager.Manager#getContext(java.lang.Class)
@@ -551,22 +593,24 @@
}
return activeContexts.iterator().next();
}
-
+
/**
* Direct access to built in contexts. For internal use.
*
- * @param scopeType The scope type of the context
+ * @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
+ * @param bean
+ * The bean to instantiate
* @return An instance of the bean
*
* @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
@@ -591,7 +635,8 @@
/**
* Returns an instance of a bean
*
- * @param bean The bean to instantiate
+ * @param bean
+ * The bean to instantiate
* @return An instance of the bean
*
* @see javax.inject.manager.Manager#getInstance(javax.inject.manager.Bean)
@@ -611,7 +656,7 @@
}
else
{
- return null;
+ return null;
}
}
else
@@ -622,10 +667,10 @@
public <T> T getInstanceToInject(InjectionPoint injectionPoint)
{
- return this.<T>getInstanceToInject(injectionPoint, null);
+ return this.<T> getInstanceToInject(injectionPoint, null);
}
- public void injectNonContextualInstance(Object instance)
+ public void injectNonContextualInstance(Object instance)
{
nonContextualInjector.inject(instance);
}
@@ -667,13 +712,13 @@
}
}
}
-
-
+
/**
* 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
+ * @param name
+ * The name to match
* @return An instance of the bean
*
* @see javax.inject.manager.Manager#getInstanceByName(java.lang.String)
@@ -694,12 +739,14 @@
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
+ * @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,
@@ -709,13 +756,14 @@
{
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
+ * @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,
@@ -725,13 +773,15 @@
{
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
+ * @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)
@@ -749,7 +799,7 @@
else if (beans.size() > 1)
{
throw new AmbiguousDependencyException(element + "Resolved multiple Web
Beans");
- }
+ }
Bean<T> bean = beans.iterator().next();
boolean normalScoped =
MetaDataCache.instance().getScopeModel(bean.getScopeType()).isNormal();
if (normalScoped && !Beans.isBeanProxyable(bean))
@@ -758,13 +808,16 @@
}
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
+ * @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,
@@ -775,13 +828,16 @@
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
+ * @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,
@@ -792,11 +848,12 @@
this.eventManager.removeObserver(observer, eventType.getRawType(), bindings);
return this;
}
-
+
/**
* Resolves a set of beans based on their name
*
- * @param The name to match
+ * @param The
+ * name to match
* @return The set of matching beans
*
* @see javax.inject.manager.Manager#resolveByName(java.lang.String)
@@ -805,12 +862,14 @@
{
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
+ * @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,
@@ -820,13 +879,15 @@
{
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
+ * @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,
@@ -836,7 +897,7 @@
{
throw new UnsupportedOperationException();
}
-
+
/**
* Get the web bean resolver. For internal use
*
@@ -846,12 +907,12 @@
{
return resolver;
}
-
+
public EjbDescriptorCache getEjbDescriptorCache()
{
return ejbDescriptorCache;
}
-
+
/**
* Gets a string representation
*
@@ -870,27 +931,27 @@
buffer.append("Specialized beans: " + specializedBeans.size() +
"\n");
return buffer.toString();
}
-
+
public Manager parse(InputStream xmlStream)
{
throw new UnsupportedOperationException();
}
-
+
public Manager createActivity()
{
throw new UnsupportedOperationException();
}
-
+
public Manager setCurrent(Class<? extends Annotation> scopeType)
{
throw new UnsupportedOperationException();
}
-
+
public ServiceRegistry getServices()
{
return simpleServiceRegistry;
}
-
+
/**
* Accesses the factory used to create each instance of InjectionPoint that
* is injected into web beans.
@@ -918,14 +979,14 @@
// 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.
*
@@ -935,10 +996,9 @@
{
return taskExecutor;
}
-
+
/**
- * Cleans up resources held by the manager prior to shutting down
- * a VM.
+ * Cleans up resources held by the manager prior to shutting down a VM.
*/
public void cleanup()
{
@@ -951,22 +1011,26 @@
protected void shutdownExecutors()
{
taskExecutor.shutdown();
- try {
+ try
+ {
// Wait a while for existing tasks to terminate
- if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS)) {
+ 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
- }
+ // Wait a while for tasks to respond to being cancelled
+ if (!taskExecutor.awaitTermination(60, TimeUnit.SECONDS))
+ {
+ // Log the error here
+ }
}
- } catch (InterruptedException ie) {
+ }
+ catch (InterruptedException ie)
+ {
// (Re-)Cancel if current thread also interrupted
- taskExecutor.shutdownNow();
+ taskExecutor.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
- }
+ }
}
-
+
}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java 2009-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/AbstractFacadeBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,165 +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.bean;
-
-import java.lang.annotation.Annotation;
-
-import javax.context.Dependent;
-import javax.inject.Production;
-import javax.inject.Standard;
-
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-
-/**
- * Facade bean for implicit beans
- *
- * @author Gavin King
- *
- * @param <T> the bean type
- * @param <S> the injection point type
- * @param <P> the parameterized type
- */
-public abstract class AbstractFacadeBean<T, S, P> extends AbstractBean<T, S>
-{
- // The underlying item
- protected AnnotatedItem<T, S> annotatedItem;
-
- /**
- * Constructor
- *
- * @param field The facaded field
- * @param manager The Web Beans manager
- */
- public AbstractFacadeBean(AnnotatedItem<T, S> field, ManagerImpl manager)
- {
- super(manager);
- this.annotatedItem = field;
- init();
- }
-
- /**
- * Gets the type paramater of the facade
- *
- * @return The type parameter
- */
- // TODO This ain't right!
- @SuppressWarnings("unchecked")
- protected Class<P> getTypeParameter()
- {
- return (Class<P>) annotatedItem.getActualTypeArguments()[0].getClass();
- }
-
- /**
- * Initializes the scope type to dependent
- */
- @Override
- protected void initScopeType()
- {
- this.scopeType = Dependent.class;
- }
-
- /**
- * Initializes the deployment type to Standard
- */
- @Override
- protected void initDeploymentType()
- {
- this.deploymentType = Standard.class;
- }
-
- @Override
- protected void checkDeploymentType()
- {
- // Allow @Standard here
- }
-
- /**
- * Gets the underlying item
- *
- * @return The underlying item
- */
- @Override
- protected AnnotatedItem<T, S> getAnnotatedItem()
- {
- return annotatedItem;
- }
-
- /**
- * Gets the default name
- *
- * @return The default name
- */
- @Override
- protected String getDefaultName()
- {
- return null;
- }
-
- /**
- * Initializes the type
- */
- @Override
- protected void initType()
- {
- try
- {
- if (getAnnotatedItem() != null)
- {
- this.type = getAnnotatedItem().getRawType();
- }
- }
- catch (ClassCastException e)
- {
- throw new IllegalArgumentException("Cannot create an instance of " +
toString() + " with " + getAnnotatedItem());
- }
- }
-
- /**
- * Gets the default deployment type, Production
- */
- @Override
- protected Class<? extends Annotation> getDefaultDeploymentType()
- {
- return Production.class;
- }
-
- /**
- * Returns a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- return "FacadeBean " + getName() + " for " + annotatedItem;
- }
-
- @Override
- public AbstractBean<?, ?> getSpecializedBean()
- {
- return null;
- }
-
- @Override
- public boolean isSpecializing()
- {
- return false;
- }
-
-}
\ No newline at end of file
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EventBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EventBean.java 2009-03-19 23:05:24
UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/EventBean.java 2009-03-20 00:05:31
UTC (rev 2118)
@@ -1,190 +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.bean;
-
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Set;
-
-import javax.context.CreationalContext;
-import javax.event.Event;
-import javax.inject.DefinitionException;
-import javax.inject.manager.InjectionPoint;
-
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.event.EventImpl;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.introspector.AnnotatedParameter;
-import org.jboss.webbeans.util.Names;
-
-/**
- * An event bean representation
- *
- * @author David Allen
- *
- * @param <T> The actual type of the event object
- * @param <S>
- */
-public class EventBean<T, S> extends AbstractFacadeBean<Event<T>, S,
T>
-{
-
- /**
- * Creates an event Web Bean
- *
- * @param field The event injection point abstraction
- * @param manager the current manager
- * @param declaringBean The declaring bean abstraction
- * @return An event Web Bean
- */
- public static <T, S> EventBean<T, S> of(AnnotatedItem<Event<T>,
S> field, ManagerImpl manager)
- {
- return new EventBean<T, S>(field, manager);
- }
-
- /**
- * Constructor
- *
- * @param field The underlying field abstraction
- * @param manager The Web Beans manager
- */
- protected EventBean(AnnotatedItem<Event<T>, S> field, ManagerImpl
manager)
- {
- super(field, manager);
- }
-
- /**
- * Initializes the bean
- *
- * Calls super method and validates the annotated item
- */
- protected void init()
- {
- validateInjectionPoint();
- super.init();
- checkAnnotatedItem();
- }
-
- /**
- * Performs early validation on the annotated item to make
- * certain the field or parameter is of the proper type.
- */
- private void validateInjectionPoint()
- {
- if (!this.getAnnotatedItem().getRawType().equals(Event.class))
- {
- throw new DefinitionException("Event field/parameter is not of type
Event<T>: " + this.getAnnotatedItem());
- }
-
- }
-
- /**
- * Validates the annotated item
- */
- private void checkAnnotatedItem()
- {
- // Only check the type arguments if this is for a field. Parameters
- // do not have access to the type arguments in Java 6.
- if (!(this.annotatedItem instanceof AnnotatedParameter))
- {
- Type[] actualTypeArguments = annotatedItem.getActualTypeArguments();
- if (actualTypeArguments.length != 1)
- {
- throw new DefinitionException("Event must have type arguments");
- }
- if (!(actualTypeArguments[0] instanceof Class))
- {
- throw new DefinitionException("Event must have concrete type
argument");
- }
- }
- }
-
- /**
- * Creates an instance
- *
- * @return an event instance
- */
- public Event<T> create(CreationalContext<Event<T>>
creationalContext)
- {
- try
- {
- DependentContext.INSTANCE.setActive(true);
- //TODO Fix to use IP's manager rather than this bean's
- InjectionPoint injectionPoint = this.getManager().getInjectionPoint();
- Class<?> clazz = Object.class;
- Type genericType = injectionPoint.getType().getClass().getGenericSuperclass();
- if (genericType instanceof ParameterizedType )
- {
- ParameterizedType type = (ParameterizedType) genericType;
- clazz = Class.class.cast(type.getActualTypeArguments()[0]);
- }
-
- // TODO should be able to move this up into annotated item?!
- @SuppressWarnings("unchecked")
- Class<T> eventType = (Class<T>) clazz;
-
- return new EventImpl<T>(eventType, manager,
injectionPoint.getBindings().toArray(new Annotation[0]));
- }
- finally
- {
- DependentContext.INSTANCE.setActive(false);
- }
- }
-
- public void destroy(Event<T> instance)
- {
- /*try
- {
- DependentContext.INSTANCE.setActive(true);
- }
- finally
- {
- DependentContext.INSTANCE.setActive(false);
- }*/
- }
-
- /**
- * Adds additional bindings to this bean. All bindings must be
- * finalized before the bean is registered with the manager.
- *
- * @param additionalBindings A set of additional bindings
- */
- public void addBindings(Set<Annotation> additionalBindings)
- {
- this.bindings.addAll(additionalBindings);
- }
-
- /**
- * Returns a string representation
- *
- * @return The string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append(Names.scopeTypeToString(getScopeType()));
- buffer.append("Event bean ");
- buffer.append(getType().getName());
- buffer.append(" API types =
").append(Names.typesToString(getTypes())).append(", binding types = " +
Names.annotationsToString(getBindings()));
- return buffer.toString();
- }
-
-}
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/InstanceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/InstanceBean.java 2009-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/InstanceBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,94 +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.bean;
-
-
-import javax.context.CreationalContext;
-import javax.inject.Instance;
-
-import org.jboss.webbeans.InstanceImpl;
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.context.DependentContext;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-
-/**
- * Helper bean for accessing instances
- *
- * @author Gavin King
- *
- * @param <T>
- * @param <S>
- */
-public class InstanceBean<T, S> extends AbstractFacadeBean<Instance<T>, S,
T>
-{
-
- /**
- * Creates an instance Web Bean
- *
- * @param item The instance injection point abstraction
- * @param manager the current manager
- * @param declaringBean The declaring bean abstraction
- * @return An event Web Bean
- */
- public static <T, S> InstanceBean<T, S>
of(AnnotatedItem<Instance<T>, S> item, ManagerImpl manager)
- {
- return new InstanceBean<T, S>(item, manager);
- }
-
- /**
- * Constructor
- *
- * @param field The underlying fields
- * @param manager The Web Beans manager
- */
- protected InstanceBean(AnnotatedItem<Instance<T>, S> field, ManagerImpl
manager)
- {
- super(field, manager);
- }
-
- /**
- * Creates the implementing bean
- *
- * @return The implementation
- */
- public Instance<T> create(CreationalContext<Instance<T>>
creationalContext)
- {
- try
- {
- DependentContext.INSTANCE.setActive(true);
- return new InstanceImpl<T>(getTypeParameter(), manager,
getAnnotatedItem().getBindingsAsArray());
- }
- finally
- {
- DependentContext.INSTANCE.setActive(false);
- }
- }
-
- public void destroy(Instance<T> instance)
- {
- /*try
- {
- DependentContext.INSTANCE.setActive(true);
- }
- finally
- {
- DependentContext.INSTANCE.setActive(false);
- }*/
- }
-
-}
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-03-19 23:05:24
UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/RIBean.java 2009-03-20 00:05:31
UTC (rev 2118)
@@ -16,7 +16,6 @@
*/
package org.jboss.webbeans.bean;
-import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -31,7 +30,7 @@
*
* @author Pete Muir
*/
-public abstract class RIBean<T> extends Bean<T> implements Serializable
+public abstract class RIBean<T> extends Bean<T>
{
private static final AtomicInteger idGenerator = new AtomicInteger();
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-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/SimpleBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -46,7 +46,6 @@
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MetaDataCache;
-import org.jboss.webbeans.resources.spi.NamingContext;
import org.jboss.webbeans.util.Names;
import org.jboss.webbeans.util.Reflections;
@@ -273,7 +272,6 @@
if (getManager().getServices().contains(EjbServices.class))
{
EjbServices ejbServices = manager.getServices().get(EjbServices.class);
- NamingContext namingContext = manager.getServices().get(NamingContext.class);
for (AnnotatedInjectionPoint<?, ?> injectionPoint : ejbInjectionPoints)
{
Object ejbInstance = ejbServices.resolveEjb(injectionPoint);
Added:
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
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,92 @@
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.context.CreationalContext;
+import javax.inject.manager.InjectionPoint;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.context.DependentContext;
+
+public abstract class AbstractFacadeBean<T> extends AbstractStandardBean<T>
+{
+
+ protected AbstractFacadeBean(ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ public T create(CreationalContext<T> creationalContext)
+ {
+ try
+ {
+ DependentContext.INSTANCE.setActive(true);
+ //TODO Fix to use IP's manager rather than this bean's
+ InjectionPoint injectionPoint = this.getManager().getInjectionPoint();
+ Type genericType = injectionPoint.getType();
+ if (genericType instanceof ParameterizedType )
+ {
+ Type type = ((ParameterizedType) genericType).getActualTypeArguments()[0];
+ if (type instanceof Class)
+ {
+ Class<?> clazz = Class.class.cast(type);
+ return newInstance(clazz, fixBindings(injectionPoint.getBindings()));
+ }
+ else
+ {
+ throw new IllegalStateException("Must have concrete type argument
" + injectionPoint);
+ }
+ }
+ else
+ {
+ throw new IllegalStateException("Must have concrete type argument "
+ injectionPoint);
+ }
+
+ }
+ finally
+ {
+ DependentContext.INSTANCE.setActive(false);
+ }
+ }
+
+ /**
+ * Merges and validates the current and new bindings
+ *
+ * Checks with an abstract method for annotations to exclude
+ *
+ * @param currentBindings Existing bindings
+ * @param newBindings New bindings
+ * @return The union of the bindings
+ */
+ protected Set<Annotation> fixBindings(Set<? extends Annotation> bindings)
+ {
+ Set<Annotation> result = new HashSet<Annotation>();
+ for (Annotation newAnnotation : bindings)
+ {
+ if (!getFilteredAnnotationTypes().contains(newAnnotation.annotationType()))
+ {
+ result.add(newAnnotation);
+ }
+ }
+ return result;
+ }
+
+ public void destroy(T instance)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /**
+ * Gets a set of annotation classes to ignore
+ *
+ * @return A set of annotation classes to ignore
+ */
+ protected abstract Set<Class<? extends Annotation>>
getFilteredAnnotationTypes();
+
+ protected abstract T newInstance(Class<?> clazz, Set<Annotation>
annotations);
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacadeBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: 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
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,72 @@
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.event.Event;
+import javax.event.Fires;
+import javax.inject.Obtains;
+import javax.inject.TypeLiteral;
+
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.event.EventImpl;
+import org.jboss.webbeans.injection.resolution.AnnotatedItemTransformer;
+import org.jboss.webbeans.literal.FiresLiteral;
+
+public class EventBean extends AbstractFacadeBean<Event<?>>
+{
+
+ private static final Class<Event<?>> TYPE = new
TypeLiteral<Event<?>>() {}.getRawType();
+ private static final Set<? extends Type> DEFAULT_TYPES = new
HashSet<Type>(Arrays.asList(TYPE, Object.class));
+ private static final Fires FIRES = new FiresLiteral();
+ private static final Set<Annotation> DEFAULT_BINDINGS = new
HashSet<Annotation>(Arrays.asList(FIRES));
+ public static final AnnotatedItemTransformer TRANSFORMER = new
FacadeBeanAnnotatedItemTransformer(Event.class, FIRES);
+ private static final Set<Class<? extends Annotation>>
FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends
Annotation>>(Arrays.asList(Obtains.class));
+
+
+ public static AbstractFacadeBean<Event<?>> of(ManagerImpl manager)
+ {
+ return new EventBean(manager);
+ }
+
+ protected EventBean(ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Class<Event<?>> getType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Set<? extends Type> getTypes()
+ {
+ return DEFAULT_TYPES;
+ }
+
+
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return DEFAULT_BINDINGS;
+ }
+
+ @Override
+ protected Event<?> newInstance(Class<?> clazz, Set<Annotation>
annotations)
+ {
+ return EventImpl.of(clazz, getManager(), annotations);
+ }
+
+ @Override
+ protected Set<Class<? extends Annotation>> getFilteredAnnotationTypes()
+ {
+ return FILTERED_ANNOTATION_TYPES;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/EventBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
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
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,91 @@
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.event.Event;
+
+import org.jboss.webbeans.injection.resolution.AnnotatedItemTransformer;
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
+
+public class FacadeBeanAnnotatedItemTransformer implements AnnotatedItemTransformer
+{
+
+ private final Class<?> clazz;
+ private final Annotation annotation;
+ private final Set<Annotation> annotations;
+ private final Set<? extends Type> flattenedTypes;
+
+ public FacadeBeanAnnotatedItemTransformer(Class<?> clazz, Annotation
annotation)
+ {
+ this.clazz = clazz;
+ this.annotation = annotation;
+ this.annotations = new HashSet<Annotation>(Arrays.asList(annotation));
+ Type[] types = {Object.class, Event.class};
+ this.flattenedTypes = new HashSet<Type>(Arrays.asList(types));
+ }
+
+ public <T, S> AnnotatedItem<T, S> transform(final AnnotatedItem<T,
S> element)
+ {
+ if (clazz.isAssignableFrom(element.getRawType()))
+ {
+ if (element.isAnnotationPresent(annotation.annotationType()))
+ {
+
+ return new ForwardingAnnotatedItem<T, S>()
+ {
+
+ @Override
+ public Type[] getActualTypeArguments()
+ {
+ return new Type[0];
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return annotations;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public Class<T> getRawType()
+ {
+ return (Class<T>) clazz;
+ }
+
+ @Override
+ public Type getType()
+ {
+ return clazz;
+ }
+
+ @Override
+ public Set<? extends Type> getFlattenedTypeHierarchy()
+ {
+ return flattenedTypes;
+ }
+
+ @Override
+ public AnnotatedItem<T, S> delegate()
+ {
+ return element;
+ }
+
+ @Override
+ public boolean isAssignableFrom(Set<? extends Type> types)
+ {
+ return types.contains(clazz);
+ }
+
+ };
+ }
+ }
+ return element;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/FacadeBeanAnnotatedItemTransformer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-03-19
23:05:24 UTC (rev 2117)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InjectionPointBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -36,8 +36,7 @@
public class InjectionPointBean extends AbstractStandardBean<InjectionPoint>
{
- private static final long serialVersionUID = -5040637694853267743L;
- private static final Set<Type> TYPES = new
HashSet<Type>(Arrays.asList(new Type[] { InjectionPoint.class }));
+ private static final Set<Type> TYPES = new HashSet<Type>(Arrays.asList(new
Type[] { InjectionPoint.class }));
/**
* Creates an InjectionPoint Web Bean for the injection of the containing bean owning
Added: 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
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,69 @@
+package org.jboss.webbeans.bean.standard;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.Instance;
+import javax.inject.Obtains;
+import javax.inject.TypeLiteral;
+
+import org.jboss.webbeans.InstanceImpl;
+import org.jboss.webbeans.ManagerImpl;
+import org.jboss.webbeans.injection.resolution.AnnotatedItemTransformer;
+import org.jboss.webbeans.literal.ObtainsLiteral;
+
+public class InstanceBean extends AbstractFacadeBean<Instance<?>>
+{
+
+ private static final Class<Instance<?>> TYPE = new
TypeLiteral<Instance<?>>() {}.getRawType();
+ private static final Set<? extends Type> DEFAULT_TYPES = new
HashSet<Type>(Arrays.asList(TYPE, Object.class));
+ private static final Obtains OBTAINS = new ObtainsLiteral();
+ private static final Set<Annotation> DEFAULT_BINDINGS = new
HashSet<Annotation>(Arrays.asList(OBTAINS));
+ private static final Set<Class<? extends Annotation>>
FILTERED_ANNOTATION_TYPES = new HashSet<Class<? extends
Annotation>>(Arrays.asList(Obtains.class));
+ public static final AnnotatedItemTransformer TRANSFORMER = new
FacadeBeanAnnotatedItemTransformer(TYPE, OBTAINS);
+
+
+ public static AbstractFacadeBean<Instance<?>> of(ManagerImpl manager)
+ {
+ return new InstanceBean(manager);
+ }
+
+ protected InstanceBean(ManagerImpl manager)
+ {
+ super(manager);
+ }
+
+ @Override
+ public Class<Instance<?>> getType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Set<? extends Type> getTypes()
+ {
+ return DEFAULT_TYPES;
+ }
+
+ @Override
+ public Set<Annotation> getBindings()
+ {
+ return DEFAULT_BINDINGS;
+ }
+
+ @Override
+ protected Instance<?> newInstance(Class<?> clazz, Set<Annotation>
annotations)
+ {
+ return InstanceImpl.of(clazz, getManager(), annotations);
+ }
+
+ @Override
+ protected Set<Class<? extends Annotation>> getFilteredAnnotationTypes()
+ {
+ return FILTERED_ANNOTATION_TYPES;
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/BeanDeployer.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,26 +1,21 @@
package org.jboss.webbeans.bootstrap;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.event.Fires;
import javax.event.Observes;
import javax.inject.BindingType;
import javax.inject.DeploymentType;
import javax.inject.Initializer;
-import javax.inject.Obtains;
import javax.inject.Produces;
import javax.inject.Realizes;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.AbstractClassBean;
import org.jboss.webbeans.bean.EnterpriseBean;
-import org.jboss.webbeans.bean.EventBean;
-import org.jboss.webbeans.bean.InstanceBean;
import org.jboss.webbeans.bean.NewEnterpriseBean;
import org.jboss.webbeans.bean.NewSimpleBean;
import org.jboss.webbeans.bean.ProducerFieldBean;
@@ -32,7 +27,6 @@
import org.jboss.webbeans.event.ObserverImpl;
import org.jboss.webbeans.introspector.AnnotatedClass;
import org.jboss.webbeans.introspector.AnnotatedField;
-import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.WrappedAnnotatedField;
import org.jboss.webbeans.introspector.WrappedAnnotatedMethod;
@@ -54,7 +48,6 @@
private final Set<RIBean<?>> beans;
private final Set<AnnotatedClass<?>> deferredClasses;
private final ManagerImpl manager;
- private EventBean<Object, Method> eventBean;
public BeanDeployer(ManagerImpl manager)
{
@@ -119,7 +112,6 @@
createProducerMethods(bean, annotatedClass);
createProducerFields(bean, annotatedClass);
createObserverMethods(bean, annotatedClass);
- createFacades(bean.getInjectionPoints());
if (annotatedClass.isAnnotationPresent(Realizes.class))
{
@@ -145,7 +137,6 @@
ProducerMethodBean<?> bean = ProducerMethodBean.of(annotatedMethod,
declaringBean, manager);
beans.add(bean);
manager.getResolver().addInjectionPoints(bean.getInjectionPoints());
- createFacades(bean.getInjectionPoints());
log.info("Web Bean: " + bean);
}
@@ -215,48 +206,7 @@
createBean(bean, annotatedClass);
beans.add(NewEnterpriseBean.of(annotatedClass, manager));
}
-
- private void createFacades(Set<? extends AnnotatedItem<?, ?>>
injectionPoints)
- {
- for (AnnotatedItem<?, ?> injectionPoint : injectionPoints)
- {
- if (injectionPoint.isAnnotationPresent(Fires.class))
- {
- createEvent(injectionPoint);
- }
- if (injectionPoint.isAnnotationPresent(Obtains.class))
- {
- createInstance(injectionPoint);
- }
- }
- }
-
- private void createEvent(AnnotatedItem<?, ?> injectionPoint)
- {
- if (eventBean == null)
- {
- // TODO Fix this!
- @SuppressWarnings("unchecked")
- EventBean<Object, Method> bean = EventBean.of((AnnotatedItem)
injectionPoint, manager);
- beans.add(bean);
- log.info("Web Bean: " + bean);
- eventBean = bean;
- }
- else
- {
- eventBean.addBindings(injectionPoint.getBindings());
- }
- }
- private void createInstance(AnnotatedItem<?, ?> injectionPoint)
- {
- // TODO FIx this
- @SuppressWarnings("unchecked")
- InstanceBean<Object, ?> bean = InstanceBean.of((AnnotatedItem)
injectionPoint, manager);
- beans.add(bean);
- log.info("Web Bean: " + bean);
- }
-
/**
* Indicates if the type is a simple Web Bean
*
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-03-19
23:05:24 UTC (rev 2117)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/bootstrap/WebBeansBootstrap.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -23,7 +23,9 @@
import org.jboss.webbeans.BeanValidator;
import org.jboss.webbeans.CurrentManager;
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;
import org.jboss.webbeans.bean.standard.ManagerBean;
import org.jboss.webbeans.bootstrap.api.Bootstrap;
import org.jboss.webbeans.bootstrap.api.Environments;
@@ -56,7 +58,6 @@
import org.jboss.webbeans.servlet.ServletApiAbstraction;
import org.jboss.webbeans.transaction.spi.TransactionServices;
import org.jboss.webbeans.xml.XmlEnvironment;
-import org.jboss.webbeans.xml.XmlEnvironment;
import org.jboss.webbeans.xml.XmlParser;
/**
@@ -123,6 +124,8 @@
beanDeployer.addClasses(classes);
beanDeployer.addBean(ManagerBean.of(manager));
beanDeployer.addBean(InjectionPointBean.of(manager));
+ beanDeployer.addBean(EventBean.of(manager));
+ beanDeployer.addBean(InstanceBean.of(manager));
if (!getEnvironment().equals(Environments.SE))
{
beanDeployer.addClass(ConversationImpl.class);
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-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -47,6 +47,12 @@
@SuppressWarnings("unchecked")
private static final Set<Class<? extends Annotation>> FILTERED_ANNOTATIONS
= new HashSet<Class<? extends Annotation>>(Arrays.asList(Fires.class));
+ public static <E> Event<E> of(Class<E> eventType, Manager manager,
Set<Annotation> bindings)
+ {
+ return new EventImpl<E>(eventType, manager, bindings);
+ }
+
+
/**
* Constructor
*
@@ -54,7 +60,7 @@
* @param manager The Web Beans manager
* @param bindings The binding types
*/
- public EventImpl(Class<T> eventType, Manager manager, Annotation... bindings)
+ public EventImpl(Class<T> eventType, Manager manager, Set<Annotation>
bindings)
{
super(eventType, manager, bindings);
}
@@ -67,7 +73,7 @@
*/
public void fire(T event, Annotation... bindings)
{
- manager.fireEvent(event, mergeBindings(bindings));
+ manager.fireEvent(event, mergeInBindings(bindings));
}
/**
@@ -78,7 +84,7 @@
*/
public void observe(Observer<T> observer, Annotation... bindings)
{
- manager.addObserver(observer, type, mergeBindings(bindings));
+ manager.addObserver(observer, type, mergeInBindings(bindings));
}
@Override
@@ -91,13 +97,4 @@
return buffer.toString();
}
- /**
- * @see org.jboss.webbeans.FacadeImpl#getFilteredAnnotations
- */
- @Override
- protected Set<Class<? extends Annotation>> getFilteredAnnotations()
- {
- return FILTERED_ANNOTATIONS;
- }
-
}
Deleted:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,149 +0,0 @@
-package org.jboss.webbeans.injection;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.inject.TypeLiteral;
-
-import org.jboss.webbeans.introspector.AnnotationStore;
-import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem;
-import org.jboss.webbeans.util.Names;
-
-/**
- * Extension of an element which bases equality not only on type, but also on
- * binding type
- */
-public class ResolvableAnnotatedClass<T> extends AbstractAnnotatedItem<T,
Class<T>>
-{
-
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
- private final Class<T> rawType;
- private final Type[] actualTypeArguments;
-
- private final String _string;
-
- public static <T> ResolvableAnnotatedClass<T> of(TypeLiteral<T>
typeLiteral, Annotation[] annotations)
- {
- return new ResolvableAnnotatedClass<T>(typeLiteral.getRawType(),
typeLiteral.getType(), annotations);
- }
-
- public static <T> ResolvableAnnotatedClass<T> of(Class<T> clazz,
Annotation[] annotations)
- {
- return new ResolvableAnnotatedClass<T>(clazz, clazz, annotations);
- }
-
- public static <T> ResolvableAnnotatedClass<T> of(Type type, Annotation[]
annotations)
- {
- if (type instanceof Class)
- {
- return new ResolvableAnnotatedClass<T>((Class<T>) type, type,
annotations);
- }
- else if (type instanceof ParameterizedType)
- {
- return new ResolvableAnnotatedClass<T>((Class<T>)
((ParameterizedType) type).getRawType(), type, annotations);
- }
- else
- {
- throw new UnsupportedOperationException("Cannot create annotated item of
" + type);
- }
- }
-
- public static <T> ResolvableAnnotatedClass<T> of(Member member,
Annotation[] annotations)
- {
- if (member instanceof Field)
- {
- return new ResolvableAnnotatedClass<T>((Class<T>) ((Field)
member).getType(), ((Field) member).getGenericType(), annotations);
- }
- else if (member instanceof Method)
- {
- return new ResolvableAnnotatedClass<T>((Class<T>) ((Method)
member).getReturnType(), ((Method) member).getGenericReturnType(), annotations);
- }
- else
- {
- throw new IllegalStateException();
- }
- }
-
- private ResolvableAnnotatedClass(Class<T> rawType, Type type, Annotation[]
annotations)
- {
- super(AnnotationStore.of(annotations, EMPTY_ANNOTATION_ARRAY));
- this.rawType = rawType;
- if (type instanceof ParameterizedType)
- {
- this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
- this._string = rawType.toString() + "<" +
Arrays.asList(actualTypeArguments).toString() + ">; binding types = " +
Names.annotationsToString(new HashSet<Annotation>(Arrays.asList(annotations)));
- }
- else
- {
- this.actualTypeArguments = new Type[0];
- this._string = rawType.toString() +"; binding types = " +
Names.annotationsToString(new HashSet<Annotation>(Arrays.asList(annotations)));
- }
- }
-
- @Override
- public String toString()
- {
- return _string;
- }
-
- @Override
- public Class<T> getDelegate()
- {
- return rawType;
- }
-
- public Type[] getActualTypeArguments()
- {
- return actualTypeArguments;
- }
-
- public String getName()
- {
- throw new UnsupportedOperationException();
- }
-
- public Class<T> getRawType()
- {
- return rawType;
- }
-
- @Override
- public Type getType()
- {
- return getRawType();
- }
-
- public boolean isFinal()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isPublic()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isStatic()
- {
- throw new UnsupportedOperationException();
- }
-
- public Set<? extends Type> getFlattenedTypeHierarchy()
- {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isProxyable()
- {
- throw new UnsupportedOperationException();
- }
-
-}
\ No newline at end of file
Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/Resolver.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/Resolver.java 2009-03-19
23:05:24 UTC (rev 2117)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/Resolver.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,350 +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.injection;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.concurrent.Callable;
-
-import javax.inject.TypeLiteral;
-import javax.inject.manager.Bean;
-
-import org.jboss.webbeans.ManagerImpl;
-import org.jboss.webbeans.introspector.AnnotatedItem;
-import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
-import org.jboss.webbeans.metadata.BindingTypeModel;
-import org.jboss.webbeans.metadata.MetaDataCache;
-import org.jboss.webbeans.util.ListComparator;
-import org.jboss.webbeans.util.collections.ConcurrentCache;
-
-/**
- * Implementation of Web Beans type safe and name based bean resolution
- *
- * @author Pete Muir
- */
-public class Resolver
-{
- private static final long serialVersionUID = 1L;
-
- private static final Class<AnnotatedItem<Object, Object>>
ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT = new TypeLiteral<AnnotatedItem<Object,
Object>>(){}.getRawType();
- private static final Class<Set<Bean<Object>>>
BEAN_SET_GENERIFIED_WITH_OBJECT = new
TypeLiteral<Set<Bean<Object>>>(){}.getRawType();
- private static final Class<Set<Bean<?>>>
BEAN_SET_GENERIFIED_WITH_WILDCARD = new
TypeLiteral<Set<Bean<?>>>(){}.getRawType();
-
- /**
- * Extension of an element which bases equality not only on type, but also on
- * binding type
- */
- private abstract class ResolvableAnnotatedItem<T, S> extends
ForwardingAnnotatedItem<T, S>
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean equals(Object other)
- {
- if (other instanceof AnnotatedItem)
- {
- AnnotatedItem<?, ?> that = (AnnotatedItem<?, ?>) other;
- return delegate().isAssignableFrom(that) &&
that.getBindings().equals(this.getBindings());
- }
- else
- {
- return false;
- }
- }
-
- @Override
- public int hashCode()
- {
- return delegate().hashCode();
- }
-
- @Override
- public String toString()
- {
- return "Resolvable annotated item for " + delegate();
- }
-
- }
-
- // The resolved injection points
- private ConcurrentCache<ResolvableAnnotatedItem<?, ?>,
Set<Bean<?>>> resolvedInjectionPoints;
- // The registerd injection points
- private Set<AnnotatedItem<?, ?>> injectionPoints;
- // The resolved names
- private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
- // The Web Beans manager
- private ManagerImpl manager;
-
- /**
- * Constructor
- *
- * @param manager The Web Beans manager
- */
- public Resolver(ManagerImpl manager)
- {
- this.injectionPoints = new HashSet<AnnotatedItem<?, ?>>();
- this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,
?>, Set<Bean<?>>>();
- this.resolvedNames = new ConcurrentCache<String,
Set<Bean<?>>>();
- this.manager = manager;
- }
-
- /**
- * Add multiple injection points for later resolving using
- * {@link #registerInjectionPoint(AnnotatedItem)}. Useful during bootstrap.
- *
- * @param elements The injection points to add
- */
- public void addInjectionPoints(Collection<? extends AnnotatedItem<?, ?>>
elements)
- {
- injectionPoints.addAll(elements);
- }
-
- /**
- * Registers an injection point
- *
- * @param <T>
- * @param <S>
- * @param element The injection point to add
- * @return A set of matching beans for the injection point
- */
- private <T, S> Set<Bean<T>> registerInjectionPoint(final
ResolvableAnnotatedItem<T, S> element)
- {
- Callable<Set<Bean<T>>> callable = new
Callable<Set<Bean<T>>>()
- {
-
- public Set<Bean<T>> call() throws Exception
- {
- return retainHighestPrecedenceBeans(getMatchingBeans(element,
manager.getBeans()), manager.getEnabledDeploymentTypes());
- }
-
- };
- return resolvedInjectionPoints.putIfAbsent(element, callable);
- }
-
- /**
- * Reset all cached injection points. You must reset all cached injection
- * points when you add a bean to the manager
- */
- public void clear()
- {
- this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,
?>, Set<Bean<?>>>();
- resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
- }
-
- /**
- * Resolve all injection points added using
- * {@link #addInjectionPoints(Collection)}
- */
- public void resolveInjectionPoints()
- {
- for (final AnnotatedItem<? extends Object, ? extends Object> injectable :
injectionPoints)
- {
-
- registerInjectionPoint(new ResolvableAnnotatedItem<Object, Object>()
- {
- private static final long serialVersionUID = 1L;
-
- @Override
- public AnnotatedItem<Object, Object> delegate()
- {
- return ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT.cast(injectable);
- }
- });
- }
- }
-
- /**
- * Get the possible beans for the given element
- *
- * @param key The resolving criteria
- * @return An unmodifiable set of matching beans
- */
- public <T, S> Set<Bean<T>> get(final AnnotatedItem<T, S> key)
- {
- Set<Bean<T>> beans = new HashSet<Bean<T>>();
-
- final ResolvableAnnotatedItem<T, S> element = new
ResolvableAnnotatedItem<T, S>()
- {
-
- @Override
- public AnnotatedItem<T, S> delegate()
- {
- return key;
- }
-
- };
- beans = registerInjectionPoint(element);
- return Collections.unmodifiableSet(beans);
- }
-
- /**
- * Get the possible beans for the given name
- *
- * @param name The name to match
- * @return The set of matching beans
- */
- public Set<Bean<? extends Object>> get(final String name)
- {
- return resolvedNames.putIfAbsent(name, new
Callable<Set<Bean<?>>>()
- {
-
- public Set<Bean<? extends Object>> call() throws Exception
- {
-
- Set<Bean<?>> beans = new HashSet<Bean<?>>();
- for (Bean<?> bean : manager.getBeans())
- {
- if ((bean.getName() == null && name == null) || (bean.getName() !=
null && bean.getName().equals(name)))
- {
- beans.add(bean);
- }
- }
- return retainHighestPrecedenceBeans(beans,
manager.getEnabledDeploymentTypes());
- }
-
- // Helper method to deal with dynamic casts being needed
- private Set<Bean<?>>
retainHighestPrecedenceBeans(Set<Bean<?>> beans, List<Class<? extends
Annotation>> enabledDeploymentTypes)
- {
- return
BEAN_SET_GENERIFIED_WITH_WILDCARD.cast(Resolver.retainHighestPrecedenceBeans(BEAN_SET_GENERIFIED_WITH_OBJECT.cast(beans),
enabledDeploymentTypes));
- }
-
- });
- }
-
-
-
- /**
- * Filters out the beans with the highest enabled deployment type
- *
- * @param <T>
- * @param beans The beans to filter
- * @param enabledDeploymentTypes The enabled deployment types
- * @return The filtered beans
- */
- private static <T> Set<Bean<T>>
retainHighestPrecedenceBeans(Set<Bean<T>> beans, List<Class<? extends
Annotation>> enabledDeploymentTypes)
- {
- if (beans.size() > 0)
- {
- SortedSet<Class<? extends Annotation>> possibleDeploymentTypes = new
TreeSet<Class<? extends Annotation>>(new ListComparator<Class<? extends
Annotation>>(enabledDeploymentTypes));
- for (Bean<?> bean : beans)
- {
- possibleDeploymentTypes.add(bean.getDeploymentType());
- }
- possibleDeploymentTypes.retainAll(enabledDeploymentTypes);
- Set<Bean<T>> trimmed = new HashSet<Bean<T>>();
- if (possibleDeploymentTypes.size() > 0)
- {
- Class<? extends Annotation> highestPrecedencePossibleDeploymentType =
possibleDeploymentTypes.last();
-
- for (Bean<T> bean : beans)
- {
- if
(bean.getDeploymentType().equals(highestPrecedencePossibleDeploymentType))
- {
- trimmed.add(bean);
- }
- }
- }
- return trimmed;
- }
- else
- {
- return beans;
- }
- }
-
- /**
- * Gets the matching beans for binding criteria from a list of beans
- *
- * @param <T> The type of the beans
- * @param element The binding criteria
- * @param beans The beans to filter
- * @return A set of filtered beans
- */
- private <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?>
element, List<Bean<?>> beans)
- {
- Set<Bean<T>> resolvedBeans = new HashSet<Bean<T>>();
- for (Bean<?> bean : beans)
- {
- if (element.isAssignableFrom(bean.getTypes()) &&
containsAllBindings(element, bean.getBindings()))
- {
- @SuppressWarnings("unchecked")
- Bean<T> b = (Bean<T>) bean;
- resolvedBeans.add(b);
- }
- }
- return resolvedBeans;
- }
-
- /**
- * Checks if binding criteria fulfill all binding types
- *
- * @param element The binding criteria to check
- * @param bindings The binding types to check
- * @return True if all matches, false otherwise
- */
- private boolean containsAllBindings(AnnotatedItem<?, ?> element,
Set<Annotation> bindings)
- {
- for (Annotation binding : element.getBindings())
- {
- BindingTypeModel<?> bindingType =
MetaDataCache.instance().getBindingTypeModel(binding.annotationType());
- if (bindingType.getNonBindingTypes().size() > 0)
- {
- boolean matchFound = false;
- for (Annotation otherBinding : bindings)
- {
- if (bindingType.isEqual(binding, otherBinding))
- {
- matchFound = true;
- }
- }
- if (!matchFound)
- {
- return false;
- }
- }
- else if (!bindings.contains(binding))
- {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Gets a string representation
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- StringBuilder buffer = new StringBuilder();
- buffer.append("Resolver\n");
- buffer.append("Injection points: " + injectionPoints.size() +
"\n");
- buffer.append("Resolved injection points: " +
resolvedInjectionPoints.size() + "\n");
- buffer.append("Resolved names points: " + resolvedNames.size() +
"\n");
- return buffer.toString();
- }
-
-}
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/AnnotatedItemTransformer.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/AnnotatedItemTransformer.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/AnnotatedItemTransformer.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.injection.resolution;
+
+import org.jboss.webbeans.introspector.AnnotatedItem;
+
+
+public interface AnnotatedItemTransformer
+{
+
+ public <T, S> AnnotatedItem<T, S> transform(AnnotatedItem<T, S>
element);
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/AnnotatedItemTransformer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedClass.java
(from rev 2112,
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/ResolvableAnnotatedClass.java)
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedClass.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedClass.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,145 @@
+package org.jboss.webbeans.injection.resolution;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.TypeLiteral;
+
+import org.jboss.webbeans.introspector.AnnotationStore;
+import org.jboss.webbeans.introspector.jlr.AbstractAnnotatedItem;
+import org.jboss.webbeans.util.Names;
+
+public class ResolvableAnnotatedClass<T> extends AbstractAnnotatedItem<T,
Class<T>>
+{
+
+ private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
+ private final Class<T> rawType;
+ private final Type[] actualTypeArguments;
+
+ private final String _string;
+
+ public static <T> ResolvableAnnotatedClass<T> of(TypeLiteral<T>
typeLiteral, Annotation[] annotations)
+ {
+ return new ResolvableAnnotatedClass<T>(typeLiteral.getRawType(),
typeLiteral.getType(), annotations);
+ }
+
+ public static <T> ResolvableAnnotatedClass<T> of(Class<T> clazz,
Annotation[] annotations)
+ {
+ return new ResolvableAnnotatedClass<T>(clazz, clazz, annotations);
+ }
+
+ public static <T> ResolvableAnnotatedClass<T> of(Type type, Annotation[]
annotations)
+ {
+ if (type instanceof Class)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) type, type,
annotations);
+ }
+ else if (type instanceof ParameterizedType)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>)
((ParameterizedType) type).getRawType(), type, annotations);
+ }
+ else
+ {
+ throw new UnsupportedOperationException("Cannot create annotated item of
" + type);
+ }
+ }
+
+ public static <T> ResolvableAnnotatedClass<T> of(Member member,
Annotation[] annotations)
+ {
+ if (member instanceof Field)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) ((Field)
member).getType(), ((Field) member).getGenericType(), annotations);
+ }
+ else if (member instanceof Method)
+ {
+ return new ResolvableAnnotatedClass<T>((Class<T>) ((Method)
member).getReturnType(), ((Method) member).getGenericReturnType(), annotations);
+ }
+ else
+ {
+ throw new IllegalStateException();
+ }
+ }
+
+ private ResolvableAnnotatedClass(Class<T> rawType, Type type, Annotation[]
annotations)
+ {
+ super(AnnotationStore.of(annotations, EMPTY_ANNOTATION_ARRAY));
+ this.rawType = rawType;
+ if (type instanceof ParameterizedType)
+ {
+ this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
+ this._string = rawType.toString() + "<" +
Arrays.asList(actualTypeArguments).toString() + ">; binding types = " +
Names.annotationsToString(new HashSet<Annotation>(Arrays.asList(annotations)));
+ }
+ else
+ {
+ this.actualTypeArguments = new Type[0];
+ this._string = rawType.toString() +"; binding types = " +
Names.annotationsToString(new HashSet<Annotation>(Arrays.asList(annotations)));
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return _string;
+ }
+
+ @Override
+ public Class<T> getDelegate()
+ {
+ return rawType;
+ }
+
+ public Type[] getActualTypeArguments()
+ {
+ return actualTypeArguments;
+ }
+
+ public String getName()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Class<T> getRawType()
+ {
+ return rawType;
+ }
+
+ @Override
+ public Type getType()
+ {
+ return getRawType();
+ }
+
+ public boolean isFinal()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isPublic()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isStatic()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Set<? extends Type> getFlattenedTypeHierarchy()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public boolean isProxyable()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedClass.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedItem.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedItem.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedItem.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,41 @@
+package org.jboss.webbeans.injection.resolution;
+
+import org.jboss.webbeans.introspector.AnnotatedItem;
+import org.jboss.webbeans.introspector.ForwardingAnnotatedItem;
+
+/**
+ * Extension of an element which bases equality not only on type, but also on
+ * binding type
+ */
+abstract class ResolvableAnnotatedItem<T, S> extends ForwardingAnnotatedItem<T,
S>
+{
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean equals(Object other)
+ {
+ if (other instanceof AnnotatedItem)
+ {
+ AnnotatedItem<?, ?> that = (AnnotatedItem<?, ?>) other;
+ return delegate().isAssignableFrom(that) &&
that.getBindings().equals(this.getBindings());
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return "Resolvable annotated item for " + delegate();
+ }
+
+}
\ No newline at end of file
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/ResolvableAnnotatedItem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
(from rev 2112, ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/Resolver.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
(rev 0)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,327 @@
+/*
+ * 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.injection.resolution;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.concurrent.Callable;
+
+import javax.inject.TypeLiteral;
+import javax.inject.manager.Bean;
+
+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;
+import org.jboss.webbeans.metadata.BindingTypeModel;
+import org.jboss.webbeans.metadata.MetaDataCache;
+import org.jboss.webbeans.util.ListComparator;
+import org.jboss.webbeans.util.collections.ConcurrentCache;
+
+/**
+ * Implementation of Web Beans type safe and name based bean resolution
+ *
+ * @author Pete Muir
+ */
+public class Resolver
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Class<AnnotatedItem<Object, Object>>
ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT = new TypeLiteral<AnnotatedItem<Object,
Object>>(){}.getRawType();
+ private static final Class<Set<Bean<Object>>>
BEAN_SET_GENERIFIED_WITH_OBJECT = new
TypeLiteral<Set<Bean<Object>>>(){}.getRawType();
+ private static final Class<Set<Bean<?>>>
BEAN_SET_GENERIFIED_WITH_WILDCARD = new
TypeLiteral<Set<Bean<?>>>(){}.getRawType();
+
+ // The resolved injection points
+ private ConcurrentCache<ResolvableAnnotatedItem<?, ?>,
Set<Bean<?>>> resolvedInjectionPoints;
+ // The registerd injection points
+ private Set<AnnotatedItem<?, ?>> injectionPoints;
+ // The resolved names
+ private ConcurrentCache<String, Set<Bean<?>>> resolvedNames;
+ // The Web Beans manager
+ private ManagerImpl manager;
+ private final Set<AnnotatedItemTransformer> transformers;
+
+ /**
+ * Constructor
+ *
+ * @param manager The Web Beans manager
+ */
+ public Resolver(ManagerImpl 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.
+ *
+ * @param elements The injection points to add
+ */
+ public void addInjectionPoints(Collection<? extends AnnotatedItem<?, ?>>
elements)
+ {
+ injectionPoints.addAll(elements);
+ }
+
+ /**
+ * Registers an injection point
+ *
+ * @param <T>
+ * @param <S>
+ * @param element The injection point to add
+ * @return A set of matching beans for the injection point
+ */
+ private <T, S> Set<Bean<T>> registerInjectionPoint(final
ResolvableAnnotatedItem<T, S> element)
+ {
+ Callable<Set<Bean<T>>> callable = new
Callable<Set<Bean<T>>>()
+ {
+
+ public Set<Bean<T>> call() throws Exception
+ {
+ return retainHighestPrecedenceBeans(getMatchingBeans(element,
manager.getBeans()), manager.getEnabledDeploymentTypes());
+ }
+
+ };
+ return resolvedInjectionPoints.putIfAbsent(element, callable);
+ }
+
+ /**
+ * Reset all cached injection points. You must reset all cached injection
+ * points when you add a bean to the manager
+ */
+ public void clear()
+ {
+ this.resolvedInjectionPoints = new ConcurrentCache<ResolvableAnnotatedItem<?,
?>, Set<Bean<?>>>();
+ resolvedNames = new ConcurrentCache<String, Set<Bean<?>>>();
+ }
+
+ /**
+ * Resolve all injection points added using
+ * {@link #addInjectionPoints(Collection)}
+ */
+ public void resolveInjectionPoints()
+ {
+ for (final AnnotatedItem<? extends Object, ? extends Object> injectable :
injectionPoints)
+ {
+
+ registerInjectionPoint(new ResolvableAnnotatedItem<Object, Object>()
+ {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public AnnotatedItem<Object, Object> delegate()
+ {
+ return ANNOTATED_ITEM_GENERIFIED_WITH_OBJECT_OBJECT.cast(injectable);
+ }
+ });
+ }
+ }
+
+ /**
+ * Get the possible beans for the given element
+ *
+ * @param key The resolving criteria
+ * @return An unmodifiable set of matching beans
+ */
+ public <T, S> Set<Bean<T>> get(final AnnotatedItem<T, S> key)
+ {
+ final AnnotatedItem<T, S> transformedElement = transformElement(key);
+
+ Set<Bean<T>> beans = registerInjectionPoint(new
ResolvableAnnotatedItem<T, S>()
+ {
+
+ @Override
+ public AnnotatedItem<T, S> delegate()
+ {
+ return transformedElement;
+ }
+
+ });
+ return Collections.unmodifiableSet(beans);
+ }
+
+ private <T, S> AnnotatedItem<T, S> transformElement(AnnotatedItem<T,
S> element)
+ {
+ for (AnnotatedItemTransformer transformer : transformers)
+ {
+ element = transformer.transform(element);
+ }
+ return element;
+ }
+
+ /**
+ * Get the possible beans for the given name
+ *
+ * @param name The name to match
+ * @return The set of matching beans
+ */
+ public Set<Bean<? extends Object>> get(final String name)
+ {
+ return resolvedNames.putIfAbsent(name, new
Callable<Set<Bean<?>>>()
+ {
+
+ public Set<Bean<? extends Object>> call() throws Exception
+ {
+
+ Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ for (Bean<?> bean : manager.getBeans())
+ {
+ if ((bean.getName() == null && name == null) || (bean.getName() !=
null && bean.getName().equals(name)))
+ {
+ beans.add(bean);
+ }
+ }
+ return retainHighestPrecedenceBeans(beans,
manager.getEnabledDeploymentTypes());
+ }
+
+ // Helper method to deal with dynamic casts being needed
+ private Set<Bean<?>>
retainHighestPrecedenceBeans(Set<Bean<?>> beans, List<Class<? extends
Annotation>> enabledDeploymentTypes)
+ {
+ return
BEAN_SET_GENERIFIED_WITH_WILDCARD.cast(Resolver.retainHighestPrecedenceBeans(BEAN_SET_GENERIFIED_WITH_OBJECT.cast(beans),
enabledDeploymentTypes));
+ }
+
+ });
+ }
+
+
+
+ /**
+ * Filters out the beans with the highest enabled deployment type
+ *
+ * @param <T>
+ * @param beans The beans to filter
+ * @param enabledDeploymentTypes The enabled deployment types
+ * @return The filtered beans
+ */
+ private static <T> Set<Bean<T>>
retainHighestPrecedenceBeans(Set<Bean<T>> beans, List<Class<? extends
Annotation>> enabledDeploymentTypes)
+ {
+ if (beans.size() > 0)
+ {
+ SortedSet<Class<? extends Annotation>> possibleDeploymentTypes = new
TreeSet<Class<? extends Annotation>>(new ListComparator<Class<? extends
Annotation>>(enabledDeploymentTypes));
+ for (Bean<?> bean : beans)
+ {
+ possibleDeploymentTypes.add(bean.getDeploymentType());
+ }
+ possibleDeploymentTypes.retainAll(enabledDeploymentTypes);
+ Set<Bean<T>> trimmed = new HashSet<Bean<T>>();
+ if (possibleDeploymentTypes.size() > 0)
+ {
+ Class<? extends Annotation> highestPrecedencePossibleDeploymentType =
possibleDeploymentTypes.last();
+
+ for (Bean<T> bean : beans)
+ {
+ if
(bean.getDeploymentType().equals(highestPrecedencePossibleDeploymentType))
+ {
+ trimmed.add(bean);
+ }
+ }
+ }
+ return trimmed;
+ }
+ else
+ {
+ return beans;
+ }
+ }
+
+ /**
+ * Gets the matching beans for binding criteria from a list of beans
+ *
+ * @param <T> The type of the beans
+ * @param element The binding criteria
+ * @param beans The beans to filter
+ * @return A set of filtered beans
+ */
+ private <T> Set<Bean<T>> getMatchingBeans(AnnotatedItem<T, ?>
element, List<Bean<?>> beans)
+ {
+ Set<Bean<T>> resolvedBeans = new HashSet<Bean<T>>();
+ for (Bean<?> bean : beans)
+ {
+ if (element.isAssignableFrom(bean.getTypes()) &&
containsAllBindings(element, bean.getBindings()))
+ {
+ @SuppressWarnings("unchecked")
+ Bean<T> b = (Bean<T>) bean;
+ resolvedBeans.add(b);
+ }
+ }
+ return resolvedBeans;
+ }
+
+ /**
+ * Checks if binding criteria fulfill all binding types
+ *
+ * @param element The binding criteria to check
+ * @param bindings The binding types to check
+ * @return True if all matches, false otherwise
+ */
+ private boolean containsAllBindings(AnnotatedItem<?, ?> element,
Set<Annotation> bindings)
+ {
+ for (Annotation binding : element.getBindings())
+ {
+ BindingTypeModel<?> bindingType =
MetaDataCache.instance().getBindingTypeModel(binding.annotationType());
+ if (bindingType.getNonBindingTypes().size() > 0)
+ {
+ boolean matchFound = false;
+ for (Annotation otherBinding : bindings)
+ {
+ if (bindingType.isEqual(binding, otherBinding))
+ {
+ matchFound = true;
+ }
+ }
+ if (!matchFound)
+ {
+ return false;
+ }
+ }
+ else if (!bindings.contains(binding))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Gets a string representation
+ *
+ * @return A string representation
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("Resolver\n");
+ buffer.append("Injection points: " + injectionPoints.size() +
"\n");
+ buffer.append("Resolved injection points: " +
resolvedInjectionPoints.size() + "\n");
+ buffer.append("Resolved names points: " + resolvedNames.size() +
"\n");
+ return buffer.toString();
+ }
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/injection/resolution/Resolver.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/FiresLiteral.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/FiresLiteral.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/FiresLiteral.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.literal;
+
+import javax.event.Fires;
+import javax.inject.AnnotationLiteral;
+
+public class FiresLiteral extends AnnotationLiteral<Fires> implements Fires
+{
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/FiresLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
(rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.literal;
+
+import javax.inject.AnnotationLiteral;
+import javax.inject.Obtains;
+
+public class ObtainsLiteral extends AnnotationLiteral<Obtains> implements Obtains
+{
+
+}
Property changes on:
ri/trunk/impl/src/main/java/org/jboss/webbeans/literal/ObtainsLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-03-19
23:05:24 UTC (rev 2117)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/bootstrap/environments/ServletEnvironmentTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,5 +1,6 @@
package org.jboss.webbeans.test.unit.bootstrap.environments;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -7,37 +8,43 @@
import javax.inject.AnnotationLiteral;
import javax.inject.manager.Bean;
-import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bean.RIBean;
import org.jboss.webbeans.bean.SimpleBean;
-import org.jboss.webbeans.mock.MockEELifecycle;
import org.jboss.webbeans.mock.MockServletLifecycle;
-import org.jboss.webbeans.test.unit.AbstractWebBeansTest;
-import org.jboss.webbeans.test.unit.StandaloneContainersImpl;
+import org.jboss.webbeans.mock.MockWebBeanDiscovery;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-// TODO shouldn't extend AbstractWebBeansTest
-
-@Artifact
-public class ServletEnvironmentTest extends AbstractWebBeansTest
+public class ServletEnvironmentTest
{
+ private MockServletLifecycle lifecycle;
+ private ManagerImpl manager;
+
@BeforeClass
- @Override
public void beforeClass() throws Throwable
{
- StandaloneContainersImpl.lifecycleClass = MockServletLifecycle.class;
- super.beforeClass();
+ lifecycle = new MockServletLifecycle();
+ lifecycle.initialize();
+ MockWebBeanDiscovery discovery = lifecycle.getWebBeanDiscovery();
+ discovery.setWebBeanClasses(Arrays.asList(Animal.class, DeadlyAnimal.class,
DeadlySpider.class, DeadlyAnimal.class, Hound.class, HoundLocal.class, Salmon.class,
ScottishFish.class, SeaBass.class, Sole.class, Spider.class, Tarantula.class,
TarantulaProducer.class, Tuna.class));
+ lifecycle.beginApplication();
+ lifecycle.beginSession();
+ lifecycle.beginRequest();
+ manager = CurrentManager.rootManager();
}
- @Override
@AfterClass(alwaysRun=true)
public void afterClass() throws Exception
{
- StandaloneContainersImpl.lifecycleClass = MockEELifecycle.class;
- super.afterClass();
+ lifecycle.endRequest();
+ lifecycle.endSession();
+ lifecycle.endApplication();
+ CurrentManager.setRootManager(null);
+ lifecycle = null;
}
@Test(groups="incontainer-broken")
Modified:
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/sbi/SessionBeanInterceptorTest.java
===================================================================
---
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/sbi/SessionBeanInterceptorTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
ri/trunk/tests/src/test/java/org/jboss/webbeans/test/unit/implementation/enterprise/sbi/SessionBeanInterceptorTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -16,7 +16,7 @@
public class SessionBeanInterceptorTest extends AbstractWebBeansTest
{
- @Test
+ @Test(groups="incontainer-broken")
public void testSerializeSessionBeanInterceptor() throws Exception
{
Bean<?> foobean = manager.getNewEnterpriseBeanMap().get(Foo.class);
Modified: ri/trunk/tests/unit-tests.xml
===================================================================
--- ri/trunk/tests/unit-tests.xml 2009-03-19 23:05:24 UTC (rev 2117)
+++ ri/trunk/tests/unit-tests.xml 2009-03-20 00:05:31 UTC (rev 2118)
@@ -3,6 +3,14 @@
<suite name="Web Beans RI" verbose="1" >
<test name="Web Beans RI">
+ <method-selectors>
+ <method-selector>
+ <selector-class
name="org.jboss.testharness.impl.testng.DisableIntegrationTestsMethodSelector"
/>
+ </method-selector>
+ <method-selector>
+ <selector-class
name="org.jboss.testharness.impl.testng.ExcludeIncontainerUnderInvestigationMethodSelector"
/>
+ </method-selector>
+ </method-selectors>
<groups>
<run>
<!--
@@ -32,7 +40,7 @@
<exclude name="broken" />
</run>
</groups>
- <packages >
+ <packages>
<package name="org.jboss.webbeans.test.examples" />
<package name="org.jboss.webbeans.test.unit.bootstrap" />
<package name="org.jboss.webbeans.test.unit.bootstrap.environments"
/>
@@ -41,7 +49,7 @@
<package
name="org.jboss.webbeans.test.unit.bootstrap.environments.multipleSimple" />
<package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleEnterprise"
/>
<package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleProducerMethod"
/>
- \<package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleSimple" />
+ <package
name="org.jboss.webbeans.test.unit.bootstrap.environments.singleSimple" />
<package name="org.jboss.webbeans.test.unit.context" />
<package name="org.jboss.webbeans.test.unit.definition" />
<package name="org.jboss.webbeans.test.unit.event" />
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/EventTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -585,7 +585,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesAPITypeOfInectionPoint() throws Exception
{
@@ -604,7 +604,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "n") } )
public void testImplicitEventBeanMatchesBindingAnnotationsOfInjectionPoint() throws
Exception
{
@@ -623,7 +623,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertion(section = "7.6", id = "o")
public void testImplicitEventBeanHasStandardDeploymentType() throws Exception
{
@@ -644,7 +644,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertion(section = "7.6", id = "p")
public void testImplicitEventBeanHasDependentScope() throws Exception
{
@@ -663,7 +663,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertion(section = "7.6", id = "q")
public void testImplicitEventBeanHasNoName() throws Exception
{
@@ -682,7 +682,7 @@
}.run();
}
- @Test(groups = { "events", "ri-broken" })
+ @Test(groups = { "events", "broken" })
@SpecAssertions( { @SpecAssertion(section = "7.6", id = "a"),
@SpecAssertion(section = "7.6", id = "r") } )
public void testImplicitEventBeanProvidedByContainer() throws Exception
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/event4/JavaSparrow_Broken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/event4/JavaSparrow_Broken.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/event/broken/event4/JavaSparrow_Broken.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,17 +1,15 @@
package org.jboss.jsr299.tck.tests.event.broken.event4;
-import java.util.ArrayList;
-
import javax.event.Event;
import javax.event.Fires;
+import javax.inject.Produces;
class JavaSparrow_Broken
{
- @Fires
- private Event<ArrayList<String>> simpleEvent;
-
- public void eliminateWarning()
+
+ @Produces
+ public <T> void produce(@Fires Event<T> event)
{
- assert simpleEvent != null;
+
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -39,7 +39,7 @@
assert injectionPoint.getPaymentProcessor() instanceof Instance;
}
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertions({
@SpecAssertion(section = "5.8", id ="b"),
@SpecAssertion(section = "5.8", id ="c"),
@@ -76,7 +76,8 @@
injectionPoint.getPaymentProcessor().get(new NonBinding() );
}
- @Test
+ @Test(groups="broken")
+ // TODO Can we test this?
@SpecAssertions({
@SpecAssertion(section = "5.8", id = "k"),
@SpecAssertion(section = "5.8", id = "l"),
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/noninstance/NonInstanceTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/noninstance/NonInstanceTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/noninstance/NonInstanceTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -16,7 +16,7 @@
@ExpectedDeploymentException(DefinitionException.class)
public class NonInstanceTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "5.8", id = "g")
public void TestInjectionPointMustBeInstance()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/notypeparam/NoTypeParameterSpecifiedTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/notypeparam/NoTypeParameterSpecifiedTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/notypeparam/NoTypeParameterSpecifiedTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -3,6 +3,7 @@
import javax.inject.DefinitionException;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
import org.testng.annotations.Test;
@@ -14,9 +15,9 @@
*/
@Artifact
@ExpectedDeploymentException(DefinitionException.class)
-public class NoTypeParameterSpecifiedTest
+public class NoTypeParameterSpecifiedTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "5.8", id = "h")
public void TestInjectionPointMustHaveTypeParameter()
{
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/Foo.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/Foo.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/Foo.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.lookup.dynamic.typevariable;
-
-class Foo<T>
-{
-
-}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableBean_Broken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableBean_Broken.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableBean_Broken.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -2,8 +2,14 @@
import javax.inject.Instance;
import javax.inject.Obtains;
+import javax.inject.Produces;
class TypeVariableBean_Broken
{
- @Obtains Instance<Foo> foo;
+
+ @Produces
+ public <T> void produce(@Obtains Instance<T> foo)
+ {
+
+ }
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/typevariable/TypeVariableTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -3,6 +3,7 @@
import javax.inject.DefinitionException;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
import org.testng.annotations.Test;
@@ -14,9 +15,9 @@
*/
@Artifact
@ExpectedDeploymentException(DefinitionException.class)
-public class TypeVariableTest
+public class TypeVariableTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "5.8", id = "i")
public void TestInjectionPointMustNotHaveTypeVariable()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/wildcard/NoWildcardTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/wildcard/NoWildcardTest.java 2009-03-19
23:05:24 UTC (rev 2117)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/wildcard/NoWildcardTest.java 2009-03-20
00:05:31 UTC (rev 2118)
@@ -3,6 +3,7 @@
import javax.inject.DefinitionException;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ExpectedDeploymentException;
import org.testng.annotations.Test;
@@ -14,9 +15,9 @@
*/
@Artifact
@ExpectedDeploymentException(DefinitionException.class)
-public class NoWildcardTest
+public class NoWildcardTest extends AbstractJSR299Test
{
- @Test(groups = "ri-broken")
+ @Test
@SpecAssertion(section = "5.8", id = "j")
public void TestInjectionPointMustNotHaveWildcard()
{