Class PluginLibraryControl

  • Direct Known Subclasses:
    AbstractConnector.Library

    public abstract class PluginLibraryControl
    extends java.lang.Object
    Methods called by the plug-in library startup session bean to register and unregister plug-ins.

    This class has to be sub-classed in plug-ins. The subclass has to be annotated as @Startup @Singleton. It contains the life-cycle methods and variables of the plug-in library.

    • Field Detail

      • appName

        protected java.lang.String appName
        Name of the application in the JavaEE container. Is read by injection.
    • Constructor Detail

      • PluginLibraryControl

        public PluginLibraryControl()
    • Method Detail

      • startupSuccess

        public void startupSuccess()
      • startupFailed

        public void startupFailed​(java.lang.String message)
      • isPluginLibraryStarted

        public static boolean isPluginLibraryStarted​(java.lang.String appName)
      • getPluginLibraryInfo

        public PluginLibraryInfo getPluginLibraryInfo()
        Returns:
        the pluginInfo
      • startup

        public void startup()
        Called by the @PostConstruct method of the plug-in library startup singleton bean

        • Reads the plug-in library configuration from the @PubServerPluginLibrary annotation
        • Scans all classes in the library for @PubServerPlugin annotation.
        • Registers the plug-in library.
        • Registers all classes with the @PubServerPlugin annotation as plug-ins.
        • Checks for @PubServerRole and @PubServerPermission annotations and creates entries if necessary.

        Throws LifeCycleException if something fails. This will also cause a failure of the application deployment in the JavaEE container.

      • getPluginTags

        public static java.lang.String getPluginTags​(java.lang.Class<?> c)
      • shutdown

        public void shutdown()
        Called by the @preDestroy method of the plug-in library startup singleton bean
        • Scans all classes in the library for @PubServerPlugin annotation
        • unregister the plug-in library
        • unregister all classes with the @PubServerPlugin annotation as plug-ins
      • getPluginConfigsFromFolder

        public java.util.List<PluginConfig> getPluginConfigsFromFolder​(java.lang.String folder,
                                                                       java.lang.Class<?>... customClazz)
        Get plugin configs from default section of plug-in folder.
        Parameters:
        folder - base folder for a plug-in
        customClazz - list of config classes
        Returns:
        list of plugin configs for a repository folder
      • getPluginConfigsFromFolder

        public java.util.Map<java.lang.String,​PluginConfig> getPluginConfigsFromFolder​(java.lang.String mappedName,
                                                                                             java.lang.String folder,
                                                                                             boolean recursively,
                                                                                             java.lang.Class<?>... customClazz)
        Get plugin configs from folder in the repository.

        This will not read from cache but from the data source.

        Parameters:
        mappedName - plugin name
        recursively - if true read from nested folders too
        customClazz - list of JAXB config classes
        Returns:
        map of parsed plugin configs for a mappedName
      • getConfigForPlugin

        public java.util.List<PluginConfig> getConfigForPlugin​(java.lang.String mappedName)
        Get the current list of loaded default configuration documents for a plug-in.

        Please note that the list only contains documents from the "default" folder in the repository, e.g. from "com.werk-ii.pluginLib.MyPlugin/WerkII/default", and not from other folders.

        Please note that the list only contains documents in the cache. Changes done in the repository - check-in via ison - are not immediately reflected in the cache. You have to call readConfigsForPluginLib() to refresh the cache before you call getConfigForPlugin(String).

        Parameters:
        mappedName - of plug-in
        Returns:
        List of PluginConfigs
      • getConfigsForPlugin

        public java.util.Map<java.lang.String,​PluginConfig> getConfigsForPlugin​(java.lang.String mappedName)
        Get the current map of loaded default configuration documents for a plug-in.

        Please note that the map only contains documents from the "default" folder in the repository, e.g. from "com.werk-ii.pluginLib.MyPlugin/WerkII/default", and not from other folders.

        Please note that the map only contains documents in the cache. Changes done in the repository - check-in via ison - are not immediately reflected in the cache. You have to call readConfigsForPluginLib() to refresh the cache before you call getConfigForPlugin(String).

        Parameters:
        mappedName - of plug-in
        Returns:
        List of PluginConfigs
      • readConfigsForPluginLib

        public void readConfigsForPluginLib()
        Read all configs for all plug-in classes into internal object.
      • getPluginManager

        public PluginManagerLocal getPluginManager()
        Returns:
        plugin manager - if it cannot retrieved an LifeCycleException will be thrown
      • getConfigManager

        public ConfigManagerLocal getConfigManager()
        Returns:
        config manager - if it cannot retrieved an LifeCycleException will be thrown
      • getAuthManager

        public AuthManagerLocal getAuthManager()
        Returns:
        auth manager - if it cannot retrieved an LifeCycleException will be thrown
      • getSessionManager

        public SessionManagerLocal getSessionManager()
        Returns:
        session manager - if it cannot retrieved an LifeCycleException will be thrown
      • getTraceManager

        public TraceManagerLocal getTraceManager()
        Returns:
        trace manager - if it cannot retrieved an LifeCycleException will be thrown
      • getDocumentManager

        public DocumentManagerLocal getDocumentManager()
        Returns:
        document manager - if it cannot retrieved an LifeCycleException will be thrown
      • getDocumentLockManager

        public DocumentLockManagerLocal getDocumentLockManager()
        Returns:
        document lock manager - if it cannot retrieved an LifeCycleException will be thrown
      • getClientManager

        public ClientManagerLocal getClientManager()
        Returns:
        client manager - if it cannot retrieved an LifeCycleException will be thrown
      • getMediaAssetManager

        public MediaAssetManagerLocal getMediaAssetManager()
        Returns:
        media asset manager - if it cannot retrieved an LifeCycleException will be thrown
      • getJNDINameForPlugin

        public static java.lang.String getJNDINameForPlugin​(java.lang.String mappedName)
        Retrieves a Java global name for a plug-in with mappedName from cache.

        If not found in cache it will query the pluginManager.

        Parameters:
        mappedName - container specific name for the plugin
        Returns:
        global jndi name or null
      • beforeVersionChange

        public void beforeVersionChange​(java.lang.String oldVersion)
        Method triggered when during startup of a plugin library a change in version is detected.

        Version is set via annotation in #PubServerPluginLibrary. It can be read via getPluginLibraryInfo() object.

        You may implement this method if you need to migrate existing repository data to new version.

        The default implementation is empty.

        The method is required to throw in exception if the migration fails. This will lead to a deployment failure in application server. The oldVersion (stored in database) will not be modified in case of failure.

        Parameters:
        oldVersion - Version string from the previous deployment - otherwise empty string
        Throws:
        PluginException - in case of failed migration from old to new version
      • getAppName

        public java.lang.String getAppName()
      • validateConfigurations

        public void validateConfigurations​(java.util.Collection<PluginConfig> pluginConfigs)
                                    throws PluginException
        Validates all configurations from list given as argument.
        Parameters:
        pluginConfigs -
        Throws:
        PluginException - if any configuration is null or invalid.
      • validateConfigurations

        public void validateConfigurations()
                                    throws PluginException
        Validates all configurations currently loaded for the plug-in. I.e. all configurations from the /default folder.
        Throws:
        PluginException - if any configuration is null or invalid.