Skip to content

Commit

Permalink
WBRI-108
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@1945 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Mar 12, 2009
1 parent a6c36a1 commit 76baa7b
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 111 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/javax/inject/manager/Bean.java
Expand Up @@ -60,7 +60,7 @@ protected Manager getManager()
*
* @return the bean types
*/
public abstract Set<Type> getTypes();
public abstract Set<? extends Type> getTypes();

/**
* The bindings of a bean
Expand Down
9 changes: 4 additions & 5 deletions impl/src/main/java/org/jboss/webbeans/bean/AbstractBean.java
Expand Up @@ -48,7 +48,6 @@
import org.jboss.webbeans.log.Logging;
import org.jboss.webbeans.metadata.MergedStereotypes;
import org.jboss.webbeans.metadata.MetaDataCache;
import org.jboss.webbeans.util.Beans;
import org.jboss.webbeans.util.Reflections;

/**
Expand Down Expand Up @@ -107,7 +106,7 @@ public static Class<? extends Annotation> getDeploymentType(List<Class<? extends
// The type
protected Class<T> type;
// The API types
protected Set<Type> types;
protected Set<? extends Type> types;
// The injection points
protected Set<AnnotatedInjectionPoint<?, ?>> injectionPoints;
// If the type a primitive?
Expand Down Expand Up @@ -163,7 +162,7 @@ protected void init()
*/
protected void initTypes()
{
types = new Reflections.HierarchyDiscovery<Type>(getAnnotatedItem().getUnderlyingType()).getFlattenedTypes();
types = getAnnotatedItem().getFlattenedTypeHierarchy();
}

/**
Expand Down Expand Up @@ -245,7 +244,7 @@ protected void initName()

protected void initProxyable()
{
proxyable = Beans.apiTypesAreProxyable(getTypes());
proxyable = getAnnotatedItem().isProxyable();
}

/**
Expand Down Expand Up @@ -459,7 +458,7 @@ public Class<T> getType()
* @see javax.inject.manager.Bean#getTypes()
*/
@Override
public Set<Type> getTypes()
public Set<? extends Type> getTypes()
{
return types;
}
Expand Down
Expand Up @@ -20,7 +20,6 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -94,14 +93,18 @@ protected void initTypes()
{
if (getType().isArray() || getType().isPrimitive())
{
Set<Type> types = new HashSet<Type>();
types = new HashSet<Type>();
types.add(getType());
types.add(Object.class);
super.types = types;
}
else if (getType().isInterface())
{
super.initTypes();
Set<Type> types = new HashSet<Type>();
types.add(Object.class);
types.addAll(getAnnotatedItem().getFlattenedTypeHierarchy());
super.types = types;
}
else
{
Expand Down
Expand Up @@ -20,6 +20,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

Expand Down Expand Up @@ -123,12 +124,14 @@ protected void init()

protected void initTypes()
{
Set<Type> types = new HashSet<Type>();
types = new LinkedHashSet<Type>();
types.add(Object.class);
for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces())
{
types.add(businessInterfaceDescriptor.getInterface());
}
super.types = types;
}

protected void initProxyClass()
Expand Down
Expand Up @@ -115,7 +115,7 @@ public Class<? extends Annotation> getScopeType()
* @return The API types
*/
@Override
public Set<Type> getTypes()
public Set<? extends Type> getTypes()
{
return delegate().getTypes();
}
Expand Down
Expand Up @@ -8,6 +8,7 @@
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import javax.inject.TypeLiteral;

Expand Down Expand Up @@ -111,5 +112,16 @@ public boolean isStatic()
{
throw new UnsupportedOperationException();
}

public Set<? extends Type> getFlattenedTypeHierarchy()
{
throw new UnsupportedOperationException();
}

@Override
public boolean isProxyable()
{
throw new UnsupportedOperationException();
}

}
Expand Up @@ -105,6 +105,8 @@ public interface AnnotatedItem<T, S>
* @return An annotation if found, null if the annotation wasn't present.
*/
public <A extends Annotation> A getAnnotation(Class<A> annotationType);

public Set<? extends Type> getFlattenedTypeHierarchy();

/**
* Indicates if an annotation type specified is present
Expand Down Expand Up @@ -149,7 +151,7 @@ public interface AnnotatedItem<T, S>
* @param types The set of types to match
* @return True if assignable, false otherwise.
*/
public boolean isAssignableFrom(Set<Type> types);
public boolean isAssignableFrom(Set<? extends Type> types);

/**
* Gets the actual type arguments for any parameterized types that this
Expand Down
Expand Up @@ -135,7 +135,7 @@ public boolean isAssignableFrom(AnnotatedItem<?, ?> that)
/**
* @see org.jboss.webbeans.introspector.AnnotatedItem
*/
public boolean isAssignableFrom(Set<Type> types)
public boolean isAssignableFrom(Set<? extends Type> types)
{
return delegate().isAssignableFrom(types);
}
Expand Down Expand Up @@ -218,5 +218,10 @@ public boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotatio
{
return delegate().isDeclaredAnnotationPresent(annotationType);
}

public Set<? extends Type> getFlattenedTypeHierarchy()
{
return delegate().getFlattenedTypeHierarchy();
}

}
Expand Up @@ -61,6 +61,9 @@ public Type getUnderlyingType()
// Cached string representation
private String toString;
private final AnnotationStore annotationStore;
private final Class<T> type;
private final Set<? extends Type> flattenedTypes;
private final boolean proxyable;

