public abstract class ReflectionJavaModelFactory extends AbstractJavaModelFactory
java.lang.Class
and
java.lang.reflect.Field
instances to get Java related
metadata about types and fields. This implementation caches JavaModel
instances per ClassLoader.Constructor and Description |
---|
ReflectionJavaModelFactory() |
Modifier and Type | Method and Description |
---|---|
JavaModel |
createJavaModel(java.lang.Object key)
Creates a new empty JavaModel instance.
|
static java.lang.Class |
forNamePrivileged(java.lang.String name,
boolean initialize,
java.lang.ClassLoader loader)
Calls Class.forName in a doPrivileged block.
|
static java.lang.ClassLoader |
getClassLoaderPrivileged(java.lang.Class clazz)
Calls getClassLoader on the specified Class instance in a
doPrivileged block.
|
java.lang.Class |
getJavaClass(JavaType javaType)
Returns the
java.lang.Class wrapped in the specified
JavaType. |
JavaType |
getJavaType(java.lang.Object typeDesc)
Returns a JavaType instance for the specified type description
(optional operation).
|
protected JavaModel |
newJavaModelInstance(java.lang.ClassLoader classLoader)
Creates a new instance of the JavaModel implementation class.
|
getJavaModel, removeJavaModel, removeJavaModel
public JavaModel createJavaModel(java.lang.Object key) throws ModelException
This implementation only accepts java.lang.ClassLoader
instances as key. A ModelException indicates an invalid key.
The method automatically sets the parent/child relationship for the created JavaModel according to the parent/child relationship of the ClassLoader passed as key.
createJavaModel
in interface JavaModelFactory
createJavaModel
in class AbstractJavaModelFactory
key
- the key that may be used to cache the returned JavaModel
instance.ModelException
- if impossible; the key is of an
inappropriate type.public JavaType getJavaType(java.lang.Object typeDesc)
getJavaModel(key).getJavaType(typeName)
.
The ReflectionJavaModelFactory supports this short cut and accepts
java.lang.Class
instances as valid arguments for this
method. The method throws a
ModelFatalException
, if the specified
type descriptor is not a java.lang.Class
instance.
getJavaType
in interface JavaModelFactory
getJavaType
in class AbstractJavaModelFactory
typeDesc
- the type descriptionModelFatalException
- the specified type description is not
a java.lang.Class
instance.public static java.lang.ClassLoader getClassLoaderPrivileged(java.lang.Class clazz)
clazz
- the class to get the ClassLoader from.ModelFatalException
- wraps the SecurityException thrown by
getClassLoader.public static java.lang.Class forNamePrivileged(java.lang.String name, boolean initialize, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundException
name
- fully qualified name of the desired classinitialize
- whether the class must be initializedloader
- class loader from which the class must be loadedModelFatalException
- wraps the SecurityException thrown by
getClassLoader.java.lang.ClassNotFoundException
- if the class cannot be located by the
specified class loader.public java.lang.Class getJavaClass(JavaType javaType)
java.lang.Class
wrapped in the specified
JavaType.java.lang.Class
for the specified
JavaType.ModelFatalException
- the specified JavaType does
not wrap a java.lang.Class
instance.protected JavaModel newJavaModelInstance(java.lang.ClassLoader classLoader)
This implementation returns a ReflectionJavaModel
instance.
Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.