JBoss Reflection 2.2.1.SP1

org.jboss.reflect.plugins.bytecode
Class BytecodeTypeInfoFactoryImpl

java.lang.Object
  extended by org.jboss.util.collection.WeakClassCache<TypeInfo>
      extended by org.jboss.reflect.plugins.bytecode.BytecodeTypeInfoFactoryImpl
All Implemented Interfaces:
AnnotationHelper, TypeInfoFactory

public class BytecodeTypeInfoFactoryImpl
extends org.jboss.util.collection.WeakClassCache<TypeInfo>
implements TypeInfoFactory, AnnotationHelper

A javassist type factory. TODO: need to fix the cl stuff

Version:
$Revision: 105101 $
Author:
Adrian Brock

Nested Class Summary
protected static class BytecodeTypeInfoFactoryImpl.ModifiableArrayType
          Wrapper around SignatureAttribute.ArrayType to make it easier to create the name used to look up the array type infos in the cache
 
Field Summary
 
Fields inherited from class org.jboss.util.collection.WeakClassCache
cache
 
Constructor Summary
BytecodeTypeInfoFactoryImpl()
           
 
Method Summary
 AnnotationValue createAnnotationValue(AnnotationInfo info, Object ann)
          Create an annotation from the underlying implementation and its info type
protected  TypeInfo createTypeInfoForTypeArgument(javassist.bytecode.SignatureAttribute.TypeArgument arg, ClassLoader loader, org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
          Gets the type info for a javassist type argument
protected  void generate(Class clazz, TypeInfo result)
           
 TypeInfo get(Class clazz)
          Get the information for a class
protected  TypeInfo get(ClassBytes classBytes, Class<?> clazz, String name, ClassLoader cl, boolean delegateToReflectIfNotFound)
          Get the information for a class
 TypeInfo get(String name, ClassLoader cl)
          Get the information for a class
protected  TypeInfo get(String name, ClassLoader cl, Class<?> clazz)
          Get the information for a class
 AnnotationValue[] getAnnotations(Object obj)
          Get the annotations for the annotated object
protected  Map<String,WeakReference<TypeInfo>> getClassLoaderCache(ClassLoader cl)
          Gets the classloader cache for the passed in classloader.
 ClassLoaderFinder getClassLoaderFinder()
           
protected  ArrayInfo getGenericArrayType(ClassLoader cl, BytecodeTypeInfoFactoryImpl.ModifiableArrayType type, org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
          Recursively get the type info for a javassist array type
protected  ArrayInfo getGenericArrayType(ClassLoader cl, javassist.bytecode.SignatureAttribute.ArrayType type, org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
          Get the type info for a javassist array type
protected  TypeInfo getGenericArrayType(GenericArrayType type)
          Get the type info for a reflect generic array type
protected  TypeInfo getParameterizedType(ParameterizedType type)
          Creates a type info from a reflect generic paramemeterized type
 TypeInfo getTypeInfo(Class<?> clazz)
          Get a type info
protected  TypeInfo getTypeInfo(ClassLoader loader, javassist.bytecode.SignatureAttribute.ClassType type, org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
          Gets the type info for a javassist generic class type
protected  TypeInfo getTypeInfo(ClassLoader loader, javassist.bytecode.SignatureAttribute.Type type, org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
          Gets the type info for a javassist type
 TypeInfo getTypeInfo(String name, ClassLoader cl)
          Gets the type info for a class
 TypeInfo getTypeInfo(Type type)
          Gets the type info for a reflect type
protected  TypeInfo getTypeVariable(TypeVariable<?> type)
          Get the type info for a reflect TypeVariable
protected  TypeInfo getWildcardType(WildcardType type)
          Gets the type info for a reflect wildcard type
protected  TypeInfo instantiate(Class clazz)
           
protected  TypeInfo instantiate(String name, ClassBytes classBytes, Class<?> clazz)
           
 void setClassLoaderFinder(ClassLoaderFinder finder)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BytecodeTypeInfoFactoryImpl

public BytecodeTypeInfoFactoryImpl()
Method Detail

getClassLoaderFinder

public ClassLoaderFinder getClassLoaderFinder()

setClassLoaderFinder

public void setClassLoaderFinder(ClassLoaderFinder finder)

instantiate

protected TypeInfo instantiate(Class clazz)
Specified by:
instantiate in class org.jboss.util.collection.WeakClassCache<TypeInfo>

instantiate

protected TypeInfo instantiate(String name,
                               ClassBytes classBytes,
                               Class<?> clazz)

generate

protected void generate(Class clazz,
                        TypeInfo result)
Specified by:
generate in class org.jboss.util.collection.WeakClassCache<TypeInfo>

getTypeInfo

public TypeInfo getTypeInfo(Class<?> clazz)
Description copied from interface: TypeInfoFactory
Get a type info

Specified by:
getTypeInfo in interface TypeInfoFactory
Parameters:
clazz - the class
Returns:
the type info

getTypeInfo

public TypeInfo getTypeInfo(String name,
                            ClassLoader cl)
                     throws ClassNotFoundException
Gets the type info for a class

Specified by:
getTypeInfo in interface TypeInfoFactory
Parameters:
type - the type
Returns:
the type info
Throws:
ClassNotFoundException - when there is no such class

getTypeInfo

public TypeInfo getTypeInfo(Type type)
Gets the type info for a reflect type

Specified by:
getTypeInfo in interface TypeInfoFactory
Parameters:
type - the type
Returns:
the type info

get

public TypeInfo get(String name,
                    ClassLoader cl)
             throws ClassNotFoundException
Get the information for a class

Overrides:
get in class org.jboss.util.collection.WeakClassCache<TypeInfo>
Parameters:
name - the name
cl - the classloader
Returns:
the info
Throws:
ClassNotFoundException - when the class cannot be found

get

public TypeInfo get(Class clazz)
Get the information for a class

Overrides:
get in class org.jboss.util.collection.WeakClassCache<TypeInfo>
Parameters:
clazz - the class
Returns:
the info

get

protected TypeInfo get(String name,
                       ClassLoader cl,
                       Class<?> clazz)
                throws ClassNotFoundException
Get the information for a class

Parameters:
name - the name
cl - the classloader
clazz - the class
Returns:
the info
Throws:
ClassNotFoundException - when the class cannot be found

get

protected TypeInfo get(ClassBytes classBytes,
                       Class<?> clazz,
                       String name,
                       ClassLoader cl,
                       boolean delegateToReflectIfNotFound)
                throws ClassNotFoundException
Get the information for a class

Parameters:
classBytes - the class bytes, may be null
clazz - the class, may be null
name - the name of the class
cl - the class loader initiating the lookup
Returns:
the info
Throws:
IllegalArgumentException - if either name or cl are null
ClassNotFoundException

getAnnotations

public AnnotationValue[] getAnnotations(Object obj)
Description copied from interface: AnnotationHelper
Get the annotations for the annotated object

Specified by:
getAnnotations in interface AnnotationHelper
Parameters:
obj - the annotated object
Returns:
the annotations

createAnnotationValue

public AnnotationValue createAnnotationValue(AnnotationInfo info,
                                             Object ann)
Description copied from interface: AnnotationHelper
Create an annotation from the underlying implementation and its info type

Specified by:
createAnnotationValue in interface AnnotationHelper
Parameters:
info - the annotation info
ann - the underlying annotation
Returns:
the annotation value

getParameterizedType

protected TypeInfo getParameterizedType(ParameterizedType type)
Creates a type info from a reflect generic paramemeterized type

Parameters:
type - the parameterized type
Returns:
the type info

getTypeInfo

protected TypeInfo getTypeInfo(ClassLoader loader,
                               javassist.bytecode.SignatureAttribute.Type type,
                               org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
Gets the type info for a javassist type

Parameters:
loader - the class loader
type - the class type
spy - used to determine actual types of type variables
Returns:
the type info

getTypeInfo

protected TypeInfo getTypeInfo(ClassLoader loader,
                               javassist.bytecode.SignatureAttribute.ClassType type,
                               org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
Gets the type info for a javassist generic class type

Parameters:
loader - the class loader of the raw class
parameterloaders - the class of the
type - the class type
spy - used to determine actual types of type variables
Returns:
the type info

createTypeInfoForTypeArgument

protected TypeInfo createTypeInfoForTypeArgument(javassist.bytecode.SignatureAttribute.TypeArgument arg,
                                                 ClassLoader loader,
                                                 org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
Gets the type info for a javassist type argument

Parameters:
arg - the type argument
loader - the class loader
spy - used to determine actual types of type variables
Returns:
the type info

getWildcardType

protected TypeInfo getWildcardType(WildcardType type)
Gets the type info for a reflect wildcard type

Parameters:
type - the wildcard type
Returns:
the type info

getClassLoaderCache

protected Map<String,WeakReference<TypeInfo>> getClassLoaderCache(ClassLoader cl)
Gets the classloader cache for the passed in classloader.

Overrides:
getClassLoaderCache in class org.jboss.util.collection.WeakClassCache<TypeInfo>
Parameters:
cl - the classloader. If null is used, the Thread context classloader will be used instead
Returns:
the cache of type infos by name

getGenericArrayType

protected TypeInfo getGenericArrayType(GenericArrayType type)
Get the type info for a reflect generic array type

Parameters:
type - the array type
Returns:
the info

getGenericArrayType

protected ArrayInfo getGenericArrayType(ClassLoader cl,
                                        javassist.bytecode.SignatureAttribute.ArrayType type,
                                        org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
Get the type info for a javassist array type

Parameters:
cl - the classloader
type - the array type
spy - used to determine actual types of type variables
Returns:
the type info

getGenericArrayType

protected ArrayInfo getGenericArrayType(ClassLoader cl,
                                        BytecodeTypeInfoFactoryImpl.ModifiableArrayType type,
                                        org.jboss.reflect.plugins.bytecode.BytecodeTypeVariableSpy spy)
Recursively get the type info for a javassist array type

Parameters:
cl - the classloader
type - the array type
spy - used to determine actual types of type variables
Returns:
the type info

getTypeVariable

protected TypeInfo getTypeVariable(TypeVariable<?> type)
Get the type info for a reflect TypeVariable

Parameters:
type - the type variable
Returns:
the type info

JBoss Reflection 2.2.1.SP1

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.