Package com.quartetfs.fwk
Class Registry
- java.lang.Object
-
- com.quartetfs.fwk.Registry
-
public final class Registry extends Object
Provides static accessors and shortcuts to the Registry currently configured in the System.- Author:
- ActiveViam
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,U extends T>
Ucreate(Class<T> interfaceClass, Object... initParams)Create 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>getPlugin(Class<T> interfaceClass)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 IRegistrygetRegistry()Gets the current singleton registry.static voidsetContributionProvider(IContributionProvider provider)Change the current system contribution provider.
-
-
-
Method Detail
-
getRegistry
public static IRegistry getRegistry()
Gets the current singleton registry.- Returns:
- the registry
-
create
public static <T,U extends T> U create(Class<T> interfaceClass, Object... initParams)
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
public static <T extends IPluginValue,U extends T> IPlugin<U> getPlugin(Class<T> interfaceClass)
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
public static void setContributionProvider(IContributionProvider provider)
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
-
-