JPOX
JPOX
JPOX  |  Version 1.0  |  Version 1.1  |  Version 1.2  |  JDO 
1.1 | Preparation | Runtime | Tutorials and Examples | Developer
JPOX 1.1 Runtime
Runtime Tools
Queries
Plug-ins
RDBMS Datastores
Plugins

JPOX is an extensible persistence tool. The JPOX Core persistence engine allows to plug in many user extensions which will contribute to augment the several persistence aspects faced by the Object/Datastore mapping.

Some aspects of the persistence includes the capability to persist java types, like java.lang.String, primitives, or other classes. Other aspects are the datastore data types, like in RDBMS a VARCHAR, CHAR or NUMERIC types. Moreover, it also is the capability to support different datastores, like the RDBMS databases MySQL, Derby, Oracle and many others.

The extensiveness aspects of persistence are made through the usage of plugins. In the next section we list the extensible parts of JPOX and how to extend it.

Persistence extensions

JPOX extensions are enabled by use of a file plugin.xml that is typically placed in your jar file at META-INF/plugins/plugin.xml. This file defines the plugin that you are providing and when you start JPOX it will be integrated into JPOX runtime seamlessly. A typical plugin.xml is shown below.

<?xml version="1.0"?>
<plugin>
<extension point="org.jpox.store.datastoremapping">
    <mapping java-type="java.lang.Enum" rdbms-mapping-class="org.jpox.store.rdbms.mapping.EnumVarCharRDBMSMapping" 
            jdbc-type="VARCHAR" sql-type="VARCHAR" default="true"/>
    <mapping java-type="java.lang.Enum" rdbms-mapping-class="org.jpox.store.rdbms.mapping.EnumIntegerRDBMSMapping" 
            jdbc-type="INTEGER" sql-type="INTEGER" default="false"/>
</extension>

<extension point="org.jpox.store.mapping">
    <mapping java-type="java.lang.Enum" mapping-class="org.jpox.store.mapping.EnumMapping"/>
</extension>
</plugin>

This particular example provides Java type support for the Java5 type "Enum", and is accompanied (in this case) by the files "org.jpox.store.rdbms.mapping.EnumVarCharRDBMSMapping", "org.jpox.store.rdbms.mapping.EnumIntegerRDBMSMapping", and "org.jpox.store.mapping.EnumMapping" which are referred to in the plugin definition above.



Custom java types

JPOX supports a very large range of Java types for persistence out of the box. It is occasionally required to persist other Java types not supported internally. You can extend JPOX's capabilities using this extension. The capability to support arbitrary java types is described here.

Custom datastore types

Placeholder for documentation.

JDOQL : Custom user defined methods

The capability to extend the JDOQL query language is described here.

RDBMS support

JPOX supports many RDBMS databases, and by default, ALL RDBMS are supported without the need to extend JPOX. Due to incompabilities, or specifics of each RDBMS database, it's allowed to extend JPOX to make the support to a specific database fit better to JPOX and your needs. The RDBMS page lists all RDBMS databases that have been tested with JPOX, and some of these databases has been adapted internally to get a good fit.

This extension is described here.

RDBMS Connection-Pooling

JPOX requires a DataSource to define the datastore in use and consequently allows use of connection pooling. JPOX provides 3 plugins for different pooling products - DBCP, C3P0, and Proxool. You can easily define your own plugin for pooling.

This extension is described here.

Annotations

JPOX (from version 1.1.2 onwards) supports Java5 annotations. More than this, it actually provides a pluggable framework whereby you can plug in your own annotations support. Let's just provide the example of what is currently provided in the "Java5" plugin, supporting JPA and JDO2 annotations.

<?xml version="1.0"?>
<plugin>
    <extension point="org.jpox.metadata.annotations">
        <annotations annotation-class="org.jpox.annotations.PersistenceCapable" 
                reader="org.jpox.metadata.annotations.JDOAnnotationReader"/>
        <annotations annotation-class="org.jpox.annotations.PersistenceAware" 
                reader="org.jpox.metadata.annotations.JDOAnnotationReader"/>
        <annotations annotation-class="javax.persistence.Entity" 
                reader="org.jpox.metadata.annotations.JPAAnnotationReader"/>
    </extension>
</plugin>

This definition means that when we come across an annotated class and the class contains an annotation of class "org.jpox.annotations.PersistenceCapable" then it will use the AnnotationReader "org.jpox.metadata.annotations.JDOAnnotationReader", similarly for an annotation of class "org.jpox.annotations.PersistenceAware" (i.e JDO2 annotations). On the other hand, when it encounters an annotation of class "javax.persistence.Entity" then it will use the AnnotationReader "org.jpox.metadata.annotations.JPAAnnotationReader". Using this mechanism it would be possible to design your own annotations (if you so wished) and write an AnnotationReader class that converted the annotations into JPOX's internal MetaData. For completeness, an AnnotationReader implements this interface

package org.jpox.metadata.annotations;

import org.jpox.metadata.PackageMetaData;
import org.jpox.metadata.ClassMetaData;

public interface AnnotationReader
{
    /**
     * Accessor for the annotations packages supported by this reader.
     * @return The annotations packages that will be processed.
     */
    String[] getSupportedAnnotationPackages();

    /**
     * Method to get the ClassMetaData for a class from its annotations.
     * @param cls The class
     * @param pmd MetaData for the owning package (that this will be a child of)
     * @return The ClassMetaData (unpopulated and unitialised)
     */
    public ClassMetaData getMetaDataForClass(Class cls, PackageMetaData pmd);
}


Caching extensions

JPOX is able to support third party caching products. This is described here.

Integrating with 3rd party products

It's a goal of the JPOX project to seemless integrate to the major 3rd party products used by the JPOX community. The JPOX project provides and maintain integration plugins that integrates to these 3rd party products, it includes plugins to the SpringFramework or the Eclipse IDE. They can be downloaded here.