Class MutableExtensionRegistry
- All Implemented Interfaces:
ExtensionRegistrar,ExtensionRegistry
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.
- Since:
- 5.5
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Loggerprivate final MutableExtensionRegistry -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MutableExtensionRegistrycreateRegistryFrom(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 MutableExtensionRegistrycreateRegistryWithDefaultExtensions(JupiterConfiguration configuration) Factory for creating and populating a new root registry with the default extensions.private booleanisAlreadyRegistered(Class<? extends Extension> extensionType) Determine if the supplied type is already registered in this registry or in a parent registry.private static voidregisterAutoDetectedExtensions(MutableExtensionRegistry extensionRegistry) private voidregisterDefaultExtension(Extension extension) (package private) voidregisterExtension(Class<? extends Extension> extensionType) Instantiate an extension of the given type using its default constructor and register it in this registry.private voidregisterExtension(Extension extension) voidregisterExtension(Extension extension, Object source) Register the suppliedExtension, without checking if an extension of that type has already been registered.Stream allExtensionsof the specified type that are present in this registry or one of its ancestors.streamLocal(Class<E> extensionType) Stream allExtensionsof the specified type that are present in this registry.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.junit.jupiter.engine.extension.ExtensionRegistry
getExtensions, getReversedExtensions
-
Field Details
-
logger
-
DEFAULT_EXTENSIONS
-
parent
-
registeredExtensionTypes
-
registeredExtensions
-
-
Constructor Details
-
MutableExtensionRegistry
-
-
Method Details
-
createRegistryWithDefaultExtensions
public static MutableExtensionRegistry createRegistryWithDefaultExtensions(JupiterConfiguration configuration) Factory for creating and populating a new root registry with the default extensions.If the
Constants.EXTENSIONS_AUTODETECTION_ENABLED_PROPERTY_NAMEconfiguration parameter has been set totrue, extensions will be auto-detected using Java'sServiceLoadermechanism and automatically registered after the default extensions.- Parameters:
configuration- configuration parameters used to retrieve the extension auto-detection flag; nevernull- Returns:
- a new
ExtensionRegistry; nevernull
-
registerAutoDetectedExtensions
-
createRegistryFrom
public 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.- Parameters:
parentRegistry- the parent registryextensionTypes- the types of extensions to be registered in the new registry- Returns:
- a new
ExtensionRegistry; nevernull
-
stream
Description copied from interface:ExtensionRegistryStream allExtensionsof the specified type that are present in this registry or one of its ancestors.- Specified by:
streamin interfaceExtensionRegistry- Parameters:
extensionType- the type ofExtensionto stream- See Also:
-
streamLocal
Stream allExtensionsof the specified type that are present in this registry.Extensions in ancestors are ignored.
- Parameters:
extensionType- the type ofExtensionto stream- See Also:
-
isAlreadyRegistered
Determine if the supplied type is already registered in this registry or in a parent registry. -
registerExtension
Instantiate an extension of the given type using its default constructor and register it in this registry.A new
Extensionwill not be registered if an extension of the given type already exists in this registry or a parent registry.- Parameters:
extensionType- the type of extension to register
-
registerDefaultExtension
-
registerExtension
-
registerExtension
Description copied from interface:ExtensionRegistrarRegister the suppliedExtension, without checking if an extension of that type has already been registered.Semantics for Source
If an extension is registered declaratively via
@ExtendWith, thesourceand theextensionshould be the same object. However, if an extension is registered programmatically via@RegisterExtension, thesourceobject should be theFieldthat is annotated with@RegisterExtension. Similarly, if an extension is registered programmatically as a lambda expression or method reference, thesourceobject should be the underlyingMethodthat implements the extension API.- Specified by:
registerExtensionin interfaceExtensionRegistrar- Parameters:
extension- the extension to register; nevernullsource- the source of the extension; nevernull
-