@API(status=INTERNAL, since="5.5") public class MutableExtensionRegistry extends 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 | Method and Description |
---|---|
static MutableExtensionRegistry |
createRegistryFrom(MutableExtensionRegistry parentRegistry,
List<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.
|
void |
registerExtension(Extension extension,
Object source)
Register the supplied
Extension , without checking if an extension
of that type has already been registered. |
<E extends Extension> |
stream(Class<E> extensionType)
Stream all
Extensions of the specified type that are present
in this registry or one of its ancestors. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getExtensions, getReversedExtensions
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 null
ExtensionRegistry
; never null
public static MutableExtensionRegistry createRegistryFrom(MutableExtensionRegistry parentRegistry, List<Class<? extends Extension>> extensionTypes)
parentRegistry
- the parent registryextensionTypes
- the types of extensions to be registered in
the new registryExtensionRegistry
; never null
public <E extends Extension> Stream<E> stream(Class<E> extensionType)
ExtensionRegistry
Extensions
of the specified type that are present
in this registry or one of its ancestors.stream
in interface ExtensionRegistry
extensionType
- the type of Extension
to streamExtensionRegistry.getReversedExtensions(Class)
,
ExtensionRegistry.getExtensions(Class)
public void registerExtension(Extension extension, Object source)
ExtensionRegistrar
Extension
, 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 ExtensionRegistrar
extension
- the extension to register; never null
source
- the source of the extension; never null
Copyright © 2020. All rights reserved.