类 BeanSafeCache<T>

java.lang.Object
cn.dinodev.spring.commons.bean.BeanSafeCache<T>

public class BeanSafeCache<T> extends Object
作者:
Cody Lu
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    void
    Accept the given ClassLoader as cache-safe, even if its classes would not qualify as cache-safe in this CachedIntrospectionResults class.
    void
    Clear the introspection cache for the given ClassLoader, removing the introspection results for all classes underneath that ClassLoader, and removing the ClassLoader (and its children) from the acceptance list.
    get(Class<?> beanClass)
    Retrieve a cached info for the given target class.
    getOrElse(Class<?> beanClass, Function<Class<?>,? extends T> provider)
    Retrieve a cached info for the given target class.
    boolean
    Check whether this CachedIntrospectionResults class is configured to accept the given ClassLoader.
    put(Class<?> beanClass, T info)
    Associates the specified value with the specified key in this cache.
    remove(Class<?> beanClass)
    remove the specified key in this cache.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • BeanSafeCache

      public BeanSafeCache()
  • 方法详细资料

    • acceptClassLoader

      public void acceptClassLoader(@Nullable ClassLoader classLoader)
      Accept the given ClassLoader as cache-safe, even if its classes would not qualify as cache-safe in this CachedIntrospectionResults class.

      This configuration method is only relevant in scenarios where the Spring classes reside in a 'common' ClassLoader (e.g. the system ClassLoader) whose lifecycle is not coupled to the application. In such a scenario, CachedIntrospectionResults would by default not cache any of the application's classes, since they would create a leak in the common ClassLoader.

      Any acceptClassLoader call at application startup should be paired with a clearClassLoader(java.lang.ClassLoader) call at application shutdown.

      参数:
      classLoader - the ClassLoader to accept
    • clearClassLoader

      public void clearClassLoader(@Nullable ClassLoader classLoader)
      Clear the introspection cache for the given ClassLoader, removing the introspection results for all classes underneath that ClassLoader, and removing the ClassLoader (and its children) from the acceptance list.
      参数:
      classLoader - the ClassLoader to clear the cache for
    • isClassLoaderAccepted

      public boolean isClassLoaderAccepted(ClassLoader classLoader)
      Check whether this CachedIntrospectionResults class is configured to accept the given ClassLoader.
      参数:
      classLoader - the ClassLoader to check
      返回:
      whether the given ClassLoader is accepted
      另请参阅:
    • get

      public T get(Class<?> beanClass)
      Retrieve a cached info for the given target class.
      参数:
      beanClass - the target class to introspect
      返回:
      the resulting cached info (never null)
    • getOrElse

      public T getOrElse(Class<?> beanClass, Function<Class<?>,? extends T> provider)
      Retrieve a cached info for the given target class.
      参数:
      beanClass - the target class to introspect
      返回:
      the resulting cached info (never null)
    • put

      public T put(Class<?> beanClass, T info)
      Associates the specified value with the specified key in this cache.
      参数:
      beanClass -
      info -
      返回:
      the previous value associated with key, or null if there was no mapping for key.
    • remove

      public T remove(Class<?> beanClass)
      remove the specified key in this cache.
      参数:
      beanClass -
      返回:
      the previous value associated with key, or null if there was no mapping for key.