Package de.xima.fc.plugin.entities
Class EntitiesRuntime
- java.lang.Object
-
- de.xima.fc.plugin.entities.EntitiesRuntime
-
public class EntitiesRuntime extends Object
A class that encapsulates a runningIPluginEntities
. 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 Summary
Constructors Constructor Description EntitiesRuntime(PluginRuntime pluginRuntime, IPluginEntities plugin)
Creates a new entities runtime with the given plugin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Class<?>>
getJpaEntities()
String
getPersistenceUnitName()
IPluginEntities
getPlugin()
PluginRuntime
getPluginRuntime()
void
initialize()
Initializes this entities runtime.void
shutdown()
Called when the plugin is deactivated or uninstalled.
-
-
-
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- evaluates the connections details specified by the plugin and acquires a data source,
- runs all liquibase scripts specified by the plugin, if any, using that data source,
- then creates the entity manager factory, and finally
- 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.
-
-