public abstract class AbstractClassGenerator extends java.lang.Object implements ClassGenerator
ClassLoader, name of the generated class, and transformations
applied before generation.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractClassGenerator.Source |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractClassGenerator(AbstractClassGenerator.Source source) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
create(java.lang.Object key) |
protected abstract java.lang.Object |
firstInstance(java.lang.Class type) |
boolean |
getAttemptLoad() |
java.lang.ClassLoader |
getClassLoader() |
protected java.lang.String |
getClassName() |
static AbstractClassGenerator |
getCurrent()
Used internally by CGLIB.
|
protected abstract java.lang.ClassLoader |
getDefaultClassLoader() |
NamingPolicy |
getNamingPolicy() |
GeneratorStrategy |
getStrategy() |
boolean |
getUseCache() |
protected abstract java.lang.Object |
nextInstance(java.lang.Object instance) |
void |
setAttemptLoad(boolean attemptLoad)
If set, CGLIB will attempt to load classes from the specified
ClassLoader before generating them. |
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set the
ClassLoader in which the class will be generated. |
protected void |
setNamePrefix(java.lang.String namePrefix) |
void |
setNamingPolicy(NamingPolicy namingPolicy)
Override the default naming policy.
|
void |
setStrategy(GeneratorStrategy strategy)
Set the strategy to use to create the bytecode from this generator.
|
void |
setUseCache(boolean useCache)
Whether use and update the static cache of generated classes
for a class with the same properties.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgenerateClassprotected AbstractClassGenerator(AbstractClassGenerator.Source source)
protected void setNamePrefix(java.lang.String namePrefix)
protected final java.lang.String getClassName()
public void setClassLoader(java.lang.ClassLoader classLoader)
ClassLoader in which the class will be generated.
Concrete subclasses of AbstractClassGenerator (such as Enhancer)
will try to choose an appropriate default if this is unset.
Classes are cached per-ClassLoader using a WeakHashMap, to allow
the generated classes to be removed when the associated loader is garbage collected.
classLoader - the loader to generate the new class with, or null to use the defaultpublic void setNamingPolicy(NamingPolicy namingPolicy)
namingPolicy - the custom policy, or null to use the defaultDefaultNamingPolicypublic NamingPolicy getNamingPolicy()
public void setUseCache(boolean useCache)
true.public boolean getUseCache()
setUseCache(boolean)public void setAttemptLoad(boolean attemptLoad)
ClassLoader before generating them. Because generated
class names are not guaranteed to be unique, the default is false.public boolean getAttemptLoad()
public void setStrategy(GeneratorStrategy strategy)
DefaultGeneratorStrategy is used.public GeneratorStrategy getStrategy()
public static AbstractClassGenerator getCurrent()
AbstractClassGenerator
that is being used to generate a class in the current thread.public java.lang.ClassLoader getClassLoader()
protected abstract java.lang.ClassLoader getDefaultClassLoader()
protected java.lang.Object create(java.lang.Object key)
protected abstract java.lang.Object firstInstance(java.lang.Class type)
throws java.lang.Exception
java.lang.Exceptionprotected abstract java.lang.Object nextInstance(java.lang.Object instance)
throws java.lang.Exception
java.lang.ExceptionCopyright © 2013 Oracle Corporation. All Rights Reserved.