类 AbstractClassGenerator<T>
- java.lang.Object
-
- net.sf.cglib.core.AbstractClassGenerator<T>
-
- 所有已实现的接口:
ClassGenerator
- 直接已知子类:
BeanCopier.Generator,BeanGenerator,BeanMap.Generator,BulkBean.Generator,ConstructorDelegate.Generator,Enhancer,FastClass.Generator,ImmutableBean.Generator,InterfaceMaker,KeyFactory.Generator,MethodDelegate.Generator,Mixin.Generator,MulticastDelegate.Generator,ParallelSorter.Generator,StringSwitcher.Generator
public abstract class AbstractClassGenerator<T> extends java.lang.Object implements ClassGenerator
Abstract class for all code-generating CGLIB utilities. In addition to caching generated classes for performance, it provides hooks for customizing theClassLoader, name of the generated class, and transformations applied before generation.
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected static classAbstractClassGenerator.ClassLoaderDataprotected static classAbstractClassGenerator.Source
-
构造器概要
构造器 限定符 构造器 说明 protectedAbstractClassGenerator(AbstractClassGenerator.Source source)
-
方法概要
所有方法 静态方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected java.lang.Objectcreate(java.lang.Object key)protected abstract java.lang.ObjectfirstInstance(java.lang.Class type)protected java.lang.Classgenerate(AbstractClassGenerator.ClassLoaderData data)booleangetAttemptLoad()java.lang.ClassLoadergetClassLoader()protected java.lang.StringgetClassName()static AbstractClassGeneratorgetCurrent()Used internally by CGLIB.protected abstract java.lang.ClassLoadergetDefaultClassLoader()NamingPolicygetNamingPolicy()protected java.security.ProtectionDomaingetProtectionDomain()Returns the protection domain to use when defining the class.GeneratorStrategygetStrategy()booleangetUseCache()protected abstract java.lang.ObjectnextInstance(java.lang.Object instance)voidsetAttemptLoad(boolean attemptLoad)If set, CGLIB will attempt to load classes from the specifiedClassLoaderbefore generating them.voidsetClassLoader(java.lang.ClassLoader classLoader)Set theClassLoaderin which the class will be generated.voidsetContextClass(java.lang.Class contextClass)protected voidsetNamePrefix(java.lang.String namePrefix)voidsetNamingPolicy(NamingPolicy namingPolicy)Override the default naming policy.voidsetStrategy(GeneratorStrategy strategy)Set the strategy to use to create the bytecode from this generator.voidsetUseCache(boolean useCache)Whether use and update the static cache of generated classes for a class with the same properties.protected java.lang.ObjectunwrapCachedValue(T cached)protected TwrapCachedClass(java.lang.Class klass)-
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
从接口继承的方法 net.sf.cglib.core.ClassGenerator
generateClass
-
-
-
-
构造器详细资料
-
AbstractClassGenerator
protected AbstractClassGenerator(AbstractClassGenerator.Source source)
-
-
方法详细资料
-
wrapCachedClass
protected T wrapCachedClass(java.lang.Class klass)
-
unwrapCachedValue
protected java.lang.Object unwrapCachedValue(T cached)
-
setNamePrefix
protected void setNamePrefix(java.lang.String namePrefix)
-
getClassName
protected final java.lang.String getClassName()
-
setClassLoader
public void setClassLoader(java.lang.ClassLoader classLoader)
Set theClassLoaderin which the class will be generated. Concrete subclasses ofAbstractClassGenerator(such asEnhancer) will try to choose an appropriate default if this is unset.Classes are cached per-
ClassLoaderusing aWeakHashMap, 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 default
-
setContextClass
public void setContextClass(java.lang.Class contextClass)
-
setNamingPolicy
public void setNamingPolicy(NamingPolicy namingPolicy)
Override the default naming policy.- 参数:
namingPolicy- the custom policy, or null to use the default- 另请参阅:
DefaultNamingPolicy
-
getNamingPolicy
public NamingPolicy getNamingPolicy()
-
setUseCache
public void setUseCache(boolean useCache)
Whether use and update the static cache of generated classes for a class with the same properties. Default istrue.
-
getUseCache
public boolean getUseCache()
- 另请参阅:
setUseCache(boolean)
-
setAttemptLoad
public void setAttemptLoad(boolean attemptLoad)
If set, CGLIB will attempt to load classes from the specifiedClassLoaderbefore generating them. Because generated class names are not guaranteed to be unique, the default isfalse.
-
getAttemptLoad
public boolean getAttemptLoad()
-
setStrategy
public void setStrategy(GeneratorStrategy strategy)
Set the strategy to use to create the bytecode from this generator. By default an instance of {@see DefaultGeneratorStrategy} is used.
-
getStrategy
public GeneratorStrategy getStrategy()
-
getCurrent
public static AbstractClassGenerator getCurrent()
Used internally by CGLIB. Returns theAbstractClassGeneratorthat is being used to generate a class in the current thread.
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
-
getDefaultClassLoader
protected abstract java.lang.ClassLoader getDefaultClassLoader()
-
getProtectionDomain
protected java.security.ProtectionDomain getProtectionDomain()
Returns the protection domain to use when defining the class.Default implementation returns
nullfor using a default protection domain. Sub-classes may override to use a more specific protection domain.- 返回:
- the protection domain (
nullfor using a default)
-
create
protected java.lang.Object create(java.lang.Object key)
-
generate
protected java.lang.Class generate(AbstractClassGenerator.ClassLoaderData data)
-
firstInstance
protected abstract java.lang.Object firstInstance(java.lang.Class type) throws java.lang.Exception- 抛出:
java.lang.Exception
-
nextInstance
protected abstract java.lang.Object nextInstance(java.lang.Object instance) throws java.lang.Exception- 抛出:
java.lang.Exception
-
-