[weld-commits] Weld SVN: r5417 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/builtin and 13 other directories.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Mon Jan 11 14:07:12 EST 2010
Author: pete.muir at jboss.org
Date: 2010-01-11 14:07:10 -0500 (Mon, 11 Jan 2010)
New Revision: 5417
Added:
core/trunk/impl/src/main/java/org/jboss/weld/literal/QualifierLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArrayListSupplier.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/CopyOnWriteArrayListSupplier.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/HashSetSupplier.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableIterable.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableToIteratorFunction.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/introspector/AnnotationStore.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/BindingTypeLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/InjectLiteral.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/EventBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractBeanDiscoveryEvent.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterDeploymentValidationImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotation.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldConstructor.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldField.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMember.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotation.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldCallable.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldConstructor.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMember.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMethod.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldCallable.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldMember.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldAnnotationImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/AnyLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/DefaultLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/InterceptorBindingTypeLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/NewLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/ScopeLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/literal/StereotypeLiteral.java
core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/BindingTypeModel.java
core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/SecureReflectionAccess.java
Log:
WELD-87, various reorgs,
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractBean.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -69,9 +69,6 @@
public abstract class AbstractBean<T, S> extends RIBean<T>
{
- private static final Annotation ANY_LITERAL = new AnyLiteral();
- private static final Annotation CURRENT_LITERAL = new DefaultLiteral();
-
private boolean proxyable;
// Logger
@@ -192,7 +189,7 @@
{
if (getAnnotatedItem().isAnnotationPresent(Typed.class))
{
- this.types = getTypedTypes(getAnnotatedItem().getTypeClosureAsMap(), getAnnotatedItem().getJavaClass(), getAnnotatedItem().getAnnotation(Typed.class));
+ this.types = getTypedTypes(Reflections.buildTypeMap(getAnnotatedItem().getTypeClosure()), getAnnotatedItem().getJavaClass(), getAnnotatedItem().getAnnotation(Typed.class));
}
else
{
@@ -238,17 +235,17 @@
if (bindings.size() == 0)
{
log.trace(USING_DEFAULT_QUALIFIER, this);
- this.bindings.add(CURRENT_LITERAL);
+ this.bindings.add(DefaultLiteral.INSTANCE);
}
if (bindings.size() == 1)
{
if (bindings.iterator().next().annotationType().equals(Named.class))
{
log.trace(USING_DEFAULT_QUALIFIER, this);
- this.bindings.add(CURRENT_LITERAL);
+ this.bindings.add(DefaultLiteral.INSTANCE);
}
}
- this.bindings.add(ANY_LITERAL);
+ this.bindings.add(AnyLiteral.INSTANCE);
}
protected void initAlternative()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -631,11 +631,11 @@
protected void checkConstructor()
{
- if (!constructor.getAnnotatedWBParameters(Disposes.class).isEmpty())
+ if (!constructor.getWeldParameters(Disposes.class).isEmpty())
{
throw new DefinitionException(PARAMETER_ANNOTATION_NOT_ALLOWED_ON_CONSTRUCTOR, "@Disposes", constructor);
}
- if (!constructor.getAnnotatedWBParameters(Observes.class).isEmpty())
+ if (!constructor.getWeldParameters(Observes.class).isEmpty())
{
throw new DefinitionException(PARAMETER_ANNOTATION_NOT_ALLOWED_ON_CONSTRUCTOR, "@Observes", constructor);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DecoratorImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -134,7 +134,7 @@
protected void initDecoratedTypes()
{
this.decoratedTypes = new HashSet<Type>();
- this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceOnlyFlattenedTypeHierarchy());
+ this.decoratedTypes.addAll(getAnnotatedItem().getInterfaceClosure());
this.decoratedTypes.remove(Serializable.class);
this.decoratedMethodSignatures = Deployers.getDecoratedMethodSignatures(getManager(), this.decoratedTypes);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/DisposalMethod.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -63,7 +63,7 @@
private void initDisposesParameter()
{
- this.disposesParameter = getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).get(0);
+ this.disposesParameter = getAnnotatedItem().getWeldParameters(Disposes.class).get(0);
}
public WeldParameter<?, X> getDisposesParameter()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -151,11 +151,11 @@
*/
protected void checkProducerMethod()
{
- if (getAnnotatedItem().getAnnotatedWBParameters(Observes.class).size() > 0)
+ if (getAnnotatedItem().getWeldParameters(Observes.class).size() > 0)
{
throw new DefinitionException(INCONSISTENT_ANNOTATIONS_ON_METHOD, "@Produces", "@Observes");
}
- else if (getAnnotatedItem().getAnnotatedWBParameters(Disposes.class).size() > 0)
+ else if (getAnnotatedItem().getWeldParameters(Disposes.class).size() > 0)
{
throw new DefinitionException(INCONSISTENT_ANNOTATIONS_ON_METHOD, "@Produces", "@Disposes");
}
@@ -276,7 +276,7 @@
@Override
protected void preSpecialize(BeanDeployerEnvironment environment)
{
- if (getDeclaringBean().getAnnotatedItem().getWeldSuperclass().getDeclaredWeldMethod(getAnnotatedItem().getAnnotatedMethod()) == null)
+ if (getDeclaringBean().getAnnotatedItem().getWeldSuperclass().getDeclaredWeldMethod(getAnnotatedItem().getJavaMember()) == null)
{
throw new DefinitionException(PRODUCER_METHOD_NOT_SPECIALIZING, this);
}
@@ -285,7 +285,7 @@
@Override
protected void specialize(BeanDeployerEnvironment environment)
{
- WeldMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWeldSuperclass().getWeldMethod(getAnnotatedItem().getAnnotatedMethod());
+ WeldMethod<?, ?> superClassMethod = getDeclaringBean().getAnnotatedItem().getWeldSuperclass().getWeldMethod(getAnnotatedItem().getJavaMember());
if (environment.getProducerMethod(superClassMethod) == null)
{
throw new ForbiddenStateException(PRODUCER_METHOD_NOT_SPECIALIZING, this);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/AbstractBuiltInBean.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -17,9 +17,7 @@
package org.jboss.weld.bean.builtin;
import java.lang.annotation.Annotation;
-import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import javax.enterprise.context.Dependent;
@@ -30,15 +28,14 @@
import org.jboss.weld.literal.AnyLiteral;
import org.jboss.weld.literal.DefaultLiteral;
import org.jboss.weld.manager.BeanManagerImpl;
+import org.jboss.weld.util.collections.Arrays2;
public abstract class AbstractBuiltInBean<T> extends RIBean<T>
{
private static final String ID_PREFIX = "Built-in";
+ private static final Set<Annotation> DEFAULT_QUALIFIERS = Arrays2.asSet( DefaultLiteral.INSTANCE, AnyLiteral.INSTANCE );
- private static final Annotation[] DEFAULT_BINDING_ARRAY = { new DefaultLiteral(), new AnyLiteral() };
- private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
-
protected AbstractBuiltInBean(String idSuffix, BeanManagerImpl manager)
{
super(new StringBuilder().append(ID_PREFIX).append(BEAN_ID_SEPARATOR).append(idSuffix).toString(), manager);
@@ -53,7 +50,7 @@
public Set<Annotation> getQualifiers()
{
- return DEFAULT_BINDING;
+ return DEFAULT_QUALIFIERS;
}
public Class<? extends Annotation> getScope()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/EventBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/EventBean.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/EventBean.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -18,8 +18,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
import javax.enterprise.event.Event;
@@ -36,8 +35,7 @@
private static final Class<Event<?>> TYPE = new TypeLiteral<Event<?>>() {}.getRawType();
private static final Set<Type> DEFAULT_TYPES = Arrays2.<Type>asSet(TYPE, Object.class);
- private static final Annotation ANY = new AnyLiteral();
- private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>(Arrays.asList(ANY));
+ private static final Set<Annotation> DEFAULT_QUALIFIERS = Collections.<Annotation>singleton(AnyLiteral.INSTANCE);
public EventBean(BeanManagerImpl manager)
@@ -65,7 +63,7 @@
@Override
public Set<Annotation> getQualifiers()
{
- return DEFAULT_BINDINGS;
+ return DEFAULT_QUALIFIERS;
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/FacadeBeanResolvableTransformer.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -38,13 +38,7 @@
public class FacadeBeanResolvableTransformer implements ResolvableTransformer
{
- private static final Set<Annotation> bindings;
-
- static
- {
- bindings = new HashSet<Annotation>();
- bindings.add(new AnyLiteral());
- }
+ private static final Set<Annotation> DEFAULT_QUALIFIERS = Collections.<Annotation>singleton(AnyLiteral.INSTANCE);
private final Class<?> clazz;
private final HashSet<Type> types;
@@ -72,7 +66,7 @@
@Override
public Set<Annotation> getQualifiers()
{
- return Collections.unmodifiableSet(bindings);
+ return Collections.unmodifiableSet(DEFAULT_QUALIFIERS);
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceBean.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/InstanceBean.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -18,11 +18,9 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Set;
-import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.util.TypeLiteral;
@@ -37,8 +35,7 @@
private static final Class<Instance<?>> INSTANCE_TYPE = new TypeLiteral<Instance<?>>() {}.getRawType();
private static final Class<Provider<?>> PROVIDER_TYPE = new TypeLiteral<Provider<?>>() {}.getRawType();
private static final Set<Type> DEFAULT_TYPES = Arrays2.<Type>asSet(INSTANCE_TYPE, PROVIDER_TYPE, Object.class);
- private static final Any ANY = new AnyLiteral();
- private static final Set<Annotation> DEFAULT_BINDINGS = new HashSet<Annotation>(Arrays.asList(ANY));
+ private static final Set<Annotation> DEFAULT_QUALIFIERS = Collections.<Annotation>singleton(AnyLiteral.INSTANCE);
public InstanceBean(BeanManagerImpl manager)
{
@@ -65,7 +62,7 @@
@Override
public Set<Annotation> getQualifiers()
{
- return DEFAULT_BINDINGS;
+ return DEFAULT_QUALIFIERS;
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -173,7 +173,7 @@
protected <X> void createProducerMethods(AbstractClassBean<X> declaringBean, WeldClass<X> annotatedClass)
{
- for (WeldMethod<?, X> method : annotatedClass.getDeclaredAnnotatedWeldMethods(Produces.class))
+ for (WeldMethod<?, X> method : annotatedClass.getDeclaredWeldMethods(Produces.class))
{
createProducerMethod(declaringBean, method);
}
@@ -211,7 +211,7 @@
protected <X> void createProducerFields(AbstractClassBean<X> declaringBean, WeldClass<X> annotatedClass)
{
- for (WeldField<?, X> field : annotatedClass.getDeclaredAnnotatedWeldFields(Produces.class))
+ for (WeldField<?, X> field : annotatedClass.getDeclaredWeldFields(Produces.class))
{
createProducerField(declaringBean, field);
}
@@ -306,7 +306,7 @@
private static boolean hasSimpleWebBeanConstructor(WeldClass<?> type)
{
- return type.getNoArgsWeldConstructor() != null || type.getAnnotatedWeldConstructors(Inject.class).size() > 0;
+ return type.getNoArgsWeldConstructor() != null || type.getWeldConstructors(Inject.class).size() > 0;
}
public E getEnvironment()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/WeldBootstrap.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -134,9 +134,7 @@
{
private final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
- private final Set<Class<?>> beanClasses = (deployment.getServices().contains(ServletServices.class))
- ? Arrays2.<Class<?>>asSet(ConversationImpl.class, ServletConversationManager.class, NumericConversationIdGenerator.class, HttpSessionManager.class)
- : Collections.EMPTY_SET;
+ private final Set<Class<?>> beanClasses = (deployment.getServices().contains(ServletServices.class)) ? Arrays2.<Class<?>> asSet(ConversationImpl.class, ServletConversationManager.class, NumericConversationIdGenerator.class, HttpSessionManager.class) : Collections.<Class<?>>emptySet();
public ServiceRegistry getServices()
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractBeanDiscoveryEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractBeanDiscoveryEvent.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractBeanDiscoveryEvent.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,11 +16,12 @@
*/
package org.jboss.weld.bootstrap.events;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_TYPES;
+
import java.lang.reflect.Type;
import java.util.Map;
import org.jboss.weld.bootstrap.BeanDeployment;
-import org.jboss.weld.bootstrap.ExtensionBeanDeployerEnvironment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.manager.BeanManagerImpl;
@@ -38,7 +39,7 @@
public AbstractBeanDiscoveryEvent(BeanManagerImpl beanManager, Type rawType, Map<BeanDeploymentArchive, BeanDeployment> beanDeployments, Deployment deployment)
{
- super(beanManager, rawType, EMPTY_TYPE_ARRAY);
+ super(beanManager, rawType, EMPTY_TYPES);
this.beanDeployments = beanDeployments;
this.deployment = deployment;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AbstractContainerEvent.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -14,11 +14,8 @@
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.util.reflection.ParameterizedTypeImpl;
-
public abstract class AbstractContainerEvent
{
-
- protected static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
private final List<Throwable> errors;
private final BeanManagerImpl beanManager;
@@ -66,7 +63,7 @@
Type eventType = new ParameterizedTypeImpl(getRawType(), getEmptyTypeArray(), null);
for (BeanDeployment beanDeployment : beanDeployments.values())
{
- observers.addAll((Set) beanDeployment.getBeanManager().resolveObserverMethods(eventType));
+ observers.addAll(beanDeployment.getBeanManager().resolveObserverMethods(eventType));
}
for (ObserverMethod<Object> observerMethod : observers)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterDeploymentValidationImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterDeploymentValidationImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/AfterDeploymentValidationImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,6 +16,8 @@
*/
package org.jboss.weld.bootstrap.events;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_TYPES;
+
import java.util.Map;
import javax.enterprise.inject.spi.AfterDeploymentValidation;
@@ -24,7 +26,6 @@
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.manager.BeanManagerImpl;
-
public class AfterDeploymentValidationImpl extends AbstractDeploymentContainerEvent implements AfterDeploymentValidation
{
@@ -35,7 +36,7 @@
protected AfterDeploymentValidationImpl(BeanManagerImpl beanManager)
{
- super(beanManager, AfterDeploymentValidation.class, EMPTY_TYPE_ARRAY);
+ super(beanManager, AfterDeploymentValidation.class, EMPTY_TYPES);
}
public void addDeploymentProblem(Throwable t)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeBeanDiscoveryImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -25,7 +25,7 @@
import org.jboss.weld.bootstrap.BeanDeployment;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
import org.jboss.weld.bootstrap.spi.Deployment;
-import org.jboss.weld.literal.BindingTypeLiteral;
+import org.jboss.weld.literal.QualifierLiteral;
import org.jboss.weld.literal.InterceptorBindingTypeLiteral;
import org.jboss.weld.literal.NormalScopeLiteral;
import org.jboss.weld.literal.ScopeLiteral;
@@ -47,12 +47,12 @@
public void addQualifier(Class<? extends Annotation> bindingType)
{
- getTypeStore().add(bindingType, new BindingTypeLiteral());
+ getTypeStore().add(bindingType, QualifierLiteral.INSTANCE);
}
public void addInterceptorBinding(Class<? extends Annotation> bindingType)
{
- getTypeStore().add(bindingType, new InterceptorBindingTypeLiteral());
+ getTypeStore().add(bindingType, InterceptorBindingTypeLiteral.INSTANCE);
}
public void addScope(Class<? extends Annotation> scopeType, boolean normal, boolean passivating)
@@ -63,13 +63,13 @@
}
else
{
- getTypeStore().add(scopeType, new ScopeLiteral());
+ getTypeStore().add(scopeType, ScopeLiteral.INSTANCE);
}
}
public void addStereotype(Class<? extends Annotation> stereotype, Annotation... stereotypeDef)
{
- getTypeStore().add(stereotype, new StereotypeLiteral());
+ getTypeStore().add(stereotype, StereotypeLiteral.INSTANCE);
for(Annotation a : stereotypeDef)
{
getTypeStore().add(stereotype, a);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/events/BeforeShutdownImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,6 +16,8 @@
*/
package org.jboss.weld.bootstrap.events;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_TYPES;
+
import java.util.Map;
import javax.enterprise.inject.spi.BeforeShutdown;
@@ -46,7 +48,7 @@
public BeforeShutdownImpl(BeanManagerImpl beanManager)
{
- super(beanManager, BeforeShutdown.class, EMPTY_TYPE_ARRAY);
+ super(beanManager, BeforeShutdown.class, EMPTY_TYPES);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/EventImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -52,7 +52,6 @@
{
private static final long serialVersionUID = 656782657242515455L;
- private static final Default DEFAULT = new DefaultLiteral();
public static <E> EventImpl<E> of(InjectionPoint injectionPoint, BeanManagerImpl beanManager)
{
@@ -64,7 +63,7 @@
if (!injectionPoint.getAnnotated().isAnnotationPresent(Default.class))
{
Set<Annotation> qualifers = new HashSet<Annotation>(injectionPoint.getQualifiers());
- qualifers.remove(DEFAULT);
+ qualifers.remove(DefaultLiteral.INSTANCE);
return qualifers.toArray(EMPTY_ANNOTATIONS);
}
else
Modified: core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverFactory.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/event/ObserverFactory.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -64,7 +64,7 @@
*/
public static TransactionPhase getTransactionalPhase(WeldMethod<?, ?> observer)
{
- WeldParameter<?, ?> parameter = observer.getAnnotatedWBParameters(Observes.class).iterator().next();
+ WeldParameter<?, ?> parameter = observer.getWeldParameters(Observes.class).iterator().next();
return parameter.getAnnotation(Observes.class).during();
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ConstructorInjectionPoint.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -69,8 +69,6 @@
}
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
private final Bean<T> declaringBean;
private final WeldConstructor<T> constructor;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/FieldInjectionPoint.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -43,8 +43,6 @@
public class FieldInjectionPoint<T, X> extends ForwardingWeldField<T, X> implements WeldInjectionPoint<T, Field>, Serializable
{
-
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
private final Bean<?> declaringBean;
private final WeldField<T, X> field;
@@ -132,14 +130,12 @@
{
return getBaseType();
}
-
+
public Member getMember()
{
return getJavaMember();
}
-
-
// Serialization
private Object writeReplace() throws ObjectStreamException
Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/MethodInjectionPoint.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -66,8 +66,6 @@
}
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
private final Bean<?> declaringBean;
private final WeldMethod<T, X> method;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/injection/ParameterInjectionPoint.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -49,8 +49,6 @@
public class ParameterInjectionPoint<T, X> extends ForwardingWeldParameter<T, X> implements WeldInjectionPoint<T, Object>, Serializable
{
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
public static <T, X> ParameterInjectionPoint<T, X> of(Bean<?> declaringBean, WeldParameter<T, X> parameter)
{
return new ParameterInjectionPoint<T, X>(declaringBean, parameter);
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/introspector/AnnotationStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/AnnotationStore.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/AnnotationStore.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -1,292 +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.weld.introspector;
-
-import static org.jboss.weld.introspector.WeldAnnotated.MAPPED_METAANNOTATIONS;
-import static org.jboss.weld.logging.messages.ReflectionMessage.ANNOTATION_MAP_NULL;
-import static org.jboss.weld.logging.messages.ReflectionMessage.DECLARED_ANNOTATION_MAP_NULL;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Qualifier;
-
-import org.jboss.weld.exceptions.WeldException;
-import org.jboss.weld.literal.DefaultLiteral;
-import org.jboss.weld.logging.messages.ReflectionMessage;
-import org.jboss.weld.metadata.TypeStore;
-
-import com.google.common.base.Supplier;
-import com.google.common.collect.Multimaps;
-import com.google.common.collect.SetMultimap;
-
-public class AnnotationStore
-{
-
- // The array of default binding types
- private static final Annotation[] DEFAULT_BINDING_ARRAY = { new DefaultLiteral() };
- // The set of default binding types
- private static final Set<Annotation> DEFAULT_BINDING = new HashSet<Annotation>(Arrays.asList(DEFAULT_BINDING_ARRAY));
-
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
- /**
- * Builds the annotation map (annotation type -> annotation)
- *
- * @param annotations The array of annotations to map
- * @return The annotation map
- */
- protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Annotation[] annotations)
- {
- Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- for (Annotation annotation : annotations)
- {
- annotationMap.put(annotation.annotationType(), annotation);
- }
- return annotationMap;
- }
-
- /**
- * Builds the annotation map (annotation type -> annotation)
- *
- * @param annotations The array of annotations to map
- * @return The annotation map
- */
- protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Iterable<Annotation> annotations)
- {
- Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- for (Annotation annotation : annotations)
- {
- annotationMap.put(annotation.annotationType(), annotation);
- }
- return annotationMap;
- }
-
- /**
- * Build an AnnotatedItemHelper from a class
- *
- * @param annotatedElement
- * @return
- */
- public static AnnotationStore of(AnnotatedElement annotatedElement, TypeStore typeStore)
- {
- return new AnnotationStore(buildAnnotationMap(annotatedElement.getAnnotations()), buildAnnotationMap(annotatedElement.getDeclaredAnnotations()), typeStore);
- }
-
- public static AnnotationStore of(AnnotatedElement annotatedElement, Set<Annotation> extraAnnotations, Set<Annotation> extraDeclaredAnnotations, TypeStore typeStore)
- {
- Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- annotationMap.putAll(buildAnnotationMap(annotatedElement.getAnnotations()));
- annotationMap.putAll(buildAnnotationMap(extraAnnotations));
-
- Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- declaredAnnotationMap.putAll(buildAnnotationMap(annotatedElement.getDeclaredAnnotations()));
- declaredAnnotationMap.putAll(buildAnnotationMap(extraDeclaredAnnotations));
-
- return new AnnotationStore(annotationMap, declaredAnnotationMap, typeStore);
- }
-
- public static AnnotationStore of(Annotation[] annotations, Annotation[] declaredAnnotations, TypeStore typeStore)
- {
- return new AnnotationStore(buildAnnotationMap(annotations), buildAnnotationMap(declaredAnnotations), typeStore);
- }
-
- public static AnnotationStore of(Set<Annotation> annotations, Set<Annotation> declaredAnnotations, TypeStore typeStore)
- {
- return new AnnotationStore(buildAnnotationMap(annotations), buildAnnotationMap(declaredAnnotations), typeStore);
- }
-
- public static AnnotationStore wrap(AnnotationStore annotationStore, Set<Annotation> annotations, Set<Annotation> declaredAnnotations, TypeStore typeStore)
- {
- Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- annotationMap.putAll(buildAnnotationMap(annotations));
- annotationMap.putAll(annotationStore.getAnnotationMap());
-
- Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
- declaredAnnotationMap.putAll(buildAnnotationMap(declaredAnnotations));
- declaredAnnotationMap.putAll(annotationStore.getDeclaredAnnotationMap());
-
- return new AnnotationStore(annotationMap, declaredAnnotationMap, typeStore);
- }
-
- // The annotation map (annotation type -> annotation) of the item
- private final Map<Class<? extends Annotation>, Annotation> annotationMap;
- // The meta-annotation map (annotation type -> set of annotations containing
- // meta-annotation) of the item
- private final SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap;
- // The set of all annotations on the item
- private final Set<Annotation> annotationSet;
-
- // The annotation map (annotation type -> annotation) of the item
- private final Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap;
- // The meta-annotation map (annotation type -> set of annotations containing
- // meta-annotation) of the item
- private final SetMultimap<Class<? extends Annotation>, Annotation> declaredMetaAnnotationMap;
- // The set of all annotations on the item
- private final Set<Annotation> declaredAnnotationSet;
-
- /**
- * Constructor
- *
- * Also builds the meta-annotation map. Throws a NullPointerException if
- * trying to register a null map
- *
- * @param annotationMap A map of annotation to register
- *
- */
- protected AnnotationStore(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, TypeStore typeStore)
- {
- if (annotationMap == null)
- {
- throw new WeldException(ANNOTATION_MAP_NULL);
- }
- this.annotationMap = annotationMap;
- this.annotationSet = new HashSet<Annotation>();
- this.metaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<Annotation>>(), new Supplier<Set<Annotation>>()
- {
-
- public Set<Annotation> get()
- {
- return new HashSet<Annotation>();
- }
- });
- for (Annotation annotation : annotationMap.values())
- {
- addMetaAnnotations(metaAnnotationMap, annotation, annotation.annotationType().getAnnotations());
- addMetaAnnotations(metaAnnotationMap, annotation, typeStore.get(annotation.annotationType()));
- annotationSet.add(annotation);
- }
-
- if (declaredAnnotationMap == null)
- {
- throw new WeldException(DECLARED_ANNOTATION_MAP_NULL);
- }
- this.declaredAnnotationMap = declaredAnnotationMap;
- this.declaredAnnotationSet = new HashSet<Annotation>();
- this.declaredMetaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<Annotation>>(), new Supplier<Set<Annotation>>()
- {
-
- public Set<Annotation> get()
- {
- return new HashSet<Annotation>();
- }
- });
- for (Annotation declaredAnnotation : declaredAnnotationMap.values())
- {
- addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, declaredAnnotation.annotationType().getAnnotations());
- addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, typeStore.get(declaredAnnotation.annotationType()));
- declaredAnnotationSet.add(declaredAnnotation);
- }
- }
-
- private static void addMetaAnnotations(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Annotation[] metaAnnotations)
- {
- for (Annotation metaAnnotation : metaAnnotations)
- {
- addMetaAnnotation(metaAnnotationMap, annotation, metaAnnotation.annotationType());
- }
- }
-
- private static void addMetaAnnotations(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Iterable<Annotation> metaAnnotations)
- {
- for (Annotation metaAnnotation : metaAnnotations)
- {
- addMetaAnnotation(metaAnnotationMap, annotation, metaAnnotation.annotationType());
- }
- }
-
- private static void addMetaAnnotation(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Class<? extends Annotation> metaAnnotationType)
- {
- // Only map meta-annotations we are interested in
- if (MAPPED_METAANNOTATIONS.contains(metaAnnotationType))
- {
- metaAnnotationMap.put(metaAnnotationType, annotation);
- }
- }
-
- public Set<Annotation> getAnnotations()
- {
- return Collections.unmodifiableSet(annotationSet);
- }
-
- public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
- {
- return Collections.unmodifiableSet(metaAnnotationMap.get(metaAnnotationType));
- }
-
- public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
- {
- return Collections.unmodifiableSet(declaredMetaAnnotationMap.get(metaAnnotationType));
- }
-
- public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation> metaAnnotationType)
- {
- return getMetaAnnotations(metaAnnotationType).toArray(EMPTY_ANNOTATION_ARRAY);
- }
-
- @Deprecated
- public Set<Annotation> getBindings()
- {
- if (getMetaAnnotations(Qualifier.class).size() > 0)
- {
- return Collections.unmodifiableSet(getMetaAnnotations(Qualifier.class));
- }
- else
- {
- return Collections.unmodifiableSet(DEFAULT_BINDING);
- }
- }
-
- @Deprecated
- public Annotation[] getBindingsAsArray()
- {
- return getBindings().toArray(EMPTY_ANNOTATION_ARRAY);
- }
-
- public <A extends Annotation> A getAnnotation(Class<? extends A> annotationType)
- {
- return annotationType.cast(annotationMap.get(annotationType));
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return annotationMap.containsKey(annotationType);
- }
-
- public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return declaredAnnotationMap.containsKey(annotationType);
- }
-
- Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
- {
- return annotationMap;
- }
-
- Map<Class<? extends Annotation>, Annotation> getDeclaredAnnotationMap()
- {
- return declaredAnnotationMap;
- }
-
-}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotated.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -18,7 +18,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Map;
import java.util.Set;
/**
@@ -42,16 +41,6 @@
return delegate().getMetaAnnotations(metaAnnotationType);
}
- public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation> metaAnnotationType)
- {
- return delegate().getMetaAnnotationsAsArray(metaAnnotationType);
- }
-
- public Map<Class<?>, Type> getTypeClosureAsMap()
- {
- return delegate().getTypeClosureAsMap();
- }
-
@Deprecated
public Set<Annotation> getQualifiers()
{
@@ -64,11 +53,6 @@
return delegate().getBindingsAsArray();
}
- public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
- {
- return delegate().getDeclaredMetaAnnotations(metaAnnotationType);
- }
-
public String getName()
{
return delegate().getName();
@@ -117,16 +101,11 @@
@Override
protected abstract WeldAnnotated<T, S> delegate();
- public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
+ public Set<Type> getInterfaceClosure()
{
- return delegate().isDeclaredAnnotationPresent(annotationType);
+ return delegate().getInterfaceClosure();
}
- public Set<Type> getInterfaceOnlyFlattenedTypeHierarchy()
- {
- return delegate().getInterfaceOnlyFlattenedTypeHierarchy();
- }
-
public boolean isParameterizedType()
{
return delegate().isParameterizedType();
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotation.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotation.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldAnnotation.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -25,9 +25,9 @@
@Override
protected abstract WeldAnnotation<T> delegate();
- public Set<WeldMethod<?, ?>> getAnnotatedMembers(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, ?>> getMembers(Class<? extends Annotation> annotationType)
{
- return delegate().getAnnotatedMembers(annotationType);
+ return delegate().getMembers(annotationType);
}
public Set<WeldMethod<?, ?>> getMembers()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldClass.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -26,44 +26,39 @@
@Override
protected abstract WeldClass<T> delegate();
- public Set<WeldConstructor<T>> getAnnotatedWeldConstructors(Class<? extends Annotation> annotationType)
+ public Set<WeldConstructor<T>> getWeldConstructors(Class<? extends Annotation> annotationType)
{
- return delegate().getAnnotatedWeldConstructors(annotationType);
+ return delegate().getWeldConstructors(annotationType);
}
- public Set<WeldField<?, ?>> getAnnotatedWeldFields(Class<? extends Annotation> annotationType)
+ public Set<WeldField<?, ?>> getWeldFields(Class<? extends Annotation> annotationType)
{
- return delegate().getAnnotatedWeldFields(annotationType);
+ return delegate().getWeldFields(annotationType);
}
- public Set<WeldMethod<?, ?>> getAnnotatedWeldMethods(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, ?>> getWeldMethods(Class<? extends Annotation> annotationType)
{
- return delegate().getAnnotatedWeldMethods(annotationType);
+ return delegate().getWeldMethods(annotationType);
}
public WeldConstructor<T> getNoArgsWeldConstructor()
{
return delegate().getNoArgsWeldConstructor();
}
-
- public Set<WeldConstructor<T>> getWeldConstructors()
- {
- return delegate().getWeldConstructors();
- }
public Set<WeldMethod<?, ?>> getWeldMethods()
{
return delegate().getWeldMethods();
}
- public Set<WeldField<?, T>> getDeclaredAnnotatedWeldFields(Class<? extends Annotation> annotationType)
+ public Set<WeldField<?, T>> getDeclaredWeldFields(Class<? extends Annotation> annotationType)
{
- return delegate().getDeclaredAnnotatedWeldFields(annotationType);
+ return delegate().getDeclaredWeldFields(annotationType);
}
- public Set<WeldMethod<?, T>> getDeclaredAnnotatedWeldMethods(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, T>> getDeclaredWeldMethods(Class<? extends Annotation> annotationType)
{
- return delegate().getDeclaredAnnotatedWeldMethods(annotationType);
+ return delegate().getDeclaredWeldMethods(annotationType);
}
public Set<WeldMethod<?, T>> getDeclaredWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
@@ -76,11 +71,6 @@
return delegate().getWeldFields();
}
- public Set<WeldField<?, ?>> getMetaAnnotatedWeldFields(Class<? extends Annotation> metaAnnotationType)
- {
- return delegate().getMetaAnnotatedWeldFields(metaAnnotationType);
- }
-
@Deprecated
public WeldMethod<?, ?> getWeldMethod(Method method)
{
@@ -92,16 +82,6 @@
return delegate().getWeldMethod(signature);
}
- public Set<WeldMethod<?, ?>> getWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
- {
- return delegate().getWeldMethodsWithAnnotatedParameters(annotationType);
- }
-
- public Set<WeldConstructor<?>> getWeldConstructorsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
- {
- return delegate().getWeldConstructorsWithAnnotatedParameters(annotationType);
- }
-
public WeldClass<?> getWeldSuperclass()
{
return delegate().getWeldSuperclass();
@@ -184,4 +164,9 @@
return delegate().getSimpleName();
}
+ public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
+ {
+ return delegate().getDeclaredMetaAnnotations(metaAnnotationType);
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldConstructor.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldConstructor.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldConstructor.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -29,9 +29,9 @@
@Override
protected abstract WeldConstructor<T> delegate();
- public List<WeldParameter<?, T>> getAnnotatedWBParameters(Class<? extends Annotation> annotationType)
+ public List<WeldParameter<?, T>> getWeldParameters(Class<? extends Annotation> annotationType)
{
- return delegate().getAnnotatedWBParameters(annotationType);
+ return delegate().getWeldParameters(annotationType);
}
@Override
@@ -60,4 +60,9 @@
return delegate().getParameters();
}
+ public Constructor<T> getJavaMember()
+ {
+ return delegate().getJavaMember();
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldField.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldField.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -29,6 +29,7 @@
return delegate().get(instance);
}
+ @Override
public WeldClass<X> getDeclaringType()
{
return delegate().getDeclaringType();
@@ -48,5 +49,10 @@
{
return delegate().isTransient();
}
+
+ public Field getJavaMember()
+ {
+ return delegate().getJavaMember();
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMember.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMember.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMember.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -23,11 +23,6 @@
@Override
protected abstract WeldMember<T, X, S> delegate();
-
- public S getJavaMember()
- {
- return delegate().getJavaMember();
- }
public WeldClass<X> getDeclaringType()
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMethod.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/ForwardingWeldMethod.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -29,14 +29,9 @@
@Override
protected abstract WeldMethod<T, X> delegate();
- public Method getAnnotatedMethod()
- {
- return delegate().getAnnotatedMethod();
- }
-
public List<WeldParameter<?, X>> getAnnotatedParameters(Class<? extends Annotation> metaAnnotationType)
{
- return delegate().getAnnotatedWBParameters(metaAnnotationType);
+ return delegate().getWeldParameters(metaAnnotationType);
}
public Class<?>[] getParameterTypesAsArray()
@@ -74,14 +69,19 @@
return delegate().getSignature();
}
- public List<WeldParameter<?, X>> getAnnotatedWBParameters(Class<? extends Annotation> metaAnnotationType)
+ public List<WeldParameter<?, X>> getWeldParameters(Class<? extends Annotation> metaAnnotationType)
{
- return delegate().getAnnotatedWBParameters(metaAnnotationType);
+ return delegate().getWeldParameters(metaAnnotationType);
}
public List<AnnotatedParameter<X>> getParameters()
{
return delegate().getParameters();
}
+
+ public Method getJavaMember()
+ {
+ return delegate().getJavaMember();
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotated.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -18,9 +18,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import javax.enterprise.context.NormalScope;
@@ -30,6 +27,8 @@
import javax.inject.Scope;
import javax.interceptor.InterceptorBinding;
+import org.jboss.weld.util.collections.Arrays2;
+
/**
* AnnotatedItem provides a uniform access to the annotations on an annotated
* item defined either in Java or XML
@@ -37,44 +36,31 @@
* @author Pete Muir
*
*/
+
public interface WeldAnnotated<T, S> extends Annotated
{
- // The set of meta-annotations to map
- @SuppressWarnings("unchecked")
- public static final Set<Class<? extends Annotation>> MAPPED_METAANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(Qualifier.class, Stereotype.class, Scope.class, NormalScope.class, InterceptorBinding.class));
-
/**
- * Gets all annotations which are annotated with the given meta annotation
- * type
- *
- * @param The meta annotation to match
- * @return A set of matching meta-annotations. Returns an empty set if there
- * are no matches.
+ * The set of meta-annotations to map
*/
- public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType);
+ @SuppressWarnings("unchecked")
+ public static final Set<Class<? extends Annotation>> MAPPED_METAANNOTATIONS = Arrays2.asSet(Qualifier.class, Stereotype.class, Scope.class, NormalScope.class, InterceptorBinding.class);
- public Map<Class<?>, Type> getTypeClosureAsMap();
-
/**
- * Gets all annotations which are declared on this annotated item with the
- * given meta annotation type
- *
- * @param The meta annotation to match
- * @return A set of matching meta-annotations. Returns an empty set if there
- * are no matches.
+ * The set of declared meta-annotations to map
*/
- public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType);
+ @SuppressWarnings("unchecked")
+ public static final Set<Class<? extends Annotation>> MAPPED_DECLARED_METAANNOTATIONS = Arrays2.asSet(Scope.class, NormalScope.class);
/**
* Gets all annotations which are annotated with the given meta annotation
* type
*
* @param The meta annotation to match
- * @return An array of matching meta-annotations. Returns an empty array if
- * there are no matches.
+ * @return A set of matching meta-annotations. Returns an empty set if there
+ * are no matches.
*/
- public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation> metaAnnotationType);
+ public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType);
/**
* Gets the binding types for this element
@@ -106,19 +92,13 @@
* The returned types should have any type parameters resolved to their
* actual types.
*
+ * There is no guarantee this methods executes in O(1) time
+ *
* @return the type hierarchy
*/
- public Set<Type> getInterfaceOnlyFlattenedTypeHierarchy();
+ public Set<Type> getInterfaceClosure();
/**
- * Indicates if an annotation type specified is present
- *
- * @param annotationType The annotation to match
- * @return True if present, false if not
- */
- public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType);
-
- /**
* Gets the type of the element
*
* @return The type of the element
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotation.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotation.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldAnnotation.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -40,14 +40,6 @@
* @param annotationType The annotation type to match
* @return A set of abstracted members with the annotation type
*/
- public Set<WeldMethod<?, ?>> getAnnotatedMembers(Class<? extends Annotation> annotationType);
+ public Set<WeldMethod<?, ?>> getMembers(Class<? extends Annotation> annotationType);
- /**
- * Get an annotation member by name
- *
- * @param memberName
- * @return
- */
- public <A> WeldMethod<A, ?> getMember(String memberName, WeldClass<A> expectedType);
-
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldCallable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldCallable.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldCallable.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -19,9 +19,14 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.util.List;
+import java.util.Set;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.spi.AnnotatedCallable;
+import org.jboss.weld.util.collections.Arrays2;
+
/**
* @author pmuir
*
@@ -29,6 +34,9 @@
public interface WeldCallable<T, X, S extends Member> extends WeldMember<T, X, S>, AnnotatedCallable<X>
{
+ @SuppressWarnings("unchecked")
+ public static final Set<Class<? extends Annotation>> MAPPED_PARAMETER_ANNOTATIONS = Arrays2.asSet(Disposes.class, Observes.class);
+
/**
* Gets the abstracted parameters of the method
*
@@ -40,10 +48,10 @@
/**
* Gets the list of annotated parameters for a given annotation
*
- * @param metaAnnotationType The annotation to match
+ * @param annotationType The annotation to match
* @return A set of matching parameter abstractions. Returns an empty list if
* there are no matches.
*/
- public List<WeldParameter<?, X>> getAnnotatedWBParameters(Class<? extends Annotation> metaAnnotationType);
+ public List<WeldParameter<?, X>> getWeldParameters(Class<? extends Annotation> annotationType);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldClass.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -69,7 +69,7 @@
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldField<?, ?>> getAnnotatedWeldFields(Class<? extends Annotation> annotationType);
+ public Set<WeldField<?, ?>> getWeldFields(Class<? extends Annotation> annotationType);
/**
* Gets all fields which are annotated with the given annotation type on this
@@ -79,34 +79,18 @@
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldField<?, T>> getDeclaredAnnotatedWeldFields(Class<? extends Annotation> annotationType);
+ public Set<WeldField<?, T>> getDeclaredWeldFields(Class<? extends Annotation> annotationType);
/**
- * Gets all fields which are meta-annotated with metaAnnotationType
- *
- * @param metaAnnotationType The meta annotation to match
- * @return A set of abstracted fields with the given meta-annotation. Returns
- * an empty set if there are no matches
- */
- public Set<WeldField<?, ?>> getMetaAnnotatedWeldFields(Class<? extends Annotation> metaAnnotationType);
-
- /**
* Gets all constructors which are annotated with annotationType
*
* @param annotationType The annotation type to match
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldConstructor<T>> getAnnotatedWeldConstructors(Class<? extends Annotation> annotationType);
+ public Set<WeldConstructor<T>> getWeldConstructors(Class<? extends Annotation> annotationType);
/**
- * Gets all constructors
- *
- * @return A set of abstracted constructors
- */
- public Set<WeldConstructor<T>> getWeldConstructors();
-
- /**
* Gets the no-args constructor
*
* @return The no-args constructor, or null if not defined
@@ -128,7 +112,7 @@
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldMethod<?, ?>> getAnnotatedWeldMethods(Class<? extends Annotation> annotationType);
+ public Set<WeldMethod<?, ?>> getWeldMethods(Class<? extends Annotation> annotationType);
/**
* Gets all methods annotated with annotationType
@@ -137,7 +121,7 @@
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldMethod<?, T>> getDeclaredAnnotatedWeldMethods(Class<? extends Annotation> annotationType);
+ public Set<WeldMethod<?, T>> getDeclaredWeldMethods(Class<? extends Annotation> annotationType);
/**
* Find the annotated method for a given methodDescriptor
@@ -146,6 +130,8 @@
* @return
*
*/
+ // TODO replace with MethodSignature variant
+ @Deprecated
public WeldMethod<?, ?> getWeldMethod(Method method);
/**
@@ -166,7 +152,7 @@
*/
public <M> WeldMethod<M, ?> getWeldMethod(MethodSignature signature);
- // TODO Replace with AnnotatedMethod variant
+ // TODO Replace with MethodSignature variant
@Deprecated
public WeldMethod<?, ?> getDeclaredWeldMethod(Method method);
@@ -177,24 +163,6 @@
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
- public Set<WeldMethod<?, ?>> getWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType);
-
- /**
- * Gets all with constructors annotated with annotationType
- *
- * @param annotationType The annotation to match
- * @return A set of abstracted constructors with the given annotation. Returns an
- * empty set if there are no matches
- */
- public Set<WeldConstructor<?>> getWeldConstructorsWithAnnotatedParameters(Class<? extends Annotation> annotationType);
-
- /**
- * Gets all with parameters annotated with annotationType
- *
- * @param annotationType The annotation to match
- * @return A set of abstracted methods with the given annotation. Returns an
- * empty set if there are no matches
- */
public Set<WeldMethod<?, T>> getDeclaredWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType);
/**
@@ -230,5 +198,16 @@
public boolean isEquivalent(Class<?> clazz);
public String getSimpleName();
+
+ /**
+ * Gets all annotations which are declared on this annotated item with the
+ * given meta annotation type
+ *
+ * @param The meta annotation to match
+ * @return A set of matching meta-annotations. Returns an empty set if there
+ * are no matches.
+ */
+ public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType);
+
}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldConstructor.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldConstructor.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldConstructor.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,11 +16,8 @@
*/
package org.jboss.weld.introspector;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.Collections;
-import java.util.Set;
import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -33,9 +30,6 @@
public interface WeldConstructor<T> extends WeldCallable<T, T, Constructor<T>>, AnnotatedConstructor<T>
{
- @SuppressWarnings("unchecked")
- public static final Set<Class<? extends Annotation>> MAPPED_PARAMETER_ANNOTATIONS = Collections.emptySet();
-
/**
* Creates a new instance of the class, using this constructor
*
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMember.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMember.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMember.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -28,8 +28,6 @@
public interface WeldMember<T, X, S extends Member> extends WeldAnnotated<T, S>, AnnotatedMember<X>
{
- public S getJavaMember();
-
/**
* Gets an abstraction of the declaring class
*
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMethod.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/WeldMethod.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,15 +16,9 @@
*/
package org.jboss.weld.introspector;
-import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.spi.AnnotatedMethod;
/**
@@ -36,8 +30,6 @@
*/
public interface WeldMethod<T, X> extends WeldCallable<T, X, Method>, AnnotatedMethod<X>
{
- @SuppressWarnings("unchecked")
- public static final Set<Class<? extends Annotation>> MAPPED_PARAMETER_ANNOTATIONS = new HashSet<Class<? extends Annotation>>(Arrays.asList(Disposes.class, Observes.class, Disposes.class));
/**
* Get the parameter types as an array
@@ -78,8 +70,6 @@
*/
public boolean isEquivalent(Method method);
- public Method getAnnotatedMethod();
-
public MethodSignature getSignature();
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldAnnotated.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,22 +16,38 @@
*/
package org.jboss.weld.introspector.jlr;
+import static org.jboss.weld.logging.messages.ReflectionMessage.ANNOTATION_MAP_NULL;
+import static org.jboss.weld.logging.messages.ReflectionMessage.DECLARED_ANNOTATION_MAP_NULL;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;
+
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.jboss.weld.introspector.AnnotationStore;
+import javax.inject.Qualifier;
+
+import org.jboss.weld.exceptions.WeldException;
import org.jboss.weld.introspector.WeldAnnotated;
+import org.jboss.weld.literal.DefaultLiteral;
+import org.jboss.weld.metadata.TypeStore;
+import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.util.Proxies;
import org.jboss.weld.util.collections.Arrays2;
+import org.jboss.weld.util.collections.HashSetSupplier;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
-import org.jboss.weld.util.reflection.Reflections;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+
/**
* Represents functionality common for all annotated items, mainly different
* mappings of the annotations and meta-annotations
@@ -49,24 +65,78 @@
public abstract class AbstractWeldAnnotated<T, S> implements WeldAnnotated<T, S>
{
- interface WrappableAnnotatedItem<T, S> extends WeldAnnotated<T, S>
+ // The set of default binding types
+ private static final Set<Annotation> DEFAULT_QUALIFIERS = Collections.<Annotation>singleton(DefaultLiteral.INSTANCE);
+
+ /**
+ * Builds the annotation map (annotation type -> annotation)
+ *
+ * @param annotations The array of annotations to map
+ * @return The annotation map
+ */
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Annotation[] annotations)
{
-
- AnnotationStore getAnnotationStore();
-
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation annotation : annotations)
+ {
+ annotationMap.put(annotation.annotationType(), annotation);
+ }
+ return annotationMap;
}
-
- // Cached string representation
- private String toString;
- private final AnnotationStore annotationStore;
+
+ /**
+ * Builds the annotation map (annotation type -> annotation)
+ *
+ * @param annotations The array of annotations to map
+ * @return The annotation map
+ */
+ protected static Map<Class<? extends Annotation>, Annotation> buildAnnotationMap(Iterable<Annotation> annotations)
+ {
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ for (Annotation annotation : annotations)
+ {
+ annotationMap.put(annotation.annotationType(), annotation);
+ }
+ return annotationMap;
+ }
+
+
+ protected static void addMetaAnnotations(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Annotation[] metaAnnotations, boolean declared)
+ {
+ for (Annotation metaAnnotation : metaAnnotations)
+ {
+ addMetaAnnotation(metaAnnotationMap, annotation, metaAnnotation.annotationType(), declared);
+ }
+ }
+
+ protected static void addMetaAnnotations(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Iterable<Annotation> metaAnnotations, boolean declared)
+ {
+ for (Annotation metaAnnotation : metaAnnotations)
+ {
+ addMetaAnnotation(metaAnnotationMap, annotation, metaAnnotation.annotationType(), declared);
+ }
+ }
+
+ private static void addMetaAnnotation(SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap, Annotation annotation, Class<? extends Annotation> metaAnnotationType, boolean declared)
+ {
+ // Only map meta-annotations we are interested in
+ if (declared ? MAPPED_DECLARED_METAANNOTATIONS.contains(metaAnnotationType) : MAPPED_METAANNOTATIONS.contains(metaAnnotationType))
+ {
+ metaAnnotationMap.put(metaAnnotationType, annotation);
+ }
+ }
+
+ // The annotation map (annotation type -> annotation) of the item
+ private final BiMap<Class<? extends Annotation>, Annotation> annotationMap;
+ // The meta-annotation map (annotation type -> set of annotations containing
+ // meta-annotation) of the item
+ private final SetMultimap<Class<? extends Annotation>, Annotation> metaAnnotationMap;
+
private final Class<T> rawType;
private final Type[] actualTypeArguments;
private final Type type;
- private final Map<Class<?>, Type> typeClosureAsMap;
- private final Set<Type> typeClosureAsSet;
- private final Set<Type> interfaceOnlyFlattenedTypes;
+ private final Set<Type> typeClosure;
private final boolean proxyable;
- private final boolean _parameterizedType;
/**
* Constructor
@@ -77,9 +147,25 @@
* @param annotationMap A map of annotation to register
*
*/
- public AbstractWeldAnnotated(AnnotationStore annotatedItemHelper, Class<T> rawType, Type type, Set<Type> typeClosure)
+ public AbstractWeldAnnotated(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer, Class<T> rawType, Type type, Set<Type> typeClosure)
{
- this.annotationStore = annotatedItemHelper;
+ if (annotationMap == null)
+ {
+ throw new WeldException(ANNOTATION_MAP_NULL);
+ }
+ this.annotationMap = HashBiMap.create(annotationMap.size());
+ this.metaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<Annotation>>(), HashSetSupplier.<Annotation>instance());
+ for (Annotation annotation : annotationMap.values())
+ {
+ addMetaAnnotations(metaAnnotationMap, annotation, annotation.annotationType().getAnnotations(), false);
+ addMetaAnnotations(metaAnnotationMap, annotation, classTransformer.getTypeStore().get(annotation.annotationType()), false);
+ this.annotationMap.put(annotation.annotationType(), annotation);
+ }
+
+ if (declaredAnnotationMap == null)
+ {
+ throw new WeldException(DECLARED_ANNOTATION_MAP_NULL);
+ }
this.rawType = rawType;
this.type = type;
if (type instanceof ParameterizedType)
@@ -90,74 +176,37 @@
{
this.actualTypeArguments = new Type[0];
}
- this._parameterizedType = Reflections.isParameterizedType(rawType);
- this.interfaceOnlyFlattenedTypes = new HashSet<Type>();
- for (Type t : rawType.getGenericInterfaces())
- {
- interfaceOnlyFlattenedTypes.addAll(new HierarchyDiscovery(t).getTypeClosure());
- }
- this.typeClosureAsMap = Reflections.buildTypeMap(typeClosure);
- this.typeClosureAsSet = typeClosure;
- this.proxyable = Proxies.isTypesProxyable(typeClosureAsSet);
+ this.typeClosure = typeClosure;
+ this.proxyable = Proxies.isTypesProxyable(typeClosure);
}
- public AbstractWeldAnnotated(AnnotationStore annotatedItemHelper)
+ protected AbstractWeldAnnotated(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, TypeStore typeStore)
{
- this.annotationStore = annotatedItemHelper;
+ if (annotationMap == null)
+ {
+ throw new WeldException(ANNOTATION_MAP_NULL);
+ }
+ this.annotationMap = HashBiMap.create(annotationMap.size());
+ this.metaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<Annotation>>(), HashSetSupplier.<Annotation>instance());
+ for (Annotation annotation : annotationMap.values())
+ {
+ addMetaAnnotations(metaAnnotationMap, annotation, annotation.annotationType().getAnnotations(), false);
+ addMetaAnnotations(metaAnnotationMap, annotation, typeStore.get(annotation.annotationType()), false);
+ this.annotationMap.put(annotation.annotationType(), annotation);
+ }
+
+ if (declaredAnnotationMap == null)
+ {
+ throw new WeldException(DECLARED_ANNOTATION_MAP_NULL);
+ }
this.rawType = null;
this.type = null;
this.actualTypeArguments = new Type[0];
- this._parameterizedType = false;
- this.typeClosureAsMap = null;
- this.typeClosureAsSet = null;
- this.interfaceOnlyFlattenedTypes = null;
+ this.typeClosure = null;
this.proxyable = false;
}
- public AnnotationStore getAnnotationStore()
- {
- return annotationStore;
- }
-
- public <A extends Annotation> A getAnnotation(Class<A> annotationType)
- {
- return getAnnotationStore().getAnnotation(annotationType);
- }
-
- public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
- {
- return getAnnotationStore().getMetaAnnotations(metaAnnotationType);
- }
-
- public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
- {
- return getAnnotationStore().getDeclaredMetaAnnotations(metaAnnotationType);
- }
-
- public Annotation[] getMetaAnnotationsAsArray(Class<? extends Annotation> metaAnnotationType)
- {
- return getMetaAnnotations(metaAnnotationType).toArray(new Annotation[0]);
- }
-
- public Set<Annotation> getAnnotations()
- {
- return getAnnotationStore().getAnnotations();
- }
-
/**
- * Checks if an annotation is present on the item
- *
- * @param annotatedType The annotation type to check for
- * @return True if present, false otherwise.
- *
- * @see org.jboss.weld.introspector.WeldAnnotated#isAnnotationPresent(Class)
- */
- public boolean isAnnotationPresent(Class<? extends Annotation> annotatedType)
- {
- return getAnnotationStore().isAnnotationPresent(annotatedType);
- }
-
- /**
* Compares two AbstractAnnotatedItems
*
* @param other The other item
@@ -186,44 +235,6 @@
}
/**
- * Gets a string representation of the item
- *
- * @return A string representation
- */
- @Override
- public String toString()
- {
- if (toString != null)
- {
- return toString;
- }
- toString = "Abstract annotated item " + getName();
- return toString;
- }
-
- @Deprecated
- public Set<Annotation> getQualifiers()
- {
- return getAnnotationStore().getBindings();
- }
-
- /**
- * Gets (as array) the binding types of the item
- *
- * Looks at the meta-annotations map for annotations with binding type
- * meta-annotation. Returns default binding (current) if none specified.
- *
- * @return An array of (binding type) annotations
- *
- * @see org.jboss.weld.introspector.WeldAnnotated#getBindingsAsArray()
- */
- @Deprecated
- public Annotation[] getBindingsAsArray()
- {
- return getAnnotationStore().getBindingsAsArray();
- }
-
- /**
* Indicates if the type is proxyable to a set of pre-defined rules
*
* @return True if proxyable, false otherwise.
@@ -245,21 +256,21 @@
return Arrays2.copyOf(actualTypeArguments, actualTypeArguments.length);
}
- public Set<Type> getInterfaceOnlyFlattenedTypeHierarchy()
+ public Set<Type> getInterfaceClosure()
{
- return Collections.unmodifiableSet(interfaceOnlyFlattenedTypes);
+ Set<Type> types = new HashSet<Type>();
+ for (Type t : rawType.getGenericInterfaces())
+ {
+ types.addAll(new HierarchyDiscovery(t).getTypeClosure());
+ }
+ return types;
}
public abstract S getDelegate();
- public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return getAnnotationStore().isDeclaredAnnotationPresent(annotationType);
- }
-
public boolean isParameterizedType()
{
- return _parameterizedType;
+ return rawType.getTypeParameters().length > 0;
}
public Type getBaseType()
@@ -269,12 +280,52 @@
public Set<Type> getTypeClosure()
{
- return typeClosureAsSet;
+ return typeClosure;
}
- public Map<Class<?>, Type> getTypeClosureAsMap()
+ public Set<Annotation> getAnnotations()
{
- return typeClosureAsMap;
+ return Collections.unmodifiableSet(annotationMap.values());
}
+ public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
+ {
+ return Collections.unmodifiableSet(metaAnnotationMap.get(metaAnnotationType));
+ }
+
+ @Deprecated
+ public Set<Annotation> getQualifiers()
+ {
+ if (getMetaAnnotations(Qualifier.class).size() > 0)
+ {
+ return Collections.unmodifiableSet(getMetaAnnotations(Qualifier.class));
+ }
+ else
+ {
+ return Collections.unmodifiableSet(DEFAULT_QUALIFIERS);
+ }
+ }
+
+ @Deprecated
+ public Annotation[] getBindingsAsArray()
+ {
+ return getQualifiers().toArray(EMPTY_ANNOTATIONS);
+ }
+
+
+ public <A extends Annotation> A getAnnotation(Class<A> annotationType)
+ {
+ return annotationType.cast(annotationMap.get(annotationType));
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotationMap.containsKey(annotationType);
+ }
+
+ Map<Class<? extends Annotation>, Annotation> getAnnotationMap()
+ {
+ return annotationMap;
+ }
+
}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldCallable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldCallable.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldCallable.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,26 +16,26 @@
*/
package org.jboss.weld.introspector.jlr;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Type;
+import java.util.Map;
import java.util.Set;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.WeldCallable;
import org.jboss.weld.introspector.WeldClass;
+import org.jboss.weld.resources.ClassTransformer;
/**
* @author pmuir
*
*/
public abstract class AbstractWeldCallable<T, X, S extends Member> extends AbstractWeldMember<T, X, S> implements WeldCallable<T, X, S>
-{
-
+{
-
- protected AbstractWeldCallable(AnnotationStore annotatedItemHelper, Member member, Class<T> rawType, Type type, Set<Type> typeClosure, WeldClass<X> declaringType)
+ protected AbstractWeldCallable(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer, Member member, Class<T> rawType, Type type, Set<Type> typeClosure, WeldClass<X> declaringType)
{
- super(annotatedItemHelper, member, rawType, type, typeClosure, declaringType);
+ super(annotationMap, declaredAnnotationMap, classTransformer, member, rawType, type, typeClosure, declaringType);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldMember.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldMember.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/AbstractWeldMember.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,15 +16,16 @@
*/
package org.jboss.weld.introspector.jlr;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
+import java.util.Map;
import java.util.Set;
-import org.jboss.weld.introspector.AnnotationStore;
-import org.jboss.weld.introspector.ForwardingWeldMember;
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldMember;
+import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.util.reflection.Reflections;
/**
@@ -39,21 +40,9 @@
*/
public abstract class AbstractWeldMember<T, X, S extends Member> extends AbstractWeldAnnotated<T, S> implements WeldMember<T, X, S>
{
-
- static abstract class WrappableForwardingAnnotatedMember<T, X, S extends Member> extends ForwardingWeldMember<T, X, S> implements WrappableAnnotatedItem<T, S>
- {
-
- }
- // The name of the member
- private final String name;
-
// Cached string representation
private String toString;
- private final boolean _public;
- private final boolean _private;
- private final boolean _packagePrivate;
- private final Package _package;
private final WeldClass<X> declaringType;
/**
@@ -61,14 +50,9 @@
*
* @param annotationMap The annotation map
*/
- protected AbstractWeldMember(AnnotationStore annotatedItemHelper, Member member, Class<T> rawType, Type type, Set<Type> typeClosure, WeldClass<X> declaringType)
+ protected AbstractWeldMember(Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer, Member member, Class<T> rawType, Type type, Set<Type> typeClosure, WeldClass<X> declaringType)
{
- super(annotatedItemHelper, rawType, type, typeClosure);
- name = member.getName();
- this._public = Modifier.isPublic(member.getModifiers());
- this._private = Modifier.isPrivate(member.getModifiers());
- this._packagePrivate = Reflections.isPackagePrivate(member.getModifiers());
- this._package = member.getDeclaringClass().getPackage();
+ super(annotationMap, declaredAnnotationMap, classTransformer, rawType, type, typeClosure);
this.declaringType = declaringType;
}
@@ -103,22 +87,22 @@
public boolean isPublic()
{
- return _public;
+ return Modifier.isPublic(getJavaMember().getModifiers());
}
public boolean isPrivate()
{
- return _private;
+ return Modifier.isPrivate(getJavaMember().getModifiers());
}
public boolean isPackagePrivate()
{
- return _packagePrivate;
+ return Reflections.isPackagePrivate(getJavaMember().getModifiers());
}
public Package getPackage()
{
- return _package;
+ return getJavaMember().getDeclaringClass().getPackage();
}
/**
@@ -141,7 +125,7 @@
*/
public String getName()
{
- return name;
+ return getJavaMember().getName();
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/MethodSignatureImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -88,7 +88,7 @@
@Override
public String toString()
{
- return getMethodName() + Arrays.asList(getParameterTypes()).toString().replace('[', '(').replace(']', ')');
+ return new StringBuffer().append("method ").append(getMethodName()).append(Arrays.toString(getParameterTypes()).replace('[', '(').replace(']', ')')).toString();
}
}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldAnnotationImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldAnnotationImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldAnnotationImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -25,16 +25,14 @@
import java.util.Map;
import java.util.Set;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.WeldAnnotation;
-import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.util.Names;
+import org.jboss.weld.util.collections.HashSetSupplier;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
import org.jboss.weld.util.reflection.SecureReflections;
-import com.google.common.base.Supplier;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
@@ -57,14 +55,16 @@
// The set of abstracted members
private final Set<WeldMethod<?, ?>> members;
- private final Map<String, WeldMethod<?, ?>> namedMembers;
-
- // Cached string representation
- private final String toString;
-
public static <A extends Annotation> WeldAnnotation<A> of(Class<A> annotationType, ClassTransformer classTransformer)
{
- return new WeldAnnotationImpl<A>(annotationType, classTransformer);
+ Map<Class<? extends Annotation>, Annotation> annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ annotationMap.putAll(buildAnnotationMap(annotationType.getAnnotations()));
+ annotationMap.putAll(buildAnnotationMap(classTransformer.getTypeStore().get(annotationType)));
+
+ Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ declaredAnnotationMap.putAll(buildAnnotationMap(annotationType.getDeclaredAnnotations()));
+ declaredAnnotationMap.putAll(buildAnnotationMap(classTransformer.getTypeStore().get(annotationType)));
+ return new WeldAnnotationImpl<A>(annotationType, annotationMap, declaredAnnotationMap, classTransformer);
}
/**
@@ -74,22 +74,12 @@
*
* @param annotationType The annotation type
*/
- protected WeldAnnotationImpl(Class<T> annotationType, ClassTransformer classTransformer)
+ protected WeldAnnotationImpl(Class<T> annotationType, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer)
{
- super(annotationType, annotationType, null, new HierarchyDiscovery(annotationType).getTypeClosure(), AnnotationStore.of(annotationType, classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore().get(annotationType), classTransformer.getTypeStore()), classTransformer);
+ super(annotationType, annotationType, null, new HierarchyDiscovery(annotationType).getTypeClosure(), annotationMap, declaredAnnotationMap, classTransformer);
this.clazz = annotationType;
- this.toString = "class " + Names.classToString(getDelegate());
members = new HashSet<WeldMethod<?, ?>>();
- annotatedMembers = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), new Supplier<Set<WeldMethod<?, ?>>>()
- {
-
- public Set<WeldMethod<?, ?>> get()
- {
- return new HashSet<WeldMethod<?, ?>>();
- }
-
- });
- this.namedMembers = new HashMap<String, WeldMethod<?, ?>>();
+ annotatedMembers = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), HashSetSupplier.<WeldMethod<?, ?>>instance());
for (Method member : SecureReflections.getDeclaredMethods(clazz))
{
WeldMethod<?, ?> annotatedMethod = WeldMethodImpl.of(member, this, classTransformer);
@@ -98,7 +88,6 @@
{
annotatedMembers.put(annotation.annotationType(), annotatedMethod);
}
- namedMembers.put(annotatedMethod.getName(), annotatedMethod);
}
}
@@ -125,18 +114,13 @@
* @return The set of abstracted members with the given annotation type
* present. An empty set is returned if no matches are found
*
- * @see org.jboss.weld.introspector.WeldAnnotation#getAnnotatedMembers(Class)
+ * @see org.jboss.weld.introspector.WeldAnnotation#getMembers(Class)
*/
- public Set<WeldMethod<?, ?>> getAnnotatedMembers(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, ?>> getMembers(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(annotatedMembers.get(annotationType));
}
- public <A> WeldMethod<A, ?> getMember(String memberName, WeldClass<A> expectedType)
- {
- return (WeldMethod<A, ?>) namedMembers.get(memberName);
- }
-
/**
* Gets a string representation of the annotation
*
@@ -145,7 +129,7 @@
@Override
public String toString()
{
- return toString;
+ return new StringBuilder().append("class ").append(Names.classToString(getDelegate())).toString();
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldClassImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -37,7 +37,6 @@
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.ConstructorSignature;
import org.jboss.weld.introspector.MethodSignature;
import org.jboss.weld.introspector.WeldClass;
@@ -46,11 +45,11 @@
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.util.Names;
+import org.jboss.weld.util.collections.HashSetSupplier;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
import org.jboss.weld.util.reflection.Reflections;
import org.jboss.weld.util.reflection.SecureReflections;
-import com.google.common.base.Supplier;
import com.google.common.collect.Multimaps;
import com.google.common.collect.SetMultimap;
@@ -69,27 +68,11 @@
// Class attributes
private final WeldClass<?> superclass;
- private final String name;
- private final String _simpleName;
- private final boolean _public;
- private final boolean _private;
- private final boolean _packagePrivate;
- private final Package _package;
- private final boolean _abstract;
- private final boolean _member;
- private final boolean _local;
- private final boolean _anonymous;
- private final boolean _enum;
- private final boolean _serializable;
- private static List<Class<?>> NO_ARGUMENTS = Collections.emptyList();
-
// The set of abstracted fields
private final Set<WeldField<?, ?>> fields;
// The map from annotation type to abstracted field with annotation
private final SetMultimap<Class<? extends Annotation>, WeldField<?, ?>> annotatedFields;
- // The map from annotation type to abstracted field with meta-annotation
- private final SetMultimap<Class<? extends Annotation>, WeldField<?, ?>> metaAnnotatedFields;
// The set of abstracted fields
private final Set<WeldField<?, ?>> declaredFields;
@@ -105,8 +88,6 @@
private final Map<MethodSignature, WeldMethod<?, ?>> methodsBySignature;
// The map from annotation type to abstracted method with annotation
private final SetMultimap<Class<? extends Annotation>, WeldMethod<?, ?>> annotatedMethods;
- // The map from annotation type to method with a parameter with annotation
- private final SetMultimap<Class<? extends Annotation>, WeldMethod<?, ?>> methodsByAnnotatedParameters;
// The set of abstracted methods
private final Set<WeldMethod<?, ?>> declaredMethods;
@@ -116,45 +97,36 @@
private final SetMultimap<Class<? extends Annotation>, WeldMethod<?, T>> declaredMethodsByAnnotatedParameters;
// The set of abstracted constructors
- private final Set<WeldConstructor<T>> constructors;
+ private final Set<AnnotatedConstructor<T>> constructors;
private final Map<ConstructorSignature, WeldConstructor<?>> declaredConstructorsBySignature;
// The map from annotation type to abstracted constructor with annotation
private final SetMultimap<Class<? extends Annotation>, WeldConstructor<T>> annotatedConstructors;
// The map from class list to abstracted constructor
private final Map<List<Class<?>>, WeldConstructor<T>> constructorsByArgumentMap;
+
+ // The meta-annotation map (annotation type -> set of annotations containing
+ // meta-annotation) of the item
+ private final SetMultimap<Class<? extends Annotation>, Annotation> declaredMetaAnnotationMap;
- private final SetMultimap<Class<? extends Annotation>, WeldConstructor<?>> constructorsByAnnotatedParameters;
-
- // Cached string representation
- private final String toString;
-
-
public static <T> WeldClass<T> of(Class<T> clazz, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(clazz.getAnnotations(), clazz.getDeclaredAnnotations(), classTransformer.getTypeStore());
- return new WeldClassImpl<T>(clazz, clazz, null, new HierarchyDiscovery(clazz).getTypeClosure(), annotationStore, classTransformer);
+ return new WeldClassImpl<T>(clazz, clazz, null, new HierarchyDiscovery(clazz).getTypeClosure(), buildAnnotationMap(clazz.getAnnotations()), buildAnnotationMap(clazz.getDeclaredAnnotations()), classTransformer);
}
public static <T> WeldClass<T> of(AnnotatedType<T> annotatedType, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(annotatedType.getAnnotations(), annotatedType.getAnnotations(), classTransformer.getTypeStore());
- return new WeldClassImpl<T>(annotatedType.getJavaClass(), annotatedType.getBaseType(), annotatedType, annotatedType.getTypeClosure(), annotationStore, classTransformer);
+ return new WeldClassImpl<T>(annotatedType.getJavaClass(), annotatedType.getBaseType(), annotatedType, annotatedType.getTypeClosure(), buildAnnotationMap(annotatedType.getAnnotations()), buildAnnotationMap(annotatedType.getAnnotations()), classTransformer);
}
-
+
public static <T> WeldClass<T> of(Class<T> rawType, Type type, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(rawType.getAnnotations(), rawType.getDeclaredAnnotations(), classTransformer.getTypeStore());
- return new WeldClassImpl<T>(rawType, type, null, new HierarchyDiscovery(type).getTypeClosure(), annotationStore, classTransformer);
+ return new WeldClassImpl<T>(rawType, type, null, new HierarchyDiscovery(type).getTypeClosure(), buildAnnotationMap(rawType.getAnnotations()), buildAnnotationMap(rawType.getDeclaredAnnotations()), classTransformer);
}
- protected WeldClassImpl(Class<T> rawType, Type type, AnnotatedType<T> annotatedType, Set<Type> typeClosure, AnnotationStore annotationStore, ClassTransformer classTransformer)
+ protected WeldClassImpl(Class<T> rawType, Type type, AnnotatedType<T> annotatedType, Set<Type> typeClosure, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, ClassTransformer classTransformer)
{
- super(annotationStore, rawType, type, typeClosure);
- this.toString = "class " + Names.classToString(rawType);
-
- // Assign class attributes
- this.name = rawType.getName();
- this._simpleName = rawType.getSimpleName();
+ super(annotationMap, declaredAnnotationMap, classTransformer, rawType, type, typeClosure);
+
if (rawType.getSuperclass() != null)
{
this.superclass = classTransformer.loadClass(rawType.getSuperclass());
@@ -163,58 +135,15 @@
{
this.superclass = null;
}
- this._public = Modifier.isFinal(rawType.getModifiers());
- this._private = Modifier.isPrivate(rawType.getModifiers());
- this._packagePrivate = Reflections.isPackagePrivate(rawType.getModifiers());
- this._package = rawType.getPackage();
- this._local = rawType.isLocalClass();
- this._anonymous = rawType.isAnonymousClass();
- this._member = rawType.isMemberClass();
- this._abstract = Reflections.isAbstract(rawType);
- this._enum = rawType.isEnum();
- this._serializable = Reflections.isSerializable(rawType);
-
+
// Assign class field information
this.fields = new HashSet<WeldField<?, ?>>();
- this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), new Supplier< Set<WeldField<?, ?>>>()
- {
-
- public Set<WeldField<?, ?>> get()
- {
- return new HashSet<WeldField<?, ?>>();
- }
-
- });
- this.metaAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), new Supplier< Set<WeldField<?, ?>>>()
- {
-
- public Set<WeldField<?, ?>> get()
- {
- return new HashSet<WeldField<?, ?>>();
- }
-
- });
+ this.annotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), HashSetSupplier.<WeldField<?, ?>> instance());
this.declaredFields = new HashSet<WeldField<?, ?>>();
this.declaredFieldsByName = new HashMap<String, WeldField<?, ?>>();
- this.declaredAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, T>>>(), new Supplier< Set<WeldField<?, T>>>()
- {
-
- public Set<WeldField<?, T>> get()
- {
- return new HashSet<WeldField<?, T>>();
- }
-
- });
- this.declaredMetaAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), new Supplier< Set<WeldField<?, ?>>>()
- {
-
- public Set<WeldField<?, ?>> get()
- {
- return new HashSet<WeldField<?, ?>>();
- }
-
- });
-
+ this.declaredAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, T>>>(), HashSetSupplier.<WeldField<?, T>> instance());
+ this.declaredMetaAnnotatedFields = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldField<?, ?>>>(), HashSetSupplier.<WeldField<?, ?>> instance());
+
Map<Field, AnnotatedField<? super T>> annotatedTypeFields = new HashMap<Field, AnnotatedField<? super T>>();
if (annotatedType != null)
{
@@ -223,7 +152,7 @@
annotatedTypeFields.put(annotatedField.getJavaMember(), annotatedField);
}
}
-
+
for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Field field : SecureReflections.getDeclaredFields(c))
@@ -231,13 +160,13 @@
WeldField<?, T> annotatedField = null;
if (annotatedTypeFields.containsKey(field))
{
- annotatedField = WeldFieldImpl.of(annotatedTypeFields.get(field), this.<T>getDeclaringWBClass(field, classTransformer), classTransformer);
+ annotatedField = WeldFieldImpl.of(annotatedTypeFields.get(field), this.<T> getDeclaringWBClass(field, classTransformer), classTransformer);
}
else
{
- annotatedField = WeldFieldImpl.of(field, this.<T>getDeclaringWBClass(field, classTransformer), classTransformer);
+ annotatedField = WeldFieldImpl.of(field, this.<T> getDeclaringWBClass(field, classTransformer), classTransformer);
}
-
+
this.fields.add(annotatedField);
if (c == rawType)
{
@@ -253,7 +182,6 @@
}
for (Annotation metaAnnotation : annotation.annotationType().getAnnotations())
{
- this.metaAnnotatedFields.put(metaAnnotation.annotationType(), annotatedField);
if (c == rawType)
{
this.declaredMetaAnnotatedFields.put(metaAnnotation.annotationType(), annotatedField);
@@ -265,27 +193,10 @@
}
// Assign constructor information
- this.constructors = new HashSet<WeldConstructor<T>>();
+ this.constructors = new HashSet<AnnotatedConstructor<T>>();
this.constructorsByArgumentMap = new HashMap<List<Class<?>>, WeldConstructor<T>>();
- this.annotatedConstructors = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldConstructor<T>>>(), new Supplier< Set<WeldConstructor<T>>>()
- {
-
- public Set<WeldConstructor<T>> get()
- {
- return new HashSet<WeldConstructor<T>>();
- }
-
- });
- this.constructorsByAnnotatedParameters = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldConstructor<?>>>(), new Supplier< Set<WeldConstructor<?>>>()
- {
-
- public Set<WeldConstructor<?>> get()
- {
- return new HashSet<WeldConstructor<?>>();
- }
-
- });
-
+ this.annotatedConstructors = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldConstructor<T>>>(), HashSetSupplier.<WeldConstructor<T>> instance());
+
Map<Constructor<? super T>, AnnotatedConstructor<T>> annotatedTypeConstructors = new HashMap<Constructor<? super T>, AnnotatedConstructor<T>>();
if (annotatedType != null)
{
@@ -294,7 +205,7 @@
annotatedTypeConstructors.put(annotated.getJavaMember(), annotated);
}
}
-
+
this.declaredConstructorsBySignature = new HashMap<ConstructorSignature, WeldConstructor<?>>();
for (Constructor<?> constructor : SecureReflections.getDeclaredConstructors(rawType))
{
@@ -308,9 +219,9 @@
{
// TODO Fix this cast
Constructor<T> c = (Constructor<T>) constructor;
- annotatedConstructor = WeldConstructorImpl.of(c, this.<T>getDeclaringWBClass(c, classTransformer), classTransformer);
+ annotatedConstructor = WeldConstructorImpl.of(c, this.<T> getDeclaringWBClass(c, classTransformer), classTransformer);
}
-
+
this.constructors.add(annotatedConstructor);
this.constructorsByArgumentMap.put(Arrays.asList(constructor.getParameterTypes()), annotatedConstructor);
@@ -324,58 +235,17 @@
}
annotatedConstructors.get(annotation.annotationType()).add(annotatedConstructor);
}
-
- for (Class<? extends Annotation> annotationType : WeldConstructor.MAPPED_PARAMETER_ANNOTATIONS)
- {
- if (annotatedConstructor.getAnnotatedWBParameters(annotationType).size() > 0)
- {
- constructorsByAnnotatedParameters.put(annotationType, annotatedConstructor);
- }
- }
}
// Assign method information
this.methods = new HashSet<WeldMethod<?, ?>>();
- this.annotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), new Supplier< Set<WeldMethod<?, ?>>>()
- {
-
- public Set<WeldMethod<?, ?>> get()
- {
- return new HashSet<WeldMethod<?, ?>>();
- }
-
- });
- this.methodsByAnnotatedParameters = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), new Supplier< Set<WeldMethod<?, ?>>>()
- {
-
- public Set<WeldMethod<?, ?>> get()
- {
- return new HashSet<WeldMethod<?, ?>>();
- }
-
- });
+ this.annotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, ?>>>(), HashSetSupplier.<WeldMethod<?, ?>> instance());
this.declaredMethods = new HashSet<WeldMethod<?, ?>>();
- this.declaredAnnotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, T>>>(), new Supplier< Set<WeldMethod<?, T>>>()
- {
-
- public Set<WeldMethod<?, T>> get()
- {
- return new HashSet<WeldMethod<?, T>>();
- }
-
- });
- this.declaredMethodsByAnnotatedParameters = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, T>>>(), new Supplier< Set<WeldMethod<?, T>>>()
- {
-
- public Set<WeldMethod<?, T>> get()
- {
- return new HashSet<WeldMethod<?, T>>();
- }
-
- });
+ this.declaredAnnotatedMethods = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, T>>>(), HashSetSupplier.<WeldMethod<?, T>> instance());
+ this.declaredMethodsByAnnotatedParameters = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldMethod<?, T>>>(), HashSetSupplier.<WeldMethod<?, T>> instance());
this.declaredMethodsBySignature = new HashMap<MethodSignature, WeldMethod<?, ?>>();
this.methodsBySignature = new HashMap<MethodSignature, WeldMethod<?, ?>>();
-
+
Map<Method, AnnotatedMethod<?>> annotatedTypeMethods = new HashMap<Method, AnnotatedMethod<?>>();
if (annotatedType != null)
{
@@ -384,7 +254,7 @@
annotatedTypeMethods.put(annotated.getJavaMember(), annotated);
}
}
-
+
for (Class<?> c = rawType; c != Object.class && c != null; c = c.getSuperclass())
{
for (Method method : SecureReflections.getDeclaredMethods(c))
@@ -396,7 +266,7 @@
}
else
{
- annotatedMethod = WeldMethodImpl.of(method, this.<T>getDeclaringWBClass(method, classTransformer), classTransformer);
+ annotatedMethod = WeldMethodImpl.of(method, this.<T> getDeclaringWBClass(method, classTransformer), classTransformer);
}
this.methods.add(annotatedMethod);
this.methodsBySignature.put(annotatedMethod.getSignature(), annotatedMethod);
@@ -415,9 +285,8 @@
}
for (Class<? extends Annotation> annotationType : WeldMethod.MAPPED_PARAMETER_ANNOTATIONS)
{
- if (annotatedMethod.getAnnotatedWBParameters(annotationType).size() > 0)
+ if (annotatedMethod.getWeldParameters(annotationType).size() > 0)
{
- methodsByAnnotatedParameters.put(annotationType, annotatedMethod);
if (c == rawType)
{
this.declaredMethodsByAnnotatedParameters.put(annotationType, annotatedMethod);
@@ -426,8 +295,16 @@
}
}
}
+
+ this.declaredMetaAnnotationMap = Multimaps.newSetMultimap(new HashMap<Class<? extends Annotation>, Collection<Annotation>>(), HashSetSupplier.<Annotation>instance());
+ for (Annotation declaredAnnotation : declaredAnnotationMap.values())
+ {
+ addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, declaredAnnotation.annotationType().getAnnotations(), true);
+ addMetaAnnotations(declaredMetaAnnotationMap, declaredAnnotation, classTransformer.getTypeStore().get(declaredAnnotation.annotationType()), true);
+ this.declaredMetaAnnotationMap.put(declaredAnnotation.annotationType(), declaredAnnotation);
+ }
}
-
+
@SuppressWarnings("unchecked")
private <X> WeldClass<X> getDeclaringWBClass(Member member, ClassTransformer transformer)
{
@@ -478,52 +355,23 @@
{
return Collections.unmodifiableSet(declaredFields);
}
-
+
public <F> WeldField<F, ?> getDeclaredWeldField(String fieldName)
{
return (WeldField<F, ?>) declaredFieldsByName.get(fieldName);
}
- public Set<WeldField<?, T>> getDeclaredAnnotatedWeldFields(Class<? extends Annotation> annotationType)
+ public Set<WeldField<?, T>> getDeclaredWeldFields(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(declaredAnnotatedFields.get(annotationType));
}
- /**
- * Gets the abstracted constructors of the class
- *
- * Initializes the constructors if they are null
- *
- * @return The set of abstracted constructors
- */
- public Set<WeldConstructor<T>> getWeldConstructors()
- {
- return Collections.unmodifiableSet(constructors);
- }
-
public WeldConstructor<T> getDeclaredWeldConstructor(ConstructorSignature signature)
{
return (WeldConstructor<T>) declaredConstructorsBySignature.get(signature);
}
/**
- * Gets abstracted fields with requested meta-annotation type present
- *
- * If the meta-annotations map is null, it is initializes. If the annotated
- * fields are null, it is initialized The meta-annotated field map is then
- * populated for the requested meta-annotation type and the result is
- * returned
- *
- * @param metaAnnotationType The meta-annotation type to match
- * @return The set of abstracted fields with meta-annotation present. Returns
- * an empty set if no matches are found.
- */
- public Set<WeldField<?, ?>> getMetaAnnotatedWeldFields(Class<? extends Annotation> metaAnnotationType)
- {
- return Collections.unmodifiableSet(metaAnnotatedFields.get(metaAnnotationType));
- }
-
- /**
* Gets the abstracted field annotated with a specific annotation type
*
* If the fields map is null, initialize it first
@@ -532,39 +380,39 @@
* @return A set of matching abstracted fields, null if none are found.
*
*/
- public Set<WeldField<?, ?>> getAnnotatedWeldFields(Class<? extends Annotation> annotationType)
+ public Set<WeldField<?, ?>> getWeldFields(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(annotatedFields.get(annotationType));
}
public boolean isLocalClass()
{
- return _local;
+ return getJavaClass().isLocalClass();
}
-
+
public boolean isAnonymousClass()
{
- return _anonymous;
+ return getJavaClass().isAnonymousClass();
}
-
+
public boolean isMemberClass()
{
- return _member;
+ return getJavaClass().isMemberClass();
}
public boolean isAbstract()
{
- return _abstract;
+ return Modifier.isAbstract(getJavaClass().getModifiers());
}
public boolean isEnum()
{
- return _enum;
+ return getJavaClass().isEnum();
}
public boolean isSerializable()
{
- return _serializable;
+ return Reflections.isSerializable(getJavaClass());
}
/**
@@ -576,14 +424,14 @@
* @return A set of matching method abstractions. Returns an empty set if no
* matches are found.
*
- * @see org.jboss.weld.introspector.WeldClass#getAnnotatedWeldMethods(Class)
+ * @see org.jboss.weld.introspector.WeldClass#getWeldMethods(Class)
*/
- public Set<WeldMethod<?, ?>> getAnnotatedWeldMethods(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, ?>> getWeldMethods(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(annotatedMethods.get(annotationType));
}
- public Set<WeldMethod<?, T>> getDeclaredAnnotatedWeldMethods(Class<? extends Annotation> annotationType)
+ public Set<WeldMethod<?, T>> getDeclaredWeldMethods(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(declaredAnnotatedMethods.get(annotationType));
}
@@ -596,28 +444,18 @@
* the constructors set is empty, initialize it first. Returns an
* empty set if there are no matches.
*
- * @see org.jboss.weld.introspector.WeldClass#getAnnotatedWeldConstructors(Class)
+ * @see org.jboss.weld.introspector.WeldClass#getWeldConstructors(Class)
*/
- public Set<WeldConstructor<T>> getAnnotatedWeldConstructors(Class<? extends Annotation> annotationType)
+ public Set<WeldConstructor<T>> getWeldConstructors(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(annotatedConstructors.get(annotationType));
}
public WeldConstructor<T> getNoArgsWeldConstructor()
{
- return constructorsByArgumentMap.get(NO_ARGUMENTS);
+ return constructorsByArgumentMap.get(Collections.emptyList());
}
- public Set<WeldMethod<?, ?>> getWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
- {
- return Collections.unmodifiableSet(methodsByAnnotatedParameters.get(annotationType));
- }
-
- public Set<WeldConstructor<?>> getWeldConstructorsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
- {
- return Collections.unmodifiableSet(constructorsByAnnotatedParameters.get(annotationType));
- }
-
public Set<WeldMethod<?, T>> getDeclaredWeldMethodsWithAnnotatedParameters(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableSet(declaredMethodsByAnnotatedParameters.get(annotationType));
@@ -653,7 +491,7 @@
}
return null;
}
-
+
public Set<WeldMethod<?, ?>> getDeclaredWeldMethods()
{
return declaredMethods;
@@ -670,7 +508,7 @@
{
return (WeldMethod<M, ?>) methodsBySignature.get(signature);
}
-
+
/**
* Gets a string representation of the class
*
@@ -679,14 +517,14 @@
@Override
public String toString()
{
- return toString;
+ return new StringBuilder().append("class ").append(Names.classToString(getJavaClass())).toString();
}
-
+
public String getSimpleName()
{
- return _simpleName;
+ return getJavaClass().getSimpleName();
}
-
+
/**
* Indicates if the type is static
*
@@ -710,10 +548,10 @@
{
return Reflections.isFinal(getDelegate());
}
-
+
public boolean isPublic()
{
- return _public;
+ return Modifier.isFinal(getJavaClass().getModifiers());
}
/**
@@ -725,7 +563,7 @@
*/
public String getName()
{
- return name;
+ return getJavaClass().getName();
}
/**
@@ -737,25 +575,25 @@
{
return superclass;
}
-
+
public boolean isEquivalent(Class<?> clazz)
{
return getDelegate().equals(clazz);
}
-
+
public boolean isPrivate()
{
- return _private;
+ return Modifier.isPrivate(getJavaClass().getModifiers());
}
-
+
public boolean isPackagePrivate()
{
- return _packagePrivate;
+ return Reflections.isPackagePrivate(getJavaClass().getModifiers());
}
-
+
public Package getPackage()
{
- return _package;
+ return getJavaClass().getPackage();
}
@SuppressWarnings("unchecked")
@@ -770,10 +608,9 @@
return (S) object;
}
- @SuppressWarnings("unchecked")
public Set<AnnotatedConstructor<T>> getConstructors()
{
- return (Set) constructors;
+ return constructors;
}
@SuppressWarnings("unchecked")
@@ -787,5 +624,10 @@
{
return (Set) methods;
}
+
+ public Set<Annotation> getDeclaredMetaAnnotations(Class<? extends Annotation> metaAnnotationType)
+ {
+ return Collections.unmodifiableSet(declaredMetaAnnotationMap.get(metaAnnotationType));
+ }
}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldConstructorImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -31,7 +31,6 @@
import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedParameter;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.ConstructorSignature;
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldConstructor;
@@ -66,20 +65,15 @@
private final ListMultimap<Class<? extends Annotation>, WeldParameter<?, T>> annotatedParameters;
private final ConstructorSignature signature;
-
- // Cached string representation
- private final String toString;
public static <T> WeldConstructor<T> of(Constructor<T> constructor, WeldClass<T> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(constructor, classTransformer.getTypeStore());
- return new WeldConstructorImpl<T>(constructor, constructor.getDeclaringClass(), constructor.getDeclaringClass(), null, new HierarchyDiscovery(constructor.getDeclaringClass()).getTypeClosure(), annotationStore, declaringClass, classTransformer);
+ return new WeldConstructorImpl<T>(constructor, constructor.getDeclaringClass(), constructor.getDeclaringClass(), null, new HierarchyDiscovery(constructor.getDeclaringClass()).getTypeClosure(), buildAnnotationMap(constructor.getAnnotations()), buildAnnotationMap(constructor.getDeclaredAnnotations()), declaringClass, classTransformer);
}
public static <T> WeldConstructor<T> of(AnnotatedConstructor<T> annotatedConstructor, WeldClass<T> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(annotatedConstructor.getAnnotations(), annotatedConstructor.getAnnotations(), classTransformer.getTypeStore());
- return new WeldConstructorImpl<T>(annotatedConstructor.getJavaMember(), annotatedConstructor.getJavaMember().getDeclaringClass(), annotatedConstructor.getBaseType(), annotatedConstructor, annotatedConstructor.getTypeClosure(), annotationStore, declaringClass, classTransformer);
+ return new WeldConstructorImpl<T>(annotatedConstructor.getJavaMember(), annotatedConstructor.getJavaMember().getDeclaringClass(), annotatedConstructor.getBaseType(), annotatedConstructor, annotatedConstructor.getTypeClosure(), buildAnnotationMap(annotatedConstructor.getAnnotations()), buildAnnotationMap(annotatedConstructor.getAnnotations()), declaringClass, classTransformer);
}
/**
@@ -90,10 +84,9 @@
* @param constructor The constructor method
* @param declaringClass The declaring class
*/
- private WeldConstructorImpl(Constructor<T> constructor, final Class<T> rawType, final Type type, AnnotatedConstructor<T> annotatedConstructor, Set<Type> typeClosure, AnnotationStore annotationStore, WeldClass<T> declaringClass, ClassTransformer classTransformer)
+ private WeldConstructorImpl(Constructor<T> constructor, final Class<T> rawType, final Type type, AnnotatedConstructor<T> annotatedConstructor, Set<Type> typeClosure, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, WeldClass<T> declaringClass, ClassTransformer classTransformer)
{
- super(annotationStore, constructor, rawType, type, typeClosure, declaringClass);
- this.toString = new StringBuilder().append("constructor ").append(constructor.toString()).toString();
+ super(annotationMap, declaredAnnotationMap, classTransformer, constructor, rawType, type, typeClosure, declaringClass);
this.constructor = constructor;
this.parameters = new ArrayList<WeldParameter<?, T>>();
@@ -170,7 +163,10 @@
for (Annotation annotation : parameter.getAnnotations())
{
- annotatedParameters.put(annotation.annotationType(), parameter);
+ if (MAPPED_PARAMETER_ANNOTATIONS.contains(annotation.annotationType()))
+ {
+ annotatedParameters.put(annotation.annotationType(), parameter);
+ }
}
}
}
@@ -221,9 +217,9 @@
* @return A list of matching parameter abstractions. An empty list is
* returned if there are no matches.
*
- * @see org.jboss.weld.introspector.WeldConstructor#getAnnotatedWBParameters(Class)
+ * @see org.jboss.weld.introspector.WeldConstructor#getWeldParameters(Class)
*/
- public List<WeldParameter<?, T>> getAnnotatedWBParameters(Class<? extends Annotation> annotationType)
+ public List<WeldParameter<?, T>> getWeldParameters(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableList(annotatedParameters.get(annotationType));
}
@@ -284,7 +280,7 @@
@Override
public String toString()
{
- return toString;
+ return new StringBuilder().append("constructor ").append(constructor.toString()).toString();
}
public ConstructorSignature getSignature()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldFieldImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -16,14 +16,17 @@
*/
package org.jboss.weld.introspector.jlr;
+import static org.jboss.weld.logging.messages.UtilMessage.ACCESS_ERROR_ON_FIELD;
+
+import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
+import java.util.Map;
import java.util.Set;
-import static org.jboss.weld.logging.messages.UtilMessage.ACCESS_ERROR_ON_FIELD;
+
import javax.enterprise.inject.spi.AnnotatedField;
import org.jboss.weld.exceptions.WeldException;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldField;
import org.jboss.weld.resources.ClassTransformer;
@@ -45,19 +48,14 @@
// The underlying field
private final Field field;
- // Cached string representation
- private final String toString;
-
public static <T, X> WeldFieldImpl<T, X> of(Field field, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(field, classTransformer.getTypeStore());
- return new WeldFieldImpl<T, X>(field, (Class<T>) field.getType(), field.getGenericType(), new HierarchyDiscovery(field.getGenericType()).getTypeClosure(), annotationStore, declaringClass, classTransformer);
+ return new WeldFieldImpl<T, X>(field, (Class<T>) field.getType(), field.getGenericType(), new HierarchyDiscovery(field.getGenericType()).getTypeClosure(), buildAnnotationMap(field.getAnnotations()), buildAnnotationMap(field.getDeclaredAnnotations()), declaringClass, classTransformer);
}
public static <T, X> WeldFieldImpl<T, X> of(AnnotatedField<? super X> annotatedField, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(annotatedField.getAnnotations(), annotatedField.getAnnotations(), classTransformer.getTypeStore());
- return new WeldFieldImpl<T, X>(annotatedField.getJavaMember(), (Class<T>) annotatedField.getJavaMember().getType(), annotatedField.getBaseType(), annotatedField.getTypeClosure(), annotationStore, declaringClass, classTransformer);
+ return new WeldFieldImpl<T, X>(annotatedField.getJavaMember(), (Class<T>) annotatedField.getJavaMember().getType(), annotatedField.getBaseType(), annotatedField.getTypeClosure(), buildAnnotationMap(annotatedField.getAnnotations()), buildAnnotationMap(annotatedField.getAnnotations()), declaringClass, classTransformer);
}
/**
@@ -69,11 +67,10 @@
* @param field The actual field
* @param declaringClass The abstraction of the declaring class
*/
- private WeldFieldImpl(Field field, final Class<T> rawType, final Type type, Set<Type> typeClosure, AnnotationStore annotationStore, WeldClass<X> declaringClass, ClassTransformer classTransformer)
+ private WeldFieldImpl(Field field, final Class<T> rawType, final Type type, Set<Type> typeClosure, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- super(annotationStore, field, rawType, type, typeClosure, declaringClass);
+ super(annotationMap, declaredAnnotationMap, classTransformer, field, rawType, type, typeClosure, declaringClass);
this.field = field;
- this.toString = new StringBuilder().append("field ").append(declaringClass.getName()).append(".").append(field.getName()).toString();
}
/**
@@ -135,7 +132,7 @@
@Override
public String toString()
{
- return this.toString;
+ return new StringBuilder().append("field ").append(getDeclaringType().getName()).append(".").append(field.getName()).toString();
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldMethodImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -32,17 +32,16 @@
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.MethodSignature;
import org.jboss.weld.introspector.WeldClass;
import org.jboss.weld.introspector.WeldMethod;
import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.resources.ClassTransformer;
+import org.jboss.weld.util.collections.ArrayListSupplier;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
import org.jboss.weld.util.reflection.Reflections;
import org.jboss.weld.util.reflection.SecureReflections;
-import com.google.common.base.Supplier;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Multimaps;
@@ -70,21 +69,16 @@
// The property name
private final String propertyName;
- // Cached string representation
- private final String toString;
-
private final MethodSignature signature;
public static <T, X> WeldMethodImpl<T, X> of(Method method, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(method, classTransformer.getTypeStore());
- return new WeldMethodImpl<T, X>(method, (Class<T>) method.getReturnType(), method.getGenericReturnType(), new HierarchyDiscovery(method.getGenericReturnType()).getTypeClosure(), null, annotationStore, declaringClass, classTransformer);
+ return new WeldMethodImpl<T, X>(method, (Class<T>) method.getReturnType(), method.getGenericReturnType(), new HierarchyDiscovery(method.getGenericReturnType()).getTypeClosure(), null, buildAnnotationMap(method.getAnnotations()), buildAnnotationMap(method.getDeclaredAnnotations()), declaringClass, classTransformer);
}
public static <T, X> WeldMethodImpl<T, X> of(AnnotatedMethod<T> method, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- AnnotationStore annotationStore = AnnotationStore.of(method.getAnnotations(), method.getAnnotations(), classTransformer.getTypeStore());
- return new WeldMethodImpl<T, X>(method.getJavaMember(), (Class<T>) method.getJavaMember().getReturnType(), method.getBaseType(), method.getTypeClosure(), method, annotationStore, declaringClass, classTransformer);
+ return new WeldMethodImpl<T, X>(method.getJavaMember(), (Class<T>) method.getJavaMember().getReturnType(), method.getBaseType(), method.getTypeClosure(), method, buildAnnotationMap(method.getAnnotations()), buildAnnotationMap(method.getAnnotations()), declaringClass, classTransformer);
}
/**
@@ -97,22 +91,13 @@
* @param declaringClass The declaring class abstraction
*/
@SuppressWarnings("unchecked")
- private WeldMethodImpl(Method method, final Class<T> rawType, final Type type, Set<Type> typeClosure, AnnotatedMethod<T> annotatedMethod, AnnotationStore annotationStore, WeldClass<X> declaringClass, ClassTransformer classTransformer)
+ private WeldMethodImpl(Method method, final Class<T> rawType, final Type type, Set<Type> typeClosure, AnnotatedMethod<T> annotatedMethod, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, WeldClass<X> declaringClass, ClassTransformer classTransformer)
{
- super(annotationStore, method, rawType, type, typeClosure, declaringClass);
+ super(annotationMap, declaredAnnotationMap, classTransformer, method, rawType, type, typeClosure, declaringClass);
this.method = method;
- this.toString = new StringBuilder().append("method ").append(method.toString()).toString();
this.parameters = new ArrayList<WeldParameter<?, X>>();
- this.annotatedParameters = Multimaps.newListMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldParameter<?, X>>>(), new Supplier<List<WeldParameter<?, X>>>()
- {
+ this.annotatedParameters = Multimaps.newListMultimap(new HashMap<Class<? extends Annotation>, Collection<WeldParameter<?, X>>>(), ArrayListSupplier.<WeldParameter<?, X>>instance());
- public List<WeldParameter<?, X>> get()
- {
- return new ArrayList<WeldParameter<?, X>>();
- }
-
- });
-
Map<Integer, AnnotatedParameter<?>> annotatedTypeParameters = new HashMap<Integer, AnnotatedParameter<?>>();
if (annotatedMethod != null)
@@ -170,11 +155,6 @@
}
- public Method getAnnotatedMethod()
- {
- return method;
- }
-
@Override
public Method getDelegate()
{
@@ -191,7 +171,7 @@
return method.getParameterTypes();
}
- public List<WeldParameter<?, X>> getAnnotatedWBParameters(Class<? extends Annotation> annotationType)
+ public List<WeldParameter<?, X>> getWeldParameters(Class<? extends Annotation> annotationType)
{
return Collections.unmodifiableList(annotatedParameters.get(annotationType));
}
@@ -244,7 +224,7 @@
@Override
public String toString()
{
- return this.toString;
+ return new StringBuilder().append(method.toString()).toString();
}
public MethodSignature getSignature()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/introspector/jlr/WeldParameterImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -17,6 +17,7 @@
package org.jboss.weld.introspector.jlr;
import static org.jboss.weld.logging.messages.ReflectionMessage.UNABLE_TO_GET_PARAMETER_NAME;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
@@ -25,7 +26,6 @@
import javax.enterprise.inject.spi.AnnotatedCallable;
import org.jboss.weld.exceptions.ForbiddenArgumentException;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.WeldCallable;
import org.jboss.weld.introspector.WeldParameter;
import org.jboss.weld.resources.ClassTransformer;
@@ -43,21 +43,6 @@
public class WeldParameterImpl<T, X> extends AbstractWeldAnnotated<T, Object> implements WeldParameter<T, X>
{
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
-
- // The final state
- private final boolean _final = false;
- // The static state
- private final boolean _static = false;
- private final boolean _public = false;
- private final boolean _private = false;
- private final boolean _packagePrivate = false;
- private final Package _package;
- private final int position;
- private final WeldCallable<?, X, ?> declaringMember;
-
- private final String toString;
-
public static <T, X> WeldParameter<T, X> of(Annotation[] annotations, Class<T> rawType, Type type, WeldCallable<?, X, ?> declaringMember, int position, ClassTransformer classTransformer)
{
return new WeldParameterImpl<T, X>(annotations, rawType, type, new HierarchyDiscovery(type).getTypeClosure(), declaringMember, position, classTransformer);
@@ -65,8 +50,11 @@
public static <T, X> WeldParameter<T, X> of(Set<Annotation> annotations, Class<T> rawType, Type type, WeldCallable<?, X, ?> declaringMember, int position, ClassTransformer classTransformer)
{
- return new WeldParameterImpl<T, X>(annotations.toArray(EMPTY_ANNOTATION_ARRAY), rawType, type, new HierarchyDiscovery(type).getTypeClosure(), declaringMember, position, classTransformer);
+ return new WeldParameterImpl<T, X>(annotations.toArray(EMPTY_ANNOTATIONS), rawType, type, new HierarchyDiscovery(type).getTypeClosure(), declaringMember, position, classTransformer);
}
+
+ private final int position;
+ private final WeldCallable<?, X, ?> declaringMember;
/**
* Constructor
@@ -76,11 +64,9 @@
*/
protected WeldParameterImpl(Annotation[] annotations, Class<T> rawType, Type type, Set<Type> typeClosure, WeldCallable<?, X, ?> declaringMember, int position, ClassTransformer classTransformer)
{
- super(AnnotationStore.of(annotations, annotations, classTransformer.getTypeStore()), rawType, type, typeClosure);
+ super(buildAnnotationMap(annotations), buildAnnotationMap(annotations), classTransformer, rawType, type, typeClosure);
this.declaringMember = declaringMember;
- this._package = declaringMember.getPackage();
this.position = position;
- this.toString = new StringBuilder().append("parameter ").append(position).append(" of ").append(declaringMember.toString()).toString();
}
/**
@@ -92,7 +78,7 @@
*/
public boolean isFinal()
{
- return _final;
+ return false;
}
/**
@@ -104,27 +90,27 @@
*/
public boolean isStatic()
{
- return _static;
+ return false;
}
public boolean isPublic()
{
- return _public;
+ return false;
}
public boolean isPrivate()
{
- return _private;
+ return false;
}
public boolean isPackagePrivate()
{
- return _packagePrivate;
+ return false;
}
public Package getPackage()
{
- return _package;
+ return declaringMember.getPackage();
}
/**
@@ -147,7 +133,7 @@
@Override
public String toString()
{
- return toString;
+ return new StringBuilder().append("parameter ").append(position).append(" of ").append(declaringMember.toString()).toString();
}
public AnnotatedCallable<X> getDeclaringCallable()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/AnyLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/AnyLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/AnyLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -22,4 +22,8 @@
public class AnyLiteral extends AnnotationLiteral<Any> implements Any
{
+ public static final Any INSTANCE = new AnyLiteral();
+
+ private AnyLiteral() {}
+
}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/literal/BindingTypeLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/BindingTypeLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/BindingTypeLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -1,25 +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.weld.literal;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Qualifier;
-
-public class BindingTypeLiteral extends AnnotationLiteral<Qualifier> implements Qualifier
-{
-
-}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/DefaultLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/DefaultLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/DefaultLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -24,4 +24,11 @@
*
* @author Pete Muir
*/
-public class DefaultLiteral extends AnnotationLiteral<Default> implements Default {}
+public class DefaultLiteral extends AnnotationLiteral<Default> implements Default
+{
+
+ public static final Default INSTANCE = new DefaultLiteral();
+
+ private DefaultLiteral() {}
+
+}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/literal/InjectLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/InjectLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/InjectLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -1,27 +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.weld.literal;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-
-/**
- * Annotation literal for @Inject
- *
- * @author Pete Muir
- */
-public class InjectLiteral extends AnnotationLiteral<Inject> implements Inject {}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/InterceptorBindingTypeLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/InterceptorBindingTypeLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/InterceptorBindingTypeLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -22,4 +22,8 @@
public class InterceptorBindingTypeLiteral extends AnnotationLiteral<InterceptorBinding> implements InterceptorBinding
{
+ public static final InterceptorBinding INSTANCE = new InterceptorBindingTypeLiteral();
+
+ private InterceptorBindingTypeLiteral() {}
+
}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/NewLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/NewLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/NewLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -31,5 +31,7 @@
{
return New.class;
}
+
+ public NewLiteral() {}
}
Copied: core/trunk/impl/src/main/java/org/jboss/weld/literal/QualifierLiteral.java (from rev 5411, core/trunk/impl/src/main/java/org/jboss/weld/literal/BindingTypeLiteral.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/QualifierLiteral.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/QualifierLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,29 @@
+/*
+ * 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.weld.literal;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+public class QualifierLiteral extends AnnotationLiteral<Qualifier> implements Qualifier
+{
+
+ public static final Qualifier INSTANCE = new QualifierLiteral();
+
+ private QualifierLiteral() {}
+
+}
\ No newline at end of file
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/literal/QualifierLiteral.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/ScopeLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/ScopeLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/ScopeLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -19,4 +19,11 @@
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Scope;
-public class ScopeLiteral extends AnnotationLiteral<Scope> implements Scope {}
\ No newline at end of file
+public class ScopeLiteral extends AnnotationLiteral<Scope> implements Scope
+{
+
+ public static final Scope INSTANCE = new ScopeLiteral();
+
+ private ScopeLiteral() {}
+
+}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/literal/StereotypeLiteral.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/literal/StereotypeLiteral.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/literal/StereotypeLiteral.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -22,6 +22,8 @@
public class StereotypeLiteral extends AnnotationLiteral<Stereotype> implements Stereotype
{
+ public static final Stereotype INSTANCE = new StereotypeLiteral();
+ private StereotypeLiteral() {}
}
\ No newline at end of file
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-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -116,11 +116,11 @@
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Observers;
import org.jboss.weld.util.Proxies;
+import org.jboss.weld.util.collections.CopyOnWriteArrayListSupplier;
+import org.jboss.weld.util.collections.IterableToIteratorFunction;
import org.jboss.weld.util.reflection.HierarchyDiscovery;
import org.jboss.weld.util.reflection.Reflections;
-import com.google.common.base.Function;
-import com.google.common.base.Supplier;
import com.google.common.collect.Iterables;
import com.google.common.collect.Iterators;
import com.google.common.collect.ListMultimap;
@@ -246,15 +246,7 @@
*/
public static BeanManagerImpl newRootManager(String id, ServiceRegistry serviceRegistry)
{
- ListMultimap<Class<? extends Annotation>, Context> contexts = Multimaps.newListMultimap(new ConcurrentHashMap<Class<? extends Annotation>, Collection<Context>>(), new Supplier<List<Context>>()
- {
-
- public List<Context> get()
- {
- return new CopyOnWriteArrayList<Context>();
- }
-
- });
+ ListMultimap<Class<? extends Annotation>, Context> contexts = Multimaps.newListMultimap(new ConcurrentHashMap<Class<? extends Annotation>, Collection<Context>>(), CopyOnWriteArrayListSupplier.<Context>instance());
return new BeanManagerImpl(
serviceRegistry,
@@ -435,21 +427,11 @@
{
return new Iterable<T>()
{
-
- private Function<Iterable<T>, Iterator<T>> function = new Function<Iterable<T>, Iterator<T>>()
- {
- public Iterator<T> apply(Iterable<T> iterable)
- {
- return iterable.iterator();
- }
-
- };
-
public Iterator<T> iterator()
{
Set<Iterable<T>> iterable = buildAccessibleClosure(new ArrayList<BeanManagerImpl>(), transform);
- return Iterators.concat(Iterators.transform(iterable.iterator(), function));
+ return Iterators.concat(Iterators.transform(iterable.iterator(), IterableToIteratorFunction.<T>instance()));
}
};
@@ -522,7 +504,7 @@
{
checkBindingTypes(Arrays.asList(bindings));
HashSet<Annotation> bindingAnnotations = new HashSet<Annotation>(Arrays.asList(bindings));
- bindingAnnotations.add(new AnyLiteral());
+ bindingAnnotations.add(AnyLiteral.INSTANCE);
Set<ObserverMethod<? super T>> observers = new HashSet<ObserverMethod<? super T>>();
Set<ObserverMethod<?>> eventObservers = observerResolver.resolve(ResolvableFactory.of(new HierarchyDiscovery(eventType).getTypeClosure(), bindingAnnotations, null));
for (ObserverMethod<?> observer : eventObservers)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/BindingTypeModel.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/BindingTypeModel.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/BindingTypeModel.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -125,7 +125,7 @@
*/
protected void initNonBindingTypes()
{
- nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(Nonbinding.class);
+ nonBindingTypes = getAnnotatedAnnotation().getMembers(Nonbinding.class);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/metadata/cache/InterceptorBindingModel.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -78,7 +78,7 @@
protected void initNonBindingTypes()
{
- nonBindingTypes = getAnnotatedAnnotation().getAnnotatedMembers(Nonbinding.class);
+ nonBindingTypes = getAnnotatedAnnotation().getMembers(Nonbinding.class);
}
protected void initInterceptionBindingTypes()
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-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableFactory.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -79,7 +79,7 @@
this.bindings = bindings;
if (bindings.size() == 0)
{
- this.bindings.add(new DefaultLiteral());
+ this.bindings.add(DefaultLiteral.INSTANCE);
}
this.annotations = new HashMap<Class<? extends Annotation>, Annotation>();
this.typeClosure = typeClosure;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resolution/ResolvableWeldClass.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -19,6 +19,7 @@
import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_RAW_TYPE;
import static org.jboss.weld.logging.messages.ResolutionMessage.CANNOT_EXTRACT_TYPE_INFORMATION;
import static org.jboss.weld.logging.messages.ResolutionMessage.INVALID_MEMBER_TYPE;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
@@ -27,8 +28,8 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import javax.enterprise.inject.spi.InjectionPoint;
@@ -38,7 +39,6 @@
import org.jboss.weld.exceptions.ForbiddenArgumentException;
import org.jboss.weld.exceptions.InvalidOperationException;
import org.jboss.weld.injection.WeldInjectionPoint;
-import org.jboss.weld.introspector.AnnotationStore;
import org.jboss.weld.introspector.WeldAnnotated;
import org.jboss.weld.introspector.jlr.AbstractWeldAnnotated;
import org.jboss.weld.manager.BeanManagerImpl;
@@ -48,18 +48,12 @@
public class ResolvableWeldClass<T> extends AbstractWeldAnnotated<T, Class<T>> implements Resolvable
{
-
- private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0];
- private static final Set<Annotation> EMPTY_ANNOTATION_SET = Collections.emptySet();
-
private final Class<T> rawType;
private final Set<Type> typeClosure;
private final Type[] actualTypeArguments;
private final String _string;
- private final BeanManagerImpl manager;
-
public static <T> WeldAnnotated<T, Class<T>> of(TypeLiteral<T> typeLiteral, Annotation[] annotations, BeanManagerImpl manager)
{
return new ResolvableWeldClass<T>(typeLiteral.getType(), annotations, manager);
@@ -100,12 +94,10 @@
}
}
- private ResolvableWeldClass(Type type, AnnotationStore annotationStore, BeanManagerImpl manager)
+ private ResolvableWeldClass(Type type, Map<Class<? extends Annotation>, Annotation> annotationMap, Map<Class<? extends Annotation>, Annotation> declaredAnnotationMap, BeanManagerImpl manager)
{
- super(annotationStore);
+ super(annotationMap, declaredAnnotationMap, manager.getServices().get(TypeStore.class));
- this.manager = manager;
-
if (type instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) type;
@@ -118,13 +110,13 @@
throw new ForbiddenArgumentException(CANNOT_EXTRACT_RAW_TYPE, type);
}
this.actualTypeArguments = ((ParameterizedType) type).getActualTypeArguments();
- this._string = rawType.toString() + "<" + Arrays.asList(actualTypeArguments).toString() + ">; binding types = " + Names.annotationsToString(annotationStore.getBindings());
+ this._string = rawType.toString() + "<" + Arrays.asList(actualTypeArguments).toString() + ">; binding types = " + Names.annotationsToString(getQualifiers());
}
else if (type instanceof Class)
{
this.rawType = (Class<T>) type;
this.actualTypeArguments = new Type[0];
- this._string = rawType.toString() +"; binding types = " + Names.annotationsToString(annotationStore.getBindings());
+ this._string = rawType.toString() +"; binding types = " + Names.annotationsToString(getQualifiers());
}
else
{
@@ -136,12 +128,12 @@
private ResolvableWeldClass(Type type, Annotation[] annotations, BeanManagerImpl manager)
{
- this(type, AnnotationStore.of(annotations, EMPTY_ANNOTATION_ARRAY, manager.getServices().get(TypeStore.class)), manager);
+ this(type, buildAnnotationMap(annotations), buildAnnotationMap(EMPTY_ANNOTATIONS), manager);
}
private ResolvableWeldClass(Type type, Set<Annotation>annotations, BeanManagerImpl manager)
{
- this(type, AnnotationStore.of(annotations, EMPTY_ANNOTATION_SET, manager.getServices().get(TypeStore.class)), manager);
+ this(type, buildAnnotationMap(annotations), buildAnnotationMap(EMPTY_ANNOTATIONS), manager);
}
@Override
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Beans.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -208,7 +208,7 @@
{
Set<FieldInjectionPoint<?, ?>> fields = new HashSet<FieldInjectionPoint<?,?>>();
injectableFieldsList.add(0, fields);
- for (WeldField<?, ?> annotatedField : t.getDeclaredAnnotatedWeldFields(Inject.class))
+ for (WeldField<?, ?> annotatedField : t.getDeclaredWeldFields(Inject.class))
{
if (!annotatedField.isStatic())
{
@@ -232,7 +232,7 @@
public static WeldMethod<?, ?> getPostConstruct(WeldClass<?> type)
{
- Set<WeldMethod<?, ?>> postConstructMethods = type.getAnnotatedWeldMethods(PostConstruct.class);
+ Set<WeldMethod<?, ?>> postConstructMethods = type.getWeldMethods(PostConstruct.class);
log.trace(FOUND_POST_CONSTRUCT_METHODS, postConstructMethods, type);
if (postConstructMethods.size() > 1)
{
@@ -252,7 +252,7 @@
public static WeldMethod<?, ?> getPreDestroy(WeldClass<?> type)
{
- Set<WeldMethod<?, ?>> preDestroyMethods = type.getAnnotatedWeldMethods(PreDestroy.class);
+ Set<WeldMethod<?, ?>> preDestroyMethods = type.getWeldMethods(PreDestroy.class);
log.trace(FOUND_PRE_DESTROY_METHODS, preDestroyMethods, type);
if (preDestroyMethods.size() > 1)
{
@@ -303,7 +303,7 @@
{
Class<? extends Annotation> ejbAnnotationType = manager.getServices().get(EJBApiAbstraction.class).EJB_ANNOTATION_CLASS;
Set<WeldInjectionPoint<?, ?>> ejbInjectionPoints = new HashSet<WeldInjectionPoint<?, ?>>();
- for (WeldField<?, ?> field : type.getAnnotatedWeldFields(ejbAnnotationType))
+ for (WeldField<?, ?> field : type.getWeldFields(ejbAnnotationType))
{
ejbInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
}
@@ -321,7 +321,7 @@
{
Set<WeldInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WeldInjectionPoint<?, ?>>();
Class<? extends Annotation> persistenceContextAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_CONTEXT_ANNOTATION_CLASS;
- for (WeldField<?, ?> field : type.getAnnotatedWeldFields(persistenceContextAnnotationType))
+ for (WeldField<?, ?> field : type.getWeldFields(persistenceContextAnnotationType))
{
jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
}
@@ -339,7 +339,7 @@
{
Set<WeldInjectionPoint<?, ?>> jpaInjectionPoints = new HashSet<WeldInjectionPoint<?, ?>>();
Class<? extends Annotation> persistenceUnitAnnotationType = manager.getServices().get(PersistenceApiAbstraction.class).PERSISTENCE_UNIT_ANNOTATION_CLASS;
- for (WeldField<?, ?> field : type.getAnnotatedWeldFields(persistenceUnitAnnotationType))
+ for (WeldField<?, ?> field : type.getWeldFields(persistenceUnitAnnotationType))
{
jpaInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
}
@@ -357,7 +357,7 @@
{
Class<? extends Annotation> resourceAnnotationType = manager.getServices().get(EJBApiAbstraction.class).RESOURCE_ANNOTATION_CLASS;
Set<WeldInjectionPoint<?, ?>> resourceInjectionPoints = new HashSet<WeldInjectionPoint<?, ?>>();
- for (WeldField<?, ?> field : type.getAnnotatedWeldFields(resourceAnnotationType))
+ for (WeldField<?, ?> field : type.getWeldFields(resourceAnnotationType))
{
resourceInjectionPoints.add(FieldInjectionPoint.of(declaringBean, field));
}
@@ -395,11 +395,11 @@
{
throw new DefinitionException(INITIALIZER_CANNOT_BE_PRODUCER, method, type);
}
- else if (method.getAnnotatedWBParameters(Disposes.class).size() > 0)
+ else if (method.getWeldParameters(Disposes.class).size() > 0)
{
throw new DefinitionException(INITIALIZER_CANNOT_BE_DISPOSAL_METHOD, method, type);
}
- else if (method.getAnnotatedWBParameters(Observes.class).size() > 0)
+ else if (method.getWeldParameters(Observes.class).size() > 0)
{
throw new DefinitionException(INITIALIZER_CANNOT_BE_OBSERVER, method, type);
}
@@ -666,7 +666,7 @@
public static <T> ConstructorInjectionPoint<T> getBeanConstructor(Bean<T> declaringBean, WeldClass<T> type)
{
ConstructorInjectionPoint<T> constructor = null;
- Set<WeldConstructor<T>> initializerAnnotatedConstructors = type.getAnnotatedWeldConstructors(Inject.class);
+ Set<WeldConstructor<T>> initializerAnnotatedConstructors = type.getWeldConstructors(Inject.class);
log.trace(FOUND_INJECTABLE_CONSTRUCTORS, initializerAnnotatedConstructors, type);
if (initializerAnnotatedConstructors.size() > 1)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -18,6 +18,7 @@
import static org.jboss.weld.logging.messages.UtilMessage.CANNOT_PROXY_NON_CLASS_TYPE;
import static org.jboss.weld.logging.messages.UtilMessage.INSTANCE_NOT_A_PROXY;
+import static org.jboss.weld.util.reflection.Reflections.EMPTY_CLASSES;
import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;
@@ -49,8 +50,6 @@
public static class TypeInfo
{
- private static final Class<?>[] EMPTY_INTERFACES_ARRAY = new Class<?>[0];
-
private final Set<Class<?>> interfaces;
private final Set<Class<?>> classes;
@@ -82,7 +81,7 @@
private Class<?>[] getInterfaces()
{
- return interfaces.toArray(EMPTY_INTERFACES_ARRAY);
+ return interfaces.toArray(EMPTY_CLASSES);
}
public ProxyFactory createProxyFactory()
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArrayListSupplier.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArrayListSupplier.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArrayListSupplier.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,26 @@
+package org.jboss.weld.util.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.common.base.Supplier;
+
+public class ArrayListSupplier<T> implements Supplier<List<T>>
+{
+
+ private static final Supplier<?> INSTANCE = new ArrayListSupplier<Object>();
+
+ @SuppressWarnings("unchecked")
+ public static <T> Supplier<List<T>> instance()
+ {
+ return (Supplier<List<T>>) INSTANCE;
+ }
+
+ private ArrayListSupplier() {}
+
+ public List<T> get()
+ {
+ return new ArrayList<T>();
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArrayListSupplier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/CopyOnWriteArrayListSupplier.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/CopyOnWriteArrayListSupplier.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/CopyOnWriteArrayListSupplier.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,27 @@
+package org.jboss.weld.util.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import com.google.common.base.Supplier;
+
+public class CopyOnWriteArrayListSupplier<T> implements Supplier<List<T>>
+{
+
+ private static final Supplier<?> INSTANCE = new CopyOnWriteArrayListSupplier<Object>();
+
+ @SuppressWarnings("unchecked")
+ public static <T> Supplier<List<T>> instance()
+ {
+ return (Supplier<List<T>>) INSTANCE;
+ }
+
+ private CopyOnWriteArrayListSupplier() {}
+
+ public List<T> get()
+ {
+ return new CopyOnWriteArrayList<T>();
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/CopyOnWriteArrayListSupplier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/HashSetSupplier.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/HashSetSupplier.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/HashSetSupplier.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,26 @@
+package org.jboss.weld.util.collections;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.common.base.Supplier;
+
+public class HashSetSupplier<T> implements Supplier<Set<T>>
+{
+
+ private static final Supplier<?> INSTANCE = new HashSetSupplier<Object>();
+
+ @SuppressWarnings("unchecked")
+ public static <T> Supplier<Set<T>> instance()
+ {
+ return (Supplier<Set<T>>) INSTANCE;
+ }
+
+ private HashSetSupplier() {}
+
+ public Set<T> get()
+ {
+ return new HashSet<T>();
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/HashSetSupplier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableIterable.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableIterable.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableIterable.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,22 @@
+package org.jboss.weld.util.collections;
+
+import java.util.Iterator;
+
+import com.google.common.collect.Iterators;
+
+public class IterableIterable<T> implements Iterable<T>
+{
+
+ private final Iterable<Iterable<T>> iterables;
+
+ public IterableIterable(Iterable<Iterable<T>> iterables)
+ {
+ this.iterables = iterables;
+ }
+
+ public Iterator<T> iterator()
+ {
+ return Iterators.concat(Iterators.transform(iterables.iterator(), IterableToIteratorFunction.<T>instance()));
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableIterable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableToIteratorFunction.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableToIteratorFunction.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableToIteratorFunction.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -0,0 +1,23 @@
+package org.jboss.weld.util.collections;
+
+import java.util.Iterator;
+
+import com.google.common.base.Function;
+
+public class IterableToIteratorFunction<T> implements Function<Iterable<T>, Iterator<T>>
+{
+
+ private static final Function<?, ?> INSTANCE = new IterableToIteratorFunction<Object>();
+
+ @SuppressWarnings("unchecked")
+ public static <T> Function<Iterable<T>, Iterator<T>> instance()
+ {
+ return (Function<Iterable<T>, Iterator<T>>) INSTANCE;
+ }
+
+ public Iterator<T> apply(Iterable<T> iterable)
+ {
+ return iterable.iterator();
+ }
+
+}
\ No newline at end of file
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/IterableToIteratorFunction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/ParameterizedTypeImpl.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -30,7 +30,7 @@
public ParameterizedTypeImpl(Type rawType, Type[] actualTypeArguments, Type ownerType)
{
- this.actualTypeArguments = Arrays2.copyOf(actualTypeArguments, actualTypeArguments.length);
+ this.actualTypeArguments = actualTypeArguments;
this.rawType = rawType;
this.ownerType = ownerType;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -59,8 +59,8 @@
private static final IMessageConveyor messageConveyer = loggerFactory().getMessageConveyor();
public static final Type[] EMPTY_TYPES = {};
-
public static final Annotation[] EMPTY_ANNOTATIONS = {};
+ public static final Class<?>[] EMPTY_CLASSES = new Class<?>[0];
public static Map<Class<?>, Type> buildTypeMap(Set<Type> types)
{
@@ -78,6 +78,10 @@
map.put((Class<?>) ((ParameterizedType) type).getRawType(), type);
}
}
+ else if (type instanceof TypeVariable<?>)
+ {
+
+ }
}
return map;
}
@@ -209,17 +213,6 @@
}
/**
- * Checks if clazz is abstract
- *
- * @param clazz Class to check
- * @return True if abstract, false otherwise
- */
- public static boolean isAbstract(Class<?> clazz)
- {
- return Modifier.isAbstract(clazz.getModifiers());
- }
-
- /**
* Checks if a method is abstract
*
* @param method
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/SecureReflectionAccess.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/SecureReflectionAccess.java 2010-01-10 23:46:34 UTC (rev 5416)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/SecureReflectionAccess.java 2010-01-11 19:07:10 UTC (rev 5417)
@@ -37,26 +37,26 @@
@SuppressWarnings("unchecked")
public Object run() throws Exception
{
- SecurityManager securityManager = System.getSecurityManager();
- if (securityManager != null)
- {
- if (true)
- {
- throw new SecurityException("Privileged execution disabled for now to prevent possible leakage, uncomment to play around with it --Nik");
- }
- securityManager.checkPermission(new RuntimePermission("weld.reflection"));
- return AccessController.doPrivileged(new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return work();
- }
- });
- }
- else
- {
+// SecurityManager securityManager = System.getSecurityManager();
+// if (securityManager != null)
+// {
+// if (true)
+// {
+// throw new SecurityException("Privileged execution disabled for now to prevent possible leakage, uncomment to play around with it --Nik");
+// }
+// securityManager.checkPermission(new RuntimePermission("weld.reflection"));
+// return AccessController.doPrivileged(new PrivilegedExceptionAction()
+// {
+// public Object run() throws Exception
+// {
+// return work();
+// }
+// });
+// }
+// else
+// {
return work();
- }
+// }
}
/**
More information about the weld-commits
mailing list