Package com.quartetfs.fwk
Class Registry
java.lang.Object
com.quartetfs.fwk.Registry
Provides static accessors and shortcuts to the Registry currently configured in the System.
- Author:
- ActiveViam
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,U extends T>
UCreate a new Type instance for the given Type interface and the supplied constructor parameters.static <T extends IExtendedPluginValue,U extends T>
UcreateExtendedPluginValue(Class<T> interfaceClass, Object pluginKey, Object... args) Creates an extended plugin value with a single key and the given args.static <T extends IExtendedPluginValue,U extends T>
IExtendedPlugin<U>getExtendedPlugin(Class<T> interfaceClass) Retrieves the extended plugin instance for a given extended plugin interface.static <T extends IExtendedPluginValue,U extends T>
IFactoryValue<U>getExtendedPluginValue(Class<T> interfaceClass, Object key) Retrieves the extended plugin instance for a given extended plugin interface.static <T extends IPluginValue,U extends T>
IPlugin<U>Retrieves the plugin instance for a given plugin interface.static <T extends IPluginValue,U extends T>
UgetPluginValue(Class<T> interfaceClass, Object key) Retrieves the plugin value for a given plugin interface.static IRegistryGets the current singleton registry.static voidsetContributionProvider(IContributionProvider provider) Change the current system contribution provider.static <T,U extends T>
voidDefines an Atoti type.
-
Method Details
-
getRegistry
Gets the current singleton registry.- Returns:
- the registry
-
setType
Defines an Atoti type.For a given interface, this sets a corresponding implementation. After this call, it will be possible to call
create(Class, Object...), passing the interface and constructor arguments to create instances for the bound type.If an implementation class is already assigned to the interface, this call replaces the previous value with the provided implementation class.
- Type Parameters:
T- Type of the interface classU- Type of the implementation class
-
create
Create a new Type instance for the given Type interface and the supplied constructor parameters.- Type Parameters:
T- Type of the interface classU- the type of the interface, including generic parameters if any- Parameters:
interfaceClass- interface of the type to create, used as a key to access the implementationinitParams- parameters to provider to constructor- Returns:
- instantiated type
-
getPlugin
Retrieves the plugin instance for a given plugin interface.- Type Parameters:
T- Type of the plugin valueU- Type of the plugin value including generic parameters if any- Parameters:
interfaceClass- interface of the plugin to look for, used as a key identifying the plugin- Returns:
- plugin instance
-
getPluginValue
public static <T extends IPluginValue,U extends T> U getPluginValue(Class<T> interfaceClass, Object key) throws IllegalArgumentException Retrieves the plugin value for a given plugin interface.- Type Parameters:
T- Type of the plugin valueU- Type of the plugin value including generic parameters if any- Parameters:
interfaceClass- interface of the plugin to look for, used as a key identifying the pluginkey- key identifying a single value- Returns:
- the plugin value
- Throws:
IllegalArgumentException- if the plugin does not exist- Since:
- 5.9.0
-
getExtendedPlugin
public static <T extends IExtendedPluginValue,U extends T> IExtendedPlugin<U> getExtendedPlugin(Class<T> interfaceClass) Retrieves the extended plugin instance for a given extended plugin interface.- Type Parameters:
T- Type of values the extended plugin createsU- expected type of the plugin. This is set mainly to correctly support extended plugin for generic interfaces, such asExtendedPlugin<Collection<?>> e = getExtendedPlugin(Collection.class).- Parameters:
interfaceClass- interface of the plugin to look for, used as a key identifying the plugin- Returns:
- extended plugin instance
-
getExtendedPluginValue
public static <T extends IExtendedPluginValue,U extends T> IFactoryValue<U> getExtendedPluginValue(Class<T> interfaceClass, Object key) Retrieves the extended plugin instance for a given extended plugin interface.- Type Parameters:
T- Type of values the extended plugin createsU- expected type of the plugin. This is set mainly to correctly support extended plugin for generic interfaces, such asExtendedPlugin<Collection<?>> e = getExtendedPlugin(Collection.class).- Parameters:
interfaceClass- interface of the plugin to look for, used as a key identifying the pluginkey- key identifying a single value- Returns:
- the extended plugin value
- Since:
- 5.9.0
-
createExtendedPluginValue
public static <T extends IExtendedPluginValue,U extends T> U createExtendedPluginValue(Class<T> interfaceClass, Object pluginKey, Object... args) throws ActiveViamRuntimeException Creates an extended plugin value with a single key and the given args.- Type Parameters:
T- Type of class for the created valuesU- Type of values the extended plugin creates- Parameters:
interfaceClass- The interface class.pluginKey- The key of the plugin to instantiate.args- The arguments with whom the plugin must be instantiated.- Returns:
- extended plugin value instance
- Throws:
ActiveViamRuntimeException- If the plugin is not defined or empty, if the pluginKey does not match any existing key, or if the instantiation fails with the given arguments.
-
setContributionProvider
Change the current system contribution provider. The current Registry implementation and all its resolved constructs are destroyed and replaced by a new Registry using the supplied contribution provider.- Parameters:
provider- new contribution provider
-