Author: pete.muir(a)jboss.org
Date: 2010-02-16 07:38:29 -0500 (Tue, 16 Feb 2010)
New Revision: 5842
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java
Log:
tidy up
Modified: core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16
11:40:10 UTC (rev 5841)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-02-16
12:38:29 UTC (rev 5842)
@@ -488,7 +488,7 @@
@SuppressWarnings("unchecked")
public <T> Set<ObserverMethod<? super T>>
resolveObserverMethods(Type eventType, Annotation... bindings)
{
- checkBindingTypes(Arrays.asList(bindings));
+ checkQualifiers(Arrays.asList(bindings));
HashSet<Annotation> bindingAnnotations = new
HashSet<Annotation>(Arrays.asList(bindings));
bindingAnnotations.add(AnyLiteral.INSTANCE);
Set<ObserverMethod<? super T>> observers = new
HashSet<ObserverMethod<? super T>>();
@@ -500,7 +500,7 @@
return observers;
}
- private void checkBindingTypes(Collection<Annotation> bindings)
+ private void checkQualifiers(Collection<Annotation> bindings)
{
HashSet<Annotation> bindingAnnotations = new
HashSet<Annotation>(bindings);
for (Annotation annotation : bindings)
@@ -879,9 +879,9 @@
}
}
- public <T> Bean<T> getBean(WeldAnnotated<T, ?> element,
Annotation... bindings)
+ public <T> Bean<T> getBean(WeldAnnotated<T, ?> element,
Annotation... qualifiers)
{
- Bean<T> bean = (Bean<T>) resolve(getBeans(element, bindings));
+ Bean<T> bean = (Bean<T>) resolve(getBeans(element, qualifiers));
if (bean == null)
{
throw new UnsatisfiedResolutionException(UNRESOLVABLE_ELEMENT, element);
@@ -900,37 +900,27 @@
return nameBasedResolver.resolve(name);
}
- /**
- * Resolves a list of decorators based on API types and binding types
- *
- * @param types The set of API types to match
- * @param bindings The binding types to match
- * @return A list of matching decorators
- *
- * @see javax.enterprise.inject.spi.BeanManager#resolveDecorators(java.util.Set,
- * java.lang.annotation.Annotation[])
- */
- public List<Decorator<?>> resolveDecorators(Set<Type> types,
Annotation... bindings)
+ public List<Decorator<?>> resolveDecorators(Set<Type> types,
Annotation... qualifiers)
{
- checkResolveDecoratorsArguments(types, Arrays.asList(bindings));
+ checkResolveDecoratorsArguments(types, Arrays.asList(qualifiers));
// TODO Fix this cast and make the resolver return a list
- return new
ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types,
null, bindings)));
+ return new
ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types,
qualifiers, null)));
}
- public List<Decorator<?>> resolveDecorators(Set<Type> types,
Set<Annotation> bindings)
+ public List<Decorator<?>> resolveDecorators(Set<Type> types,
Set<Annotation> qualifiers)
{
- checkResolveDecoratorsArguments(types, bindings);
+ checkResolveDecoratorsArguments(types, qualifiers);
// TODO Fix this cast and make the resolver return a list
- return new
ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types,
bindings, null)));
+ return new
ArrayList<Decorator<?>>(decoratorResolver.resolve(ResolvableFactory.of(types,
qualifiers, null)));
}
- private void checkResolveDecoratorsArguments(Set<Type> types,
Collection<Annotation> bindings)
+ private void checkResolveDecoratorsArguments(Set<Type> types,
Collection<Annotation> qualifiers)
{
if (types.isEmpty())
{
throw new ForbiddenArgumentException(NO_DECORATOR_TYPES);
}
- checkBindingTypes(bindings);
+ checkQualifiers(qualifiers);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java
===================================================================
---
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java 2010-02-16
11:40:10 UTC (rev 5841)
+++
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java 2010-02-16
12:38:29 UTC (rev 5842)
@@ -18,7 +18,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -30,38 +29,39 @@
import org.jboss.weld.bean.AbstractClassBean;
import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.literal.DefaultLiteral;
+import org.jboss.weld.util.collections.Arrays2;
import org.jboss.weld.util.reflection.Reflections;
public class ResolvableFactory
{
- public static Resolvable of(WeldAnnotated<?, ?> element)
+ public static Resolvable of(WeldAnnotated<?, ?> annotated)
{
- if (element instanceof Resolvable)
+ if (annotated instanceof Resolvable)
{
- return (Resolvable) element;
+ return (Resolvable) annotated;
}
else
{
Set<Type> types = new HashSet<Type>();
- types.add(element.getBaseType());
- return new ResolvableImpl(element.getQualifiers(), types, null);
+ types.add(annotated.getBaseType());
+ return new ResolvableImpl(types, annotated.getQualifiers(), null);
}
}
- public static Resolvable of(Set<Type> typeClosure, Set<Annotation>
bindings, AbstractClassBean<?> declaringBean)
+ public static Resolvable of(Set<Type> typeClosure, Set<Annotation>
qualifiers, AbstractClassBean<?> declaringBean)
{
- return new ResolvableImpl(bindings, typeClosure, declaringBean);
+ return new ResolvableImpl(typeClosure, qualifiers, declaringBean);
}
- public static Resolvable of(Set<Type> typeClosure, AbstractClassBean<?>
declaringBean, Annotation... bindings)
+ public static Resolvable of(Set<Type> typeClosure, Annotation[] qualifiers,
AbstractClassBean<?> declaringBean)
{
- return new ResolvableImpl(new HashSet<Annotation>(Arrays.asList(bindings)),
typeClosure, declaringBean);
+ return new ResolvableImpl(typeClosure, Arrays2.asSet(qualifiers), declaringBean);
}
- public static InterceptorResolvable of(InterceptionType interceptionType,
Annotation... bindings)
+ public static InterceptorResolvable of(InterceptionType interceptionType, Annotation[]
qualifiers)
{
- return new InterceptorResolvableImpl(new
HashSet<Annotation>(Arrays.asList(bindings)), interceptionType );
+ return new InterceptorResolvableImpl(Arrays2.asSet(qualifiers), interceptionType
);
}
private ResolvableFactory() {}
@@ -69,21 +69,21 @@
private static class ResolvableImpl implements Resolvable
{
- private final Set<Annotation> bindings;
+ private final Set<Annotation> qualifiers;
private final Map<Class<? extends Annotation>, Annotation>
annotations;
private final Set<Type> typeClosure;
private final AbstractClassBean<?> declaringBean;
- public ResolvableImpl(Set<Annotation> bindings, Set<Type> typeClosure,
AbstractClassBean<?> declaringBean)
+ public ResolvableImpl(Set<Type> typeClosure, Set<Annotation>
qualifiers, AbstractClassBean<?> declaringBean)
{
- this.bindings = bindings;
- if (bindings.size() == 0)
+ this.qualifiers = qualifiers;
+ if (qualifiers.size() == 0)
{
- this.bindings.add(DefaultLiteral.INSTANCE);
+ this.qualifiers.add(DefaultLiteral.INSTANCE);
}
this.annotations = new HashMap<Class<? extends Annotation>,
Annotation>();
this.typeClosure = typeClosure;
- for (Annotation annotation : bindings)
+ for (Annotation annotation : qualifiers)
{
annotations.put(annotation.annotationType(), annotation);
}
@@ -92,7 +92,7 @@
public Set<Annotation> getQualifiers()
{
- return bindings;
+ return qualifiers;
}
public boolean isAnnotationPresent(Class<? extends Annotation>
annotationType)
@@ -140,7 +140,7 @@
private InterceptorResolvableImpl(Set<Annotation> bindings, InterceptionType
interceptionType)
{
- super(bindings, Collections.singleton((Type)Object.class), null);
+ super(Collections.singleton((Type)Object.class), bindings, null);
this.interceptionType = interceptionType;
}