Class AgentCachingPoolStrategy

  • All Implemented Interfaces:
    net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy

    public class AgentCachingPoolStrategy
    extends Object
    implements net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy
    NEW (Jan 2020) Custom Pool strategy.
      Uses a Guava Cache directly...
    • better control over locking than WeakMap.Provider
    • provides direct control over concurrency level
    • initial and maximum capacity
      There two core parts to the cache...
    • a cache of ClassLoader to WeakReference<ClassLoader>
    • a single cache of TypeResolutions for all ClassLoaders - keyed by a custom composite key of ClassLoader and class name

    This design was chosen to create a single limited size cache that can be adjusted for the entire application -- without having to create a large number of WeakReference objects.

    Eviction is handled almost entirely through a size restriction; however, softValues are still used as a further safeguard.

    • Nested Class Summary

      • Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy

        net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.ClassLoading, net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.Default, net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.Eager, net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy.WithTypePoolCache
    • Constructor Detail

      • AgentCachingPoolStrategy

        public AgentCachingPoolStrategy()
    • Method Detail

      • typePool

        public final net.bytebuddy.pool.TypePool typePool​(net.bytebuddy.dynamic.ClassFileLocator classFileLocator,
                                                          ClassLoader classLoader)
        Specified by:
        typePool in interface net.bytebuddy.agent.builder.AgentBuilder.PoolStrategy