T - the type of the superclasspublic abstract class AbstractClassFactory<T> extends Object
generateClass() to perform the actual class generation. The class will only be generated
once at most| Modifier and Type | Field and Description |
|---|---|
protected org.jboss.classfilewriter.ClassFile |
classFile
The class file that is used to generate the class.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClassFactory(String className,
Class<T> superClass)
Construct a new instance with a
null protection domain. |
protected |
AbstractClassFactory(String className,
Class<T> superClass,
ClassLoader classLoader)
Construct a new instance with a
null protection domain. |
protected |
AbstractClassFactory(String className,
Class<T> superClass,
ClassLoader classLoader,
ProtectionDomain protectionDomain)
Construct a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterClassLoad(Class<?> clazz)
Hook that is called after the class is loaded, before
cleanup() is called. |
void |
buildClassDefinition()
Generates the class
|
protected abstract void |
cleanup()
Cleans up any resources left over from generating the class.
|
Class<? extends T> |
defineClass()
Returns the
Class object for the generated class, creating it if it does not exist |
protected abstract void |
generateClass()
Generate the class.
|
ClassLoader |
getClassLoader()
Get the defining class loader.
|
String |
getClassName()
Get the class name.
|
ProtectionDomain |
getProtectionDomain()
Get the defined protection domain.
|
Class<T> |
getSuperClass()
Get the superclass.
|
String |
getSuperClassName()
Get the superclass name.
|
boolean |
isProxyClassDefined()
Checks if the proxy class is defined in the factories class loader
|
boolean |
isProxyClassDefined(ClassLoader classLoader)
Checks if the proxy class has been defined in the given class loader
|
T |
newInstance()
Creates a new instance of the generated class by invoking the default constructor.
|
protected org.jboss.classfilewriter.ClassFile classFile
generateClass() will only be called once
by a single thread.protected AbstractClassFactory(String className, Class<T> superClass, ClassLoader classLoader, ProtectionDomain protectionDomain)
className - the generated class namesuperClass - the superclass of the generated classclassLoader - the class loader used to load the classprotectionDomain - the protection domain of the classprotected AbstractClassFactory(String className, Class<T> superClass, ClassLoader classLoader)
null protection domain.className - the generated class namesuperClass - the superclass of the generated classclassLoader - the class loader used to load the classprotected abstract void generateClass()
protected abstract void cleanup()
public void afterClassLoad(Class<?> clazz)
cleanup() is called.
This method may be called mutiple times, if the proxy is definined in multiple class loadersclazz - The newly loaded classpublic Class<? extends T> defineClass()
Class object for the generated class, creating it if it does not existpublic boolean isProxyClassDefined()
public boolean isProxyClassDefined(ClassLoader classLoader)
classLoader - The class loader to checkpublic void buildClassDefinition()
public T newInstance() throws InstantiationException, IllegalAccessException
InstantiationException - if the new instance could not be createdIllegalAccessException - if the new constructor is inaccessible for some reasonpublic String getClassName()
public String getSuperClassName()
public ClassLoader getClassLoader()
public ProtectionDomain getProtectionDomain()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.