Package net.bytebuddy.dynamic.loading
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 givenProtectionDomain
on class loading.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.loading.ClassLoadingStrategy
ClassLoadingStrategy.Configurable<S extends ClassLoader>, ClassLoadingStrategy.Default, ClassLoadingStrategy.ForBootstrapInjection, ClassLoadingStrategy.ForUnsafeInjection, ClassLoadingStrategy.UsingLookup
-
-
Field Summary
-
Fields inherited from interface net.bytebuddy.dynamic.loading.ClassLoadingStrategy
BOOTSTRAP_LOADER, NO_PROTECTION_DOMAIN
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WrappingDispatcher(ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst)
Creates a new wrapping dispatcher with a default protection domain and a default access control context.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClassLoadingStrategy.Configurable<ClassLoader>
allowExistingTypes()
Determines 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.ClassLoadingStrategy.Configurable<ClassLoader>
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.ClassLoadingStrategy.Configurable<ClassLoader>
with(ProtectionDomain protectionDomain)
Overrides the implicitly set defaultProtectionDomain
with an explicit one.ClassLoadingStrategy.Configurable<ClassLoader>
with(PackageDefinitionStrategy packageDefinitionStrategy)
Defines the supplied package definition strategy to be used for defining packages.
-
-
-
Constructor Detail
-
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
-true
if the created class loader should apply child-first semantics.
-
-
Method Detail
-
load
public Map<TypeDescription,Class<?>> load(ClassLoader classLoader, Map<TypeDescription,byte[]> types)
Loads a given collection of classes given their binary representation.- Specified by:
load
in 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
public ClassLoadingStrategy.Configurable<ClassLoader> with(ProtectionDomain protectionDomain)
Overrides the implicitly set defaultProtectionDomain
with an explicit one.- Specified by:
with
in interfaceClassLoadingStrategy.Configurable<ClassLoader>
- Parameters:
protectionDomain
- The protection domain to apply ornull
if 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:
with
in 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.
-
allowExistingTypes
public ClassLoadingStrategy.Configurable<ClassLoader> 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:
allowExistingTypes
in interfaceClassLoadingStrategy.Configurable<ClassLoader>
- Returns:
- A version of this class loading strategy that does not throw an exception when a class is already loaded.
-
opened
public ClassLoadingStrategy.Configurable<ClassLoader> 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:
opened
in interfaceClassLoadingStrategy.Configurable<ClassLoader>
- Returns:
- A version of this class loading strategy that opens for future injections into a class loader.
-
-