JPOX is developed as a plugin-driven framework and one of the components that is pluggable is the Level 1
caching of objects (between PersistenceManagers for the same PersistenceManagerFactory). JPOX provides
three Level 1 caches but is structured so that you can easily add your own
variant and have it usable within your JPOX usage.
This is available in JPOX from version 1.1.3
JPOX is able to support third party Level 1 Cache products. There are JPOX-provided plugins for
weak and soft referenced caches. You can extend JPOX's capabilities using the
plugin extension org.jpox.cache_level1.
| Plugin extension-point | Key | Description | Location |
|---|
| org.jpox.cache_level1 | weak | Weak referenced cache (default) | jpox-core |
| org.jpox.cache_level1 | soft | Soft referenced cache | jpox-core |
| org.jpox.cache_level1 | hard | Hard-referenced cache (HashMap) | jpox-core |
The following sections describe how to create your own Level 1 cache plugin for JPOX.
If you have your own Level1 cache you can easily use it with JPOX.
JPOX defines a Level1Cache interface and you need to implement this.
package org.jpox.cache;
public interface Level1Cache extends Map
{
}
So you need to create a class, MyLevel1Cache for example, that implements this interface (i.e
that implements java.util.Map).
Once you have this implementation you then need to make the class available as a JPOX plugin.
You do this by putting a file plugin.xml in your JAR at the root of the CLASSPATH.
The file plugin.xml will look like this
<?xml version="1.0"?>
<plugin id="mydomain.mycache" name="JPOX plug-ins" provider-name="My Company">
<extension point="org.jpox.cache_level1">
<cache name="MyCache" class-name="mydomain.MyLevel1Cache"/>
</extension>
</plugin>