Class EntitiesRuntime


  • public class EntitiesRuntime
    extends Object
    A class that encapsulates a running IPluginEntities. This class is responsible for performing any initialization processes specific to entities plugins, and also for cleaning up when the plugin is deactivated or uninstalled. Specifically, tasks this class performs include scanning the plugin for entity classes, initializing the connection to the database, applying any unrun liquibase changesets and creating the entity manager factory.
    Author:
    XIMA MEDIA GmbH
    • Constructor Detail

      • EntitiesRuntime

        public EntitiesRuntime​(PluginRuntime pluginRuntime,
                               IPluginEntities plugin)
        Creates a new entities runtime with the given plugin. The JPA entities are read from the plugin via reflection.
        Parameters:
        pluginRuntime - The runtime of the plugin.
        plugin - The actual entities plugin.
    • Method Detail

      • getJpaEntities

        public Set<Class<?>> getJpaEntities()
        Returns:
        All JPA entities that are available to this runtime.
      • getPersistenceUnitName

        public String getPersistenceUnitName()
        Returns:
        The persistence unit name of this runtime, used by the entity manager.
      • getPlugin

        public IPluginEntities getPlugin()
        Returns:
        The entities plugin wrapped by this runtime.
      • getPluginRuntime

        public PluginRuntime getPluginRuntime()
        Returns:
        The plugin runtime of the entities plugin wrapped by this runtime.
      • initialize

        public void initialize()
                        throws FCPluginException
        Initializes this entities runtime. This
        1. evaluates the connections details specified by the plugin and acquires a data source,
        2. runs all liquibase scripts specified by the plugin, if any, using that data source,
        3. then creates the entity manager factory, and finally
        4. initializes the entities plugin by passing it that factory
        Throws:
        FCPluginException - When the above steps could not be performed, such as due to a database connection error or a wrong plugin configuration.
      • shutdown

        public void shutdown()
        Called when the plugin is deactivated or uninstalled. Closes the entity manager factory and all open connections to the database.