![]() | ![]() |
![]() |
| Project | Ver 1.1 | Ver 1.2 | JDO | JPA | Guides | Tools |
| 1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer |
![]() JPOX is an extensible persistence tool. The JPOX Core persistence engine allows the user to plug in many user extensions which will contribute to augment the numerous persistence aspects faced by the Object/Datastore mapping. Plugins are loaded by a plugin manager which uses a registry mechanism, inspecting jars in the CLASSPATH. These plugins are defined in OSGi format. This format relies on there being a set of extension-points where JPOX can be extended, and then adding extensions for each of these points. The format means that with very little effort any user can provide their own JPOX plugins and have them available very quickly. In short, the three steps necessary for creating a JPOX plugin are
A minimum MANIFEST.MF for a plugin jar should look like this Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: myplugin Bundle-SymbolicName: org.jpox.myplugin Bundle-Version: 1.0.0 Bundle-Vendor: My Company Below we describe the aspects of the persistence process that are currently pluggable using this mechanism.
If you write a JPOX plugin and you either want it to be included in the JPOX distribution, or want it to be listed here then please contact us via the JPOX Forum
Non managed environment is a runtime environment where JPOX runs and plug-ins are not managed by a container. In this environment the plug-in discovery and lifecycle is managed by JPOX. There is a 1 to N instance relationship from JPOX to a plug-in per PMF. More exactly, if only one PMF exists, there is only one Plug-in instance for a Connection Pool Plug-in, and if "N" PMF exist, there are "N" Plug-in instances for a Connection Pool Plug-in. Standard Java runtimes and J2EE containers are considered non managed environments. In non managed environments there is no lifecycle itself of plug-ins. Extensions implemented by plug-ins are instantiated on demand and terminated on PMF closing, PM closing or in another form depending in what the extension is used for.
Managed environment is a runtime environment where JPOX plug-ins are managed by a container. The discovery, registry and lifecycle of plug-ins are controlled by the container. There is no plug-in instance relationship from JPOX to a plug-in regarding PMF instances. In managed environments, there is only one plug-in instance for one or "N" PMFs. Again, this is managed by the container. JPOX supports OSGi containers as managed environment. In OSGi managed environments plug-in lifecycle is determined by OSGi specification. Once activated, a plug-in is only stopped when the OSGi container finishes its execution, or the plug-in is stopped by an OSGi command.
JPOX has mechanism that allows extending its persistence engine while not coupling the JPOX engine to the extensions. This mechanism is known as "Extension Points", which are well defined interfaces that allows the extension of certain aspects of JPOX in a dynamic and consistent model. The "Extensions" are the implementation of Extension Points that are registered in a PluginRegistry and used by JPOX Core or other JPOX Plug-ins. A plugin owns an Extension. The behaviour is defined below :-
Plugins can make use of existing persistence properties defined by "core" etc. They can also add on their own persistence properties. They define these in the plugin.xml. Let's take an example
<!-- PERSISTENCE PROPERTIES -->
<extension point="org.jpox.persistence_properties">
<persistence-property name="org.jpox.rdbms.query.fetchDirection" value="forward"
validator="org.jpox.store.rdbms.RDBMSPropertyValidator"/>
</extension>So here we have a property defined in the "store.rdbms" plugin which defines a persistence property org.jpox.rdbms.query.fetchDirection with a default value of forward and with values validated by the class org.jpox.store.rdbms.RDBMSPropertyValidator. This means that when we instantiate a PMF/EMF we automatically get that property defined with value "forward", and if we provide it ourselves we override this default. We do the same with any properties we want in our own plugins. In order to avoid conflicts between different property names that can be set in the PMF and to have a consistent naming schema for properties, the following recommendations should be applied. Naming the persistence property name should be prefixed by the plug-in id. Example: Plugin: org.jpox.myplugin1 Property: myprop1 The persistence property should look like org.jpox.myplugin1.myprop1. If an extension point defines a new persistence configuration, the property name should be prefixed by the extension-point id. Example: Extension-Point id: org.jpox.myplugin2.myextensionpoint2 Property: myprop2 The PMF property should look like org.jpox.myplugin2.myextensionpoint2.myprop2. Another form of persistence configuration could happen if multiple Extension-Points uses the same information. In this case an abstraction of the plug-in id and extension point id could be used, as the following example. However, make sure to use this naming schema only when absolutelly necessary. Extension-Point id: org.jpox.myplugin3.myextensionpoint3 Extension-Point id: org.jpox.yourplugin3.yourextensionpoint4 Extension-Point id: org.jpox.theirplugin4.theirextensionpoint5 Property: myprop345 The PMF property should look like org.jpox.somepluginXXXX.someextensionpointYYYY.myprop345. Alternativelly, the PMF property could also look like org.jpox.myplugin3.myextensionpoint3.myprop345
It's a goal of the JPOX project to seamless integrate to all major 3rd party products used by the JPOX community. In addition to the plugins above it also provides plugins for the SpringFramework or the Eclipse IDE. All plugins can be downloaded here. |