类 AbstractClassGenerator<T>

java.lang.Object
cn.taketoday.bytecode.core.AbstractClassGenerator<T>
所有已实现的接口:
ClassGenerator
直接已知子类:
BeanCopier.Generator, BeanGenerator, BeanMap.Generator, BulkBean.Generator, ConstructorDelegate.Generator, Enhancer, ImmutableBean.Generator, InterfaceMaker, KeyFactory.Generator, MethodAccess.Generator, MethodDelegate.Generator, Mixin.Generator, MulticastDelegate.Generator, ParallelSorter.Generator, StringSwitcher.Generator

public abstract class AbstractClassGenerator<T> extends Object implements ClassGenerator
Abstract class for all code-generating CGLIB utilities. In addition to caching generated classes for performance, it provides hooks for customizing the ClassLoader, name of the generated class, and transformations applied before generation.
从以下版本开始:
2019-09-04 20:12
作者:
Harry Yang
  • 字段详细资料

  • 构造器详细资料

    • AbstractClassGenerator

      protected AbstractClassGenerator(String source)
    • AbstractClassGenerator

      protected AbstractClassGenerator(Class<?> source)
  • 方法详细资料

    • wrapCachedClass

      protected T wrapCachedClass(Class klass)
    • unwrapCachedValue

      protected Object unwrapCachedValue(T cached)
    • setNamePrefix

      protected AbstractClassGenerator setNamePrefix(String namePrefix)
    • getClassName

      protected final String getClassName()
    • setClassName

      private void setClassName(String className)
    • generateClassName

      private String generateClassName(Predicate<String> nameTestPredicate)
    • setClassLoader

      public AbstractClassGenerator setClassLoader(ClassLoader classLoader)
      Set the 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 default
    • setNamingPolicy

      public AbstractClassGenerator setNamingPolicy(@Nullable NamingPolicy namingPolicy)
      Override the default naming policy.
      参数:
      namingPolicy - the custom policy, or null to use the default
      另请参阅:
    • getNamingPolicy

      public NamingPolicy getNamingPolicy()
      另请参阅:
    • setDefineClassStrategy

      public void setDefineClassStrategy(@Nullable DefineClassStrategy defineClassStrategy)
    • getDefineClassStrategy

      @Nullable public DefineClassStrategy getDefineClassStrategy()
    • setUseCache

      public AbstractClassGenerator setUseCache(boolean useCache)
      Whether use and update the static cache of generated classes for a class with the same properties. Default is true.
    • getUseCache

      public boolean getUseCache()
      另请参阅:
    • setAttemptLoad

      public void setAttemptLoad(boolean attemptLoad)
      If set, CGLIB will attempt to load classes from the specified ClassLoader before generating them. Because generated class names are not guaranteed to be unique, the default is false.
    • isAttemptLoad

      public boolean isAttemptLoad()
    • setStrategy

      public AbstractClassGenerator setStrategy(GeneratorStrategy strategy)
      Set the strategy to use to create the bytecode from this generator. By default an instance of is used.
    • getStrategy

      public GeneratorStrategy getStrategy()
      另请参阅:
    • getCurrent

      public static AbstractClassGenerator getCurrent()
      Used internally by CGLIB. Returns the AbstractClassGenerator that is being used to generate a class in the current thread.
    • getClassLoader

      public ClassLoader getClassLoader()
    • getDefaultClassLoader

      protected abstract ClassLoader getDefaultClassLoader()
    • getProtectionDomain

      protected ProtectionDomain getProtectionDomain()
      Returns the protection domain to use when defining the class.

      Default implementation returns null for using a default protection domain. Sub-classes may override to use a more specific protection domain.

      返回:
      the protection domain (null for using a default)
    • create

      protected Object create(Object key)
    • generate

      protected Class generate(AbstractClassGenerator.ClassLoaderData data)
    • setNeighbor

      public void setNeighbor(Class<?> neighbor)
    • firstInstance

      protected abstract Object firstInstance(Class<T> type) throws Exception
      抛出:
      Exception
    • nextInstance

      protected abstract Object nextInstance(Object instance) throws Exception
      抛出:
      Exception