/**
* Constructor
Expand All @@ -71,9 +74,20 @@ public Type getUnderlyingType()
* @param annotationMap A map of annotation to register
*
*/
public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper, Class<T> type)
{
this.annotationStore = annotatedItemHelper;
this.type = type;
this.flattenedTypes = new Reflections.HierarchyDiscovery<Type>(type).getFlattenedTypes();
this.proxyable = Proxies.isTypesProxyable(flattenedTypes);
}

public AbstractAnnotatedItem(AnnotationStore annotatedItemHelper)
{
this.annotationStore = annotatedItemHelper;
this.type = null;
this.flattenedTypes = null;
this.proxyable = false;
}

public AnnotationStore getAnnotationStore()
Expand Down Expand Up @@ -158,7 +172,7 @@ public boolean isAssignableFrom(AnnotatedItem<?, ?> that)
*
* @see org.jboss.webbeans.introspector.AnnotatedItem#isAssignableFrom(Set)
*/
public boolean isAssignableFrom(Set<Type> types)
public boolean isAssignableFrom(Set<? extends Type> types)
{
for (Type type : types)
{
Expand Down Expand Up @@ -255,7 +269,17 @@ public Annotation[] getBindingsAsArray()
*/
public boolean isProxyable()
{
return Proxies.isTypeProxyable(getType());
return proxyable;
}

public Class<T> getType()
{
return type;
}

public Set<? extends Type> getFlattenedTypeHierarchy()
{
return flattenedTypes;
}

public abstract S getDelegate();
Expand Down
Expand Up @@ -110,9 +110,9 @@ public List<AnnotatedParameter<?>> get(Object key)
*
* @param annotationMap The annotation map
*/
public AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member)
public AbstractAnnotatedMember(AnnotationStore annotatedItemHelper, Member member, Class<T> type)
{
super(annotatedItemHelper);
super(annotatedItemHelper, type);
name = member.getName();
_public = Modifier.isPublic(member.getModifiers());
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ public abstract class AbstractAnnotatedType<T> extends AbstractAnnotatedItem<T,
*/
public AbstractAnnotatedType(AnnotationStore annotatedItemHelper, Class<T> type)
{
super(annotatedItemHelper);
super(annotatedItemHelper, type);
this.name = type.getName();
this._simpleName = type.getSimpleName();
if (type.getSuperclass() != null)
Expand Down
Expand Up @@ -152,16 +152,6 @@ public Set<AnnotatedMethod<?>> getMembers()
return Collections.unmodifiableSet(members);
}

/**
* Gets the type of the annotation
*
* @see org.jboss.webbeans.introspector.AnnotatedAnnotation#getType()
*/
public Class<T> getType()
{
return clazz;
}

/**
* Returns the annotated members with a given annotation type
*
Expand Down Expand Up @@ -202,5 +192,4 @@ public AnnotatedAnnotation<T> wrap(Set<Annotation> annotations)
{
throw new UnsupportedOperationException();
}

}
Expand Up @@ -257,6 +257,7 @@ public String toString()
private final boolean _nonStaticMemberClass;
private final boolean _parameterizedType;
private final boolean _abstract;


public static <T> AnnotatedClass<T> of(Class<T> clazz)
{
Expand Down Expand Up @@ -475,16 +476,6 @@ public Set<AnnotatedField<?>> getAnnotatedFields(Class<? extends Annotation> ann
return Collections.unmodifiableSet(annotatedFields.get(annotationType));
}

/**
* Gets the type of the class
*
* @return The type
*/
public Class<T> getType()
{
return clazz;
}

public boolean isNonStaticMemberClass()
{
return _nonStaticMemberClass;
Expand Down
Expand Up @@ -77,7 +77,7 @@ public static <T> AnnotatedConstructor<T> of(Constructor<T> constructor, Annotat
*/
public AnnotatedConstructorImpl(Constructor<T> constructor, AnnotatedType<T> declaringClass)
{
super(AnnotationStore.of(constructor), constructor);
super(AnnotationStore.of(constructor), constructor, constructor.getDeclaringClass());
this.constructor = constructor;
this.declaringClass = declaringClass;

Expand Down Expand Up @@ -130,16 +130,6 @@ public Constructor<T> getDelegate()
return constructor;
}

/**
* Gets the type of the constructor
*
* @return The type of the constructor
*/
public Class<T> getType()
{
return constructor.getDeclaringClass();
}

/**
* Gets the actual type arguments
*
Expand Down
Expand Up @@ -60,7 +60,7 @@ public class AnnotatedFieldImpl<T> extends AbstractAnnotatedMember<T, Field> imp
*/
public AnnotatedFieldImpl(Field field, AnnotatedType<?> declaringClass)
{
super(AnnotationStore.of(field), field);
super(AnnotationStore.of(field), field, (Class<T>) field.getType());
this.field = field;
field.setAccessible(true);
this.declaringClass = declaringClass;
Expand Down Expand Up @@ -90,17 +90,6 @@ public Field getDelegate()
return field;
}

/**
* Gets the type
*
* @return The type
*/
@SuppressWarnings("unchecked")
public Class<T> getType()
{
return (Class<T>) field.getType();
}

/**
* Gets the actual type arguments
*
Expand Down Expand Up @@ -189,5 +178,5 @@ public int hashCode()
{
return getDelegate().hashCode();
}

}

0 comments on commit 76baa7b

Please sign in to comment.