Class ClassLoadingStrategy.Default.WrappingDispatcher
java.lang.Object
net.bytebuddy.dynamic.loading.ClassLoadingStrategy.Default.WrappingDispatcher
- All Implemented Interfaces:
ClassLoadingStrategy<ClassLoader>, ClassLoadingStrategy.Configurable<ClassLoader>
- Enclosing class:
ClassLoadingStrategy.Default
@Enhance
protected static class ClassLoadingStrategy.Default.WrappingDispatcher
extends Object
implements ClassLoadingStrategy.Configurable<ClassLoader>
A class loading strategy which creates a wrapping class loader while applying a given
ProtectionDomain on class loading.-
Nested Class Summary
Nested classes/interfaces inherited from interface ClassLoadingStrategy
ClassLoadingStrategy.Configurable<S>, ClassLoadingStrategy.Default, ClassLoadingStrategy.ForBootstrapInjection, ClassLoadingStrategy.ForJnaInjection, ClassLoadingStrategy.ForUnsafeInjection, ClassLoadingStrategy.UsingLookup -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final booleanIndicates that a child first loading strategy should be attempted.private final booleantrueif the created class loader should apply child-first semantics.private final ClassLoaderDecorator.FactoryThe class loader decorator factory to use.private final booleanDetermines if an exception should be thrown when attempting to load a type that already exists.private final PackageDefinitionStrategyThe package definer to be used for querying information on package information.private static final booleanIndicates that a parent first loading strategy should be attempted.private final ByteArrayClassLoader.PersistenceHandlerThe persistence handler to apply.private final ProtectionDomainThe protection domain to apply ornullif no protection domain is set.private final booleantrueif the class loader should be sealed.Fields inherited from interface ClassLoadingStrategy
BOOTSTRAP_LOADER, NO_PROTECTION_DOMAIN -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateWrappingDispatcher(ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, ByteArrayClassLoader.PersistenceHandler persistenceHandler, ClassLoaderDecorator.Factory classLoaderDecoratorFactory, boolean childFirst, boolean forbidExisting, boolean sealed) Creates a new protection domain specific class loading wrapper.protectedWrappingDispatcher(ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst) Creates a new wrapping dispatcher with a default protection domain and a default access control context. -
Method Summary
Modifier and TypeMethodDescriptionDetermines if this class loading strategy should not throw an exception when attempting to load a class that was already loaded.Map<TypeDescription, Class<?>> load(ClassLoader classLoader, Map<TypeDescription, byte[]> types) Loads a given collection of classes given their binary representation.opened()With an opened class loading strategy, it is assured that types can be added to the class loader, either by indirect injection using this strategy or by creating a class loader that explicitly supports injection.with(ProtectionDomain protectionDomain) Overrides the implicitly set defaultProtectionDomainwith an explicit one.with(ClassLoaderDecorator.Factory classLoaderDecoratorFactory) Defines a factory that decorates a given class loader prior to class loading.with(PackageDefinitionStrategy packageDefinitionStrategy) Defines the supplied package definition strategy to be used for defining packages.
-
Field Details
-
CHILD_FIRST
private static final boolean CHILD_FIRSTIndicates that a child first loading strategy should be attempted.- See Also:
-
PARENT_FIRST
private static final boolean PARENT_FIRSTIndicates that a parent first loading strategy should be attempted.- See Also:
-
protectionDomain
The protection domain to apply ornullif no protection domain is set. -
persistenceHandler
The persistence handler to apply. -
packageDefinitionStrategy
The package definer to be used for querying information on package information. -
classLoaderDecoratorFactory
The class loader decorator factory to use. -
childFirst
private final boolean childFirsttrueif the created class loader should apply child-first semantics. -
forbidExisting
private final boolean forbidExistingDetermines if an exception should be thrown when attempting to load a type that already exists. -
sealed
private final boolean sealedtrueif the class loader should be sealed.
-
-
Constructor Details
-
WrappingDispatcher
protected WrappingDispatcher(ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst) Creates a new wrapping dispatcher with a default protection domain and a default access control context.- Parameters:
persistenceHandler- The persistence handler to apply.childFirst-trueif the created class loader should apply child-first semantics.
-
WrappingDispatcher
private WrappingDispatcher(@MaybeNull ProtectionDomain protectionDomain, PackageDefinitionStrategy packageDefinitionStrategy, ByteArrayClassLoader.PersistenceHandler persistenceHandler, ClassLoaderDecorator.Factory classLoaderDecoratorFactory, boolean childFirst, boolean forbidExisting, boolean sealed) Creates a new protection domain specific class loading wrapper.- Parameters:
protectionDomain- The protection domain to apply ornullif no protection domain is set.packageDefinitionStrategy- The package definer to be used for querying information on package information.persistenceHandler- The persistence handler to apply.classLoaderDecoratorFactory- The class loader decorator factory to use.childFirst-trueif the created class loader should apply child-first semantics.forbidExisting- Determines if an exception should be thrown when attempting to load a type that already exists.sealed-trueif the class loader should be sealed.
-
-
Method Details
-
load
public Map<TypeDescription, Class<?>> load(@MaybeNull ClassLoader classLoader, Map<TypeDescription, byte[]> types) Loads a given collection of classes given their binary representation.- Specified by:
loadin interfaceClassLoadingStrategy<ClassLoader>- Parameters:
classLoader- The class loader to used for loading the classes.types- Byte array representations of the types to be loaded mapped by their descriptions, where an iteration order defines an order in which they are supposed to be loaded, if relevant.- Returns:
- A collection of the loaded classes which will be initialized in the iteration order of the returned collection.
-
with
Overrides the implicitly set defaultProtectionDomainwith an explicit one.- Specified by:
within interfaceClassLoadingStrategy.Configurable<ClassLoader>- Parameters:
protectionDomain- The protection domain to apply ornullif no protection domain is set.- Returns:
- This class loading strategy with an explicitly set
ProtectionDomain.
-
with
public ClassLoadingStrategy.Configurable<ClassLoader> with(PackageDefinitionStrategy packageDefinitionStrategy) Defines the supplied package definition strategy to be used for defining packages.- Specified by:
within interfaceClassLoadingStrategy.Configurable<ClassLoader>- Parameters:
packageDefinitionStrategy- The package definer to be used.- Returns:
- A version of this class loading strategy that applies the supplied package definition strategy.
-
with
public ClassLoadingStrategy.Configurable<ClassLoader> with(ClassLoaderDecorator.Factory classLoaderDecoratorFactory) Defines a factory that decorates a given class loader prior to class loading. Note that this cannot be used with injection.- Specified by:
within interfaceClassLoadingStrategy.Configurable<ClassLoader>- Parameters:
classLoaderDecoratorFactory- The class loader decorator factory to use.- Returns:
- A version of this class loading strategy that applies the supplied class loader decorator factory.
-
allowExistingTypes
Determines if this class loading strategy should not throw an exception when attempting to load a class that was already loaded. In this case, the already loaded class is used instead of the generated class.- Specified by:
allowExistingTypesin interfaceClassLoadingStrategy.Configurable<ClassLoader>- Returns:
- A version of this class loading strategy that does not throw an exception when a class is already loaded.
-
opened
With an opened class loading strategy, it is assured that types can be added to the class loader, either by indirect injection using this strategy or by creating a class loader that explicitly supports injection.- Specified by:
openedin interfaceClassLoadingStrategy.Configurable<ClassLoader>- Returns:
- A version of this class loading strategy that opens for future injections into a class loader.
-