How to use Castor in a J2EE cluster Introduction Intended Audience Prerequisites Steps Add <cache-type> element to class mapping Add Coherence JARs to CLASSPATH References
Introduction
With release 0.9.9, several cache providers have been added that are distributed caches
per se or can be configured to operate in such a mode. This effectively allows Castor JDO
to be used in a clustered J2EE (multi-JVM) environment, where Castor JDO runs on each of
the cluster instances, and where cache state is automatically snychronized between these
instances.
In such an environment, Castor JDO will make use of the underlying cache provider
to replicate/distribute the content of a specific cache between the various
JDOManager instances. Through the distribution mechanism of the cache provider, a client
of a Castor JDO instance on one JVM will see any updates made to domain objects performed
against any other JVM/JDO instance.
Intended Audience
Anyone who wants to use Castor JDO in a J2EE cluster.
The example given describes the use of the Coherence cache provider to enable
distributed caching.
Prerequisites
You should have a valid class mapping for a Java class, similar to the following
one:
<mapping>
<class name="com.xyz.MyOtherObject" identity="id">
<field name="id" type="integer">
...
</field>
<field name="description" type="string">
...
</field>
</class>
</mapping>
|
|
Steps
Here is how to proceed.
Add <cache-type> element to class mapping
Add a <cache-type> element as shown below, specifying the cache provider to
use in the 'type' attribute.
<mapping>
<class name="com.xyz.MyOtherObject" identity="id">
<cache-type type="coherence"/>
<field name="id" type="integer">
...
</field>
<field name="description" type="string">
...
</field>
</class>
</mapping>
|
|
This instructs Castor JDO to use the 'coherence' cache provider for objects of type
com.xyz.MyOtherObject. It is the cache provider that is responsible to distribute
any changes to the cache state to all other Castor JDO instances within the same cluster.
Add Coherence JARs to CLASSPATH
Add the Coherence JARs to the class path of your e.g. web application by
putting the JARs into the WEB-INF/lib folder of your web application.
References
|