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 Details

    • getRegistry

      public static IRegistry getRegistry()
      Gets the current singleton registry.
      Returns:
      the registry
    • setType

      public static <T, U extends T> void setType(Class<T> interfaceClass, Class<U> implementationClass)
      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 class
      U - Type of the implementation class
    • 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 class
      U - 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 implementation
      initParams - 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 value
      U - 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 value
      U - 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
      key - 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 creates
      U - expected type of the plugin. This is set mainly to correctly support extended plugin for generic interfaces, such as ExtendedPlugin<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 creates
      U - expected type of the plugin. This is set mainly to correctly support extended plugin for generic interfaces, such as ExtendedPlugin<Collection<?>> e = getExtendedPlugin(Collection.class).
      Parameters:
      interfaceClass - interface of the plugin to look for, used as a key identifying the plugin
      key - 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 values
      U - 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