@API(status=INTERNAL,
since="5.5")
public class MutableExtensionRegistry
extends java.lang.Object
implements ExtensionRegistry, ExtensionRegistrar
ExtensionRegistry.
A registry has a reference to its parent registry, and all lookups are performed first in the current registry itself and then recursively in its ancestors.
| Modifier and Type | Field and Description |
|---|---|
private static java.util.List<Extension> |
DEFAULT_STATELESS_EXTENSIONS |
private static Logger |
logger |
private MutableExtensionRegistry |
parent |
private java.util.List<Extension> |
registeredExtensions |
private java.util.Set<java.lang.Class<? extends Extension>> |
registeredExtensionTypes |
| Modifier | Constructor and Description |
|---|---|
private |
MutableExtensionRegistry(MutableExtensionRegistry parent) |
| Modifier and Type | Method and Description |
|---|---|
private java.lang.String |
buildSourceInfo(java.lang.Object source) |
static MutableExtensionRegistry |
createRegistryFrom(MutableExtensionRegistry parentRegistry,
java.util.stream.Stream<java.lang.Class<? extends Extension>> extensionTypes)
Factory for creating and populating a new registry from a list of
extension types and a parent registry.
|
static MutableExtensionRegistry |
createRegistryWithDefaultExtensions(JupiterConfiguration configuration)
Factory for creating and populating a new root registry with the default
extensions.
|
private boolean |
isAlreadyRegistered(java.lang.Class<? extends Extension> extensionType)
Determine if the supplied type is already registered in this registry or in a
parent registry.
|
private void |
registerAutoDetectedExtension(Extension extension) |
private static void |
registerAutoDetectedExtensions(MutableExtensionRegistry extensionRegistry) |
private void |
registerDefaultExtension(Extension extension) |
void |
registerExtension(java.lang.Class<? extends Extension> extensionType)
Instantiate an extension of the given type using its default constructor
and register it in the registry.
|
void |
registerExtension(Extension extension,
java.lang.Object source)
Register the supplied
Extension, without checking if an extension
of that type has already been registered. |
private void |
registerExtension(java.lang.String category,
Extension extension) |
private void |
registerExtension(java.lang.String category,
Extension extension,
java.lang.Object source) |
private void |
registerLocalExtension(Extension extension) |
void |
registerSyntheticExtension(Extension extension,
java.lang.Object source)
Register the supplied
Extension as a synthetic extension,
without checking if an extension of that type has already been registered. |
<E extends Extension> |
stream(java.lang.Class<E> extensionType)
Stream all
Extensions of the specified type that are present
in this registry or one of its ancestors. |
private <E extends Extension> |
streamLocal(java.lang.Class<E> extensionType)
Stream all
Extensions of the specified type that are present
in this registry. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetExtensionsprivate static final Logger logger
private static final java.util.List<Extension> DEFAULT_STATELESS_EXTENSIONS
private final MutableExtensionRegistry parent
private final java.util.Set<java.lang.Class<? extends Extension>> registeredExtensionTypes
private final java.util.List<Extension> registeredExtensions
private MutableExtensionRegistry(MutableExtensionRegistry parent)
public static MutableExtensionRegistry createRegistryWithDefaultExtensions(JupiterConfiguration configuration)
If the Constants.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAME
configuration parameter has been set to true, extensions will be
auto-detected using Java's ServiceLoader mechanism and automatically
registered after the default extensions.
configuration - configuration parameters used to retrieve the extension
auto-detection flag; never nullExtensionRegistry; never nullprivate static void registerAutoDetectedExtensions(MutableExtensionRegistry extensionRegistry)
public static MutableExtensionRegistry createRegistryFrom(MutableExtensionRegistry parentRegistry, java.util.stream.Stream<java.lang.Class<? extends Extension>> extensionTypes)
parentRegistry - the parent registryextensionTypes - the types of extensions to be registered in
the new registryExtensionRegistry; never nullpublic <E extends Extension> java.util.stream.Stream<E> stream(java.lang.Class<E> extensionType)
ExtensionRegistryExtensions of the specified type that are present
in this registry or one of its ancestors.stream in interface ExtensionRegistryextensionType - the type of Extension to streamExtensionRegistry.getExtensions(Class)private <E extends Extension> java.util.stream.Stream<E> streamLocal(java.lang.Class<E> extensionType)
Extensions of the specified type that are present
in this registry.
Extensions in ancestors are ignored.
extensionType - the type of Extension to streampublic void registerExtension(java.lang.Class<? extends Extension> extensionType)
ExtensionRegistrarA new Extension should not be registered if an extension of the
given type already exists in the registry or a parent registry.
registerExtension in interface ExtensionRegistrarextensionType - the type of extension to registerprivate boolean isAlreadyRegistered(java.lang.Class<? extends Extension> extensionType)
public void registerExtension(Extension extension, java.lang.Object source)
ExtensionRegistrarExtension, without checking if an extension
of that type has already been registered.
If an extension is registered declaratively via
@ExtendWith, the
source and the extension should be the same object.
However, if an extension is registered programmatically via
@RegisterExtension,
the source object should be the Field
that is annotated with @RegisterExtension. Similarly, if an
extension is registered programmatically as a lambda expression
or method reference, the source object should be the underlying
Method that implements the extension API.
registerExtension in interface ExtensionRegistrarextension - the extension to register; never nullsource - the source of the extension; never nullpublic void registerSyntheticExtension(Extension extension, java.lang.Object source)
ExtensionRegistrarExtension as a synthetic extension,
without checking if an extension of that type has already been registered.registerSyntheticExtension in interface ExtensionRegistrarextension - the extension to register; never nullsource - the source of the extension; never nullExtensionRegistrar.registerExtension(Extension, Object)private void registerDefaultExtension(Extension extension)
private void registerAutoDetectedExtension(Extension extension)
private void registerLocalExtension(Extension extension)
private void registerExtension(java.lang.String category,
Extension extension)
private void registerExtension(java.lang.String category,
Extension extension,
java.lang.Object source)
private java.lang.String buildSourceInfo(java.lang.Object source)