[jbosscache-commits] JBoss Cache SVN: r4247 - in pojo/trunk: assembly and 25 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Aug 14 12:26:14 EDT 2007


Author: manik.surtani at jboss.com
Date: 2007-08-14 12:26:14 -0400 (Tue, 14 Aug 2007)
New Revision: 4247

Added:
   pojo/trunk/README-Maven.txt
   pojo/trunk/assembly/
   pojo/trunk/assembly/all.xml
   pojo/trunk/assembly/bin.xml
   pojo/trunk/assembly/doc.xml
   pojo/trunk/pom.xml
   pojo/trunk/src/
   pojo/trunk/src/main/
   pojo/trunk/src/main/docbook/
   pojo/trunk/src/main/docbook/css/
   pojo/trunk/src/main/docbook/css/css/
   pojo/trunk/src/main/docbook/css/css/html.css
   pojo/trunk/src/main/docbook/faq/
   pojo/trunk/src/main/docbook/faq/en/
   pojo/trunk/src/main/docbook/faq/en/master.xml
   pojo/trunk/src/main/docbook/images/
   pojo/trunk/src/main/docbook/images/images/
   pojo/trunk/src/main/docbook/images/images/classes.png
   pojo/trunk/src/main/docbook/images/images/demoAddress.png
   pojo/trunk/src/main/docbook/images/images/demoAddressInternal.png
   pojo/trunk/src/main/docbook/images/images/demoJoe.png
   pojo/trunk/src/main/docbook/images/images/demogui.gif
   pojo/trunk/src/main/docbook/images/images/get.gif
   pojo/trunk/src/main/docbook/images/images/get.png
   pojo/trunk/src/main/docbook/images/images/graph.gif
   pojo/trunk/src/main/docbook/images/images/guiAddress.png
   pojo/trunk/src/main/docbook/images/images/guiJoe.png
   pojo/trunk/src/main/docbook/images/images/guiJoeAddress.png
   pojo/trunk/src/main/docbook/images/images/guiJoeInternal.png
   pojo/trunk/src/main/docbook/images/images/guiMary.png
   pojo/trunk/src/main/docbook/images/images/guiMaryAddress.png
   pojo/trunk/src/main/docbook/images/images/guiMaryInternal.png
   pojo/trunk/src/main/docbook/images/images/map.gif
   pojo/trunk/src/main/docbook/images/images/map.png
   pojo/trunk/src/main/docbook/images/images/object_split.jpg
   pojo/trunk/src/main/docbook/images/images/pojocache_architecture.png
   pojo/trunk/src/main/docbook/images/images/reference.png
   pojo/trunk/src/main/docbook/images/images/set.gif
   pojo/trunk/src/main/docbook/images/images/set.png
   pojo/trunk/src/main/docbook/tutorial/
   pojo/trunk/src/main/docbook/tutorial/en/
   pojo/trunk/src/main/docbook/tutorial/en/master.xml
   pojo/trunk/src/main/docbook/userguide/
   pojo/trunk/src/main/docbook/userguide/en/
   pojo/trunk/src/main/docbook/userguide/en/master.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/
   pojo/trunk/src/main/docbook/userguide/en/modules/architecture.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/basic_api.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/compatibility.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/configuration.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/deployment.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/eviction_policies.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/introduction.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/jmx_reference.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/preface.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/replication.xml
   pojo/trunk/src/main/docbook/userguide/en/modules/transactions.xml
   pojo/trunk/src/main/java/
   pojo/trunk/src/main/java/org/
   pojo/trunk/src/main/java/org/jboss/
   pojo/trunk/src/main/java/org/jboss/cache/
   pojo/trunk/src/main/java/org/jboss/cache/MyClass.java
   pojo/trunk/src/main/resources/
   pojo/trunk/src/main/resources/replSync-service.xml
   pojo/trunk/src/test/
   pojo/trunk/src/test/java/
   pojo/trunk/src/test/java/org/
   pojo/trunk/src/test/java/org/jboss/
   pojo/trunk/src/test/java/org/jboss/cache/
   pojo/trunk/src/test/java/org/jboss/cache/MyClassTest.java
   pojo/trunk/src/test/resources/
   pojo/trunk/src/test/resources/replSync-service-test.xml
Log:
POJO edition of JBoss Cache

Added: pojo/trunk/README-Maven.txt
===================================================================
--- pojo/trunk/README-Maven.txt	                        (rev 0)
+++ pojo/trunk/README-Maven.txt	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,50 @@
+Working with Maven
+------------------
+
+Requirements:
+
+* Java 5.0 and above
+* Maven 2.x
+
+Typical lifecycle phases
+------------------------
+
+Maven will create a target/ directory under the root for the creation of
+output at every stage.
+
+* mvn clean: cleans out any old builds and binaries
+
+* mvn compile: compiles java source code.
+
+* mvn test: runs the TestNG unit test suite on the compiled code.  Will also compile the tests.
+
+* mvn package: packages the module as a jar file and builds the javadocs and user documentation from docbook sources.
+
+* mvn install: will install the artifacts in your local repo for use by other projects (such as JBoss Cache POJO edition which depends on JBoss Cache Core).  Will also use Maven's assembly plugin to build ZIP files for download (in target/distribution)
+
+* mvn deploy: will build and deploy the project to the JBoss snapshots repository.  Note that you should have your WebDAV username and password set up.  (Deploys snapshots to http://snapshots.jboss.org/maven2/org/jboss/cache/)
+
+
+Setting up your WebDAV username and password to deploy project snapshots
+------------------------------------------------------------------------
+
+You will also have to configure maven to use your username and password to access this repository. For this, you will have to modify the servers section of maven settings file ($MAVEN_HOME/conf/settings.xml, or ~/.m2/settings.xml). Something similar to the following should be added:
+
+  <servers>
+...
+    <server>
+      <id>snapshots.jboss.org</id>
+      <username>webdav-user</username>
+      <password>webdav-pass</password>
+    </server>
+  </servers>
+
+
+Integration with CruiseControl
+------------------------------
+
+CruiseControl should do the following:
+
+* Go into core/code
+* Run "mvn clean site" - will clean and run tests, and then prepare reports.  In addition to unit tests, this project is set up to run FindBugs, PMD, jxr, and a bunch of other code analysis tools and provide a report in target/site/project-reports.html - which should be linked from the CruiseControl summary page.
+

Added: pojo/trunk/assembly/all.xml
===================================================================
--- pojo/trunk/assembly/all.xml	                        (rev 0)
+++ pojo/trunk/assembly/all.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,74 @@
+<assembly>
+  <id>all</id>
+
+  <formats>
+    <format>zip</format>
+  </formats>
+
+  <includeBaseDirectory>true</includeBaseDirectory>
+
+  <fileSets>
+
+    <!-- code -->
+    <fileSet>
+      <directory>target</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.jar</include>
+      </includes>
+    </fileSet>
+
+    <!-- resources -->
+    <fileSet>
+      <directory>src/main/resources</directory>
+      <outputDirectory>etc</outputDirectory>
+    </fileSet>
+
+    <!-- srcs -->
+    <fileSet>
+      <directory>src/main/java</directory>
+      <outputDirectory>src</outputDirectory>
+    </fileSet>
+
+    <!-- tests -->
+    <fileSet>
+      <directory>src/test/java</directory>
+      <outputDirectory>test</outputDirectory>
+    </fileSet>
+
+    <!-- test resources -->
+    <fileSet>
+      <directory>src/test/resources</directory>
+      <outputDirectory>test</outputDirectory>
+    </fileSet>
+
+    <!-- EULAs and license files -->
+    <fileSet>
+      <directory>doc</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.txt</include>
+      </includes>
+    </fileSet>
+
+    <!-- docs -->
+    <fileSet>
+      <directory>target/site/apidocs</directory>
+      <outputDirectory>doc/apidocs</outputDirectory>
+    </fileSet>
+
+    <fileSet>
+      <directory>target/docbook</directory>
+      <outputDirectory>doc/</outputDirectory>
+    </fileSet>
+  </fileSets>
+
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
+      <unpack>false</unpack>
+      <scope>runtime</scope>
+    </dependencySet>
+  </dependencySets>
+</assembly>

Added: pojo/trunk/assembly/bin.xml
===================================================================
--- pojo/trunk/assembly/bin.xml	                        (rev 0)
+++ pojo/trunk/assembly/bin.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,46 @@
+<assembly>
+  <id>bin</id>
+
+  <formats>
+    <format>zip</format>
+  </formats>
+
+  <includeBaseDirectory>true</includeBaseDirectory>
+
+  <fileSets>
+    <!-- code -->
+    <fileSet>
+      <directory>target</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.jar</include>
+      </includes>
+    </fileSet>
+
+    <!-- resources -->
+    <fileSet>
+      <directory>src/main/resources</directory>
+      <outputDirectory>etc</outputDirectory>
+    </fileSet>
+
+    <!-- EULAs and license files -->
+    <fileSet>
+      <directory>doc</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.txt</include>
+      </includes>
+    </fileSet>
+
+  </fileSets>
+
+  <dependencySets>
+    <dependencySet>
+      <outputDirectory>lib</outputDirectory>
+      <outputFileNameMapping>${artifactId}.${extension}</outputFileNameMapping>
+      <unpack>false</unpack>
+      <scope>runtime</scope>
+    </dependencySet>
+  </dependencySets>
+
+</assembly>

Added: pojo/trunk/assembly/doc.xml
===================================================================
--- pojo/trunk/assembly/doc.xml	                        (rev 0)
+++ pojo/trunk/assembly/doc.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,32 @@
+<assembly>
+  <id>doc</id>
+
+  <formats>
+    <format>zip</format>
+  </formats>
+
+  <includeBaseDirectory>true</includeBaseDirectory>
+
+  <fileSets>
+    <!-- EULAs and license files -->
+    <fileSet>
+      <directory>doc</directory>
+      <outputDirectory/>
+      <includes>
+        <include>*.txt</include>
+      </includes>
+    </fileSet>
+
+    <!-- docs -->
+    <fileSet>
+      <directory>target/site/apidocs</directory>
+      <outputDirectory>doc/apidocs</outputDirectory>
+    </fileSet>
+
+    <fileSet>
+      <directory>target/docbook</directory>
+      <outputDirectory>doc/</outputDirectory>
+    </fileSet>
+  </fileSets>
+
+</assembly>

Added: pojo/trunk/pom.xml
===================================================================
--- pojo/trunk/pom.xml	                        (rev 0)
+++ pojo/trunk/pom.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,193 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <properties>
+    <jbosscache-pojo-version>2.1.0-SNAPSHOT</jbosscache-pojo-version>
+  </properties>
+  <parent>
+    <groupId>org.jboss.cache</groupId>
+    <artifactId>jbosscache-common-parent</artifactId>
+    <version>1.0</version>
+  </parent>
+  <groupId>org.jboss.cache</groupId>
+  <artifactId>jbosscache-pojo</artifactId>
+  <version>${jbosscache-pojo-version}</version>
+  <name>JBoss Cache - POJO Edition</name>
+  <description>JBoss Cache - POJO Edition</description>
+  <packaging>jar</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.cache</groupId>
+      <artifactId>jbosscache-core</artifactId>
+      <version>2.1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-1</version>
+        <executions>
+          <execution>
+            <id>assemble</id>
+            <phase>install</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+            <configuration>
+              <descriptors>
+                <descriptor>assembly/bin.xml</descriptor>
+                <descriptor>assembly/doc.xml</descriptor>
+                <descriptor>assembly/all.xml</descriptor>
+              </descriptors>
+              <finalName>${artifactId}-${jbosscache-pojo-version}</finalName>
+              <outputDirectory>target/distribution</outputDirectory>
+              <workDirectory>target/assembly/work</workDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <!-- the docbook generation plugin for the user guide -->
+      <plugin>
+        <groupId>org.jboss.maven.plugins</groupId>
+        <artifactId>maven-jdocbook-plugin</artifactId>
+        <version>2.0.0</version>
+        <extensions>true</extensions>
+        <dependencies>
+          <dependency>
+            <groupId>org.jboss.cache</groupId>
+            <artifactId>jbosscache-doc-xslt-support</artifactId>
+            <version>1.0</version>
+          </dependency>
+        </dependencies>
+        <executions>
+
+          <!-- The User Guide-->
+          <execution>
+            <id>userguide_en</id>
+            <phase>package</phase>
+            <goals>
+              <goal>resources</goal>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <sourceDocumentName>master.xml</sourceDocumentName>
+              <sourceDirectory>${basedir}/src/main/docbook/userguide/en</sourceDirectory>
+              <imageResource>
+                <directory>${basedir}/src/main/docbook/images</directory>
+              </imageResource>
+              <cssResource>
+                <directory>${basedir}/src/main/docbook/css</directory>
+              </cssResource>
+              <targetDirectory>${basedir}/target/docbook/userguide_en</targetDirectory>
+              <formats>
+                <format>
+                  <formatName>pdf</formatName>
+                  <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+                  <finalName>userguide_en.pdf</finalName>
+                </format>
+                <format>
+                  <formatName>html</formatName>
+                  <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+                <format>
+                  <formatName>html_single</formatName>
+                  <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+              </formats>
+              <options>
+                <xincludeSupported>false</xincludeSupported>
+              </options>
+            </configuration>
+          </execution>
+
+          <!-- The Tutorial -->
+          <execution>
+            <id>tutorial_en</id>
+            <phase>package</phase>
+            <goals>
+              <goal>resources</goal>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <sourceDocumentName>master.xml</sourceDocumentName>
+              <sourceDirectory>${basedir}/src/main/docbook/tutorial/en</sourceDirectory>
+              <imageResource>
+                <directory>${basedir}/src/main/docbook/images</directory>
+              </imageResource>
+              <cssResource>
+                <directory>${basedir}/src/main/docbook/css</directory>
+              </cssResource>
+              <targetDirectory>${basedir}/target/docbook/tutorial_en</targetDirectory>
+              <formats>
+                <format>
+                  <formatName>pdf</formatName>
+                  <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+                  <finalName>tutorial_en.pdf</finalName>
+                </format>
+                <format>
+                  <formatName>html</formatName>
+                  <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+                <format>
+                  <formatName>html_single</formatName>
+                  <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+              </formats>
+              <options>
+                <xincludeSupported>false</xincludeSupported>
+              </options>
+            </configuration>
+          </execution>
+
+          <!-- the FAQs -->
+          <execution>
+            <id>faq_en</id>
+            <phase>package</phase>
+            <goals>
+              <goal>resources</goal>
+              <goal>generate</goal>
+            </goals>
+            <configuration>
+              <sourceDocumentName>master.xml</sourceDocumentName>
+              <sourceDirectory>${basedir}/src/main/docbook/faq/en</sourceDirectory>
+              <imageResource>
+                <directory>${basedir}/src/main/docbook/images</directory>
+              </imageResource>
+              <cssResource>
+                <directory>${basedir}/src/main/docbook/css</directory>
+              </cssResource>
+              <targetDirectory>${basedir}/target/docbook/faq_en</targetDirectory>
+              <formats>
+                <format>
+                  <formatName>pdf</formatName>
+                  <stylesheetResource>classpath:/standard/fopdf.xsl</stylesheetResource>
+                  <finalName>faq_en.pdf</finalName>
+                </format>
+                <format>
+                  <formatName>html</formatName>
+                  <stylesheetResource>classpath:/standard/html_chunk.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+                <format>
+                  <formatName>html_single</formatName>
+                  <stylesheetResource>classpath:/standard/html.xsl</stylesheetResource>
+                  <finalName>index.html</finalName>
+                </format>
+              </formats>
+              <options>
+                <xincludeSupported>false</xincludeSupported>
+              </options>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: pojo/trunk/src/main/docbook/css/css/html.css
===================================================================
--- pojo/trunk/src/main/docbook/css/css/html.css	                        (rev 0)
+++ pojo/trunk/src/main/docbook/css/css/html.css	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,168 @@
+* {
+   font-family: sans-serif;
+   font-size: 14px;
+}
+
+A {
+   color: #0000CC;
+}
+
+A:active {
+   color: #0000CC;
+}
+
+A:visited {
+   color: #0000CC;
+}
+
+P, OL, UL, LI, DL, DT, DD, BLOCKQUOTE {
+   color: #000000;
+}
+
+TD, TH, SPAN {
+   color: #000000;
+}
+
+BLOCKQUOTE {
+   margin-right: 0px;
+}
+
+H1, H2, H3, H4, H5, H6 {
+   color: #003399; /*font-weight: 500;*/
+/*margin-top:  10px;*/
+/*padding-top: 5px;*/
+}
+
+.title {
+   margin-top: 10px;
+   padding-top: 5px;
+   font-weight: bold;
+}
+
+.subtitle {
+   margin-top: 10px;
+   padding-top: 5px;
+   font-style: italic;
+   font-weight: normal;
+}
+
+H1 {
+   font-size: 180%;
+}
+
+H2 {
+   font-size: 140%;
+}
+
+H3 {
+   font-size: 120%;
+}
+
+H4 {
+   font-size: 100%;
+}
+
+H5 {
+   font-size: 100%;
+}
+
+H6 {
+   font-size: 100%;
+}
+
+TABLE {
+   border-collapse: collapse;
+   border-spacing: 0; /*border:          1px dashed #CCCCCC;*/
+   empty-cells: hide;
+   width: 100%
+}
+
+TD {
+   padding: 4pt;
+}
+
+TT {
+   font-size: 100%;
+   color: #111111;
+   font-family: monospace;
+}
+
+PRE {
+   font-size: 100%;
+   padding: 5px;
+   border-style: solid;
+   border-width: 1px;
+   border-color: #CCCCCC;
+   background-color: #F4F4F4;
+   font-family: monospace;
+   width: auto;
+}
+
+HR {
+   width: 100%;
+   height: 1px;
+   background-color: #CCCCCC;
+   border-width: 0px;
+   padding: 0px;
+   color: #CCCCCC;
+}
+
+.term {
+   font-weight: bold;
+}
+
+.note {
+   padding-bottom: 5px;
+   padding-left: 5px;
+   padding-right: 5px;
+   background-color: #FFFFCC;
+}
+
+.warning {
+   padding-bottom: 5px;
+   padding-left: 5px;
+   padding-right: 5px;
+   background-color: #FBDADA;
+}
+
+.releaseinfo {
+   font-size: 100%;
+   font-weight: bold;
+}
+
+.pubdate, .copyright {
+   font-size: 80%;
+   font-style: italic;
+}
+
+.email {
+   font-family: sans-serif;
+   padding-left: 40px;
+   padding-right: 0;
+   padding-top: 0;
+   padding-bottom: 0;
+   font-size: 10pt;
+   margin: 0 0 0 0;
+
+}
+
+.firstname {
+   font-weight: bold;
+   margin: 0 0 0 0;
+   padding: 0 0 0 0;
+   padding-left: 20px;
+   font-size: 10pt;
+}
+
+.surname {
+   font-weight: bold;
+   margin: 0 0 0 0;
+   padding: 0 0 0 0;
+   font-size: 10pt;
+}
+
+.author {
+   padding: 0 0 0 0;
+   margin: 0 0 0 0;
+}
+

Added: pojo/trunk/src/main/docbook/faq/en/master.xml
===================================================================
--- pojo/trunk/src/main/docbook/faq/en/master.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/faq/en/master.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,805 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+      "../../../../docbook-support/support/docbook-dtd/docbookx.dtd"
+      >
+<article class="faq" lang="en">
+   <articleinfo>
+      <title>Frequently Asked Questions about PojoCache</title>
+      <releaseinfo>Release 2.0.0</releaseinfo>
+      <pubdate>June 2007</pubdate>
+
+      <author>
+         <firstname>Ben</firstname>
+         <surname>Wang</surname>
+         <email>ben.wang at jboss.com</email>
+      </author>
+      <author>
+         <firstname>Scott</firstname>
+         <surname>Marlow</surname>
+         <email>smarlow at novell.com</email>
+      </author>
+
+   </articleinfo>
+
+   <para>These are frequently asked questions regarding Pojocache.</para>
+
+   <qandaset defaultlabel="qanda">
+      <title>General Information</title>
+
+      <qandaentry>
+         <question id="a49">
+            <para>What is PojoCache?</para>
+         </question>
+
+         <answer>
+            <para>PojoCache is a fine-grained field-level replicated and
+               transactional POJO (plain old Java object) cache. By POJO, we mean
+               that the cache: 1) automatically manages object mapping and
+               relationship for a client under both local and replicated cache
+               mode, 2) provides support for inheritance relationship between
+               "aspectized" POJOs. By leveraging the dynamic AOP in JBossAop, it is
+               able to map a complex object into the cache store, preserve and
+               manage the object relationship behind the scene. During replication
+               mode, it performs fine-granularity (i.e., on a per-field basis)
+               update, and thus has the potential to boost cache performance and
+               minimize network traffic.
+            </para>
+
+            <para>From a user perspective, once your POJO is managed by the
+               cache, all cache operations are transparent. Therefore, all the
+               usual in-VM POJO method semantics are still preserved, providing
+               ease of use. For example, if a POJO has been put in PojoCache (by
+               calling
+               <literal>attach</literal>
+               , for example), then any POJO get/set
+               method will be
+               intercepted by PojoCache to provide the data from the
+               cache.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a1">
+            <para>What is the relationship between Cache and PojoCache?</para>
+         </question>
+
+         <answer>
+            <para>The core JBoss Cache library
+               <literal>Cache</literal>
+               is a traditional generic distributed cache system.
+               PojoCache uses Cache as the underlying distributed state system to achieve POJO caching. It uses Cache as
+               a
+               delegate. As a result, all the replication aspects are configured with the Cache configuration XML.
+               Additionally, PojoCache also has API to expose the Cache interface (via
+               <literal>getCache()</literal>
+               API).
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a52">
+            <para>What is the difference between Cache and
+               PojoCache?
+            </para>
+         </question>
+
+         <answer>
+            <para>Think of PojoCache as a Cache on steroids. :-)
+               Seriously, both are cache stores-- one is a generic cache and the other other one POJO Cache.
+               However, while Cache only
+               provides pure object reference storage (e.g.,
+               <literal>put(FQN fqn,
+                  Object key, Object value)
+               </literal>
+               ), PojoCache goes beyond that
+               and performs fine-grained field level replication object mapping and
+               relationship management for a user behind the scenes. As a result,
+               if you have complex object systems that you would like to cache, you
+               can have PojoCache manage it for you. You simply treat your
+               object systems as they are residing in-memory, e.g., use your
+               regular POJO methods without worrying about cache management.
+               Furthermore, this is true in replication mode as well.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a521">
+            <para>How does PojoCache work then?</para>
+         </question>
+
+         <answer>
+            <para>PojoCache uses the so-called AOP technology (aspect oriented programming) to do field level
+               interception. Currently, it uses
+               <literal>JBoss Aop</literal>
+               library to do it.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a522">
+            <para>What's changed between 1.x and 2.x release then?</para>
+         </question>
+
+         <answer>
+            <para>Starting in 2.0 release, we have a separate library for PojoCache,
+               <literal>pojocache.jar</literal>
+               that
+               is extra to the core
+               <literal>jboss-cache.jar</literal>
+               . Since we uses Cache as a delegate, user
+               will need to have a regular xml to configure the core Cache functionality (e.g., replication and locking
+               aspect). In addition, there is also the
+               <literal>pojocache-aop.xml</literal>
+               that specifies the PojoCache
+               interceptor stack (that can be left as default).
+            </para>
+            <para>Additionally, here are the changed features:
+               <itemizedlist>
+                  <listitem>
+                     <para>New APIs. It replaces
+                        <literal>putObject, removeObject, and get</literal>
+                        with
+                        <literal>attach, detach, and find</literal>
+                        .
+                     </para>
+                  </listitem>
+                  <listitem>
+                     <para>New POJO based events that a user can subscribe to.</para>
+                  </listitem>
+                  <listitem>
+                     <para>New configuration pojocache-aop.xml specifically for PojoCache, in addition to
+                        the regular cache-service.xml for the delegating Cache.
+                     </para>
+                  </listitem>
+                  <listitem>
+                     <para>New package namespace (
+                        <literal>org.jboss.cache.pojo)</literal>
+                        for PojoCache.
+                        The previous
+                        <literal>org.jboss.cache.aop</literal>
+                        space has been deprecated.
+                     </para>
+                  </listitem>
+               </itemizedlist>
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a53">
+            <para>What are the steps to use the PojoCache feature?</para>
+         </question>
+
+         <answer>
+            <para>In order to use PojoCache, you will need to:</para>
+
+            <itemizedlist>
+               <listitem>
+                  <para>prepare POJO. You can do either via xml declaration or JDK50 annotation.
+                     This is the step to declare your POJO such that it will be instrumented by
+                     <literal>JBoss Aop</literal>
+                     .
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>instrumentation. You will need to instrument your POJO either at compile- or load-time.
+                     If you do it during compile-time, you use so-called an aop pre-compiler (aopc) to do bytecode
+                     manipulation.
+                     If you do it via load-time, however, you need either a special system class loader or, in JDK50,
+                     you can
+                     use the javaagent option. Either way,
+                     <literal>JBoss Aop</literal>
+                     will byte code manipulate your POJO
+                     class such that all field access can be intercepted.
+                  </para>
+               </listitem>
+            </itemizedlist>
+            <para>So if you use JDK50, for example, with annotation and load-time instrumentation, then you won't need
+               any pre-processing step to use PojoCache. For a full example, please refer to the distro examples
+               directory.
+               There are numerous PojoCache examples that uses different options.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a541">
+            <para>What is the JDK version required to run PojoCache 2.x?</para>
+         </question>
+
+         <answer>
+            <para>PojoCache 2.x requires JDK5.0 since it uses the annotation extensively.</para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a542">
+            <para>Can I run PojoCache as a standalone mode?</para>
+         </question>
+
+         <answer>
+            <para>Yes, same as the core Cache library, you can run PojoCache either as a standalone or
+               inside an application server.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a543">
+            <para>What is the JBoss AS recommended version to run PojoCache 2.x?</para>
+         </question>
+
+         <answer>
+            <para>PojoCache can be run either in AS4.0.5 (and up) and 5.0. But either way, it will require
+               JDK5.0 though.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a56">
+            <para>Can I pre-compile the aop classes such that I don't need to
+               use the system classloader and jboss-aop configuration xml during runtime?
+            </para>
+         </question>
+
+         <answer>
+            <para>Yes. The latest versions of JBossCache have a pre-compiler
+               option called
+               <literal>aopc</literal>
+               . You can use this option to
+               pre-compile your "aspectized" POJO. Once the classes have been byte
+               code generated, they can be treated as regular class files, i.e.,
+               you will not need to include any
+               <literal>jboss-aop.xml</literal>
+               that specifies the advisable POJO and to specify the JBossAop system
+               class loader.
+            </para>
+
+            <para>For an example of how to use
+               <literal>aopc</literal>
+               , please
+               see 1)
+               <literal>tools</literal>
+               directory for PojoCacheTasks14.xml
+               and PojoCacheTasks50.xml. Both contain Ant tasks that you can
+               import to your regular project for
+               <literal>aopc</literal>
+               . In addition, please also check out the
+               <literal>examples</literal>
+               directory for concrete examples.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a561">
+            <para>In PojoCache 2.x release, do I still need
+               <literal>annoc</literal>
+               ?
+            </para>
+         </question>
+
+         <answer>
+            <para>The annoc precompiler is needed for JDK1.4 style annotation. For 2.x release, since
+               we require the use of JDK5.0, there is no need to use annoc anymore.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a57">
+            <para>How do I use aopc on multiple module directories?</para>
+         </question>
+
+         <answer>
+            <para>In aopc, you specify the src path for a specific directory. To
+               pre-compile multiple ones, you will need to invoke aopc multiple
+               times.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a57a">
+            <para>Does PojoCache provide POJO event subscription?</para>
+         </question>
+
+         <answer>
+            <para>Yes, since 2.0, you can use PojoCacheListener to subscribe to events
+               such as POJO attach and detach and field updates. And if you need some customization,
+               you can also use the Obervable pattern directly. TO see an example, please check
+               out the test case:
+               <literal>org.jboss.cache.pojo.observer.LocalTest.java</literal>
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a58">
+            <para>What's in the
+               <literal>jboss-aop.xml</literal>
+               configuration?
+            </para>
+         </question>
+
+         <answer>
+            <para>
+               <literal>jboss-aop.xml</literal>
+               is needed for POJO
+               instrumentation. In
+               <literal>jboss-aop.xml</literal>
+               , you can
+               declare your POJO (e.g.,
+               <literal>Person</literal>
+               ) to be
+               "prepared", a JBossAop term to denote that the object will be
+               "aspectized" by the system. After this declaration, JBossAop will
+               invoke any interceptor that associates with this POJO. PojoCache
+               will dynamically add an
+               <literal>org.jboss.cache.pojo.interceptor.dynamic.CacheFieldInterceptor</literal>
+               to this POJO
+               to perform object mapping and relationship management.
+            </para>
+
+            <para>Note that to add your POJO, you should declare all the fields
+               to be "prepared" as in the example.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a58a">
+            <para>What's the difference between
+               <literal>jboss-aop.xml</literal>
+               <literal>pojocache-aop.xml</literal>
+               ?
+            </para>
+         </question>
+
+         <answer>
+            <para>
+               <literal>pojocache-aop.xml</literal>
+               is essentially a
+               <literal>jboss-aop.xml</literal>
+               ,
+               except it is used specifically for PojoCache. The analogy is similar to JBoss' own
+               MBean service file
+               <literal>jboss-service.xml</literal>
+               , for example. So in our documentation,
+               we will use these two terms interchangeably.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a59">
+            <para>Can I use annotation instead of the xml declaration?</para>
+         </question>
+
+         <answer>
+            <para>Yes, in release 2.0, you can use JDK5.0 annotation to
+               instrument your POJO. Check the documentation for details.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a60">
+            <para>What are the pro and con of xml vs. annotation?</para>
+         </question>
+
+         <answer>
+            <para>It really depends on your organization environment, I'd say, since this can be turned into a
+               hot debate. Having said that, I feel strongly that POJO annotation is well suited for PojoCache. This is
+               because once you specify the annotation, you'd probably change it rarely since there is no parameters to
+               tune, for example.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a61">
+            <para>What are the
+               <literal>@org.jboss.cache.pojo.annotation.Transient</literal>
+               and
+               <literal>@org.jboss.cache.pojo.annotation.Serializable</literal>
+               field level annotations?
+            </para>
+         </question>
+
+         <answer>
+            <para>In 2.0, we also offer two additional field-level annotations. The first one,
+               <literal>@org.jboss.cache.pojo.Transient</literal>
+               ,
+               when applied has the same effect as declaring a field
+               <literal>transient</literal>
+               . PojoCache
+               won't put this field under management.
+            </para>
+            <para>The second one,
+               <literal>@org.jboss.cache.pojo.Serializable</literal>
+               when applied,
+               will cause PojoCache to
+               treat the field as a Serializable object even when it is
+               <literal>@org.jboss.cache.pojo.Replicable</literal>
+               .
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a62">
+            <para>What about compile-time vs. load-time instrumentation then?</para>
+         </question>
+
+         <answer>
+            <para>Again it depends. But my preference is to do compile-time instrumentation via aopc. I prefer this
+               approach because it is easier to debug (at least at the development stage). In addition, once I generate
+               the
+               new class, there is no more steps needed.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a63">
+            <para>Is it possible to store the same object multiple times but
+               with different Fqn paths? Like /foo/byName and /foo/byId ?
+            </para>
+         </question>
+
+         <answer>
+            <para>Yes, you can use PojoCache to do that. It supports the
+               notion of object reference. PojoCache manages the unique object
+               through association of the dynamic cache interceptor.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a64">
+            <para>Do I need to declare all my objects "prepared" in
+               <literal>jboss-aop.xml</literal>
+               ?
+            </para>
+         </question>
+
+         <answer>
+            <para>Not necessarily. If there is an object that you don't need the
+               cache to manage for you, you can leave it out of the declaration.
+               The cache will treat this object as a "primitive" type. However, the
+               object will need to implement
+               <literal>Serializable</literal>
+               interface for replication.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a65">
+            <para>Can the cache aop intercept update via reflection?</para>
+         </question>
+
+         <answer>
+            <para>No. The update via reflection will not be intercepted in
+               JBossAop and therefore PojoCache will not be able to perform the
+               necessary synchronization.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a66">
+            <para>When I declare my POJO to be "aspectized", what happens to the
+               fields with transient, static, and final modifiers?
+            </para>
+         </question>
+
+         <answer>
+            <para>PojoCache currently will ignore the fields with these
+               modifiers. That is, it won't put these fields into the cache (and
+               thus no replication either).
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a67">
+            <para>What are those keys such as
+               <literal>JBoss:internal:class</literal>
+               and
+               <literal>PojoInstance</literal>
+               ?
+            </para>
+         </question>
+
+         <answer>
+            <para>They are for internal use only. Users should ignore these keys
+               and values in the node hashmap.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a68">
+            <para>What about Collection classes? Do I need to declare them
+               "prepared"?
+            </para>
+         </question>
+
+         <answer>
+            <para>No. Since the Collection classes such as
+               <literal>ArrayList</literal>
+               are java util classes, aop by default
+               won't instrument these classes. Instead, PojoCache will generate
+               a dynamic class proxy for the Collection classes (upon the
+               <literal>attach</literal>
+               call is invoked). The proxy will
+               delegate the operations to a cache interceptor that implements the
+               actual Collection classes APIs. That is, the system classes won't be
+               invoked when used in PojoCache.
+            </para>
+
+            <para>Internally, the cache interceptor implements the APIs by
+               direct interaction with respect to the underlying cache store. Note
+               that this can have implications in performance for certain APIs. For
+               example, both
+               <literal>ArrayList</literal>
+               and
+               <literal>LinkedList</literal>
+               will have the same implementation.
+               Plan is currently underway to optimize these APIs.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a69">
+            <para>How do I use
+               <literal>List</literal>
+               ,
+               <literal>Set</literal>
+               ,
+               and
+               <literal>Map</literal>
+               dynamic proxy?
+            </para>
+         </question>
+
+         <answer>
+            <para>PojoCache supports classes extending from
+               <literal>List</literal>
+               ,
+               <literal>Set</literal>
+               , and
+               <literal>Map</literal>
+               without users to declare them "aspectized".
+               It is done via a dynamic proxy. Here is a code snippet to use an
+               <literal>ArrayList</literal>
+               proxy class.
+            </para>
+
+            <programlisting>ArrayList list = new ArrayList();
+               list.add("first");
+
+               cache.attach("list/test", list); // Put the list under the aop cache
+               list.add("second"); // Won't work since AOP intercepts the dynamic proxy not the original POJO.
+
+               ArrayList myList = (List)cache.find("list/test"); // we are getting a dynamic proxy instead
+               myList.add("second"); // it works now
+               myList.add("third");
+               myList.remove("third");
+            </programlisting>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a70">
+            <para>What is the proper way of assigning two different keys with
+               Collection class object?
+            </para>
+         </question>
+
+         <answer>
+            <para>Let's say you want to assign a
+               <literal>List</literal>
+               object
+               under two different names, you will need to use the class proxy to
+               insert the second time to ensure both are managed by the cache. Here
+               is the code snippet.
+            </para>
+
+            <programlisting>ArrayList list = new ArrayList();
+               list.add("first");
+
+               cache.attach("list", list); // Put the list under the aop cache
+
+               ArrayList myList = (List)cache.find("list"); // we are getting a dynamic proxy instead
+               myList.add("second"); // it works now
+
+               cache.attach("list_alias", myList); // Note you will need to use the proxy here!!
+               myList.remove("second");
+            </programlisting>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a71">
+            <para>OK, so I know I am supposed to use proxy when manipulating the
+               Collection classes once they are managed by the cache. But what
+               happens to Pojos that share the Collection objects, e.g., a
+               <literal>List</literal>
+               instance that is shared by 2 Pojos?
+            </para>
+         </question>
+
+         <answer>
+            <para>Pojos that share Collection instance references will be
+               handled by the cache automatically. That is, when you ask the Cache
+               to manage it, the Cache will dynamically swap out the regular
+               Collection references with the dynamic proxy ones. As a result, it
+               is transparent to the users.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a72">
+            <para>What happens when my "aspectized" POJO has field members that
+               are of Collection class ?
+            </para>
+         </question>
+
+         <answer>
+            <para>When a user puts a POJO into the cache through the call
+               <literal>attach</literal>
+               , it will recursively map the field
+               members into the cache store as well. When the field member is of a
+               Collection class (e.g., List, Set, or Map), PojoCache will first
+               map the collection into cache. Then, it will swap out dynamically
+               the field reference with an corresponding proxy reference.
+            </para>
+
+            <para>This is necessary so that an internal update on the field
+               member will be intercepted by the cache.
+            </para>
+         </answer>
+      </qandaentry>
+
+
+      <qandaentry>
+         <question id="a73">
+            <para>What are the limitation of Collection classes in PojoCache?</para>
+         </question>
+
+         <answer>
+            <para>Use of Collection class in PojoCache helps you to track fine-grained changes
+               in your collection fields automatically. However, current implementation has the follow
+               limitation that we plan to address soon.
+            </para>
+            <para>Currently, we only support a limited implementation of Collection classes. That is,
+               we support APIs in List, Set, and Map. However, since the APIs do not stipulate
+               of constraints like NULL key or value, it makes mapping of user instance to our proxy tricky.
+               For example, ArrayList would allow NULL value and some other implementation would not.
+               The Set interface maps to java.util.HashSet implementation. The List interface maps
+               to java.util.ArrayList implementation. The Map interface maps to java.util.HashMap
+               implementation.
+            </para>
+            <para>Another related issue is the expected performance. For example, the current implementation is ordered,
+               so
+               that makes insert/delete from the Collection slow. Performance between Set, Map and List collections also
+               vary.
+               Adding items to a Set is slower than a List or Map, since Set does not allow duplicate entries.
+            </para>
+         </answer>
+      </qandaentry>
+
+
+      <qandaentry>
+         <question id="a74">
+            <para>What are the pros and cons of PojoCache?</para>
+         </question>
+
+         <answer>
+            <para>As mentioned in the reference doc, PojoCache has the following advantages:</para>
+            <itemizedlist>
+               <listitem>
+                  <para>Fine-grained replication and/or persistency. If you use a distributed PojoCache
+                     and once your POJO is put in the cache store, there is no need to use another API to
+                     trigger your changes. Furthermore, the replication are fine-grained field level. Note this
+                     also applies to persistency.
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>Fine-grained replication can have potential performance gain if your POJO is big and
+                     the changes are fine-grained, e.g., only to some selected fields.
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>POJO can posses object relationship, e.g., multiple referenced. Distributed
+                     PojoCache will handle this transparently for you.
+                  </para>
+               </listitem>
+            </itemizedlist>
+            <para>And here are some cases that you may not want to use PojoCache:</para>
+            <itemizedlist>
+               <listitem>
+                  <para>You use only cache. That is you don't need replication or persistency. Then since
+                     everything is operated on the in-memory POJO reference, there is no need for PojoCache.
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>You have simple and small POJOs. Your POJO is small in size and also there is no
+                     object relationship, then PojoCache possess not clear advantage to plain cache.
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>Your application is bounded by memory usage. Because PojoCache need almost twice as much
+                     of memory (the original POJO in-memory space and also the additional cache store for the
+                     primitive fields), you may not want to use PojoCache.
+                  </para>
+               </listitem>
+               <listitem>
+                  <para>Your POJO lifetime is short. That is, you need to create and destroy your POJO often.
+                     Then you need to do "attach" and "detach" often, it will be slow in performance.
+                  </para>
+               </listitem>
+            </itemizedlist>
+         </answer>
+      </qandaentry>
+   </qandaset>
+
+
+   <qandaset defaultlabel="qanda">
+      <title>Passiviation and eviction</title>
+      <qandaentry>
+         <question id="a80">
+            <para>Can I use eviction to evict POJO from the memory?</para>
+         </question>
+         <answer>
+            <para>No. In 2.0 release, we have deprecated the POJO-based eviction policy since it has always been
+               problematic in earlier release. The main reason is that when we evict a POJO from
+               the memory, the user has no ways of knowing it. So if the POJO is accessed after the
+               eviction, there won't be any PojoCache interception (e.g., it will be just like ordinary POJO),
+               but user may still expect that it will be managed by PojoCache.
+            </para>
+         </answer>
+      </qandaentry>
+
+      <qandaentry>
+         <question id="a81">
+            <para>So what do I do now?</para>
+         </question>
+         <answer>
+            <para>In order to keep your memory from overflowing, you can use the passivation feature that comes with
+               the core Cache. Passivation uses the combination of eviction and cache loader such that when the
+               items are old, it will be evicted from memory and store in a cache store (can be DB or file). Next time,
+               when the item needs to be accessed again, we will retrieve it from the cache store.
+            </para>
+            <para>In this sense, PojoCache level is not aware of the passivation aspect. It is configured through
+               the underlying cache xml.
+            </para>
+         </answer>
+      </qandaentry>
+   </qandaset>
+
+   <qandaset defaultlabel="qanda">
+      <title>Troubleshooting</title>
+      <qandaentry>
+         <question id="a90">
+            <para>I am having problems getting PojoCache to work, where can I get information on troubleshooting?</para>
+         </question>
+         <answer>
+            <para>Troubleshooting section can be found in the following
+               <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=PojoCacheTroubleshooting">wiki link</ulink>
+               .
+            </para>
+         </answer>
+      </qandaentry>
+   </qandaset>
+</article>

Added: pojo/trunk/src/main/docbook/images/images/classes.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/classes.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/demoAddress.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/demoAddress.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/demoAddressInternal.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/demoAddressInternal.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/demoJoe.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/demoJoe.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/demogui.gif
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/demogui.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/get.gif
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/get.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/get.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/get.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/graph.gif
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/graph.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiAddress.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiAddress.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiJoe.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiJoe.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiJoeAddress.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiJoeAddress.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiJoeInternal.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiJoeInternal.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiMary.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiMary.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiMaryAddress.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiMaryAddress.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/guiMaryInternal.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/guiMaryInternal.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/map.gif
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/map.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/map.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/map.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/object_split.jpg
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/object_split.jpg
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/pojocache_architecture.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/pojocache_architecture.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/reference.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/reference.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/set.gif
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/set.gif
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/images/images/set.png
===================================================================
(Binary files differ)


Property changes on: pojo/trunk/src/main/docbook/images/images/set.png
___________________________________________________________________
Name: svn:executable
   + *
Name: svn:mime-type
   + application/octet-stream

Added: pojo/trunk/src/main/docbook/tutorial/en/master.xml
===================================================================
--- pojo/trunk/src/main/docbook/tutorial/en/master.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/tutorial/en/master.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,398 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<article lang="en">
+   <articleinfo>
+      <title>PojoCache Tutorial</title>
+      <releaseinfo>Release 2.0.0</releaseinfo>
+      <pubdate>June 2007</pubdate>
+      <author>
+         <firstname>Ben</firstname>
+         <surname>Wang</surname>
+         <email>ben.wang at jboss.com</email>
+      </author>
+      <author>
+         <firstname>Galder</firstname>
+         <surname>Zamarreño</surname>
+         <email>galder.zamarreno at jboss.com</email>
+      </author>      
+   </articleinfo>
+
+   <section>
+      <title>Introduction</title>
+
+      <para>PojoCache is an in-memory, transactional, and replicated POJO (plain old Java object) cache system that
+         allows users to operate on a POJO transparently without active user management of either replication or
+         persistency aspects. This tutorial focuses on the usage of the PojoCache API.
+      </para>
+      <para>For details of configuration, usage and APIs, please refer to the
+        <ulink url="http://labs.jboss.org/portal/jbosscache/docs/index.html">users manual</ulink>.
+      </para>
+   </section>
+
+   <section>
+      <title>What You Will Learn</title>
+
+      <itemizedlist>
+         <listitem>
+            <para>PojoCache creation and modification</para>
+         </listitem>
+
+         <listitem>
+            <para>Replication of POJO fields</para>
+         </listitem>
+
+         <listitem>
+            <para>Using Collections in PojoCache</para>
+         </listitem>
+         
+         <listitem>
+            <para>Transactions</para>
+         </listitem>
+
+      </itemizedlist>
+   </section>
+
+   <section>
+      <title>Configuration</title>
+
+      <para>First download the JBoss Cache 2.x distribution from
+         <ulink url="http://labs.jboss.org/portal/jbosscache/download/index.html">the download page</ulink>
+         . You probably want the
+         <literal>JBossCache-pojo-2.X.Y.zip</literal>
+         distribution. Unzip it, and you will get a directory containing the distribution, such as
+         <literal>JBossCache-pojo-2.X.Y</literal>
+         .
+         For the sake of this tutorial, I will refer to this as
+         <literal>PojoCache</literal>
+         .
+      </para>
+
+      <para>The configuration files are located under the
+         <literal>PojoCache/etc</literal>
+         directory. You can modify the behavior of the underlying cache through editing the various configuration files.
+      </para>
+
+      <itemizedlist>
+         <listitem>
+            <para>
+               <literal>log4j.xml</literal>
+               . Logging output. You can enable logging, specify log levels or change the name and path to the log file.
+            </para>
+         </listitem>
+
+         <listitem>
+            <para>
+               <literal>META-INF/replSync-service.xml</literal>
+               . Cache configuration file used for this tutorial.
+            </para>
+         </listitem>
+
+         <listitem>
+            <para>
+               <literal>pojocache-aop.xml</literal>
+               . PojoCache configuration file that contains, amongst other things, the annotation to use on POJOs so
+               that they're aspectised. For more information, please the PojoCache
+               <ulink url="http://labs.jboss.org/portal/jbosscache/docs/index.html">users manual</ulink>
+               .
+            </para>
+         </listitem>
+      </itemizedlist>
+   </section>
+
+   <section>
+      <title>Script</title>
+
+      <para>The only script needed for this tutorial is the
+         <literal>PojoCache/build.xml</literal>
+         ant script and the accompanying
+         driver scripts (
+         <literal>build.sh</literal>
+         for Unix and
+         <literal>build.bat</literal>
+         for Windows).
+      </para>
+   </section>
+
+   <section>
+      <title>Example POJOs</title>
+
+      <para>The example POJO classes used for PojoCache demo are:
+         <literal>org.jboss.cache.pojo.test.Person</literal>
+         and
+         <literal>org.jboss.cache.pojo.test.Address</literal>
+         . They are located
+         under
+         <literal>tests/functional</literal>
+         directory.The demo will demonstrate that once a POJO has been attached to the cache, plain get/set POJO methods
+         will be intercepted by the cache.
+      </para>
+
+      <para>Here is the snippet of the class definition for
+         <literal>Person</literal>
+         and
+         <literal>Address</literal>
+         with the
+         <literal>Replicable</literal>
+         annotation.
+      </para>
+
+      <programlisting><![CDATA[
+   @org.jboss.cache.pojo.annotation.Replicable
+   public class Person {
+      ...
+      public String getName() { return name; }
+      public void setName(String name) { this.name=name; }
+      ...
+      public List<String> getLanguages() { return languages; }
+      public void setLanguages(List<String> languages) { this.languages = languages; }
+      ...
+      public Address getAddress() { return address; }
+      public void setAddress(Address address) { this.address = address; }
+      ...
+   }
+      ]]></programlisting>
+
+      <programlisting><![CDATA[
+   @org.jboss.cache.pojo.annotation.Replicable
+   public class Address {
+      ...
+      public String getStreet() { return street; }
+      public void setStreet(String street) { this.street=street; }
+      ...
+   }
+      ]]></programlisting>
+   </section>
+
+   <section>
+      <title>Running The Demo GUI</title>
+
+      <para>
+         The demo is run by calling the ant script (via the driver) with the
+         <literal>run.demo.pojocache</literal>
+         target. E.g.,
+      </para>
+
+      <para>
+         <literal>./build.sh run.demo.pojocache</literal>
+      </para>
+      <para>
+         This will cause a GUI window to appear, giving you a tree view of the cache in the top pane and a BeanShell
+         view of the JVM in the lower pane.
+      </para>
+      <para>
+         The BeanShell view is preset with the following variables:
+         <itemizedlist>
+            <listitem>
+               <literal>cache</literal>
+               - a reference to the PojoCache interface, used by the GUI instance.
+            </listitem>
+            <listitem>
+               <literal>transactionManager</literal>
+               - a reference to the registered transaction manager.
+            </listitem>
+         </itemizedlist>
+         The references made available to the BeanShell window point to the same cache instance used by the tree view in
+         the GUI above.
+      </para>
+
+      <para>
+         To run the demo as a replicated demo, it is useful to start another command line window and run the ant script
+         again as you did above. Now you will have two cache instances running in two separate GUIs, replicating state
+         to each other.
+      </para>
+
+   </section>
+
+   <section>
+      <title>Tutorials</title>
+      It is recommended that you shut down and restart the demo GUI for each of the following tutorials, to ensure
+      clean caches every time. To inspect POJO attribute changes via GUI, please refer to the PojoCache
+      <ulink
+            url="http://labs.jboss.org/portal/jbosscache/docs/index.html">user manual
+      </ulink>
+      to understand how the POJOs are mapped internally in the cache.
+
+      <section>
+         <title>PojoCache API, POJO manipulation, and Replication</title>
+         <para>
+            For this tutorial, start two instance of the demo GUI. In this tutorial, we will:
+
+            <itemizedlist>
+               <listitem>Attach POJOs to the cache and see them being replicated.</listitem>
+               <listitem>After attaching, manipulate the POJOs and see the individual changes replicated.</listitem>
+               <listitem>Retrieve POJOs from the cache, manipulate them and see the changes replicated.</listitem>
+               <listitem>Create POJOs that share a common POJO and the consequences of changes to this.</listitem>
+               <listitem>Detach POJOs from the cache.</listitem>
+               <listitem>After detaching, manipulates the POJOs and see how the values in the cache are unchanged.</listitem>
+            </itemizedlist>
+            
+         </para>
+
+         <orderedlist>
+            <listitem>In the 1st GUI instance, create a POJO, i.e. a Person with an Address:
+               <programlisting><![CDATA[
+
+   joe = new Person();
+   joe.setName("Joe Black");
+   joe.setAge(31);
+
+   addr = new Address();
+   addr.setCity("Sunnyvale");
+   addr.setStreet("123 Albert Ave");
+   addr.setZip(94086);
+
+   joe.setAddress(addr);
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Attach the POJO to the cache:
+               <programlisting><![CDATA[
+
+   cache.attach("pojo/joe", joe);
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Change attributes of the POJO and see the individual changes being propagated to the 2nd
+               cache GUI:
+               <programlisting><![CDATA[
+
+   joe.setAge(41);
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>In the 2nd GUI instance, get a reference to the Person in the cache and create a second Person
+               with the existing Person's Address:
+               <programlisting><![CDATA[
+
+   joe = cache.find("pojo/joe");
+
+   mary = new Person();
+   mary.setName("Mary White");
+   mary.setAge(30);
+
+   mary.setAddress(joe.getAddress());
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Attach the new POJO to the cache:
+               <programlisting><![CDATA[
+
+   cache.attach("pojo/mary", mary);
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Now, change either Person's Address and see how the change applies to both POJOs and has been
+               propagated to the other cache, visible in the 1st GUI instance:
+               <programlisting><![CDATA[
+
+   mary.getAddress().setZip(95000);
+
+                 ]]></programlisting>
+            </listitem>
+
+
+            <listitem>Still in the 2nd GUI instance, detach the POJOs from the cache and see how the POJOs are no longer
+               visible:
+               <programlisting><![CDATA[
+
+   cache.detach("pojo/joe");
+   cache.detach("pojo/mary");
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Finally, in any of GUI instances, change some attributes of the POJO and see these changes have
+               no effect in the cache:
+               <programlisting><![CDATA[
+
+   joe.setName("Joe White");
+
+                 ]]></programlisting>
+            </listitem>
+
+         </orderedlist>
+
+      </section>
+      
+      <section>
+         <title>Collections</title>
+         <para>
+            For this tutorial, start two instances of the demo GUI. In this tutorial, we will:
+
+            <itemizedlist>
+               <listitem>Attach a POJO to the cache and see it being replicated.</listitem>
+               <listitem>Set a Collection attribute in this POJO</listitem>
+               <listitem>Manipulate this Collection attribute and see the changes visible in the GUI and being replicated</listitem>
+               <listitem>Detach a POJO from the cache.</listitem>
+            </itemizedlist>
+
+         </para>
+
+         <orderedlist>
+            <listitem>In the 1st GUI instance, create a POJO with a Collection attribute:
+               <programlisting><![CDATA[
+
+   joe = new Person();
+   joe.setName("Joe Black");
+
+   lang = new ArrayList();
+   lang.add("Spanish");
+
+   joe.setLanguages(lang);
+   
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Attach the POJO to the cache:
+               <programlisting><![CDATA[
+
+   cache.attach("pojo/joe", joe);
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Get a proxy reference to the Collection and add a new element to it:
+               <programlisting><![CDATA[
+
+   proxyLang = joe.getLanguages();
+   proxyLang.add("English"); 
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Detach the pojo from the cache:
+               <programlisting><![CDATA[
+
+   cache.detach("pojo/joe");
+
+                 ]]></programlisting>
+            </listitem>
+
+            <listitem>Use the proxy reference to the Collection to add another element and see how this does not get
+               added to the cache:
+               <programlisting><![CDATA[
+
+   proxyLang.add("French");
+
+                 ]]></programlisting>
+            </listitem>
+
+         </orderedlist>
+      </section>
+   </section>
+
+   <section>
+      <title>Transactions</title>
+      <para>
+         For this tutorial, start two instances instance of the demo GUI. Repeat the exercises in the previous
+         tutorial, only starting transactions before attaching/detaching nodes or modiying the POJOs. This will depict
+         how replication only occurs on transaction boundaries. Try rolling back a few transactions as well, to see how
+         nothing gets replicated in these cases.
+      </para>
+   </section>
+
+</article>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/master.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/master.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/master.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,102 @@
+<?xml version='1.0' encoding="iso-8859-1"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3CR3//EN"
+      "../../../../docbook-support/support/docbook-dtd/docbookx.dtd"
+      [
+            <!ENTITY term                  SYSTEM "modules/term.xml">
+            <!ENTITY intro                  SYSTEM "modules/introduction.xml">
+            <!ENTITY arch                  SYSTEM "modules/architecture.xml">
+            <!ENTITY api                  SYSTEM "modules/api.xml">
+            <!ENTITY config                  SYSTEM "modules/configuration.xml">
+            <!ENTITY instrumentation                  SYSTEM "modules/instrumentation.xml">
+            <!ENTITY example                  SYSTEM "modules/example.xml">
+            <!ENTITY trouble                  SYSTEM "modules/troubleshooting.xml">
+            <!ENTITY appendix                  SYSTEM "modules/appendix.xml">
+            ]>
+
+<book lang="en">
+
+   <bookinfo>
+      <title>POJO Cache</title>
+      <subtitle>User Documentation</subtitle>
+      <releaseinfo>Release 2.0.0</releaseinfo>
+      <pubdate>July 2007</pubdate>
+
+      <author>
+         <firstname>Ben</firstname>
+         <surname>Wang</surname>
+         <email>ben.wang at jboss.com</email>
+      </author>
+      <author>
+         <firstname>Jason</firstname>
+         <surname>Greene</surname>
+         <email>jason.greene at jboss.com</email>
+      </author>
+   </bookinfo>
+
+   <toc/>
+
+   <preface id="preface" revision="1">
+      <title>Preface</title>
+
+      <para>
+         POJO Cache is an in-memory, transactional, and clustered cache system that
+         allows users to operate on a POJO (Plain Old Java Object) transparently and without
+         active user management of either replication or persistence aspects.  
+         
+         JBoss Cache, which includes POJO Cache, is a 100% Java based library that can be 
+         run either as a standalone program or inside an application server.
+      </para>
+
+      <para>
+         This document is meant to be a user and reference guide to explain the architecture, api, configuration, and
+         examples for POJO Cache. We assume the readers are familiar with both JGroups and the core JBoss Cache usages.
+      </para>
+
+      <para>
+         If you have questions, use the user
+         <ulink url="http://www.jboss.com/index.html?module=bb&amp;op=viewforum&amp;f=157">forum</ulink>
+         linked on the JBoss Cache website. We also
+         provide tracking links for tracking bug reports and feature requests on
+         <ulink url="http://jira.jboss.com">JBoss Jira web site</ulink>
+         . If you
+         are interested in the development of POJO Cache, post a message on the forum. If
+         you are interested in translating this documentation into your language, contact us
+         on the developer mailing list.
+      </para>
+
+      <para>
+         JBoss Cache is an open source product, using the business and OEM-friendly OSI-approved  LGPL license.  
+         Commercial development support, production support and training for JBoss Cache is available through 
+         <ulink url="http://www.jboss.com">JBoss, a division of Red Hat Inc.</ulink>
+      </para>
+
+      <para>
+         In some of the example listings, what is meant to be displayed on one line does not fit
+         inside the available page width. These lines have been broken up. A '\' at the end of a
+         line means that a break has been introduced to fit in the page, with the following lines
+         indented. So:
+         <programlisting>
+            Let's pretend to have an extremely \
+            long line that \
+            does not fit
+            This one is short
+         </programlisting>
+         Is really:
+         <programlisting>
+            Let's pretend to have an extremely long line that does not fit
+            This one is short
+         </programlisting>
+      </para>
+   </preface>
+
+
+   &term;
+   &intro;
+   &arch;
+   &api;
+   &config;
+   &instrumentation;
+   &trouble;
+   &appendix;
+</book>
+

Added: pojo/trunk/src/main/docbook/userguide/en/modules/architecture.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/architecture.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/architecture.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,498 @@
+<chapter id="architecture">
+   <title>Architecture</title>
+   <section id="architecture.tree_structure">
+      <title>Data Structures Within The Cache</title>
+
+
+      <para>
+         A
+         <literal>Cache</literal>
+         consists of a collection of
+         <literal>Node</literal>
+         instances, organised in a tree
+         structure. Each
+         <literal>Node</literal>
+         contains a
+         <literal>Map</literal>
+         which holds the data
+         objects to be cached. It is important to note that the structure is a mathematical tree, and not a graph; each
+         <literal>Node</literal>
+         has one and only one parent, and the root node is denoted by the constant fully qualitied name,
+         <literal>Fqn.ROOT</literal>
+         .
+      </para>
+      <para>
+         The reason for organising nodes as such is to improve concurrent access to data and make replication and
+         persistence
+         more fine-grained.
+      </para>
+      <para>
+         <figure>
+            <title>Data structured as a tree</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="TreeCacheArchitecture.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+         In the diagram above, each box represents a JVM. You see 2 caches in separate JVMs, replicating data to each
+         other.
+         These VMs can be located on the same physical machine, or on 2 different machines connected by a network link.
+         The
+         underlying group communication between networked nodes is done using
+         <ulink url="http://www.jgroups.org">JGroups</ulink>
+         .
+      </para>
+
+      <para>Any modifications (see
+         <link linkend="api">API chapter</link>
+         ) in one cache instance will be replicated to
+         the other cache. Naturally, you can have more than 2 caches in a cluster.
+         Depending on the transactional settings, this replication will occur either after each modification or at the
+         end of a transaction, at commit time. When a new cache is created, it can optionally acquire the contents
+         from one of the existing caches on startup.
+      </para>
+   </section>
+
+   <section id="architecture.SPI_interfaces">
+      <title>SPI Interfaces</title>
+      <para>
+         In addition to
+         <literal>Cache</literal>
+         and
+         <literal>Node</literal>
+         interfaces, JBoss Cache exposes more powerful
+         <literal>CacheSPI</literal>
+         and
+         <literal>NodeSPI</literal>
+         interfaces, which offer more control over the internals
+         of JBoss Cache. These interfaces are not intended for general use, but are designed for people who wish to
+         extend and enhance JBoss Cache, or write custom
+         <literal>Interceptor</literal>
+         or
+         <literal>CacheLoader</literal>
+         instances.
+      </para>
+      <figure>
+         <title>SPI Interfaces</title>
+
+         <mediaobject>
+            <imageobject>
+               <imagedata fileref="SPI.png"/>
+            </imageobject>
+         </mediaobject>
+      </figure>
+      <para>
+         The
+         <literal>CacheSPI</literal>
+         interface cannot be created, but is injected into
+         <literal>Interceptor</literal>
+         and
+         <literal>CacheLoader</literal>
+         implementations by the
+         <literal>setCache(CacheSPI cache)</literal>
+         methods on these interfaces.
+         <literal>CacheSPI</literal>
+         extends
+         <literal>Cache</literal>
+         so all the functionality of the basic API is made available.
+      </para>
+      <para>
+         Similarly, a
+         <literal>NodeSPI</literal>
+         interface cannot be created. Instead, one is obtained by performing operations on
+         <literal>CacheSPI</literal>
+         ,
+         obtained as above. For example,
+         <literal>Cache.getRoot() : Node</literal>
+         is overridden as
+         <literal>CacheSPI.getRoot() : NodeSPI</literal>
+         .
+      </para>
+      <para>
+         It is important to note that directly casting a
+         <literal>Cache</literal>
+         or
+         <literal>Node</literal>
+         to it's SPI
+         counterpart is not recommended and is bad practice, since the inheritace of interfaces it is not a contract
+         that is guaranteed to be upheld moving forward. The exposed public APIs, on the other hand, is guaranteed to
+         be upheld.
+      </para>
+   </section>
+
+   <section id="architecture.invocations">
+      <title>Method Invocations On Nodes</title>
+      <para>
+         Since the cache is essentially a collection of nodes, aspects such as clustering, persistence, eviction, etc.
+         need to be applied to these nodes when operations are invoked on the cache as a whole or on individual nodes.
+         To achieve this in a clean, modular and extensible manner, an interceptor chain is used. The chain is built
+         up of a series of interceptors, each one adding an aspect or particular functionality. The chain is built
+         when the cache is created, based on the configuration used.
+      </para>
+      <para>
+         It is important to note that the
+         <literal>NodeSPI</literal>
+         offers some methods (such as the
+         <literal>xxxDirect()</literal>
+         method
+         family) that operate on a node directly without passing through the interceptor stack. Plugin authors should
+         note
+         that using such methods will affect the aspects of the cache that may need to be applied, such as locking,
+         replication, etc. Basically, don't use such methods unless you
+         <emphasis>really</emphasis>
+         know what you're doing!
+      </para>
+      <section id="architecture.interceptors">
+         <title>Interceptors</title>
+         <para>
+            An
+            <literal>Interceptor</literal>
+            is an abstract class, several of which comprise an interceptor chain. It
+            exposes an
+            <literal>invoke()</literal>
+            method, which must be overridden by implementing classes to add behaviour
+            to a call before passing the call down the chain by calling
+            <literal>super.invoke()</literal>
+            .
+         </para>
+         <figure>
+            <title>SPI Interfaces</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="Interceptor.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+         <para>
+            JBoss Cache ships with several interceptors, representing different configuration options, some of which
+            are:
+            <itemizedlist>
+               <listitem>
+                  <literal>TxInterceptor</literal>
+                  - looks for ongoing transactions and registers with transaction managers to participate in
+                  synchronization events
+               </listitem>
+               <listitem>
+                  <literal>ReplicationInterceptor</literal>
+                  - replicates state across a cluster using a JGroups channel
+               </listitem>
+               <listitem>
+                  <literal>CacheLoaderInterceptor</literal>
+                  - loads data from a persistent store if the data requested is not available in memory
+               </listitem>
+            </itemizedlist>
+            The interceptor chain configured for your cache instance can be obtained and inspected by calling
+            <literal>CacheSPI.getInterceptorChain()</literal>
+            ,
+            which returns an ordered
+            <literal>List</literal>
+            of interceptors.
+         </para>
+         <section id="architecture.custom_interceptors">
+            <title>Writing Custom Interceptors</title>
+            <para>
+               Custom interceptors to add specific aspects or features can be written by extending
+               <literal>Interceptor</literal>
+               and overriding
+               <literal>invoke()</literal>
+               . The custom interceptor will need to be added to the interceptor chain by using the
+               <literal>CacheSPI.addInterceptor()</literal>
+               method.
+            </para>
+            <para>
+               Adding custom interceptors via XML is not supported at this time.
+            </para>
+         </section>
+      </section>
+
+      <section id="architecture.methodcalls">
+         <title>MethodCalls</title>
+         <para>
+            <literal>org.jboss.cache.marshall.MethodCall</literal>
+            is a class that encapsulates a
+            <literal>java.lang.reflection.Method</literal>
+            and an
+            <literal>Object[]</literal>
+            representing the method's arguments. It is an extension of the
+            <literal>org.jgroups.blocks.MethodCall</literal>
+            class, that adds a mechanism for identifying known methods using magic numbers and method ids,
+            which makes marshalling and unmarshalling more efficient and performant.
+         </para>
+         <para>
+            This is central to the
+            <literal>Interceptor</literal>
+            architecture, and is the only parameter passed in to
+            <literal>Interceptor.invoke()</literal>
+            .
+         </para>
+      </section>
+
+      <section id="architecture.invocationcontext">
+         <title>InvocationContexts</title>
+         <para>
+            <literal>InvocationContext</literal>
+            holds intermediate state for the duration of a single invocation, and is set up and
+            destroyed by the
+            <literal>InvocationContextInterceptor</literal>
+            which sits at the start of the chain.
+         </para>
+         <para>
+            <literal>InvocationContext</literal>
+            , as its name implies, holds contextual information associated with a single cache
+            method invocation. Contextual information includes associated
+            <literal>javax.transaction.Transaction</literal>
+            or
+            <literal>org.jboss.cache.transaction.GlobalTransaction</literal>
+            ,
+            method invocation origin (
+            <literal>InvocationContext.isOriginLocal()</literal>
+            ) as well as
+            <link
+                  linkend="configuration.options">
+               <literal>Option</literal>
+               overrides
+            </link>
+            .
+         </para>
+         <para>
+            The
+            <literal>InvocationContext</literal>
+            can be obtained by calling
+            <literal>Cache.getInvocationContext()</literal>
+            .
+         </para>
+      </section>
+   </section>
+
+   <section id="architecture.managers">
+      <title>Managers For Subsystems</title>
+      <para>
+         Some aspects and functionality is shared by more than a single interceptor. Some of these have been
+         encapsulated
+         into managers, for use by various interceptors, and are made available by the
+         <literal>CacheSPI</literal>
+         interface.
+      </para>
+
+      <section id="architecture.rpcmanager">
+         <title>RpcManager</title>
+         <para>
+            This class is responsible for calls made via the JGroups channel for all RPC calls to remote caches, and
+            encapsulates the JGroups channel used.
+         </para>
+      </section>
+
+      <section id="architecture.buddymanager">
+         <title>BuddyManager</title>
+         <para>
+            This class manages buddy groups and invokes group organisation remote calls to organise a cluster of
+            caches into smaller sub-groups.
+         </para>
+      </section>
+
+      <section id="architecture.cacheloadermanager">
+         <title>CacheLoaderManager</title>
+         <para>
+            Sets up and configures cache loaders. This class wraps individual
+            <literal>CacheLoader</literal>
+            instances
+            in delegating classes, such as
+            <literal>SingletonStoreCacheLoader</literal>
+            or
+            <literal>AsyncCacheLoader</literal>
+            ,
+            or may add the
+            <literal>CacheLoader</literal>
+            to a chain using the
+            <literal>ChainingCacheLoader</literal>
+            .
+         </para>
+      </section>
+
+   </section>
+
+   <section id="architecture.marshalling">
+      <title>Marshalling And Wire Formats</title>
+      <para>
+         Early versions of JBoss Cache simply wrote cached data to the network by writing to an
+         <literal>ObjectOutputStream</literal>
+         during replication. Over various releases in the JBoss Cache 1.x.x series this approach was gradually
+         deprecated
+         in favour of a more mature marshalling framework. In the JBoss Cache 2.x.x series, this is the only officially
+         supported and recommended mechanism for writing objects to datastreams.
+      </para>
+      <figure>
+         <title>The Marshaller interface</title>
+
+         <mediaobject>
+            <imageobject>
+               <imagedata fileref="Marshaller.png"/>
+            </imageobject>
+         </mediaobject>
+      </figure>
+      <section>
+         <title>The Marshaller Interface</title>
+         <para>
+            The
+            <literal>Marshaller</literal>
+            interface extends
+            <literal>RpcDispatcher.Marshaller</literal>
+            from JGroups.
+            This interface has two main implementations - a delegating
+            <literal>VersionAwareMarshaller</literal>
+            and a
+            concrete
+            <literal>CacheMarshaller200</literal>
+            .
+         </para>
+         <para>
+            The marshaller can be obtained by calling
+            <literal>CacheSPI.getMarshaller()</literal>
+            , and defaults to the
+            <literal>VersionAwareMarshaller</literal>
+            .
+            Users may also write their own marshallers by implementing the
+            <literal>Marshaller</literal>
+            interface and
+            adding it to their configuration, by using the
+            <literal>MarshallerClass</literal>
+            configuration attribute.
+         </para>
+      </section>
+
+      <section>
+         <title>VersionAwareMarshaller</title>
+         <para>
+            As the name suggests, this marshaller adds a version
+            <literal>short</literal>
+            to the start of any stream when
+            writing, enabling similar
+            <literal>VersionAwareMarshaller</literal>
+            instances to read the version short and
+            know which specific marshaller implementation to delegate the call to.
+            For example,
+            <literal>CacheMarshaller200</literal>
+            , is the marshaller for JBoss Cache 2.0.x.
+            JBoss Cache 2.1.x, say, may ship with
+            <literal>CacheMarshaller210</literal>
+            with an improved wire protocol.
+            Using a
+            <literal>VersionAwareMarshaller</literal>
+            helps achieve wire protocol compatibility between minor
+            releases but still affords us the flexibility to tweak and improve the wire protocol between minor or micro
+            releases.
+         </para>
+
+         <section>
+            <title>CacheLoaders</title>
+            <para>
+               Some of the existing cache loaders, such as the
+               <literal>JDBCCacheLoader</literal>
+               and the
+               <literal>FileCacheLoader</literal>
+               relied on persisting data using
+               <literal>ObjectOutputStream</literal>
+               as well, but now, they are using the
+               <literal>VersionAwareMarshaller</literal>
+               to marshall the persisted
+               data to their cache stores.
+            </para>
+         </section>
+
+      </section>
+
+      <section>
+         <title>CacheMarshaller200</title>
+         <para>
+            This marshaller treats well-known objects that need marshalling - such as
+            <literal>MethodCall</literal>
+            ,
+            <literal>Fqn</literal>
+            ,
+            <literal>DataVersion</literal>
+            , and even some JDK objects such as
+            <literal>String</literal>
+            ,
+            <literal>List</literal>
+            ,
+            <literal>Boolean</literal>
+            and others as types that do not need complete class definitions.
+            Instead, each of these well-known types are represented by a
+            <literal>short</literal>
+            , which is a lot more efficient.
+         </para>
+         <para>
+            In addition, reference counting is done to reduce duplication of writing certain objects multiple times, to
+            help
+            keep the streams small and efficient.
+         </para>
+         <para>
+            Also, if
+            <literal>UseRegionBasedMarshalling</literal>
+            is enabled (disabled by default) the marshaller adds region
+            information to the stream before writing any data. This region information is in the form of a
+            <literal>String</literal>
+            representation of an
+            <literal>Fqn</literal>
+            . When unmarshalling, the
+            <literal>RegionManager</literal>
+            can be used to
+            find the relevant
+            <literal>Region</literal>
+            , and use a region-specific
+            <literal>ClassLoader</literal>
+            to unmarshall
+            the stream. This is specifically useful when used to cluster state for application servers, where each
+            deployment has
+            it's own
+            <literal>ClassLoader</literal>
+            . See the section below on
+            <link linkend="architecture.regions">regions</link>
+            for more information.
+         </para>
+      </section>
+
+   </section>
+   <section id="architecture.regions">
+      <title>Class Loading and Regions</title>
+      <para>
+         When used to cluster state of application servers, applications deployed in the application tend to put
+         instances
+         of objects specific to their application in the cache (or in an
+         <literal>HttpSession</literal>
+         object) which
+         would require replication. It is common for application servers to assign separate
+         <literal>ClassLoader</literal>
+         instances to each application deployed, but have JBoss Cache libraries referenced by the application server's
+         <literal>ClassLoader</literal>
+         .
+      </para>
+      <para>
+         To enable us to successfully marshall and unmarshall objects from such class loaders, we use a concept called
+         regions. A region is a portion of the cache which share a common class loader (a region also has other uses -
+         see
+         <link linkend="eviction_policies">eviction policies</link>
+         ).
+      </para>
+      <para>
+         A region is created by using the
+         <literal>Cache.getRegion(Fqn fqn, boolean createIfNotExists)</literal>
+         method,
+         and returns an implementation of the
+         <literal>Region</literal>
+         interface. Once a region is obtained, a
+         class loader for the region can be set or unset, and the region can be activated/deactivated. By default,
+         regions
+         are active unless the
+         <literal>InactiveOnStartup</literal>
+         configuration attribute is set to
+         <literal>true</literal>
+         .
+      </para>
+   </section>
+
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/basic_api.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/basic_api.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/basic_api.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,719 @@
+<chapter id="api">
+   <title>User API</title>
+   <section>
+      <title>API Classes</title>
+      <para>
+         The
+         <literal>Cache</literal>
+         interface is the primary mechanism for interacting with JBoss Cache. It is
+         constructed and optionally started using the
+         <literal>CacheFactory</literal>
+         . The
+         <literal>CacheFactory</literal>
+         allows you to create a
+         <literal>Cache</literal>
+         either from a
+         <literal>Configuration</literal>
+         object
+         or an XML file. Once you have a reference to a
+         <literal>Cache</literal>
+         , you can use it to look up
+         <literal>Node</literal>
+         objects in the tree structure, and store data in the tree.
+
+         <mediaobject>
+            <imageobject>
+               <imagedata fileref="PublicAPI.png" format="PNG"/>
+            </imageobject>
+         </mediaobject>
+
+      </para>
+
+      <para>
+         Reviewing the javadoc for the above interfaces is the best way
+         to learn the API. Below we cover some of the main points.
+      </para>
+   </section>
+
+   <section id="api.create_start">
+      <title>Instantiating and Starting the Cache</title>
+      <para>
+         An instance of the
+         <literal>Cache</literal>
+         interface can only be created
+         via a
+         <literal>CacheFactory</literal>
+         . (This is unlike JBoss Cache 1.x,
+         where an instance of the old
+         <literal>TreeCache</literal>
+         class could
+         be directly instantiated.)
+      </para>
+      <para>
+         <literal>CacheFactory</literal>
+         provides a number of overloaded methods
+         for creating a
+         <literal>Cache</literal>
+         , but they all do the same thing:
+         <itemizedlist>
+            <listitem>Gain access to a
+               <literal>Configuration</literal>
+               , either
+               by having one passed in as a method parameter, or by parsing XML
+               content and constructing one. The XML content can come from a
+               provided input stream or from a classpath or filesystem location.
+               See the
+               <link linkend="configuration">chapter on Configuration</link>
+               for
+               more on obtaining a
+               <literal>Configuration</literal>
+               .
+            </listitem>
+            <listitem>Instantiate the
+               <literal>Cache</literal>
+               and provide
+               it with a reference to the
+               <literal>Configuration</literal>
+               .
+            </listitem>
+            <listitem>Optionally invoke the cache's
+               <literal>create()</literal>
+               and
+               <literal>start()</literal>
+               methods.
+            </listitem>
+         </itemizedlist>
+      </para>
+
+      <para>
+         An example of the simplest mechanism for creating and starting
+         a cache, using the default configuration values:
+      </para>
+
+      <programlisting>
+         CacheFactory factory = DefaultCacheFactory.getInstance();
+         Cache cache = factory.createCache();
+      </programlisting>
+
+      <para>Here we tell the
+         <literal>CacheFactory</literal>
+         to find and
+         parse a configuration file on the classpath:
+      </para>
+
+      <programlisting>
+         CacheFactory factory = DefaultCacheFactory.getInstance();
+         Cache cache = factory.createCache("cache-configuration.xml");
+      </programlisting>
+
+      <para>Here we configure the cache from a file, but want to programatically
+         change a configuration element. So, we tell the factory not to start
+         the cache, and instead do it ourselves:
+      </para>
+
+      <programlisting>
+         CacheFactory factory = DefaultCacheFactory.getInstance();
+         Cache cache = factory.createCache("cache-configuration.xml", false);
+         Configuration config = cache.getConfiguration();
+         config.setClusterName(this.getClusterName());
+
+         // Have to create and start cache before using it
+         cache.create();
+         cache.start();
+      </programlisting>
+
+   </section>
+
+   <section>
+      <title>Caching and Retrieving Data</title>
+
+      <para>Next, let's use the
+         <literal>Cache</literal>
+         API to access
+         a
+         <literal>Node</literal>
+         in the cache and then do some
+         simple reads and writes to that node.
+      </para>
+      <programlisting>
+         // Let's get ahold of the root node.
+         Node rootNode = cache.getRoot();
+
+         // Remember, JBoss Cache stores data in a tree structure.
+         // All nodes in the tree structure are identified by Fqn objects.
+         Fqn peterGriffinFqn = Fqn.fromString("/griffin/peter");
+
+         // Create a new Node
+         Node peterGriffin = rootNode.addChild(peterGriffinFqn);
+
+         // let's store some data in the node
+         peterGriffin.put("isCartoonCharacter", Boolean.TRUE);
+         peterGriffin.put("favouriteDrink", new Beer());
+
+         // some tests (just assume this code is in a JUnit test case)
+         assertTrue(peterGriffin.get("isCartoonCharacter"));
+         assertEquals(peterGriffinFqn, peterGriffin.getFqn());
+         assertTrue(rootNode.hasChild(peterGriffinFqn));
+
+         Set keys = new HashSet();
+         keys.add("isCartoonCharacter");
+         keys.add("favouriteDrink");
+
+         assertEquals(keys, peterGriffin.getKeys());
+
+         // let's remove some data from the node
+         peterGriffin.remove("favouriteDrink");
+
+         assertNull(peterGriffin.get("favouriteDrink");
+
+         // let's remove the node altogether
+         rootNode.removeChild(peterGriffinFqn);
+
+         assertFalse(rootNode.hasChild(peterGriffinFqn));
+      </programlisting>
+
+      <para>
+         The
+         <literal>Cache</literal>
+         interface also exposes put/get/remove
+         operations that take an
+         <link linkend="basic_api.fqn">Fqn</link>
+         as an argument:
+      </para>
+
+      <programlisting>
+         Fqn peterGriffinFqn = Fqn.fromString("/griffin/peter");
+
+         cache.put(peterGriffinFqn, "isCartoonCharacter", Boolean.TRUE);
+         cache.put(peterGriffinFqn, "favouriteDrink", new Beer());
+
+         assertTrue(peterGriffin.get(peterGriffinFqn, "isCartoonCharacter"));
+         assertTrue(cache.getRootNode().hasChild(peterGriffinFqn));
+
+         cache.remove(peterGriffinFqn, "favouriteDrink");
+
+         assertNull(cache.get(peterGriffinFqn, "favouriteDrink");
+
+         cache.removeNode(peterGriffinFqn);
+
+         assertFalse(cache.getRootNode().hasChild(peterGriffinFqn));
+      </programlisting>
+   </section>
+
+   <section id="basic_api.fqn">
+      <title>The
+         <literal>Fqn</literal>
+         Class
+      </title>
+
+      <para>
+         The previous section used the
+         <literal>Fqn</literal>
+         class in its
+         examples; now let's learn a bit more about that class.
+      </para>
+
+      <para>
+         A Fully Qualified Name (Fqn) encapsulates a list of names which represent
+         a path to a particular location in the cache's tree structure. The
+         elements in the list are typically
+         <literal>String</literal>
+         s but can be
+         any
+         <literal>Object</literal>
+         or a mix of different types.
+      </para>
+
+      <para>
+         This path can be absolute (i.e., relative to the root node), or relative
+         to any node in the cache. Reading the documentation on each API call that
+         makes use of
+         <literal>Fqn</literal>
+         will tell you whether the API expects
+         a relative or absolute
+         <literal>Fqn</literal>
+         .
+      </para>
+
+      <para>
+         The
+         <literal>Fqn</literal>
+         class provides are variety of constructors;
+         see the javadoc for all the possibilities. The following illustrates the
+         most commonly used approaches to creating an Fqn:
+      </para>
+
+      <programlisting>
+         <![CDATA[
+	    // Create an Fqn pointing to node 'Joe' under parent node 'Smith'
+	    // under the 'people' section of the tree
+	    
+	    // Parse it from a String
+	    Fqn<String> abc = Fqn.fromString("/people/Smith/Joe/");
+	    
+	    // Build it directly. A bit more efficient to construct than parsing
+	    String[] strings = new String[] { "people", "Smith", "Joe" };
+	    Fqn<String> abc = new Fqn<String>(strings);
+	    
+	    // Here we want to use types other than String
+	    Object[] objs = new Object[]{ "accounts", "NY", new Integer(12345) };
+	    Fqn<Object> acctFqn = new Fqn<Object>(objs);
+     ]]>
+      </programlisting>
+
+      <para>Note that</para>
+      <para>
+         <programlisting><![CDATA[Fqn<String> f = new Fqn<String>("/a/b/c");]]></programlisting>
+      </para>
+      <para>is
+         <emphasis>not</emphasis>
+         the same as
+      </para>
+      <para>
+         <programlisting><![CDATA[Fqn<String> f = Fqn.fromString("/a/b/c");]]></programlisting>
+      </para>
+
+      <para>
+         The former will result in an Fqn with a single element, called "/a/b/c"
+         which hangs directly under the cache root. The latter will result
+         in a 3 element Fqn, where "c" idicates a child of "b", which is a child
+         of "a", and "a" hangs off the cache root. Another way to
+         look at it is that the "/" separarator is only parsed when it forms
+         part of a String passed in to
+         <literal>Fqn.fromString()</literal>
+         and not
+         otherwise.
+      </para>
+
+      <para>
+         The JBoss Cache API in the 1.x releases included many overloaded
+         convenience methods that took a string in the "/a/b/c" format in place
+         of an
+         <literal>Fqn</literal>
+         . In the interests of API simplicity, no
+         such convenience methods are available in the JBC 2.x API.
+      </para>
+
+   </section>
+
+   <section>
+      <title>Stopping and Destroying the Cache</title>
+      <para>
+         It is good practice to stop and destroy your cache when you are done
+         using it, particularly if it is a clustered cache and has thus
+         used a JGroups channel. Stopping and destroying a cache ensures
+         resources like the JGroups channel are properly cleaned up.
+      </para>
+
+      <programlisting>
+         cache.stop();
+         cache.destroy();
+      </programlisting>
+
+      <para>
+         Not also that a cache that has had
+         <literal>stop()</literal>
+         invoked
+         on it can be started again with a new call to
+         <literal>start()</literal>
+         .
+         Similarly, a cache that has had
+         <literal>destroy()</literal>
+         invoked
+         on it can be created again with a new call to
+         <literal>create()</literal>
+         (and then started again with a
+         <literal>start()</literal>
+         call).
+      </para>
+   </section>
+
+   <section>
+      <title>Cache Modes</title>
+      <para>
+         Although technically not part of the API, the
+         <emphasis>mode</emphasis>
+         in which the cache is configured to operate affects the cluster-wide
+         behavior of any
+         <literal>put</literal>
+         or
+         <literal>remove</literal>
+         operation, so we'll briefly mention the various modes here.
+      </para>
+      <para>
+         JBoss Cache modes are denoted by the
+         <literal>org.jboss.cache.config.Configuration.CacheMode</literal>
+         enumeration.
+         They consist of:
+         <itemizedlist>
+            <listitem>
+               <emphasis>LOCAL</emphasis>
+               - local, non-clustered cache. Local caches don't join a cluster and don't
+               communicate with other caches in a cluster. Therefore their contents don't need to be Serializable;
+               however, we recommend making them Serializable, allowing you the flexibility to change the cache mode at
+               any time.
+            </listitem>
+            <listitem>
+               <emphasis>REPL_SYNC</emphasis>
+               - synchronous replication. Replicated caches replicate all changes to the other
+               caches in the cluster. Synchronous replication means that changes are replicated and the caller blocks
+               until replication acknowledgements are received.
+            </listitem>
+            <listitem>
+               <emphasis>REPL_ASYNC</emphasis>
+               - asynchronous replication. Similar to REPL_SYNC above, replicated caches replicate
+               all changes to the other caches in the cluster. Being asynchronous, the caller does not block until
+               replication acknowledgements are received.
+            </listitem>
+            <listitem>
+               <emphasis>INVALIDATION_SYNC</emphasis>
+               - if a cache is configured for invalidation rather than replication,
+               every time data is changed in a cache other caches in the cluster
+               receive a message informing them that their data is now stale and should
+               be evicted from memory. This reduces replication overhead while still being able to invalidate stale data
+               on remote caches.
+            </listitem>
+            <listitem>
+               <emphasis>INVALIDATION_ASYNC</emphasis>
+               - as above, except this invalidation mode causes invalidation messages
+               to be broadcast asynchronously.
+            </listitem>
+         </itemizedlist>
+      </para>
+      <para>See the
+         <link linkend="clustering">chapter on Clustering</link>
+         for
+         more details on how the cache's mode affects behavior. See the
+         <link linkend="configuration">chapter on Configuration</link>
+         for info
+         on how to configure things like the cache's mode.
+      </para>
+   </section>
+
+   <section id="api.listener">
+      <title>
+         Adding a CacheListener
+      </title>
+      <para>
+         The
+         <literal>@org.jboss.cache.notifications.annotation.CacheListener</literal>
+         annotation is a convenient
+         mechanism for receiving notifications from a cache about events that happen in the cache. Classes annotated
+         with
+         <literal>@CacheListener</literal>
+         need to be public classes. In addition, the class needs to have one or
+         more methods annotated with one of the method-level annotations (in the
+         <literal>org.jboss.cache.notifications.annotation</literal>
+         package). Methods annotated as such need to be public, have a void return type, and accept a single parameter
+         of
+         type
+         <literal>org.jboss.cache.notifications.event.Event</literal>
+         or one of it's subtypes.
+
+         <itemizedlist>
+            <listitem>
+               <para>
+                  <literal>@CacheStarted</literal>
+                  - methods annotated such receive a notification when the cache is
+                  started. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.CacheStartedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@CacheStopped</literal>
+                  - methods annotated such receive a notification when the cache is
+                  stopped. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.CacheStoppedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeCreated</literal>
+                  - methods annotated such receive a notification when a node is
+                  created. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeCreatedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeRemoved</literal>
+                  - methods annotated such receive a notification when a node is
+                  removed. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeRemovedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeModified</literal>
+                  - methods annotated such receive a notification when a node is
+                  modified. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeModifiedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeMoved</literal>
+                  - methods annotated such receive a notification when a node is
+                  moved. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeMovedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeVisited</literal>
+                  - methods annotated such receive a notification when a node is
+                  started. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeVisitedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeLoaded</literal>
+                  - methods annotated such receive a notification when a node is
+                  loaded from a
+                  <literal>CacheLoader</literal>
+                  . Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeLoadedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeEvicted</literal>
+                  - methods annotated such receive a notification when a node is
+                  evicted from memory. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeEvictedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodeActivated</literal>
+                  - methods annotated such receive a notification when a node is
+                  activated. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodeActivatedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@NodePassivated</literal>
+                  - methods annotated such receive a notification when a node is
+                  passivated. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.NodePassivatedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@TransactionRegistered</literal>
+                  - methods annotated such receive a notification when the cache
+                  registers a
+                  <literal>javax.transaction.Synchronization</literal>
+                  with a registered transaction manager.
+                  Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.TransactionRegisteredEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@TransactionCompleted</literal>
+                  - methods annotated such receive a notification when the cache
+                  receives a commit or rollback call from a registered transaction manager.
+                  Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.TransactionCompletedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@ViewChanged</literal>
+                  - methods annotated such receive a notification when the group structure
+                  of the cluster changes. Methods need to accept a parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.ViewChangedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@CacheBlocked</literal>
+                  - methods annotated such receive a notification when the cluster
+                  requests that cache operations are blocked for a state transfer event. Methods need to accept a
+                  parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.CacheBlockedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>@CacheUnblocked</literal>
+                  - methods annotated such receive a notification when the cluster
+                  requests that cache operations are unblocked after a state transfer event. Methods need to accept a
+                  parameter type which is assignable from
+                  <literal>org.jboss.cache.notifications.event.CacheUnblockedEvent</literal>
+                  .
+               </para>
+            </listitem>
+
+         </itemizedlist>
+      </para>
+      <para>
+         Refer to the javadocs on the annotations as well as the
+         <literal>Event</literal>
+         subtypes
+         for details of what is passed in to your method, and when.
+      </para>
+      <para>
+         Example:
+         <programlisting><![CDATA[
+
+   @CacheListener
+   public class MyListener
+   {
+
+      @CacheStarted
+      @CacheStopped
+      public void cacheStartStopEvent(Event e)
+      {
+         switch (e.getType())
+         {
+            case Event.Type.CACHE_STARTED:
+               System.out.println("Cache has started");
+               break;
+            case Event.Type.CACHE_STOPPED:
+               System.out.println("Cache has stopped");
+               break;
+         }
+      }
+
+      @NodeCreated
+      @NodeRemoved
+      @NodeVisited
+      @NodeModified
+      @NodeMoved
+      public void logNodeEvent(NodeEvent ne)
+      {
+         log("An event on node " + ne.getFqn() + " has occured");
+      }
+   }
+
+         ]]></programlisting>
+      </para>
+   </section>
+
+   <section>
+      <title>Using Cache Loaders</title>
+      <para>
+         Cache loaders are an important part of JBoss Cache. They allow persistence of nodes to disk or to remote cache
+         clusters, and allow for passivation when caches run out of memory. In addition, cache loaders allow JBoss Cache
+         to perform 'warm starts', where in-memory state can be preloaded from persistent storage. JBoss Cache ships
+         with a number of cache loader implementations.
+         <itemizedlist>
+            <listitem>
+               <literal>org.jboss.cache.loader.FileCacheLoader</literal>
+               - a basic, filesystem based cache loader that persists data to disk. Non-transactional and not very
+               performant, but a very simple solution. Used mainly for testing and not recommended for production use.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.loader.JDBCCacheLoader</literal>
+               - uses a JDBC connection to store data. Connections could be created and maintained in an internal pool
+               (uses the c3p0 pooling library)
+               or from a configured DataSource. The database this CacheLoader connects to could be local or remotely
+               located.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.loader.BdbjeCacheLoader</literal>
+               - uses Oracle's BerkeleyDB file-based transactional database to persist data. Transactional and very
+               performant, but potentially restrictive license.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.loader.JdbmCacheLoader</literal>
+               - an upcoming open source alternative to the BerkeleyDB.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.loader.tcp.TcpCacheLoader</literal>
+               - uses a TCP socket to "persist" data to a remote cluster, using a "far cache" pattern.
+               <footnote>
+                  <para>http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossClusteringPatternFarCache</para>
+               </footnote>
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.loader.ClusteredCacheLoader</literal>
+               - used as a "read-only" CacheLoader, where other nodes in the cluster are queried for state.
+            </listitem>
+         </itemizedlist>
+         These CacheLoaders, along with advanced aspects and tuning issues, are discussed in the
+         <link linkend="cache_loaders">chapter dedicated to CacheLoaders</link>
+         .
+      </para>
+   </section>
+
+   <section>
+      <title>Using Eviction Policies</title>
+      <para>
+         Eviction policies are the counterpart to CacheLoaders. They are necessary to make sure the cache does not run
+         out of memory and when the cache starts to fill,
+         the eviction algorithm running in a separate thread offloads in-memory state to the CacheLoader and frees up
+         memory. Eviction policies can be configured
+         on a per-region basis, so different subtrees in the cache could have different eviction preferences.
+
+         JBoss Cache ships with several eviction policies:
+         <itemizedlist>
+            <listitem>
+               <literal>org.jboss.cache.eviction.LRUPolicy</literal>
+               - an eviction policy that evicts the least recently used nodes when thresholds are hit.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.eviction.LFUPolicy</literal>
+               - an eviction policy that evicts the least frequently used nodes when thresholds are hit.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.eviction.MRUPolicy</literal>
+               - an eviction policy that evicts the most recently used nodes when thresholds are hit.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.eviction.FIFOPolicy</literal>
+               - an eviction policy that creates a first-in-first-out queue and evicts the oldest nodes when thresholds
+               are hit.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.eviction.ExpirationPolicy</literal>
+               - an eviction policy that selects nodes for eviction based on an expiry time each node is configured
+               with.
+            </listitem>
+            <listitem>
+               <literal>org.jboss.cache.eviction.ElementSizePolicy</literal>
+               - an eviction policy that selects nodes for eviction based on the number of key/value pairs held in the
+               node.
+            </listitem>
+         </itemizedlist>
+         Detailed configuration and implementing custom eviction policies are discussed in the
+         <link linkend="eviction_policies">chapter dedicated to eviction policies.</link>
+         .
+      </para>
+   </section>
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/cache_loaders.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,1325 @@
+<chapter id="cache_loaders">
+   <title>Cache Loaders</title>
+   <para>JBoss Cache can use a
+      <literal>CacheLoader</literal>
+      to back up the in-memory cache to a backend datastore.
+      If JBoss Cache is configured with a cache loader, then the following features are provided:
+      <itemizedlist>
+         <listitem>Whenever a cache element is accessed, and that element is not in
+            the cache (e.g. due to eviction or due to server restart), then the cache loader transparently
+            loads the element into the cache if found in the backend
+            store.
+         </listitem>
+
+         <listitem>Whenever an element is modified, added or removed, then that
+            modification is persisted in the backend store via the cache loader. If
+            transactions are used, all modifications created within a transaction
+            are persisted. To this end, the
+            <literal>CacheLoader</literal>
+            takes part in the two
+            phase commit protocol run by the transaction manager, although it does not do so explicitly.
+         </listitem>
+      </itemizedlist>
+   </para>
+
+   <section>
+      <title>The CacheLoader Interface and Lifecycle</title>
+
+      <figure>
+         <title>The CacheLoader interface</title>
+
+         <mediaobject>
+            <imageobject>
+               <imagedata fileref="CacheLoader.png"/>
+            </imageobject>
+         </mediaobject>
+      </figure>
+
+
+      <para>The interaction between JBoss Cache and a
+         <literal>CacheLoader</literal>
+         implementation is as follows. When
+         <literal>CacheLoaderConfiguration</literal>
+         (see below) is non-null, an
+         instance of each configured
+         <literal>CacheLoader</literal>
+         is created when the cache is created, and started when the cache is started.
+      </para>
+
+      <para>
+         <literal>CacheLoader.create()</literal>
+         and
+         <literal>CacheLoader.start()</literal>
+         are called when the cache is
+         started. Correspondingly,
+         <literal>stop()</literal>
+         and
+         <literal>destroy()</literal>
+         are called when the cache is
+         stopped.
+      </para>
+
+      <para>Next,
+         <literal>setConfig()</literal>
+         and
+         <literal>setCache()</literal>
+         are called. The latter can be used to
+         store a reference to the cache, the former is used to configure this
+         instance of the
+         <literal>CacheLoader</literal>
+         . For example, here a database cache loader
+         could establish a connection to the database.
+      </para>
+
+      <para>The
+         <literal>CacheLoader</literal>
+         interface has a set of methods that are called
+         when no transactions are used:
+         <literal>get()</literal>
+         ,
+         <literal>put()</literal>
+         ,
+         <literal>remove()</literal>
+         and
+         <literal>removeData()</literal>
+         : they get/set/remove the value
+         immediately. These methods are described as javadoc comments in the
+         interface.
+      </para>
+
+      <para>Then there are three methods that are used with transactions:
+         <literal>prepare()</literal>
+         ,
+         <literal>commit()</literal>
+         and
+         <literal>rollback()</literal>
+         . The
+         <literal>prepare()</literal>
+         method
+         is called when a transaction is to be committed. It has a transaction
+         object and a list of modfications as argument. The transaction object
+         can be used as a key into a hashmap of transactions, where the values
+         are the lists of modifications. Each modification list has a number of
+         <literal>Modification</literal>
+         elements, which represent the changes
+         made to a cache for a given transaction. When
+         <literal>prepare()</literal>
+         returns successfully, then the cache loader
+         <emphasis>must</emphasis>
+         be able to commit (or rollback) the
+         transaction successfully.
+      </para>
+
+      <para>
+         JBoss Cache takes care of calling prepare(), commit()
+         and rollback() on the cache loaders at the right time.
+      </para>
+
+      <para>The
+         <literal>commit()</literal>
+         method tells the cache loader to
+         commit the transaction, and the
+         <literal>rollback()</literal>
+         method
+         tells the cache loader to discard the changes associated with that
+         transaction.
+      </para>
+
+      <para>See the javadocs on this interface for a detailed explanation on each method and the contract
+         implementations
+         would need to fulfil.
+      </para>
+
+   </section>
+
+   <section>
+      <title>Configuration</title>
+
+      <para>Cache loaders are configured as follows in the JBoss Cache XML
+         file. Note that you can define several cache loaders, in
+         a chain. The impact is that the cache will look at all of the cache
+         loaders in the order they've been configured, until it finds a valid,
+         non-null element of data. When performing writes, all cache loaders are
+         written to (except if the
+         <literal>ignoreModifications</literal>
+         element has been set to
+         <literal>true</literal>
+         for a specific cache loader. See the configuration section below for
+         details.
+      </para>
+
+      <programlisting>
+         <![CDATA[
+
+...
+
+<!-- Cache loader config block -->
+<attribute name="CacheLoaderConfiguration">
+   <config>
+      <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+      <passivation>false</passivation>
+      <!-- comma delimited FQNs to preload -->
+      <preload>/</preload>
+      <!-- are the cache loaders shared in a cluster? -->
+      <shared>false</shared>
+
+      <!-- we can now have multiple cache loaders, which get chained -->
+      <!-- the 'cacheloader' element may be repeated -->
+      <cacheloader>
+
+         <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+
+         <!-- properties to pass in to the cache loader -->
+         <properties>
+            cache.jdbc.driver=com.mysql.jdbc.Driver
+            cache.jdbc.url=jdbc:mysql://localhost:3306/jbossdb
+            cache.jdbc.user=root
+            cache.jdbc.password=
+            cache.jdbc.sql-concat=concat(1,2)
+         </properties>
+
+         <!-- whether the cache loader writes are asynchronous -->
+         <async>false</async>
+
+         <!-- only one cache loader in the chain may set fetchPersistentState to true.
+              An exception is thrown if more than one cache loader sets this to true. -->
+         <fetchPersistentState>true</fetchPersistentState>
+
+         <!-- determines whether this cache loader ignores writes - defaults to false. -->
+         <ignoreModifications>false</ignoreModifications>
+
+         <!-- if set to true, purges the contents of this cache loader when the cache starts up.
+              Defaults to false. -->
+         <purgeOnStartup>false</purgeOnStartup>
+
+         <!-- defines the cache loader as a singleton store where only the coordinator of the
+              cluster will store modifications. -->
+         <singletonStore>
+            <!-- if true, singleton store functionality is enabled, defaults to false -->
+            <enabled>false</enabled>
+
+            <!-- implementation class for singleton store functionality which must extend
+                 org.jboss.cache.loader.AbstractDelegatingCacheLoader. Default implementation
+                 is org.jboss.cache.loader.SingletonStoreCacheLoader -->
+            <class>org.jboss.cache.loader.SingletonStoreCacheLoader</class>
+
+            <!-- properties and default values for the default singleton store functionality
+                 implementation -->
+            <properties>
+               pushStateWhenCoordinator=true
+               pushStateWhenCoordinatorTimeout=20000
+            </properties>
+         </singletonStore>
+      </cacheloader>
+
+   </config>
+</attribute>
+]]>
+      </programlisting>
+
+      <para>The
+         <literal>class</literal>
+         element defines the
+         class of the cache loader implementation. (Note that, because of a bug in
+         the properties editor in JBoss AS, backslashes in variables for Windows
+         filenames might not get expanded correctly, so replace="false" may be
+         necessary). Note that an implementation of cache loader has to have an empty
+         constructor.
+      </para>
+
+      <para>The
+         <literal>properties</literal>
+         element defines a configuration
+         specific to the given implementation. The filesystem-based
+         implementation for example defines the root directory to be used,
+         whereas a database implementation might define the database URL, name
+         and password to establish a database connection. This configuration is
+         passed to the cache loader implementation via
+         <literal>CacheLoader.setConfig(Properties)</literal>
+         . Note that
+         backspaces may have to be escaped.
+      </para>
+
+      <para>
+         <literal>preload</literal>
+         allows us to define a list of nodes, or
+         even entire subtrees, that are visited by the cache on startup, in order
+         to preload the data associated with those nodes. The default ("/") loads
+         the entire data available in the backend store into the cache, which is
+         probably not a good idea given that the data in the backend store might
+         be large. As an example,
+         <literal>/a,
+            /product/catalogue
+         </literal>
+         loads the subtrees
+         <literal>/a</literal>
+         and
+         <literal>/product/catalogue</literal>
+         into the cache, but nothing
+         else. Anything else is loaded lazily when accessed. Preloading makes
+         sense when one anticipates using elements under a given subtree
+         frequently.
+         .
+      </para>
+
+      <para>
+         <literal>fetchPersistentState</literal>
+         determines whether or not
+         to fetch the persistent state of a cache when joining a cluster. Only
+         one configured cache loader may set this property to true; if more than
+         one cache loader does so, a configuration exception will be thrown when
+         starting your cache service.
+      </para>
+
+      <para>
+         <literal>async</literal>
+         determines whether writes to the cache
+         loader block until completed, or are run on a separate thread so writes
+         return immediately. If this is set to true, an instance of
+         <literal>org.jboss.cache.loader.AsyncCacheLoader</literal>
+         is
+         constructed with an instance of the actual cache loader to be used. The
+         <literal>AsyncCacheLoader</literal>
+         then delegates all requests to the
+         underlying cache loader, using a separate thread if necessary. See the
+         Javadocs on
+         <literal>AsyncCacheLoader</literal>
+         for more details. If unspecified, the
+         <literal>async</literal>
+         element
+         defaults to
+         <literal>false</literal>
+         .
+      </para>
+
+      <para>
+         <emphasis role="bold">Note on using the
+            <literal>async</literal>
+            element:
+         </emphasis>
+         there is always the possibility of dirty reads since
+         all writes are performed asynchronously, and it is thus impossible to
+         guarantee when (and even if) a write succeeds. This needs to be kept in
+         mind when setting the
+         <literal>async</literal>
+         element to true.
+      </para>
+
+      <para>
+         <literal>ignoreModifications</literal>
+         determines whether write
+         methods are pushed down to the specific cache loader. Situations may
+         arise where transient application data should only reside in a file
+         based cache loader on the same server as the in-memory cache, for
+         example, with a further shared
+         <literal>JDBCCacheLoader</literal>
+         used by all servers in
+         the network. This feature allows you to write to the 'local' file cache
+         loader but not the shared
+         <literal>JDBCCacheLoader</literal>
+         . This property defaults to
+         <literal>false</literal>
+         , so writes are propagated to all cache loaders
+         configured.
+      </para>
+
+      <para>
+         <literal>purgeOnStatup</literal>
+         empties the specified cache loader
+         (if
+         <literal>ignoreModifications</literal>
+         is
+         <literal>false</literal>
+         )
+         when the cache loader starts up.
+      </para>
+
+      <para>
+         <literal>shared</literal>
+         indicates that the cache loader is shared among different cache instances, for example where all instances in a
+         cluster use the same JDBC settings t talk to the same remote, shared database. Setting this to
+         <literal>true</literal>
+         prevents repeated and unnecessary writes of the same data to the cache loader by different cache instances.
+         Default value is
+         <literal>false</literal>
+         .
+      </para>
+
+      <section>
+         <title>Singleton Store Configuration</title>
+
+         <para>
+            <literal>singletonStore</literal>
+            element enables modifications to be stored by only one node in the cluster,
+            the coordinator. Essentially, whenever any data comes in to some node
+            it is always replicated so as to keep the caches' in-memory states in
+            sync; the coordinator, though, has the sole responsibility of pushing
+            that state to disk. This functionality can be activated setting the
+            <literal>enabled</literal>
+            subelement to true in all nodes, but
+            again only the coordinator of the cluster will store the modifications
+            in the underlying cache loader as defined in
+            <literal>cacheloader</literal>
+            element. You cannot define a cache loader as
+            <literal>shared</literal>
+            and with
+            <literal>singletonStore</literal>
+            enabled at the same time.
+            Default value for
+            <literal>enabled</literal>
+            is
+            <literal>false</literal>
+            .
+         </para>
+
+         <para>            
+            Optionally, within the
+            <literal>singletonStore</literal>
+            element, you can define a
+            <literal>class</literal>
+            element that specifies the implementation class that provides the
+            singleton store functionality. This class must extend
+            <literal>org.jboss.cache.loader.AbstractDelegatingCacheLoader</literal>
+            , and if absent, it defaults to
+            <literal>org.jboss.cache.loader.SingletonStoreCacheLoader</literal>
+            .
+         </para>
+
+         <para>
+            The
+            <literal>properties</literal>
+            subelement defines properties that allow changing the behaivour of the
+            class providing the singleton store functionality. By default,
+            <literal>pushStateWhenCoordinator</literal>
+            and
+            <literal>pushStateWhenCoordinatorTimeout</literal>
+            properties have been defined, but more could be added as
+            required by the user-defined class providing singleton store
+            functionality.
+         </para>
+
+         <para>
+            <literal>pushStateWhenCoordinator</literal>
+            allows the in-memory
+            state to be pushed to the cache store when a node becomes the
+            coordinator, as a result of the new election of coordinator due to a
+            cluster topology change. This can be very useful in situations where the
+            coordinator crashes and there's a gap in time until the new coordinator
+            is elected. During this time, if this property was set to
+            <literal>false</literal>
+            and the
+            cache was updated, these changes would never be persisted. Setting this
+            property to
+            <literal>true</literal>
+            would ensure that any changes during this process also
+            get stored in the cache loader. You would also want to set this property
+            to
+            <literal>true</literal>
+            if each node's cache loader is configured with a different
+            location. Default value is
+            <literal>true</literal>
+            .
+         </para>
+
+         <para>
+            <literal>pushStateWhenCoordinatorTimeout</literal>
+            is only relevant if
+            <literal>pushStateWhenCoordinator</literal>
+            is
+            <literal>true</literal>
+            in which case, sets the maximum number of milliseconds that the process
+            of pushing the in-memory state to the underlying cache loader should take,
+            reporting a
+            <literal>PushStateException</literal>
+            if exceeded. Default value is 20000.
+         </para>
+   
+         <para>
+            <emphasis role="bold">Note on using the
+               <literal>singletonStore</literal>
+               element:
+            </emphasis>
+            setting
+            up a cache loader as a singleton and using cache passivation (via
+            evictions) can lead to undesired effects. If a node is to be passivated
+            as a result of an eviction, while the cluster is in the process of
+            electing a new coordinator, the data will be lost. This is because no
+            coordinator is active at that time and therefore, none of the nodes in
+            the cluster will store the passivated node. A new coordinator is elected
+            in the cluster when either, the coordinator leaves the cluster, the
+            coordinator crashes or stops responding.
+         </para>
+      </section>
+   </section>
+
+   <section id="cl.impls">
+
+      <title>Shipped Implementations</title>
+
+      <para>The currently available implementations shipped with JBoss Cache are as follows.</para>
+
+      <section>
+         <title>File system based cache loaders</title>
+         <para>
+            JBoss Cache ships with several cache loaders that utilise the file system as a data store. They all require
+            that the
+            <literal><![CDATA[<cacheloader><properties>]]></literal>
+            configuration element
+            contains a
+            <literal>location</literal>
+            property, which maps to a directory to be used as a persistent store.
+            (e.g.,
+            <literal>location=/tmp/myDataStore</literal>
+            ). Used mainly for testing and not recommended for production use.
+         </para>
+         <itemizedlist>
+            <listitem>
+               <para>
+                  <literal>FileCacheLoader</literal>
+                  , which is a simple filesystem-based implementation. By default, this cache
+                  loader checks for any potential character portability issues in the
+                  location or tree node names, for example invalid characters, producing
+                  warning messages. These checks can be disabled adding
+                  <literal>check.character.portability</literal>
+                  property to the
+                  <literal><![CDATA[<properties>]]></literal>
+                  element and setting it to
+                  <literal>false</literal>
+                  (e.g.,
+                  <literal>check.character.portability=false</literal>
+                  ).
+               </para>
+               <para>
+                  The FileCacheLoader has some severe limitations which restrict it's use in a production
+                  environment, or if used in such an environment, it should be used with due care and sufficient
+                  understanding of these limitations.
+                  <itemizedlist>
+                     <listitem>Due to the way the FileCacheLoader represents a tree structure on disk (directories and
+                        files) traversal is inefficient for deep trees.
+                     </listitem>
+                     <listitem>Usage on shared filesystems like NFS, Windows shares, etc. should be avoided as these do
+                        not implement proper file locking and can cause data corruption.
+                     </listitem>
+                     <listitem>Usage with an isolation level of NONE can cause corrupt writes as multiple threads
+                        attempt to write to the same file.
+                     </listitem>
+                     <listitem>File systems are inherently not transactional, so when attempting to use your cache in a
+                        transactional context, failures when writing to the file (which happens during the commit phase)
+                        cannot be recovered.
+                     </listitem>
+                  </itemizedlist>
+
+                  As a rule of thumb, it is recommended that the FileCacheLoader not be used in a highly concurrent,
+                  transactional or stressful environment, and it's use is restricted to testing.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>BdbjeCacheLoader</literal>
+                  , which is a cache loader implementation based on the Oracle/Sleepycat's
+                  <ulink url="http://www.oracle.com/database/berkeley-db/index.html">BerkeleyDB Java Edition</ulink>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>
+                  <literal>JdbmCacheLoader</literal>
+                  , which is a cache loader
+                  implementation based on the
+                  <ulink url="http://jdbm.sourceforge.net/">JDBM engine</ulink>
+                  , a fast and free alternative to
+                  BerkeleyDB.
+               </para>
+            </listitem>
+         </itemizedlist>
+
+         <para>Note that the BerkeleyDB implementation is much more efficient than
+            the filesystem-based implementation, and provides transactional
+            guarantees, but requires a commercial license if distributed with an
+            application (see http://www.oracle.com/database/berkeley-db/index.html for
+            details).
+         </para>
+
+      </section>
+
+      <section>
+         <title>Cache loaders that delegate to other caches</title>
+         <itemizedlist>
+            <listitem>
+               <para>
+                  <literal>LocalDelegatingCacheLoader</literal>
+                  , which enables
+                  loading from and storing to another local (same JVM) cache.
+               </para>
+            </listitem>
+            <listitem>
+               <para>
+                  <literal>ClusteredCacheLoader</literal>
+                  , which allows querying
+                  of other caches in the same cluster for in-memory data via the same
+                  clustering protocols used to replicate data. Writes are
+                  <emphasis>not</emphasis>
+                  'stored' though, as replication would
+                  take care of any updates needed. You need to specify a property
+                  called
+                  <literal>timeout</literal>
+                  , a long value telling the cache
+                  loader how many milliseconds to wait for responses from the cluster
+                  before assuming a null value. For example,
+                  <literal>timeout = 3000</literal>
+                  would use a timeout value of 3 seconds.
+               </para>
+            </listitem>
+         </itemizedlist>
+      </section>
+
+
+      <section id="cl.jdbc">
+         <title>JDBCCacheLoader</title>
+
+         <para>JBossCache is distributed with a JDBC-based cache loader
+            implementation that stores/loads nodes' state into a relational database.
+            The implementing class is
+            <literal>org.jboss.cache.loader.JDBCCacheLoader</literal>
+            .
+         </para>
+
+         <para>The current implementation uses just one table. Each row in the table
+            represents one node and contains three columns:
+            <itemizedlist>
+               <listitem>column for
+                  <literal>Fqn</literal>
+                  (which is also a primary key
+                  column)
+               </listitem>
+
+               <listitem>column for node contents (attribute/value
+                  pairs)
+               </listitem>
+
+               <listitem>column for parent
+                  <literal>Fqn</literal>
+               </listitem>
+            </itemizedlist>
+         </para>
+
+         <para>
+            <literal>Fqn</literal>
+            's are stored as strings. Node content is stored
+            as a BLOB.
+            <emphasis>WARNING:</emphasis>
+            JBoss Cache does not impose any
+            limitations on the types of objects used in
+            <literal>Fqn</literal>
+            but this implementation of
+            cache loader requires
+            <literal>Fqn</literal>
+            to contain only objects of type
+            <literal>java.lang.String</literal>
+            . Another limitation for
+            <literal>Fqn</literal>
+            is its
+            length. Since
+            <literal>Fqn</literal>
+            is a primary key, its default column type is
+            <literal>VARCHAR</literal>
+            which can store text values up to some
+            maximum length determined by the database in use.
+         </para>
+
+         <para>See
+            <ulink
+                  url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JDBCCacheLoader">
+               http://wiki.jboss.org/wiki/Wiki.jsp?page=JDBCCacheLoader
+            </ulink>
+            for configuration tips with specific database systems.
+         </para>
+
+         <section>
+            <title>JDBCCacheLoader configuration</title>
+
+            <section>
+               <title>Table configuration</title>
+
+               <para>Table and column names as well as column types are
+                  configurable with the following properties.
+                  <itemizedlist>
+                     <listitem>
+                        <emphasis>cache.jdbc.table.name</emphasis>
+                        - the name
+                        of the table. The default value is 'jbosscache'.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.table.primarykey</emphasis>
+                        - the
+                        name of the primary key for the table. The default value is
+                        'jbosscache_pk'.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.table.create</emphasis>
+                        - can be
+                        true or false. Indicates whether to create the table during startup.
+                        If true, the table is created if it doesn't already exist. The
+                        default value is true.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.table.drop</emphasis>
+                        - can be
+                        true or false. Indicates whether to drop the table during shutdown. The
+                        default value is true.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.fqn.column</emphasis>
+                        - FQN
+                        column name. The default value is 'fqn'.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.fqn.type</emphasis>
+                        - FQN column
+                        type. The default value is 'varchar(255)'.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.node.column</emphasis>
+                        - node
+                        contents column name. The default value is 'node'.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.node.type</emphasis>
+                        - node
+                        contents column type. The default value is 'blob'. This type must specify
+                        a valid binary data type for the database being used.
+                     </listitem>
+                  </itemizedlist>
+               </para>
+            </section>
+
+            <section>
+               <title>DataSource</title>
+
+               <para>If you are using JBossCache in a managed environment (e.g., an
+                  application server) you can specify the JNDI name of the DataSource
+                  you want to use.
+                  <itemizedlist>
+                     <listitem>
+                        <emphasis>cache.jdbc.datasource</emphasis>
+                        - JNDI name
+                        of the DataSource. The default value is
+                        <literal>java:/DefaultDS</literal>
+                        .
+                     </listitem>
+                  </itemizedlist>
+               </para>
+            </section>
+
+            <section>
+               <title>JDBC driver</title>
+
+               <para>If you are
+                  <emphasis>not</emphasis>
+                  using DataSource you have
+                  the following properties to configure database access using a JDBC
+                  driver.
+                  <itemizedlist>
+                     <listitem>
+                        <emphasis>cache.jdbc.driver</emphasis>
+                        - fully
+                        qualified JDBC driver name.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.url</emphasis>
+                        - URL to connect
+                        to the database.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.user</emphasis>
+                        - user name to
+                        connect to the database.
+                     </listitem>
+
+                     <listitem>
+                        <emphasis>cache.jdbc.password</emphasis>
+                        - password to
+                        connect to the database.
+                     </listitem>
+                  </itemizedlist>
+               </para>
+            </section>
+
+            <section>
+               <title>c3p0 connection pooling</title>
+
+               <para>JBoss Cache implements JDBC connection pooling when running outside of an application server
+                  standalone using
+                  the c3p0:JDBC DataSources/Resource Pools library. In order to enable it, just edit the following
+                  property:
+                  <itemizedlist>
+                     <listitem>
+                        <emphasis>cache.jdbc.connection.factory</emphasis>
+                        - Connection factory class name.
+                        If not set, it defaults to standard non-pooled implementation. To enable c3p0 pooling, just set
+                        the
+                        connection factory class for c3p0. See example below.
+                     </listitem>
+                  </itemizedlist>
+               </para>
+
+               <para>You can also set any c3p0 parameters in the same cache loader properties section but don't forget
+                  to
+                  start the property name with 'c3p0.'. To find a list of available properties, please check the
+                  c3p0 documentation for the c3p0 library version distributed in
+                  <ulink url="http://sourceforge.net/projects/c3p0">c3p0:JDBC DataSources/Resource Pools</ulink>
+                  .
+                  Also, in order to provide quick and easy way to try out different pooling
+                  parameters, any of these properties can be set via a System property overriding any values these
+                  properties might have in the JBoss Cache XML configuration file, for example:
+                  <literal>-Dc3p0.maxPoolSize=20</literal>
+                  .
+                  If a c3p0 property is not defined in either the configuration file or as a System property, default
+                  value, as indicated in the c3p0 documentation, will apply.
+               </para>
+            </section>
+
+            <section>
+               <title>Configuration example</title>
+
+               <para>Below is an example of a JDBCCacheLoader using Oracle as
+                  database. The CacheLoaderConfiguration XML element contains an
+                  arbitrary set of properties which define the database-related
+                  configuration.
+               </para>
+
+               <para>
+                  <programlisting>
+                     <![CDATA[
+<attribute name="CacheLoaderConfiguration">
+<config>
+   <passivation>false</passivation>
+   <preload>/some/stuff</preload>
+   <cacheloader>
+      <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+
+      <properties>
+         cache.jdbc.table.name=jbosscache
+         cache.jdbc.table.create=true
+         cache.jdbc.table.drop=true
+         cache.jdbc.table.primarykey=jbosscache_pk
+         cache.jdbc.fqn.column=fqn
+         cache.jdbc.fqn.type=varchar(255)
+         cache.jdbc.node.column=node
+         cache.jdbc.node.type=blob
+         cache.jdbc.parent.column=parent
+         cache.jdbc.driver=oracle.jdbc.OracleDriver
+         cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
+         cache.jdbc.user=SCOTT
+         cache.jdbc.password=TIGER
+         cache.jdbc.sql-concat=concat(1,2)
+      </properties>
+
+      <async>false</async>
+      <fetchPersistentState>true</fetchPersistentState>
+      <ignoreModifications>false</ignoreModifications>
+      <purgeOnStartup>false</purgeOnStartup>
+   </cacheloader>
+</config>
+</attribute>
+]]>
+                  </programlisting>
+               </para>
+
+               <para>As an alternative to configuring the entire JDBC connection,
+                  the name of an existing data source can be given:
+               </para>
+
+               <programlisting>
+                  <![CDATA[
+<attribute name="CacheLoaderConfiguration">
+<config>
+   <passivation>false</passivation>
+   <preload>/some/stuff</preload>
+   <cacheloader>
+      <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+
+      <properties>
+         cache.jdbc.datasource=java:/DefaultDS
+      </properties>
+
+      <async>false</async>
+      <fetchPersistentState>true</fetchPersistentState>
+      <ignoreModifications>false</ignoreModifications>
+      <purgeOnStartup>false</purgeOnStartup>
+   </cacheloader>
+</config>
+</attribute>
+]]>
+               </programlisting>
+
+               <para>Cconfiguration example for a cache loader using c3p0 JDBC connection pooling:</para>
+
+               <programlisting>
+                  <![CDATA[
+<attribute name="CacheLoaderConfiguration">
+<config>
+   <passivation>false</passivation>
+   <preload>/some/stuff</preload>
+   <cacheloader>
+      <class>org.jboss.cache.loader.JDBCCacheLoader</class>
+
+      <properties>
+         cache.jdbc.table.name=jbosscache
+         cache.jdbc.table.create=true
+         cache.jdbc.table.drop=true
+         cache.jdbc.table.primarykey=jbosscache_pk
+         cache.jdbc.fqn.column=fqn
+         cache.jdbc.fqn.type=varchar(255)
+         cache.jdbc.node.column=node
+         cache.jdbc.node.type=blob
+         cache.jdbc.parent.column=parent
+         cache.jdbc.driver=oracle.jdbc.OracleDriver
+         cache.jdbc.url=jdbc:oracle:thin:@localhost:1521:JBOSSDB
+         cache.jdbc.user=SCOTT
+         cache.jdbc.password=TIGER
+         cache.jdbc.sql-concat=concat(1,2)
+         cache.jdbc.connection.factory=org.jboss.cache.loader.C3p0ConnectionFactory
+         c3p0.maxPoolSize=20
+         c3p0.checkoutTimeout=5000
+      </properties>
+
+      <async>false</async>
+      <fetchPersistentState>true</fetchPersistentState>
+      <ignoreModifications>false</ignoreModifications>
+      <purgeOnStartup>false</purgeOnStartup>
+   </cacheloader>
+</config>
+</attribute>
+]]>
+               </programlisting>
+
+            </section>
+         </section>
+      </section>
+
+      <section id="cl.tcp">
+         <title>TcpDelegatingCacheLoader</title>
+
+         <para>This cache loader allows to delegate loads and stores to another
+            instance of JBoss Cache, which could reside (a) in the same address
+            space, (b) in a different process on the same host, or (c) in a
+            different process on a different host.
+         </para>
+
+         <para>A TcpDelegatingCacheLoader talks to a remote
+            <literal>org.jboss.cache.loader.tcp.TcpCacheServer</literal>
+            ,
+            which can be a standalone process started on the command line, or embedded as an MBean inside
+            JBoss AS. The
+            <literal>TcpCacheServer</literal>
+            has a reference to another JBoss Cache instance, which
+            it can create itself, or which is given to it (e.g. by JBoss, using
+            dependency injection).
+         </para>
+
+         <para>The TcpDelegatingCacheLoader is configured with the host and
+            port of the remote TcpCacheServer, and uses this to communicate to
+            it.
+         </para>
+
+         <para>The configuration looks as follows:</para>
+
+         <programlisting>
+            <![CDATA[
+<attribute name="CacheLoaderConfiguration">
+<config>
+   <cacheloader>
+      <class>org.jboss.cache.loader.TcpDelegatingCacheLoader</class>
+      <properties>
+         host=myRemoteServer
+         port=7500
+      </properties>
+   </cacheloader>
+</config>
+</attribute>
+]]>
+         </programlisting>
+
+         <para>This means this instance of JBoss Cache will delegate all load
+            and store requests to the remote TcpCacheServer running on
+            <literal>myRemoteServer:7500</literal>
+            .
+         </para>
+
+         <para>A typical use case could be multiple replicated instances of
+            JBoss Cache in the same cluster, all delegating to the same
+            TcpCacheServer instance. The TcpCacheServer might itself delegate to a
+            database via JDBCCacheLoader, but the point here is that - if we have
+            5 nodes all accessing the same dataset - they will load the data from
+            the TcpCacheServer, which has do execute one SQL statement per
+            unloaded data set. If the nodes went directly to the database, then
+            we'd have the same SQL executed multiple times. So TcpCacheServer
+            serves as a natural cache in front of the DB (assuming that a network
+            round trip is faster than a DB access (which usually also include a
+            network round trip)).
+         </para>
+
+         <para>To alleviate single point of failure, we could configure several cache loaders.
+            The first cache loader is a ClusteredCacheLoader, the second a TcpDelegatingCacheLoader, and the
+            last a JDBCacheLoader, effectively defining our cost of access to a
+            cache in increasing order.
+         </para>
+
+      </section>
+
+      <section id="cl.transforming">
+         <title>Transforming Cache Loaders</title>
+
+         <para>The way cached data is written to
+            <literal>FileCacheLoader</literal>
+            and
+            <literal>JDBCCacheLoader</literal>
+            based cache stores has changed in JBoss Cache 2.0 in such way that
+            these cache loaders now write and read data using the same marhalling framework used to replicate data
+            accross the network. Such change is trivial for replication purpouses as it just requires the rest of the
+            nodes to understand this format. However, changing the format of the data in cache stores brings up a new
+            problem: how do users, which have their data stored in JBoss Cache 1.x.x format, migrate their stores to
+            JBoss Cache 2.0 format?
+         </para>
+
+         <para>With this in mind, JBoss Cache 2.0 comes with two cache loader implementations called
+            <literal>org.jboss.cache.loader.TransformingFileCacheLoader</literal>
+            and
+            <literal>org.jboss.cache.loader.TransformingJDBCCacheLoader</literal>
+            located within the optional
+            jbosscache-cacheloader-migration.jar file. These are one-off cache loaders that read data from the
+            cache store in JBoss Cache 1.x.x format and write data to cache stores in JBoss Cache 2.0 format.
+         </para>
+
+         <para>The idea is for users to modify their existing cache configuration file(s) momentarily to use these
+            cache loaders and for them to create a small Java application that creates an instance of this cache,
+            recursively reads the entire cache and writes the data read back into the cache. Once the data is
+            transformed, users can revert back to their original cache configuration file(s). In order to help the users
+            with this task, a cache loader migration example has been constructed which can be located under the
+            <literal>examples/cacheloader-migration</literal>
+            directory within the JBoss Cache distribution. This
+            example, called
+            <literal>examples.TransformStore</literal>
+            , is independent of the actual data stored in
+            the cache as it writes back whatever it was read recursively. It is highly recommended that anyone
+            interested in porting their data run this example first, which contains a
+            <literal>readme.txt</literal>
+            file with detailed information about the example itself, and also use it as base for their own application.
+         </para>
+
+      </section>
+
+   </section>
+
+
+   <section id="cl.pass">
+      <title>Cache Passivation</title>
+
+      <para>A cache loader can be used to enforce node passivation and
+         activation on eviction in a cache.
+      </para>
+
+      <para>
+         <emphasis>Cache Passivation</emphasis>
+         is the process of removing
+         an object from in-memory cache and writing it to a secondary data store
+         (e.g., file system, database) on eviction.
+         <emphasis>Cache
+            Activation
+         </emphasis>
+         is the process of restoring an object from the
+         data store into the in-memory cache when it's needed to be used. In both
+         cases, the configured cache loader will be used to read from the data
+         store and write to the data store.
+      </para>
+
+      <para>When an eviction policy in effect evicts a node
+         from the cache, if passivation is enabled, a notification that the node
+         is being passivated will be emitted to the cache listeners and the
+         node and its children will be stored in the cache loader store. When a
+         user attempts to retrieve a node that was evicted earlier, the node is loaded
+         (lazy loaded) from the cache loader store into memory. When
+         the node and its children have been loaded, they're removed from the
+         cache loader and a notification is emitted to the cache listeners
+         that the node has been activated.
+      </para>
+
+      <para>To enable cache passivation/activation, you can set
+         <literal>passivation</literal>
+         to true. The default is
+         <literal>false</literal>
+         .
+         When passivation is used, only the first cache loader configured is
+         used and all others are ignored.
+      </para>
+   </section>
+
+   <section>
+      <title>Strategies</title>
+      <para>
+         This section discusses different patterns of combining different cache loader types and configuration
+         options to achieve specific outcomes.
+      </para>
+
+      <section>
+         <title>Local Cache With Store</title>
+
+         <para>This is the simplest case. We have a JBoss Cache instance, whose
+            cache mode is
+            <literal>LOCAL</literal>
+            , therefore no replication is going
+            on. The cache loader simply loads non-existing elements from the store
+            and stores modifications back to the store. When the cache is started,
+            depending on the
+            <literal>preload</literal>
+            element, certain data can
+            be preloaded, so that the cache is partly warmed up.
+         </para>
+      </section>
+
+      <section>
+         <title>Replicated Caches With All Caches Sharing The Same Store</title>
+
+         <para>The following figure shows 2 JBoss Cache instances sharing the same
+            backend store:
+         </para>
+
+         <figure>
+            <title>2 nodes sharing a backend store</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="SharedCacheLoader.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+         <para>Both nodes have a cache loader that accesses a common shared
+            backend store. This could for example be a shared filesystem (using
+            the FileCacheLoader), or a shared database. Because both nodes access
+            the same store, they don't necessarily need state transfer on
+            startup.
+            <footnote>
+               <para>Of course they can enable state transfer, if they want to
+                  have a warm or hot cache after startup.
+               </para>
+            </footnote>
+            Rather, the
+            <literal>FetchInMemoryState</literal>
+            attribute could be set to false, resulting in a 'cold' cache, that
+            gradually warms up as elements are accessed and loaded for the first
+            time. This would mean that individual caches in a cluster might have
+            different in-memory state at any given time (largely depending on
+            their preloading and eviction strategies).
+         </para>
+
+         <para>When storing a value, the writer takes care of storing the
+            change in the backend store. For example, if node1 made change C1 and
+            node2 C2, then node1 would tell its cache loader to store C1, and node2
+            would tell its cache loader to store C2.
+         </para>
+      </section>
+
+      <section>
+         <title>Replicated Caches With Only One Cache Having A Store</title>
+
+         <figure>
+            <title>2 nodes but only one accesses the backend store</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="OnlyOneCacheLoader.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+         <para>This is a similar case to the previous one, but here only one
+            node in the cluster interacts with a backend store via its
+            cache loader. All other nodes perform in-memory replication. The idea
+            here is all application state is kept in memory in each node, with
+            the existence of multiple caches making the data highly available. 
+            (This assumes that a client that needs the data is able to somehow 
+            fail over from one cache to another.) The single persistent backend 
+            store then provides a backup copy of the data in case all caches in 
+            the cluster fail or need to be restarted.
+         </para>
+         <para>
+            Note that here it may make sense for the cache loader to store 
+            changes asynchronously, that is <emphasis>not</emphasis>
+            on the caller's thread, in order not to slow
+            down the cluster by accessing (for example) a database. This is a
+            non-issue when using asynchronous replication.
+         </para>
+         <para>
+            A weakness with this architecture is that the cache with access
+            to the cache loader becomes a single point of failure. Furthermore,
+            if the cluster is restarted, the cache with the cache loader must
+            be started first (easy to forget).  A solution to the first problem
+            is to configure a cache loader on each node, but set the
+            <literal>singletonStore</literal> configuration to 
+            <literal>true</literal>. With this kind of setup, one but only one 
+            node will always be writing to a persistent store. However, this 
+            complicates the restart problem, as before restarting you need
+            to determine which cache was writing before the shutdown/failure
+            and then start that cache first.
+         </para>
+      </section>
+
+      <section>
+         <title>Replicated Caches With Each Cache Having Its Own Store</title>
+
+         <figure>
+            <title>2 nodes each having its own backend store</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="LocalCacheLoader.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+         <para>Here, each node has its own datastore. Modifications to the
+            cache are (a) replicated across the cluster and (b) persisted using
+            the cache loader. This means that all datastores have exactly the same
+            state. When replicating changes synchronously and in a transaction,
+            the two phase commit protocol takes care that all modifications are
+            replicated and persisted in each datastore, or none is replicated and
+            persisted (atomic updates).
+         </para>
+
+         <para>Note that JBoss Cache is
+            <emphasis>not</emphasis>
+            an
+            XA Resource, that means it doesn't implement recovery. When used with a
+            transaction manager that supports recovery, this functionality is not
+            available.
+         </para>
+
+         <para>The challenge here is state transfer: when a new node starts it
+            needs to do the following:
+         </para>
+
+         <orderedlist>
+            <listitem>
+               <para>Tell the coordinator (oldest node in a cluster) to send it
+                  the state. This is always a full state transfer, overwriting
+                  any state that may already be present.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>The coordinator then needs to wait until all in-flight
+                  transactions have completed. During this time, it will not allow
+                  for new transactions to be started.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>Then the coordinator asks its cache loader for the entire
+                  state using
+                  <literal>loadEntireState()</literal>
+                  . It then sends
+                  back that state to the new node.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>The new node then tells its cache loader to store that state
+                  in its store, overwriting the old state. This is the
+                  <literal>CacheLoader.storeEntireState()</literal>
+                  method
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>As an option, the transient (in-memory) state can be
+                  transferred as well during the state transfer.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>The new node now has the same state in its backend store as
+                  everyone else in the cluster, and modifications received from
+                  other nodes will now be persisted using the local
+                  cache loader.
+               </para>
+            </listitem>
+         </orderedlist>
+
+
+      </section>
+
+      <section>
+         <title>Hierarchical Caches</title>
+
+         <para>If you need to set up a hierarchy within a single JVM, you can
+            use the
+            <literal>LocalDelegatingCacheLoader</literal>
+            . This type of
+            hierarchy can currently only be set up programmatically.
+         </para>
+
+         <para>
+            Hierarchical caches could also be set up spanning more than one JVM or server, using the
+            <literal>TcpDelegatingCacheLoader</literal>
+            .
+            <figure>
+               <title>TCP delegating cache loader</title>
+
+               <mediaobject>
+                  <imageobject>
+                     <imagedata fileref="DelegatingCacheLoader.png"/>
+                  </imageobject>
+               </mediaobject>
+            </figure>
+
+         </para>
+
+      </section>
+
+
+      <section>
+         <title>Multiple Cache Loaders</title>
+
+         <para>
+            You can set up more than one cache loader in a chain. Internally, a delegating
+            <literal>ChainingCacheLoader</literal>
+            is used, with references to each
+            cache loader you have configured. Use cases vary depending on the type of cache loaders used in the chain.
+            One example is
+            using a filesystem based cache loader, colocated on the same host as the JVM, used as an overflow for
+            memory. This ensures
+            data is available relatively easily and with low cost. An additional remote cache loader, such as a
+            <literal>TcpDelegatingCacheLoader</literal>
+            provides resilience between server restarts.
+         </para>
+
+         <figure>
+            <title>Multiple cache loaders in a chain</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="MultipleCacheLoaders.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+      </section>
+
+
+   </section>
+
+
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/compatibility.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/compatibility.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/compatibility.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,37 @@
+<chapter id="compatibility">
+   <title>Version Compatibility and Interoperability</title>
+
+   <para>
+      Within a major version, releases of JBoss Cache are meant to be compatible and
+      interoperable. Compatible in the sense that it should be possible to
+      upgrade an application from one version to another by simply replacing the
+      jars. Interoperable in the sense that if two different versions of
+      JBoss Cache are used in the same cluster, they should be able to exchange
+      replication and state transfer messages. Note however that interoperability
+      requires use of the same JGroups version in all nodes in the cluster.
+      In most cases, the version of JGroups used by a version of JBoss Cache can
+      be upgraded.
+   </para>
+
+   <para>
+      As such, JBoss Cache 2.x.x is not API or binary compatible with prior 1.x.x versions.
+      However, JBoss Cache 2.1.x will be API and binary compatible with 2.0.x.
+   </para>
+
+   <para>
+      A configuration attribute, <literal>ReplicationVersion</literal>, is available and is used
+      to control the wire format of inter-cache communications.  They can be wound back from more
+      efficient and newer protocols to "compatible" versions when talking to older releases.
+      This mechanism allows us to improve JBoss Cache by using more efficient wire formats while
+      still providing a means to preserve interoperability.
+   </para>
+
+   <section>
+      <title>Compatibility Matrix</title>
+      <para>
+         A <ulink url="http://labs.jboss.com/portal/jbosscache/compatibility/index.html">compatibility matrix</ulink> is maintained on the JBoss Cache website, which contains information on 
+         different versions of JBoss Cache, JGroups and JBoss AS.
+      </para>
+   </section>
+   
+</chapter>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/modules/configuration.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/configuration.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/configuration.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,447 @@
+<chapter id="configuration">
+   <title>Configuration</title>
+
+   <section>
+      <title>Configuration Overview</title>
+
+      <para>
+         The
+         <literal>org.jboss.cache.config.Configuration</literal>
+         class
+         (along with its
+         <link linkend="configuration.elements">component parts</link>
+         )
+         is a Java Bean that encapsulates the configuration of the
+         <literal>Cache</literal>
+         and all of its architectural elements
+         (cache loaders, evictions policies, etc.)
+      </para>
+
+      <para>
+         The
+         <literal>Configuration</literal>
+         exposes numerous properties which
+         are summarized in the
+         <link linkend="configuration_reference">configuration reference</link>
+         section of this book and many of which are discussed in later
+         chapters. Any time you see a configuration option
+         discussed in this book, you can assume that the
+         <literal>Configuration</literal>
+         class or one of its component parts exposes a simple property setter/getter for that configuration option.
+      </para>
+
+   </section>
+
+   <section id="configuration.creation">
+      <title>Creating a
+         <literal>Configuration</literal>
+      </title>
+
+      <para>
+         As discussed in the
+         <link linkend="api.create_start">User API section</link>
+         ,
+         before a
+         <literal>Cache</literal>
+         can be created, the
+         <literal>CacheFactory</literal>
+         must be provided with a
+         <literal>Configuration</literal>
+         object or with a file name or
+         input stream to use to parse a
+         <literal>Configuration</literal>
+         from XML. The following sections describe how to accomplish this.
+      </para>
+
+      <section>
+         <title>Parsing an XML-based Configuration File</title>
+         <para>
+            The most convenient way to configure JBoss Cache is via an XML file. The JBoss Cache distribution ships
+            with a number of configuration files for common use cases. It is recommended that these files be used as
+            a starting point, and tweaked to meet specific needs.
+         </para>
+
+         <para>
+            Here is a simple example configuration file:
+         </para>
+         <programlisting>
+            <![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample JBoss Cache Service Configuration                             -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+   
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" name="jboss.cache:service=Cache">
+   
+      <!-- Configure the TransactionManager -->
+      <attribute name="TransactionManagerLookupClass">
+         org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+
+      <!-- Node locking level : SERIALIZABLE
+                                REPEATABLE_READ (default)
+                                READ_COMMITTED
+                                READ_UNCOMMITTED
+                                NONE             -->
+      <attribute name="IsolationLevel">READ_COMMITTED</attribute>
+
+      <!-- Lock parent before doing node additions/removes -->
+      <attribute name="LockParentForChildInsertRemove">true</attribute>
+
+      <!-- Valid modes are LOCAL (default)
+                           REPL_ASYNC
+                           REPL_SYNC
+                           INVALIDATION_ASYNC
+                           INVALIDATION_SYNC   -->
+      <attribute name="CacheMode">LOCAL</attribute>
+
+      <!-- Max number of milliseconds to wait for a lock acquisition -->
+      <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+
+      <!-- Specific eviction policy configurations. This is LRU -->
+      <attribute name="EvictionConfig">
+         <config>
+            <attribute name="wakeUpIntervalSeconds">5</attribute>
+            <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+            <!-- Cache wide default -->
+            <region name="/_default_">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+         </config>
+      </attribute>
+   </mbean>
+</server>
+]]>
+         </programlisting>
+
+         <para>
+            Another, more complete, sample XML file is included in the
+            <link linkend="sample_xml_file">configuration reference</link>
+            section of this book,
+            along with
+            <link linkend="configuration_reference">a handy look-up table</link>
+            explaining the various options.
+         </para>
+
+         <para>
+            For historical reasons, the format of the JBoss Cache configuraton
+            file follows that of a JBoss AS Service Archive (SAR) deployment
+            descriptor (and still can be used as such
+            <link linkend="deployment.microkernel">inside JBoss AS</link>
+            ). Because
+            of this dual usage, you may see elements in some configuration files
+            (such as
+            <literal>depends</literal>
+            or
+            <literal>classpath</literal>
+            ) that are
+            not relevant outside JBoss AS. These can safely be ignored.
+         </para>
+
+         <para>
+            Here's how you tell the
+            <literal>CacheFactory</literal>
+            to create
+            and start a cache by finding and parsing a configuration file on the
+            classpath:
+         </para>
+
+         <programlisting>
+            CacheFactory factory = DefaultCacheFactory.getInstance();
+            Cache cache = factory.createCache("cache-configuration.xml");
+         </programlisting>
+
+      </section>
+
+      <section>
+         <title>Programmatic Configuration</title>
+         <para>
+            In addition to the XML-based configuration above, the
+            <literal>Configuration</literal>
+            can be built up programatically,
+            using the simple property mutators exposed by
+            <literal>Configuration</literal>
+            and its components. When constructed,
+            the
+            <literal>Configuration</literal>
+            object is preset with JBoss Cache
+            defaults and can even be used as-is for a quick start.
+         </para>
+
+         <para>
+            Following is an example of programatically creating a
+            <literal>Configuration</literal>
+            configured to match the one produced
+            by the XML example above, and then using it to create a
+            <literal>Cache</literal>
+            :
+         </para>
+
+         <programlisting>
+            <![CDATA[
+            Configuration config = new Configuration();
+            String tmlc = GenericTransactionManagerLookup.class.getName();
+            config.setTransactionManagerLookupClass(tmlc);
+            config.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+            config.setCacheMode(CacheMode.LOCAL);
+            config.setLockParentForChildInsertRemove(true);
+            config.setLockAcquisitionTimeout(15000);
+            
+            EvictionConfig ec = new EvictionConfig();
+            ec.setWakeupIntervalSeconds(5);
+            ec.setDefaultEvictionPolicyClass(LRUPolicy.class.getName());
+            
+            EvictionRegionConfig erc = new EvictionRegionConfig();
+            erc.setRegionName("_default_");
+            
+            LRUConfiguration lru = new LRUConfiguration();
+            lru.setMaxNodes(5000);
+            lru.setTimeToLiveSeconds(1000);
+            
+            erc.setEvictionPolicyConfig(lru);
+            
+            List<EvictionRegionConfig> ercs = new ArrayList<EvictionRegionConfig>();
+            ercs.add(erc);
+            ec.setEvictionRegionConfigs(erc);
+            
+            config.setEvictionConfig(ec);
+            
+            CacheFactory factory = DefaultCacheFactory.getInstance();
+            Cache cache = factory.createCache(config);         
+]]>
+         </programlisting>
+
+         <para>
+            Even the above fairly simple configuration is pretty tedious programming;
+            hence the preferred use of XML-based configuration. However, if your
+            application requires it, there is no reason not to use XML-based
+            configuration for most of the attributes, and then access the
+            <literal>Configuration</literal>
+            object to programatically change
+            a few items from the defaults, add an eviction region, etc.
+         </para>
+
+         <para>
+            Note that configuration values may not be changed programmatically when a cache is running,
+            except those annotated as
+            <literal>@Dynamic</literal>
+            . Dynamic properties are also marked as such in the
+            <link linkend="configuration_reference">configuration reference</link>
+            table. Attempting to change a non-dynamic
+            property will result in a
+            <literal>ConfigurationException</literal>
+            .
+         </para>
+      </section>
+
+      <section>
+         <title>Using an IOC Framework</title>
+
+         <para>
+            The
+            <literal>Configuration</literal>
+            class and its
+            <link linkend="configuration.elements">component parts</link>
+            are all Java Beans that expose all config elements via simple setters
+            and getters. Therefore, any good IOC framework should be able to
+            build up a
+            <literal>Configuration</literal>
+            from an XML file in
+            the framework's own format. See the
+            <link linkend="deployment.microcontainer">deployment via the JBoss micrcontainer</link>
+            section for an example of this.
+         </para>
+      </section>
+   </section>
+
+   <section id="configuration.elements">
+      <title>Composition of a
+         <literal>Configuration</literal>
+         Object
+      </title>
+
+      <para>
+         A
+         <literal>Configuration</literal>
+         is composed of a number of
+         subobjects:
+
+         <mediaobject>
+            <imageobject>
+               <imagedata fileref="Configuration.png"/>
+            </imageobject>
+         </mediaobject>
+      </para>
+
+      <para>
+         Following is a brief overview of the components of a
+         <literal>Configuration</literal>
+         . See the javadoc and the linked
+         chapters in this book for a more complete explanation of the
+         configurations associated with each component.
+
+         <itemizedlist>
+            <listitem>
+               <literal>Configuration</literal>
+               : top level object
+               in the hierarchy; exposes the configuration properties listed in the
+               <link linkend="configuration_reference">configuration reference</link>
+               section of this book.
+            </listitem>
+
+            <listitem>
+               <literal>BuddyReplicationConfig</literal>
+               : only relevant if
+               <link linkend="br">buddy replication</link>
+               is used. General
+               buddy replication configuration options. Must include a:
+            </listitem>
+
+            <listitem>
+               <literal>BuddyLocatorConfig</literal>
+               : implementation-specific
+               configuration object for the
+               <literal>BuddyLocator</literal>
+               implementation
+               being used. What configuration elements are exposed depends on
+               the needs of the
+               <literal>BuddyLocator</literal>
+               implementation.
+            </listitem>
+
+            <listitem>
+               <literal>EvictionConfig</literal>
+               : only relevant if
+               <link linkend="eviction_policies">eviction</link>
+               is used. General
+               eviction configuration options. Must include at least one:
+            </listitem>
+
+            <listitem>
+               <literal>EvictionRegionConfig</literal>
+               : one for each
+               eviction region; names the region, etc. Must include a:
+            </listitem>
+
+            <listitem>
+               <literal>EvictionPolicyConfig</literal>
+               : implementation-specific
+               configuration object for the
+               <literal>EvictionPolicy</literal>
+               implementation
+               being used. What configuration elements are exposed depends on
+               the needs of the
+               <literal>EvictionPolicy</literal>
+               implementation.
+            </listitem>
+
+            <listitem>
+               <literal>CacheLoaderConfig</literal>
+               : only relevant if a
+               <link linkend="cache_loaders">cache loader</link>
+               is used. General
+               cache loader configuration options. Must include at least one:
+            </listitem>
+
+            <listitem>
+               <literal>IndividualCacheLoaderConfig</literal>
+               : implementation-specific
+               configuration object for the
+               <literal>CacheLoader</literal>
+               implementation
+               being used. What configuration elements are exposed depends on
+               the needs of the
+               <literal>CacheLoader</literal>
+               implementation.
+            </listitem>
+
+            <listitem>
+               <literal>RuntimeConfig</literal>
+               : exposes to cache clients
+               certain information about the cache's runtime environment (e.g. membership
+               in buddy replication groups if
+               <link linkend="br">buddy replication</link>
+               is used.) Also allows
+               direct injection into the cache of needed external services like a
+               JTA
+               <literal>TransactionManager</literal>
+               or a JGroups
+               <literal>ChannelFactory</literal>
+               .
+            </listitem>
+         </itemizedlist>
+      </para>
+   </section>
+
+   <section>
+      <title>Dynamic Reconfiguration</title>
+      <para>
+         Dynamically changing the configuration of
+         <emphasis>some</emphasis>
+         options while the cache is running is supported,
+         by programmatically obtaining the
+         <literal>Configuration</literal>
+         object from the running cache and changing values. E.g.,
+         <programlisting>
+
+            Configuration liveConfig = cache.getConfiguration();
+            liveConfig.setLockAcquisitionTimeout(2000);
+
+         </programlisting>
+         A complete listing of which options may be changed dynamically is in the
+         <link linkend="configuration_reference">configuration reference</link>
+         section. An
+         <literal>org.jboss.cache.config.ConfigurationException</literal>
+         will be thrown if you attempt to change a
+         setting that is not dynamic.
+      </para>
+   </section>
+
+   <section id="configuration.options">
+      <title>Overriding the Configuration Via the Option API</title>
+      <para>
+         The Option API allows you to override certain behaviours of the cache on a per invocation basis.
+         This involves creating an instance of
+         <literal>org.jboss.cache.config.Option</literal>
+         , setting the options
+         you wish to override on the
+         <literal>Option</literal>
+         object and passing it in the
+         <literal>InvocationContext</literal>
+         before invoking your method on the cache.
+      </para>
+      <para>
+         E.g., to override the default node versioning used with optimistic locking:
+         <programlisting>
+
+            DataVersion v = new MyCustomDataVersion();
+            cache.getInvocationContext().getOptionOverrides().setDataVersion(v);
+            Node ch = cache.getRoot().addChild(Fqn.fromString("/a/b/c"));
+
+         </programlisting>
+      </para>
+      <para>
+         E.g., to suppress replication of a put call in a REPL_SYNC cache:
+         <programlisting>
+
+            Node node = cache.getChild(Fqn.fromString("/a/b/c"));
+            cache.getInvocationContext().getOptionOverrides().setLocalOnly(true);
+            node.put("localCounter", new Integer(2));
+
+         </programlisting>
+      </para>
+      <para>
+         See the javadocs on the
+         <literal>Option</literal>
+         class for details on the options available.
+      </para>
+   </section>
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/configuration_reference.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,665 @@
+<chapter id="configuration_reference_chapter">
+   <title>Configuration References</title>
+   <section id="sample_xml_file">
+      <title>Sample XML Configuration File</title>
+      <para>
+         This is what a typical XML configuration file looks like. It is recommended that you use one of the
+         configurations
+         shipped with the JBoss Cache distribution and tweak according to your needs rather than write one from scratch.
+      </para>
+      <programlisting>
+         <![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample JBoss Cache Service Configuration                             -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+   
+   <!-- ==================================================================== -->
+   <!-- Defines JBoss Cache configuration                                      -->
+   <!-- ==================================================================== -->
+
+   <!-- Note the value of the 'code' attribute has changed since JBC 1.x -->
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" name="jboss.cache:service=Cache">
+   
+      <!-- Ensure JNDI and the TransactionManager are started before the
+           cache.  Only works inside JBoss AS; ignored otherwise -->
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+
+      <!-- Configure the TransactionManager -->
+      <attribute name="TransactionManagerLookupClass">
+         org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+
+      <!-- Node locking level : SERIALIZABLE
+                                REPEATABLE_READ (default)
+                                READ_COMMITTED
+                                READ_UNCOMMITTED
+                                NONE             -->
+      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+      <!-- Lock parent before doing node additions/removes -->
+      <attribute name="LockParentForChildInsertRemove">true</attribute>
+
+      <!-- Valid modes are LOCAL (default)
+                           REPL_ASYNC
+                           REPL_SYNC
+                           INVALIDATION_ASYNC
+                           INVALIDATION_SYNC   -->
+      <attribute name="CacheMode">REPL_ASYNC</attribute>
+
+      <!-- Name of cluster. Needs to be the same for all JBoss Cache nodes in a
+           cluster in order to find each other. 
+      -->
+      <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+      <!--Uncomment next three statements to use the JGroups multiplexer.
+         This configuration is dependent on the JGroups multiplexer being
+         registered in an MBean server such as JBossAS.  This type of
+         dependency injection only works in the AS; outside it's up to
+         your code to inject a ChannelFactory if you want to use one. 
+      -->
+      <!--
+      <depends optional-attribute-name="MultiplexerService" 
+      		proxy-type="attribute">jgroups.mux:name=Multiplexer</depends>
+      <attribute name="MultiplexerStack">tcp</attribute>
+      -->
+
+      <!-- JGroups protocol stack properties.
+         ClusterConfig isn't used if the multiplexer is enabled above.
+      -->
+      <attribute name="ClusterConfig">
+         <config>
+            <!-- UDP: if you have a multihomed machine, set the bind_addr 
+                 attribute to the appropriate NIC IP address -->
+            <!-- UDP: On Windows machines, because of the media sense feature
+                 being broken with multicast (even after disabling media sense)
+                 set the loopback attribute to true -->
+            <UDP mcast_addr="228.1.2.3" mcast_port="48866"
+                 ip_ttl="64" ip_mcast="true"
+                 mcast_send_buf_size="150000" mcast_recv_buf_size="80000"
+                 ucast_send_buf_size="150000" ucast_recv_buf_size="80000"
+                 loopback="false"/>
+            <PING timeout="2000" num_initial_members="3"/>
+            <MERGE2 min_interval="10000" max_interval="20000"/>
+            <FD shun="true"/>
+            <FD_SOCK/>
+            <VERIFY_SUSPECT timeout="1500"/>
+            <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800"
+                           max_xmit_size="8192"/>
+            <UNICAST timeout="600,1200,2400",4800/>
+            <pbcast.STABLE desired_avg_gossip="400000"/>
+            <FC max_credits="2000000" min_threshold="0.10"/>
+            <FRAG2 frag_size="8192"/>
+            <pbcast.GMS join_timeout="5000" join_retry_timeout="2000"
+                        shun="true" print_local_addr="true"/>
+            <pbcast.STATE_TRANSFER/>
+         </config>
+      </attribute>
+      
+      <!--
+          The max amount of time (in milliseconds) we wait until the
+          initial state (ie. the contents of the cache) are retrieved from
+          existing members in a clustered environment
+      -->
+      <attribute name="StateRetrievalTimeout">20000</attribute>
+
+      <!--
+          Number of milliseconds to wait until all responses for a
+          synchronous call have been received.
+      -->
+      <attribute name="SyncReplTimeout">20000</attribute>
+
+      <!-- Max number of milliseconds to wait for a lock acquisition -->
+      <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+
+      <!-- Specific eviction policy configurations. This is LRU -->
+      <attribute name="EvictionConfig">
+         <config>
+            <attribute name="wakeUpIntervalSeconds">5</attribute>
+            <!-- This defaults to 200000 if not specified -->
+            <attribute name="eventQueueSize">200000</attribute>
+            <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+            <!-- Cache wide default -->
+            <region name="/_default_">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+            <region name="/org/jboss/data">
+               <attribute name="maxNodes">5000</attribute>
+               <attribute name="timeToLiveSeconds">1000</attribute>
+            </region>
+            <region name="/org/jboss/test/data">
+               <attribute name="maxNodes">5</attribute>
+               <attribute name="timeToLiveSeconds">4</attribute>
+            </region>
+            <region name="/test">
+               <attribute name="maxNodes">10000</attribute>
+               <attribute name="timeToLiveSeconds">4</attribute>
+            </region>
+            <region name="/maxAgeTest">
+               <attribute name="maxNodes">10000</attribute>
+               <attribute name="timeToLiveSeconds">8</attribute>
+               <attribute name="maxAgeSeconds">10</attribute>
+            </region>
+         </config>
+      </attribute>
+   </mbean>
+</server>
+]]>
+      </programlisting>
+   </section>
+
+
+   <section id="configuration_reference">
+      <title>
+         Reference table of XML attributes
+      </title>
+      <para>A list of definitions of each of the XML attributes used above. If the
+         description of an attribute states that it is
+         <emphasis>dynamic</emphasis>
+         ,
+         that means it can be changed after the cache is created and started.
+      </para>
+
+      <informaltable frame="all">
+         <tgroup cols="2">
+            <tbody>
+               <row>
+                  <entry>
+                     <para>Name</para>
+                  </entry>
+
+                  <entry>
+                     <para>Description</para>
+                  </entry>
+               </row>
+               <row>
+                  <entry>
+                     <para>BuddyReplicationConfig</para>
+                  </entry>
+
+                  <entry>
+                     <para>An XML element that contains detailed buddy replication
+                        configuration. See
+                        <link linkend="br">section on Buddy Replication</link>
+                        for details.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>CacheLoaderConfig</para>
+                  </entry>
+
+                  <entry>
+                     <para>An XML element that contains detailed cache loader
+                        configuration. See
+                        <link linkend="cache_loaders">chapter on Cache Loaders</link>
+                        for details.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>CacheLoaderConfiguration</para>
+                  </entry>
+
+                  <entry>
+                     <para>
+                        <emphasis>Deprecated</emphasis>
+                        . Use
+                        <literal>CacheLoaderConfig</literal>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>CacheMode</para>
+                  </entry>
+
+                  <entry>
+                     <para>LOCAL, REPL_SYNC, REPL_ASYNC, INVALIDATION_SYNC or
+                        INVALIDATION_ASYNC. Defaults to LOCAL. See the
+                        <link linkend="clustering">chapter on Clustering</link>
+                        for details.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ClusterConfig</para>
+                  </entry>
+
+                  <entry>
+                     <para>The configuration of the underlying JGroups stack.
+                        Ignored if
+                        <literal>MultiplexerService</literal>
+                        and
+                        <literal>MultiplexerStack</literal>
+                        are used.
+                        See the various *-service.xml files in the source distribution
+                        <literal>etc/META-INF</literal>
+                        folder for examples.
+                        See the
+                        <ulink url="http://www.jgroups.org">JGroups documentation</ulink>
+                        or the
+                        <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JGroups">JGroups wiki page</ulink>
+                        for more information.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ClusterName</para>
+                  </entry>
+
+                  <entry>
+                     <para>Name of cluster. Needs to be the same for all nodes in a
+                        cluster in order for them to communicate with each other.
+                     </para>
+                  </entry>
+               </row>
+               <row>
+                  <entry>
+                     <para>EvictionPolicyConfig</para>
+                  </entry>
+
+                  <entry>
+                     <para>Configuration parameter for the specified eviction policy.
+                        See
+                        <link linkend="eviction_policies">chapter on eviction policies</link>
+                        for details. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ExposeManagementStatistics</para>
+                  </entry>
+
+                  <entry>
+                     <para>
+                        Specifies whether interceptors that provide statistics should have statistics
+                        gathering enabled at startup. Also controls whether a
+                        <literal>CacheMgmtInterceptor</literal>
+                        (whose sole purpose is gathering
+                        statistics) should be added to the interceptor chain. Default value is
+                        <emphasis>true</emphasis>
+                        . See the
+                        <link linkend="jmx.statistics">JBoss Cache Statistics section</link>
+                        section for more details.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>FetchInMemoryState
+                     </para>
+                  </entry>
+
+                  <entry>
+                     <para>Whether or not to acquire the initial in-memory state from
+                        existing members. Allows for hot caches when enabled. Also
+                        see the
+                        <literal>fetchPersistentState</literal>
+                        element in
+                        <literal>CacheLoaderConfig</literal>
+                        . Defaults to
+                        <literal>true</literal>
+                        . This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>InactiveOnStartup</para>
+                  </entry>
+
+                  <entry>
+                     <para>Whether or not the entire tree is inactive upon startup,
+                        only responding to replication messages after
+                        <literal>activateRegion()</literal>
+                        is called to activate one or
+                        more parts of the tree. If true, property
+                        <literal>FetchInMemoryState</literal>
+                        is ignored. This property
+                        should only be set to true if
+                        <literal>UseRegionBasedMarshalling</literal>
+                        is also
+                        <literal>true</literal>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>StateRetrievalTimeout</para>
+                  </entry>
+
+                  <entry>
+                     <para>Time in milliseconds to wait for state
+                        retrieval. This should be longer than
+                        <literal>LockAcquisitionTimeout</literal>
+                        as the node
+                        providing state may need to wait that long to acquire
+                        necessary read locks on the cache. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+
+               <row>
+                  <entry>
+                     <para>IsolationLevel</para>
+                  </entry>
+
+                  <entry>
+                     <para>Node locking isolation level : SERIALIZABLE, REPEATABLE_READ
+                        (default), READ_COMMITTED, READ_UNCOMMITTED, and NONE. Note that this is ignored if
+                        NodeLockingScheme is OPTIMISTIC. Case doesn't matter. See documentation on Transactions and
+                        Concurrency for more details.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>LockAcquisitionTimeout</para>
+                  </entry>
+
+                  <entry>
+                     <para>Time in milliseconds to wait for a lock to be acquired. If
+                        a lock cannot be acquired an exception will be thrown. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>LockParentForChildInsertRemove</para>
+                  </entry>
+
+                  <entry>
+                     <para>Controls whether inserting or removing a node requires a write
+                        lock on the node's parent (when pessimistic locking is used) or whether
+                        it results in an update of the parent node's version (when optimistic
+                        locking is used). The default value is
+                        <code>false</code>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>MarshallerClass</para>
+                  </entry>
+
+                  <entry>
+                     <para>An instance of
+                        <literal>org.jboss.cache.marshall.Marshaller</literal>
+                        used to serialize data to byte streams.
+                        Defaults to
+                        <literal>org.jboss.cache.marshall.VersionAwareMarshaller</literal>
+                        if not specified.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>MultiplexerService</para>
+                  </entry>
+
+                  <entry>
+                     <para>The JMX object name of the service that defines the JGroups multiplexer.
+                        In JBoss AS 5.0 this service is normally defined in the jgroups-multiplexer.sar.
+                        This XML attribute can only be handled by the JBoss AS MBean deployment services;
+                        if it is included in a file passed to a
+                        <literal>CacheFactory</literal>
+                        the
+                        factory's creation of the cache will fail. Inside JBoss AS, the attribute should
+                        be specified using the "depends optional-attribute-name" syntax shown in
+                        the example above. Inside the AS if this attribute
+                        is defined, an instance of
+                        <literal>org.jgroups.jmx.JChannelFactoryMBean</literal>
+                        will be injected into the
+                        <literal>CacheJmxWrapper</literal>
+                        which will use
+                        it to obtain a multiplexed JGroups channel. The configuration
+                        of the channel will be that associated with
+                        <literal>MultiplexerStack</literal>
+                        .
+                        The
+                        <literal>ClusterConfig</literal>
+                        attribute will be ignored.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>MultiplexerStack</para>
+                  </entry>
+
+                  <entry>
+                     <para>The name of the JGroups stack to be used with the cache cluster.
+                        Stacks are defined in the configuration of the external
+                        <literal>MultiplexerService</literal>
+                        discussed above. In JBoss AS 5 this is normally done in the
+                        jgroups-multiplexer.sar/META-INF/multiplexer-stacks.xml file.
+                        The default stack is
+                        <literal>udp</literal>
+                        . This attribute is used in conjunction with
+                        <literal>MultiplexerService</literal>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>NodeLockingScheme</para>
+                  </entry>
+
+                  <entry>
+                     <para>May be PESSIMISTIC (default) or OPTIMISTIC.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ReplicationVersion</para>
+                  </entry>
+                  <entry>
+                     <para>Tells the cache to serialize cluster traffic
+                        in a format consistent with that used by the given release
+                        of JBoss Cache. Different JBoss Cache versions use different
+                        wire formats; setting this attribute tells a cache from a later
+                        release to serialize data using the format from an earlier
+                        release. This allows caches from different releases to
+                        interoperate. For example, a 2.1.0 cache could have this
+                        value set to "2.0.0", allowing it to interoperate with a 2.0.0
+                        cache. Valid values are a dot-separated release number, with
+                        any final qualifer also separated by a dot, e.g. "2.0.0" or "2.0.0.GA".
+                        Values that indicate a 1.x release are not supported in the 2.x series.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ReplQueueInterval</para>
+                  </entry>
+
+                  <entry>
+                     <para>Time in milliseconds for elements from the replication
+                        queue to be replicated. Only used if
+                        <literal>UseReplQueue</literal>
+                        is enabled. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>ReplQueueMaxElements</para>
+                  </entry>
+
+                  <entry>
+                     <para>Max number of elements in the replication queue until
+                        replication kicks in. Only used if
+                        <literal>UseReplQueue</literal>
+                        is enabled. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>SyncCommitPhase</para>
+                  </entry>
+
+                  <entry>
+                     <para>This option is used to control the behaviour of the commit part of a 2-phase commit protocol,
+                        when
+                        using REPL_SYNC (does not apply to other cache modes). By default this is set to
+                        <literal>false</literal>
+                        . There is a performance penalty to enabling this, especially when running
+                        in a large cluster, but the upsides are greater cluster-wide data integrity. See the chapter on
+                        clustered caches for more information on this. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>SyncReplTimeout</para>
+                  </entry>
+
+                  <entry>
+                     <para>For synchronous replication: time in milliseconds to wait
+                        until replication acks have been received from all nodes in the
+                        cluster. It is usually best that this is greater than
+                        <literal>LockAcquisitionTimeout</literal>
+                        .
+                        This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>SyncRollbackPhase</para>
+                  </entry>
+
+                  <entry>
+                     <para>This option is used to control the behaviour of the rollback part of a 2-phase commit
+                        protocol, when
+                        using REPL_SYNC (does not apply to other cache modes). By default this is set to
+                        <literal>false</literal>
+                        . There is a performance penalty to enabling this, especially when running
+                        in a large cluster, but the upsides are greater cluster-wide data integrity. See the chapter on
+                        clustered caches for more information on this. This property is
+                        <emphasis>dynamic</emphasis>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>TransactionManagerLookupClass</para>
+                  </entry>
+
+                  <entry>
+                     <para>The fully qualified name of a class implementing
+                        TransactionManagerLookup. Default is
+                        JBossTransactionManagerLookup. There is also an option of
+                        GenericTransactionManagerLookup for example.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>UseInterceptorMbeans</para>
+                  </entry>
+
+                  <entry>
+                     <para>
+                        <emphasis>Deprecated</emphasis>
+                        . Use
+                        <literal>ExposeManagementStatistics</literal>
+                        .
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>UseRegionBasedMarshalling</para>
+                  </entry>
+
+                  <entry>
+                     <para>When unmarshalling replicated data, this option specifies whether or not to
+                        support use of different classloaders for different cache regions. This defaults to
+                        <literal>false</literal>
+                        if unspecified.
+                     </para>
+                  </entry>
+               </row>
+
+               <row>
+                  <entry>
+                     <para>UseReplQueue</para>
+                  </entry>
+
+                  <entry>
+                     <para>For asynchronous replication: whether or not to use a
+                        replication queue. Defaults to
+                        <literal>false</literal>
+                        .
+                     </para>
+                  </entry>
+               </row>
+            </tbody>
+         </tgroup>
+      </informaltable>
+   </section>
+</chapter>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/modules/deployment.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/deployment.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/deployment.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,901 @@
+<chapter id="deployment">
+   <title>Deploying JBoss Cache</title>
+   <section id="deployment.standalone">
+      <title>Standalone Use / Programatic Deployment</title>
+      <para>
+         When used in a standalone Java program, all that needs to be done is to instantiate the cache using the
+         <literal>CacheFactory</literal>
+         and a
+         <literal>Configuration</literal>
+         instance or an XML file, as discussed
+         in the
+         <link linkend="api.create_start">User API</link>
+         and
+         <link linkend="configuration.creation">Configuration</link>
+         chapters.
+      </para>
+
+      <para>
+         The same techniques can be used when an application running in an application
+         server wishes to programatically deploy a cache rather than relying on an application server's
+         deployment features. An example of this would be
+         a webapp deploying a cache via a
+         <literal>javax.servlet.ServletContextListener</literal>
+         .
+      </para>
+
+      <para>
+         If, after deploying your cache you wish to expose a management interface
+         to it in JMX, see the
+         <link linkend="jmx.registration.programatic">section on Programatic Registration in JMX</link>
+         .
+      </para>
+   </section>
+
+   <section id="deployment.microkernel">
+      <title>JMX-Based Deployment in JBoss AS (JBoss AS 5.x and 4.x)</title>
+      <para>If JBoss Cache is run in JBoss AS then the cache can be deployed as an
+         MBean simply by copying a standard cache configuration file to the server's
+         <literal>deploy</literal>
+         directory. The standard format of JBoss Cache's
+         standard XML configuration file (as shown in the
+         <link linkend="sample_xml_file">Configuration Reference</link>
+         ) is the same
+         as a JBoss AS MBean deployment descriptor, so the AS's SAR Deployer has
+         no trouble handling it. Also, you don't have to place the configuration
+         file directly in
+         <literal>deploy</literal>
+         ; you can package it along
+         with other services or JEE components in a SAR or EAR.
+      </para>
+
+      <para>
+         In AS 5, if you're using a server config based on the standard
+         <literal>all</literal>
+         config, then that's all you need to do; all required
+         jars will be on the classpath. Otherwise, you will need to ensure
+         <literal>jbosscache.jar</literal>
+         and
+         <literal>jgroups-all.jar</literal>
+         are on the classpath. You may need to add other jars if you're using
+         things like
+         <literal>JdbmCacheLoader</literal>
+         . The simplest way to do
+         this is to copy the jars from the JBoss Cache distribution's
+         <literal>lib</literal>
+         directory to the server config's
+         <literal>lib</literal>
+         directory. You could also package the jars with the configuration file
+         in Service Archive (.sar) file or an EAR.
+      </para>
+
+      <para>
+         It is possible to deploy a JBoss Cache 2.0 instance in JBoss AS 4.x
+         (at least in 4.2.0.GA; other AS releases are completely untested).
+         However, the significant API changes between the JBoss Cache 2.x and 1.x releases
+         mean none of the standard AS 4.x clustering services (e.g.
+         http session replication) that rely on JBoss Cache will work with
+         JBoss Cache 2.x. Also, be aware that usage of JBoss Cache 2.x in AS 4.x is not
+         something the JBoss Cache developers are making any significant effort to test,
+         so be sure to test your application well (which of course you're doing anyway.)
+      </para>
+
+      <para>
+         Note in the
+         <link linkend="sample_xml_file">example</link>
+         the value of the
+         <literal>mbean</literal>
+         element's
+         <literal>code</literal>
+         attribute:
+         <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
+         . This is the
+         class JBoss Cache uses to handle JMX integration; the
+         <literal>Cache</literal>
+         itself does not expose an MBean
+         interface. See the
+         <link linkend="jmx.mbeans">JBoss Cache MBeans section</link>
+         for more on the
+         <literal>CacheJmxWrapper</literal>
+         .
+      </para>
+
+      <para>
+         Once your cache is deployed, in order to use it with an in-VM client
+         such as a servlet, a JMX proxy can be used to get a reference to
+         the cache:
+      </para>
+
+      <programlisting>
+         <![CDATA[
+      MBeanServer server = MBeanServerLocator.locateJBoss();
+      ObjectName on = new ObjectName("jboss.cache:service=Cache");
+      CacheJmxWrapperMBean cacheWrapper = 
+        (CacheJmxWrapperMBean) MBeanServerInvocationHandler.newProxyInstance(server, on, 
+                                                CacheJmxWrapperMBean.class, false);
+      Cache cache = cacheWrapper.getCache();
+      Node root = cache.getRoot(); // etc etc
+   ]]>
+      </programlisting>
+
+      <para>The MBeanServerLocator class is a helper to find the (only) JBoss
+         MBean server inside the current JVM. The
+         <literal>javax.management.MBeanServerInvocationHandler</literal>
+         class'
+         <literal>newProxyInstance</literal>
+         method creates a
+         dynamic proxy implementing the given interface and uses JMX to
+         dynamically dispatch methods invoked against the generated interface
+         to the MBean. The name used to look up the MBean is the same as defined
+         in the cache's configuration file.
+      </para>
+
+      <para>
+         Once the proxy to the
+         <literal>CacheJmxWrapper</literal>
+         is obtained,
+         the
+         <literal>getCache()</literal>
+         will return a reference to the
+         <literal>Cache</literal>
+         itself.
+      </para>
+
+   </section>
+
+   <section id="deployment.microcontainer">
+      <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
+
+      <para>
+         Beginning with AS 5, JBoss AS also supports deployment of POJO services via
+         deployment of a file whose name ends with
+         <literal>-beans.xml</literal>
+         .
+         A POJO service is one whose implementation is via a "Plain Old Java Object",
+         meaning a simple java bean that isn't required to implement any special
+         interfaces or extend any particular superclass. A
+         <literal>Cache</literal>
+         is a POJO service, and all the components in a
+         <literal>Configuration</literal>
+         are also POJOS, so deploying a cache in this way is a natural step.
+      </para>
+      <para>
+         Deployment of the cache is done using the JBoss Microcontainer that forms the
+         core of JBoss AS. JBoss Microcontainer is a sophisticated IOC framework
+         (similar to Spring). A
+         <literal>-beans.xml</literal>
+         file is basically
+         a descriptor that tells the IOC framework how to assemble the various
+         beans that make up a POJO service.
+      </para>
+      <para>
+         The rules for how to deploy the file, how to package it, how to
+         ensure the required jars are on the classpath, etc. are the same
+         as for a
+         <link linkend="deployment.microkernel">JMX-based deployment</link>
+         .
+      </para>
+
+      <para>
+         Following is an example
+         <literal>-beans.xml</literal>
+         file. If you
+         look in the
+         <literal>server/all/deploy</literal>
+         directory of an AS 5
+         installation, you can find several more examples.
+      </para>
+
+      <programlisting>
+         <![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- First we create a Configuration object for the cache -->
+   <bean name="ExampleCacheConfig"
+   		 class="org.jboss.cache.config.Configuration">
+      
+      <!-- Externally injected services -->  
+      <property name="runtimeConfig">
+         <bean name="ExampleCacheRuntimeConfig" class="org.jboss.cache.config.RuntimeConfig">
+            <property name="transactionManager">
+               <inject bean="jboss:service=TransactionManager" 
+                       property="TransactionManager"/>
+            </property>
+            <property name="muxChannelFactory"><inject bean="JChannelFactory"/></property>
+         </bean>
+      </property>
+      
+      <property name="multiplexerStack">udp</property>
+
+      <property name="clusterName">Example-EntityCache</property>
+        
+      <!--
+              Node locking level : SERIALIZABLE
+                                   REPEATABLE_READ (default)
+                                   READ_COMMITTED
+                                   READ_UNCOMMITTED
+                                   NONE
+      -->
+      <property name="isolationLevel">REPEATABLE_READ</property>
+
+      <!--     Valid modes are LOCAL
+                               REPL_ASYNC
+                               REPL_SYNC
+      -->
+      <property name="cacheMode">REPL_SYNC</property>
+
+      <!--  The max amount of time (in milliseconds) we wait until the
+            initial state (ie. the contents of the cache) are retrieved from
+            existing members in a clustered environment
+      -->
+      <property name="initialStateRetrievalTimeout">15000</property>
+
+      <!--    Number of milliseconds to wait until all responses for a
+              synchronous call have been received.
+      -->
+      <property name="syncReplTimeout">20000</property>
+
+      <!--  Max number of milliseconds to wait for a lock acquisition -->
+      <property name="lockAcquisitionTimeout">15000</property>
+        
+      <property name="exposeManagementStatistics">true</property>
+      
+      <!-- Must be true if any entity deployment uses a scoped classloader -->
+      <property name="useRegionBasedMarshalling">true</property>
+      <!-- Must match the value of "useRegionBasedMarshalling" -->
+      <property name="inactiveOnStartup">true</property>
+
+      <!--  Specific eviction policy configurations. This is LRU -->
+      <property name="evictionConfig">
+      	 <bean name="ExampleEvictionConfig" 
+      	       class="org.jboss.cache.config.EvictionConfig">
+      	    <property name="defaultEvictionPolicyClass">
+      	       org.jboss.cache.eviction.LRUPolicy
+      	    </property>
+            <property name="wakeupIntervalSeconds">5</property>
+            <property name="evictionRegionConfigs">
+               <list>
+                  <bean name="ExampleDefaultEvictionRegionConfig" 
+                        class="org.jboss.cache.config.EvictionRegionConfig">
+                     <property name="regionName">/_default_</property>
+            	     <property name="evictionPolicyConfig">
+                        <bean name="ExampleDefaultLRUConfig" 
+                              class="org.jboss.cache.eviction.LRUConfiguration">
+                           <property name="maxNodes">5000</property>
+                           <property name="timeToLiveSeconds">1000</property>
+                        </bean>
+                     </property>
+                  </bean>
+               </list>
+            </property>
+         </bean>
+      </property>
+      
+   </bean>
+   
+   <!-- Factory to build the Cache. -->
+   <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">      
+      <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" 
+                   factoryMethod="getInstance"/>
+   </bean>
+   
+   <!-- The cache itself -->
+   <bean name="ExampleCache" class="org.jboss.cache.CacheImpl">
+      
+      <constructor factoryMethod="createCache">
+          <factory bean="DefaultCacheFactory"/>
+          <parameter><inject bean="ExampleCacheConfig"/></parameter>
+          <parameter>false</false>
+      </constructor>
+          
+   </bean>
+
+</deployment>      
+]]>
+      </programlisting>
+
+      <para>
+         See the JBoss Microcontainer documentation
+         <footnote>
+            <para>http://labs.jboss.com/jbossmc/docs</para>
+         </footnote>
+         for details on the above syntax. Basically, each
+         <literal>bean</literal>
+         element represents an object; most going to create a
+         <literal>Configuration</literal>
+         and its
+         <link linkend="configuration.elements">constituent parts</link>
+         .
+      </para>
+      <para>
+         An interesting thing to note in the above example is the use of the
+         <literal>RuntimeConfig</literal>
+         object. External resources like
+         a
+         <literal>TransactionManager</literal>
+         and a JGroups
+         <literal>ChannelFactory</literal>
+         that are visible to the
+         microcontainer are dependency injected into the
+         <literal>RuntimeConfig</literal>
+         .
+         The assumption here is that in some other deployment descriptor in the AS,
+         the referenced beans have been described.
+      </para>
+   </section>
+
+   <section>
+      <title>Binding to JNDI in JBoss AS</title>
+      <para>
+         With the 1.x JBoss Cache releases, a proxy to the cache could be bound
+         into JBoss AS's JNDI tree using the AS's
+         <literal>JRMPProxyFactory</literal>
+         service. With JBoss Cache 2.x, this no longer works. An alternative
+         way of doing a similar thing with a POJO (i.e. non-JMX-based) service
+         like a
+         <literal>Cache</literal>
+         is under development by the JBoss AS
+         team
+         <footnote>
+            <para>http://jira.jboss.com/jira/browse/JBAS-4456</para>
+         </footnote>
+         . That feature is not available as of the time of this writing,
+         although it will be completed before AS 5.0.0.GA is released.
+         We will add a wiki page describing how to use it once it becomes available.
+      </para>
+   </section>
+
+   <section>
+      <title>Runtime Management Information</title>
+      <para>JBoss Cache includes JMX MBeans to expose cache functionality and provide statistics that can be
+         used to analyze cache operations. JBoss Cache can also broadcast cache events as MBean notifications for
+         handling
+         via JMX monitoring tools.
+      </para>
+
+      <section id="jmx.mbeans">
+         <title>JBoss Cache MBeans</title>
+         <para>
+            JBoss Cache provides an MBean that can be registered with your environments JMX server to allow access
+            to the cache instance via JMX. This MBean is the
+            <literal>org.jboss.cache.jmx.CacheJmxWrapper</literal>
+            .
+            It is a StandardMBean, so it's MBean interface is
+            <literal>org.jboss.cache.jmx.CacheJmxWrapperMBean</literal>
+            .
+            This MBean can be used to:
+            <itemizedlist>
+               <listitem>Get a reference to the underlying
+                  <literal>Cache</literal>
+                  .
+               </listitem>
+               <listitem>Invoke create/start/stop/destroy lifecycle operations on
+                  the underlying
+                  <literal>Cache</literal>
+                  .
+               </listitem>
+               <listitem>Inspect various details about the cache's current state (number of nodes, lock information,
+                  etc.)
+               </listitem>
+               <listitem>See numerous details about the cache's configuration, and
+                  change those configuration items that can be changed when the
+                  cache has already been started.
+               </listitem>
+            </itemizedlist>
+            See the
+            <literal>CacheJmxWrapperMBean</literal>
+            javadoc for more details.
+         </para>
+         <para>
+            It is important to note a significant architectural difference between JBoss Cache 1.x and 2.x. In 1.x,
+            the old
+            <literal>TreeCache</literal>
+            class was itself an MBean, and essentially exposed the cache's entire
+            API via JMX. In 2.x, JMX has been returned to it's fundamental role as a management layer. The
+            <literal>Cache</literal>
+            object itself is completely unaware of JMX; instead JMX functionality is added
+            through a wrapper class designed for that purpose. Furthermore, the interface exposed through JMX
+            has been limited to management functions; the general
+            <literal>Cache</literal>
+            API is no longer exposed
+            through JMX. For example, it is no longer possible to invoke a cache
+            <literal>put</literal>
+            or
+            <literal>get</literal>
+            via the JMX interface.
+         </para>
+         <para>
+            If a
+            <literal>CacheJmxWrapper</literal>
+            is registered, JBoss Cache also provides MBeans
+            for each interceptor configured in the cache's interceptor stack. These
+            MBeans are used to capture and expose statistics related to cache operations. They are hierarchically
+            associated with the
+            <literal>CacheJmxWrapper</literal>
+            MBean and have service names that reflect this relationship. For
+            example, a replication interceptor MBean for the
+            <literal>jboss.cache:service=TomcatClusteringCache</literal>
+            instance will be
+            accessible through the service named
+            <literal>jboss.cache:service=TomcatClusteringCache,cache-interceptor=ReplicationInterceptor</literal>
+            .
+         </para>
+      </section>
+
+      <section id="jmx.registration">
+         <title>Registering the CacheJmxWrapper with the MBeanServer</title>
+
+         <para>
+            The best way to ensure the
+            <literal>CacheJmxWrapper</literal>
+            is registered
+            in JMX depends on how you are deploying your cache:
+         </para>
+
+         <section id="jmx.registration.programatic">
+            <title>Programatic Registration</title>
+
+            <para>
+               Simplest way to do this is to create your
+               <literal>Cache</literal>
+               and pass it to the
+               <literal>CacheJmxWrapper</literal>
+               constructor.
+            </para>
+
+            <programlisting>
+               CacheFactory factory = DefaultCacheFactory.getInstance();
+               // Build but don't start the cache
+               // (although it would work OK if we started it)
+               Cache cache = factory.createCache("cache-configuration.xml", false);
+
+               CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(cache);
+               MBeanServer server = getMBeanServer(); // however you do it
+               ObjectName on = new ObjectName("jboss.cache:service=TreeCache");
+               server.registerMBean(wrapper, on);
+
+               // Invoking lifecycle methods on the wrapper results
+               // in a call through to the cache
+               wrapper.create();
+               wrapper.start();
+
+               ... use the cache
+
+               ... on application shutdown
+
+               // Invoking lifecycle methods on the wrapper results
+               // in a call through to the cache
+               wrapper.stop();
+               wrapper.destroy();
+            </programlisting>
+
+            <para>
+               Alternatively, build a
+               <literal>Configuration</literal>
+               object
+               and pass it to the
+               <literal>CacheJmxWrapper</literal>
+               . The wrapper
+               will construct the
+               <literal>Cache</literal>
+               :
+            </para>
+
+            <programlisting>
+               Configuration config = buildConfiguration(); // whatever it does
+
+               CacheJmxWrapperMBean wrapper = new CacheJmxWrapper(config);
+               MBeanServer server = getMBeanServer(); // however you do it
+               ObjectName on = new ObjectName("jboss.cache:service=TreeCache");
+               server.registerMBean(wrapper, on);
+
+               // Call to wrapper.create() will build the Cache if one wasn't injected
+               wrapper.create();
+               wrapper.start();
+
+               // Now that it's built, created and started, get the cache from the wrapper
+               Cache cache = wrapper.getCache();
+
+               ... use the cache
+
+               ... on application shutdown
+
+               wrapper.stop();
+               wrapper.destroy();
+
+            </programlisting>
+         </section>
+
+         <section>
+            <title>JMX-Based Deployment in JBoss AS (JBoss AS 4.x and 5.x)</title>
+
+            <para>
+               When you
+               <link linkend="deployment.microkernel">deploy your cache in JBoss AS using a -service.xml file</link>
+               ,
+               a
+               <literal>CacheJmxWrapper</literal>
+               is automatically registered. There is no need
+               to do anything further. The
+               <literal>CacheJmxWrapper</literal>
+               is accessible from an MBean server
+               through the service name specified in the cache configuration file's
+               <literal>mbean</literal>
+               element.
+            </para>
+         </section>
+
+         <section>
+            <title>Via JBoss Microcontainer (JBoss AS 5.x)</title>
+
+            <para>
+               <literal>CacheJmxWrapper</literal>
+               is a POJO, so the microcontainer
+               has no problem creating one. The trick is
+               getting it to register your bean in JMX. This can be done by
+               specifying the
+               <literal>org.jboss.aop.microcontainer.aspects.jmx.JMX</literal>
+               annotation on the
+               <literal>CacheJmxWrapper</literal>
+               bean:
+            </para>
+
+            <programlisting>
+               <![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- First we create a Configuration object for the cache -->
+   <bean name="ExampleCacheConfig"
+   		 class="org.jboss.cache.config.Configuration">
+      
+      ... build up the Configuration
+      
+   </bean>
+   
+   <!-- Factory to build the Cache. -->
+   <bean name="DefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">      
+      <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" 
+                   factoryMethod="getInstance"/>
+   </bean>
+   
+   <!-- The cache itself -->
+   <bean name="ExampleCache" class="org.jboss.cache.CacheImpl">
+      
+      <constructor factoryMethod="createnewInstance">
+          <factory bean="DefaultCacheFactory"/>
+          <parameter><inject bean="ExampleCacheConfig"/></parameter>
+          <parameter>false</false>
+      </constructor>
+          
+   </bean>
+   
+   <!-- JMX Management -->
+   <bean name="ExampleCacheJmxWrapper" class="org.jboss.cache.jmx.CacheJmxWrapper">
+      
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=ExampleTreeCache", 
+                         exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, 
+                         registerDirectly=true)</annotation>
+      
+      <constructor>
+          <parameter><inject bean="ExampleCache"/></parameter>
+      </constructor>
+          
+   </bean>
+
+</deployment>      
+]]>
+            </programlisting>
+
+            <para>
+               As discussed in the
+               <link linkend="jmx.registration.programatic">Programatic Registration</link>
+               section,
+               <literal>CacheJmxWrapper</literal>
+               can do the work of building,
+               creating and starting the
+               <literal>Cache</literal>
+               if it is provided
+               with a
+               <literal>Configuration</literal>
+               . With the microcontainer,
+               this is the preferred approach, as it saves the boilerplate XML
+               needed to create the
+               <literal>CacheFactory</literal>
+               :
+            </para>
+
+            <programlisting>
+               <![CDATA[
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- First we create a Configuration object for the cache -->
+   <bean name="ExampleCacheConfig"
+   		 class="org.jboss.cache.config.Configuration">
+      
+      ... build up the Configuration
+      
+   </bean>
+    
+   <bean name="ExampleCache" class="org.jboss.cache.jmx.CacheJmxWrapper">
+      
+      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=ExampleTreeCache", 
+                         exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class, 
+                         registerDirectly=true)</annotation>
+      
+      <constructor>
+          <parameter><inject bean="ExampleCacheConfig"/></parameter>
+      </constructor>
+          
+   </bean>
+
+</deployment>      
+]]>
+            </programlisting>
+         </section>
+
+      </section>
+
+      <section id="jmx.statistics">
+         <title>JBoss Cache Statistics</title>
+         <para>
+            JBoss Cache captures statistics in its interceptors and exposes the statistics through interceptor
+            MBeans. Gathering of statistics is enabled by default; this can be disabled for a specific cache
+            instance through the
+            <literal>ExposeManagementStatistics</literal>
+            configuration attribute. Note that
+            the majority of the statistics are provided by the
+            <literal>CacheMgmtInterceptor</literal>
+            ,
+            so this MBean is the most significant in this regard. If you want to disable all statistics for performance
+            reasons, you set
+            <literal>ExposeManagementStatistics</literal>
+            to
+            <literal>false</literal>
+            as this will
+            prevent the
+            <literal>CacheMgmtInterceptor</literal>
+            from being included in the cache's interceptor stack
+            when the cache is started.
+         </para>
+         <para>
+            If a
+            <literal>CacheJmxWrapper</literal>
+            is registered with JMX, the wrapper also ensures that
+            an MBean is registered in JMX for each interceptor that exposes statistics
+            <footnote>
+               <para>
+                  Note that if the
+                  <literal>CacheJmxWrapper</literal>
+                  is not registered in JMX, the
+                  interceptor MBeans will not be registered either. The JBoss Cache 1.4 releases
+                  included code that would try to "discover" an
+                  <literal>MBeanServer</literal>
+                  and
+                  automatically register the interceptor MBeans with it. For JBoss Cache 2.x we decided
+                  that this sort of "discovery" of the JMX environment was beyond the proper scope of
+                  a caching library, so we removed this functionality.
+               </para>
+            </footnote>
+            .
+            Management tools can then access those MBeans to examine the statistics. See the section in the
+            <link linkend="jmx_reference.statistics">JMX Reference chapter</link>
+            pertaining to the
+            statistics that are made available via JMX.
+         </para>
+         <para>
+            The name under which the interceptor MBeans will be registered is derived by taking the
+            <literal>ObjectName</literal>
+            under which the
+            <literal>CacheJmxWrapper</literal>
+            is
+            registered and adding a
+            <literal>cache-interceptor</literal>
+            attribute key whose value
+            is the non-qualified name of the interceptor class. So, for example, if the
+            <literal>CacheJmxWrapper</literal>
+            were registered under
+            <literal>jboss.cache:service=TreeCache</literal>
+            , the name of the
+            <literal>CacheMgmtInterceptor</literal>
+            MBean would be
+            <literal>jboss.cache:service=TreeCache,cache-interceptor=CacheMgmtInterceptor</literal>
+            .
+         </para>
+         <para>
+            Each interceptor's MBean exposes a
+            <literal>StatisticsEnabled</literal>
+            attribute that can be used to disable maintenance of statistics for
+            that interceptor. In addition, each interceptor MBean provides the following common operations and
+            attributes.
+            <itemizedlist>
+               <listitem>
+                  <literal>dumpStatistics</literal>
+                  - returns a
+                  <literal>Map</literal>
+                  containing the interceptor's attributes and values.
+               </listitem>
+               <listitem>
+                  <literal>resetStatistics</literal>
+                  - resets all statistics maintained by the interceptor.
+               </listitem>
+               <listitem>
+                  <literal>setStatisticsEnabled(boolean)</literal>
+                  - allows statistics to be disabled for a specific interceptor.
+               </listitem>
+            </itemizedlist>
+         </para>
+         <para>
+         </para>
+      </section>
+
+      <section>
+         <title>Receiving JMX Notifications</title>
+         <para>
+            JBoss Cache users can register a listener to receive cache events described earlier in the
+            <link linkend="api.listener">User API</link>
+            chapter. Users can alternatively utilize the cache's management information infrastructure to receive these
+            events
+            via JMX notifications. Cache events are accessible as notifications by registering a
+            <literal>NotificationListener</literal>
+            for the
+            <literal>CacheJmxWrapper</literal>
+            .
+         </para>
+
+         <para>
+            See the section in the
+            <link linkend="jmx_reference.notifications">JMX Reference chapter</link>
+            pertaining
+            to JMX notifications for a list of notifications that can be received through the
+            <literal>CacheJmxWrapper</literal>
+            .
+         </para>
+
+
+         <para>
+            The following is an example of how to programmatically receive cache notifications when running in a
+            JBoss AS environment. In this example, the client uses a filter to specify which events are of interest.
+         </para>
+
+         <programlisting>
+            <![CDATA[
+         MyListener listener = new MyListener();
+         NotificationFilterSupport filter = null;
+
+         // get reference to MBean server
+         Context ic = new InitialContext();
+         MBeanServerConnection server = (MBeanServerConnection)ic.lookup("jmx/invoker/RMIAdaptor");
+
+         // get reference to CacheMgmtInterceptor MBean
+         String cache_service = "jboss.cache:service=TomcatClusteringCache";
+         ObjectName mgmt_name = new ObjectName(cache_service);
+
+         // configure a filter to only receive node created and removed events
+         filter = new NotificationFilterSupport();
+         filter.disableAllTypes();
+         filter.enableType(CacheNotificationBroadcaster.NOTIF_NODE_CREATED);
+         filter.enableType(CacheNotificationBroadcaster.NOTIF_NODE_REMOVED);
+
+         // register the listener with a filter
+         // leave the filter null to receive all cache events
+         server.addNotificationListener(mgmt_name, listener, filter, null);
+
+         // ...
+
+         // on completion of processing, unregister the listener
+         server.removeNotificationListener(mgmt_name, listener, filter, null);
+         ]]>
+         </programlisting>
+
+         <para>The following is the simple notification listener implementation used in the previous example.</para>
+         <programlisting>
+            <![CDATA[
+         private class MyListener implements NotificationListener, Serializable
+         {
+            public void handleNotification(Notification notification, Object handback)
+            {
+               String message = notification.getMessage();
+               String type = notification.getType();
+               Object userData = notification.getUserData();
+
+               System.out.println(type + ": " + message);
+
+               if (userData == null)
+               {
+                  System.out.println("notification data is null");
+               }
+               else if (userData instanceof String)
+               {
+                  System.out.println("notification data: " + (String) userData);
+               }
+               else if (userData instanceof Object[])
+               {
+                  Object[] ud = (Object[]) userData;
+                  for (Object data : ud)
+                  {
+                     System.out.println("notification data: " + data.toString());
+                  }
+               }
+               else
+               {
+                  System.out.println("notification data class: " + userData.getClass().getName());
+               }
+            }
+         }
+         ]]>
+         </programlisting>
+
+         <para>Note that the JBoss Cache management implementation only listens to cache events after a client registers
+            to receive MBean notifications. As soon as no clients are registered for notifications, the MBean will
+            remove
+            itself as a cache listener.
+         </para>
+
+      </section>
+
+      <section>
+         <title>Accessing Cache MBeans in a Standalone Environment</title>
+         <para>
+            JBoss Cache MBeans are easily accessed when running cache instances in an application server that
+            provides an MBean server interface such as JBoss JMX Console. Refer to your server documentation
+            for instructions on how to access MBeans running in a server's MBean container.
+         </para>
+         <para>
+            In addition, though, JBoss Cache MBeans are also accessible when running in a non-server environment if the
+            JVM is JDK 5.0 or later. When running a standalone cache in a JDK 5.0 environment, you can access the
+            cache's MBeans as follows.
+         </para>
+         <para>
+            <orderedlist>
+               <listitem>
+                  Set the system property
+                  <literal>-Dcom.sun.management.jmxremote</literal>
+                  when starting the JVM
+                  where the cache will run.
+               </listitem>
+               <listitem>
+                  Once the JVM is running, start the JDK 5.0
+                  <literal>jconsole</literal>
+                  utility, located in your JDK's
+                  <literal>/bin</literal>
+                  directory.
+               </listitem>
+               <listitem>When the utility loads, you will be able to select your running JVM and connect to it. The
+                  JBoss Cache
+                  MBeans will be available on the MBeans panel.
+               </listitem>
+            </orderedlist>
+         </para>
+         <para>Note that the
+            <literal>jconsole</literal>
+            utility will automatically register as a listener for cache notifications when
+            connected to a JVM running JBoss Cache instances.
+         </para>
+
+         <para>The following figure shows cache interceptor MBeans in
+            <literal>jconsole</literal>
+            . Cache statistics are displayed
+            for the
+            <literal>CacheMgmtInterceptor</literal>
+            :
+         </para>
+
+         <figure>
+            <title>CacheMgmtInterceptor MBean in jconsole</title>
+
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="CacheMgmtInterceptor.png"/>
+               </imageobject>
+            </mediaobject>
+         </figure>
+
+      </section>
+   </section>
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/eviction_policies.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/eviction_policies.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/eviction_policies.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,537 @@
+<chapter id="eviction_policies">
+   <title>Eviction Policies</title>
+
+   <para>
+      Eviction policies control JBoss Cache's memory management by managing how many nodes are allowed to be stored in
+      memory and their life spans. Memory constraints on servers mean cache cannot grow indefinitely, so policies
+      need to be in place to restrict the size of the cache. Eviction policies are most often used alongside
+      <link linkend="cache_loaders">cache loaders</link>
+      .
+   </para>
+
+   <section>
+      <title>Configuring Eviction Policies</title>
+      <section>
+         <title>Basic Configuration</title>
+         <para>
+            The basic eviction policy configuration element looks like:
+            <programlisting>
+               <![CDATA[
+
+   ...
+
+   <attribute name="EvictionConfig">
+      <config>
+         <attribute name="wakeUpIntervalSeconds">3</attribute>
+
+         <!-- This defaults to 200000 if not specified -->
+         <attribute name="eventQueueSize">100000</attribute>
+
+         <!-- Name of the DEFAULT eviction policy class. -->
+         <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+
+         <!-- Cache wide default -->
+         <region name="/_default_">
+            <attribute name="maxNodes">100</attribute>
+         </region>
+
+         <!-- override policy used for this region -->
+         <region name="/org/jboss/data" policyClass="org.jboss.cache.eviction.MRUPolicy">
+            <attribute name="maxNodes">250</attribute>
+         </region>
+
+         <!-- We expect a lot of events for this region, 
+              so override the default event queue size -->
+         <region name="/org/jboss/test/data" eventQueueSize="500000">
+            <attribute name="maxNodes">60000</attribute>
+         </region>
+
+      </config>
+   </attribute>
+
+   ...
+]]>
+            </programlisting>
+
+            <itemizedlist>
+               <listitem>
+                  <literal>wakeUpIntervalSeconds</literal>
+                  - this required parameter defines how often the eviction thread runs
+               </listitem>
+               <listitem>
+                  <literal>eventQueueSize</literal>
+                  - this optional parameter defines the size of the queue which holds eviction events. If your eviction
+                  thread does not run often enough, you may need to increase this. This can be overridden on a
+                  per-region basis.
+               </listitem>
+               <listitem>
+                  <literal>policyClass</literal>
+                  - this is required, unless you set individual policyClass attributes on each and every region. This
+                  defines the eviction policy to use if one is not defined for a region.
+               </listitem>
+            </itemizedlist>
+
+         </para>
+      </section>
+      <section>
+         <title>Eviction Regions</title>
+         <para>
+            The concept of regions and the
+            <literal>Region</literal>
+            class were
+            <link linkend="architecture.regions">visited earlier</link>
+            when talking about marshalling. Regions also have another use, in that they are used to define the eviction
+            policy used within the region. In addition to using a region-specific configuration, you can also configure
+            a default, cache-wide eviction policy for nodes that do not fall into predefined regions or if you do not
+            wish to define specific regions. It is important to note that when defining regions using the configuration
+            XML file, all elements of the
+            <literal>Fqn</literal>
+            that defines the region are
+            <literal>java.lang.String</literal>
+            objects.
+         </para>
+         <para>
+            Looking at the eviction configuration snippet above, we see that a default region,
+            <literal>_default_</literal>
+            , holds attributes
+            which apply to nodes that do not fall into any of the other regions defined.
+         </para>
+         <para>
+            For each region, you can define parameters which affect how the policy which applies to the region chooses
+            to evict nodes.
+            In the example above, the
+            <literal>LRUPolicy</literal>
+            allows a
+            <literal>maxNodes</literal>
+            parameter which defines
+            how many nodes can exist in the region before it chooses to start evicting nodes. See the javadocs for each
+            policy for a list of allowed parameters.
+         </para>
+
+         <section>
+            <title>Overlapping Eviction Regions</title>
+
+            <para>It's possible to define regions that overlap. In other words, one region can be defined for
+               <emphasis>/a/b/c</emphasis>
+               , and another
+               defined for
+               <emphasis>/a/b/c/d</emphasis>
+               (which is just the
+               <emphasis>d</emphasis>
+               subtree of the
+               <emphasis>/a/b/c</emphasis>
+               sub-tree).
+               The algorithm, in order to handle scenarios like this consistently, will always choose the first region
+               it encounters.
+               In this way, if the algorithm needed to decide how to handle
+               <emphasis>/a/b/c/d/e</emphasis>
+               , it would start from there and work
+               its way up the tree until it hits the first defined region - in this case
+               <emphasis>/a/b/c/d</emphasis>
+               .
+            </para>
+         </section>
+
+      </section>
+      <section>
+         <title>Programmatic Configuration</title>
+         <para>
+            Configuring eviction using the
+            <literal>Configuration</literal>
+            object entails the use of the
+            <literal>org.jboss.cache.config.EvictionConfig</literal>
+            bean, which is passed into
+            <literal>Configuration.setEvictionConfig()</literal>
+            . See the
+            <link linkend="configuration">chapter on Configuration</link>
+            for more on building a
+            <literal>Configuration</literal>
+            programatically.
+         </para>
+
+         <para>
+            The use of simple POJO beans to represent all elements in a
+            cache's configuration also makes it fairly easy to programatically
+            add eviction regions after the cache is started . For example,
+            assume we had an existing cache configured via XML with the
+            EvictionConfig element shown above. Now at runtime we wished to
+            add a new eviction region named "/org/jboss/fifo", using
+            <literal>LRUPolicy</literal>
+            but a different number of
+            <literal>maxNodes</literal>
+            :
+         </para>
+
+         <programlisting>
+            Fqn fqn = Fqn.fromString("/org/jboss/fifo");
+
+            // Create a configuration for an LRUPolicy
+            LRUConfiguration lruc = new LRUConfiguration();
+            lruc.setMaxNodes(10000);
+
+            // Create the region and set the config
+            Region region = cache.getRegion(fqn, true);
+            region.setEvictionPolicy(lruc);
+         </programlisting>
+      </section>
+   </section>
+
+   <section>
+      <title>Shipped Eviction Policies</title>
+      <section>
+         <title>LRUPolicy - Least Recently Used</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.LRUPolicy</literal>
+            controls both the node lifetime and age. This policy guarantees a constant order (
+            <literal>O (1)</literal>
+            ) for
+            adds, removals and lookups (visits). It has the following configuration
+            parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+            <listitem>
+               <literal>timeToLiveSeconds</literal>
+               - The amount of time a node is not written to or read (in seconds) before the node is swept away. 0
+               denotes no limit.
+            </listitem>
+
+            <listitem>
+               <literal>maxAgeSeconds</literal>
+               - Lifespan of a node (in seconds) regardless of idle time before the node is swept away. 0 denotes no
+               limit.
+            </listitem>
+         </itemizedlist>
+      </section>
+
+      <section>
+         <title>FIFOPolicy - First In, First Out</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.FIFOPolicy</literal>
+            controls the eviction in a proper first in first out order. This policy
+            guarantees a constant order (
+            <literal>O (1)</literal>
+            ) for adds, removals and lookups (visits). It has the
+            following configuration parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+         </itemizedlist>
+      </section>
+
+
+      <section>
+         <title>MRUPolicy - Most Recently Used</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.MRUPolicy</literal>
+            controls
+            the eviction in based on most recently used algorithm. The most recently
+            used nodes will be the first to evict with this policy. This policy
+            guarantees a constant order (
+            <literal>O (1)</literal>
+            ) for adds, removals and lookups (visits). It has the
+            following configuration parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+         </itemizedlist>
+      </section>
+
+      <section>
+         <title>LFUPolicy - Least Frequently Used</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.LFUPolicy</literal>
+            controls
+            the eviction in based on least frequently used algorithm. The least
+            frequently used nodes will be the first to evict with this policy. Node
+            usage starts at 1 when a node is first added. Each time it is visted,
+            the node usage counter increments by 1. This number is used to determine
+            which nodes are least frequently used. LFU is also a sorted eviction
+            algorithm. The underlying EvictionQueue implementation and algorithm is
+            sorted in ascending order of the node visits counter. This class
+            guarantees a constant order (
+            <literal>O (1)</literal>
+            ) for adds, removal and searches. However, when any
+            number of nodes are added/visited to the queue for a given processing
+            pass, a single quasilinear (
+            <literal>O (n * log n)</literal>
+            ) operation is used to resort the queue in
+            proper LFU order. Similarly if any nodes are removed or evicted, a
+            single linear (
+            <literal>O (n)</literal>
+            ) pruning operation is necessary to clean up the
+            EvictionQueue. LFU has the following configuration parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+            <listitem>
+               <literal>minNodes</literal>
+               - This is the minimum number of nodes allowed in this region. This value determines what
+               the eviction queue should prune down to per pass. e.g. If
+               minNodes is 10 and the cache grows to 100 nodes, the cache is
+               pruned down to the 10 most frequently used nodes when the
+               eviction timer makes a pass through the eviction
+               algorithm.
+            </listitem>
+
+         </itemizedlist>
+
+      </section>
+
+      <section>
+         <title>ExpirationPolicy</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.ExpirationPolicy</literal>
+            is a policy
+            that evicts nodes based on an absolute expiration time. The
+            expiration time is indicated using the
+            <literal>org.jboss.cache.Node.put()</literal>
+            method, using a String key
+            <literal>expiration</literal>
+            and the absolute time as a
+            <literal>java.lang.Long</literal>
+            object, with a value indicated as milliseconds past midnight
+            January 1st, 1970 UTC (the same relative time as provided by
+            <literal>java.lang.System.currentTimeMillis()</literal>
+            ).
+         </para>
+
+         <para>
+            This policy guarantees a constant order (
+            <literal>O (1)</literal>
+            ) for adds and removals.
+            Internally, a sorted set (TreeSet) containing the expiration
+            time and Fqn of the nodes is stored, which essentially
+            functions as a heap.
+         </para>
+
+         <para>
+            This policy has the following configuration parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>expirationKeyName</literal>
+               - This is the Node key name used
+               in the eviction algorithm. The configuration default is
+               <literal>expiration</literal>
+               .
+            </listitem>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+
+         </itemizedlist>
+
+         <para>
+            The following listing shows how the expiration date is indicated and how the
+            policy is applied:
+            <programlisting>
+               <![CDATA[
+   Cache cache = DefaultCacheFactory.createCache();
+   Fqn fqn1 = Fqn.fromString("/node/1");
+   Long future = new Long(System.currentTimeMillis() + 2000);
+
+   // sets the expiry time for a node
+   cache.getRoot().addChild(fqn1).put(ExpirationConfiguration.EXPIRATION_KEY, future);
+
+   assertTrue(cache.getRoot().hasChild(fqn1));
+   Thread.sleep(5000);
+
+   // after 5 seconds, expiration completes
+   assertFalse(cache.getRoot().hasChild(fqn1));
+]]>
+            </programlisting>
+            Note that the expiration time of nodes is only checked when the
+            region manager wakes up every
+            <literal>wakeUpIntervalSeconds</literal>
+            , so eviction
+            may happen a few seconds later than indicated.
+         </para>
+      </section>
+      <section>
+         <title>ElementSizePolicy - Eviction based on number of key/value pairs in a node</title>
+
+         <para>
+            <literal>org.jboss.cache.eviction.ElementSizePolicy</literal>
+            controls
+            the eviction in based on the number of key/value pairs in the node. Nodes The most recently
+            used nodes will be the first to evict with this policy. It has the following configuration parameters:
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <literal>maxNodes</literal>
+               - This is the maximum number of nodes allowed in this region. 0 denotes no limit.
+            </listitem>
+            <listitem>
+               <literal>maxElementsPerNode</literal>
+               - This is the trigger number of attributes per node for the node to be selected for eviction. 0 denotes
+               no limit.
+            </listitem>
+         </itemizedlist>
+      </section>
+   </section>
+
+   <section>
+      <title>Writing Your Own Eviction Policies</title>
+      <section>
+         <title>Eviction Policy Plugin Design</title>
+
+         <para>The design of the JBoss Cache eviction policy framework is based
+            on an
+            <literal>EvictionInterceptor</literal>
+            to handle cache events and relay them back to the eviction
+            policies. During the cache start up, an
+            <literal>EvictionInterceptor</literal>
+            will be added to the cache
+            interceptor stack if the eviction policy is specified.
+            Then whenever a node is added, removed, evicted, or visited, the
+            <literal>EvictionInterceptor</literal>
+            will maintain state statistics and
+            information will be relayed to each individual eviction region.
+         </para>
+
+         <para>
+            There is a single eviction thread (timer) that will run at a
+            configured interval. This thread will make calls into each of the policy
+            providers and inform it of any aggregated adds,
+            removes and visits (gets) events to the cache during the configured interval.
+            The eviction thread is responsible for kicking off the eviction policy
+            processing (a single pass) for each configured eviction cache
+            region.
+         </para>
+      </section>
+
+      <section>
+         <title>Interfaces to implement</title>
+         <para>In order to implement an eviction policy, the following interfaces
+            must be implemented:
+            <itemizedlist>
+               <listitem>
+                  <literal>org.jboss.cache.eviction.EvictionPolicy</literal>
+               </listitem>
+               <listitem>
+                  <literal>org.jboss.cache.eviction.EvictionAlgorithm</literal>
+               </listitem>
+               <listitem>
+                  <literal>org.jboss.cache.eviction.EvictionQueue</literal>
+               </listitem>
+               <listitem>
+                  <literal>org.jboss.cache.config.EvictionPolicyConfig</literal>
+               </listitem>
+            </itemizedlist>
+            When compounded
+            together, each of these interface implementations define all the
+            underlying mechanics necessary for a complete eviction policy
+            implementation.
+         </para>
+
+         <para>
+            <emphasis>Note that:</emphasis>
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <para>The
+                  <literal>EvictionPolicyConfig</literal>
+                  implementation
+                  should maintain
+                  getter and setter methods for whatever configuration properties
+                  the policy supports (e.g. for
+                  <literal>LRUConfiguration</literal>
+                  among others there is a
+                  <literal>int getMaxNodes()</literal>
+                  and a
+                  <literal>setMaxNodes(int)</literal>
+                  ). When the "EvictionConfig" section of an XML configuration
+                  is parsed, these properties will be set by reflection.
+               </para>
+            </listitem>
+         </itemizedlist>
+
+         <para>Alternatively, the implementation of a new eviction policy
+            provider can be simplified by extending
+            <literal>BaseEvictionPolicy</literal>
+            and
+            <literal>BaseEvictionAlgorithm</literal>
+            . Or for properly sorted EvictionAlgorithms (sorted
+            in eviction order - see
+            <literal>LFUAlgorithm</literal>
+            ) extending
+            <literal>BaseSortedEvictionAlgorithm</literal>
+            and implementing
+            <literal>SortedEvictionQueue</literal>
+            takes
+            care of most of the common functionality available in a set of eviction
+            policy provider classes
+         </para>
+
+
+         <para>
+            <emphasis>Note that:</emphasis>
+         </para>
+
+         <itemizedlist>
+            <listitem>
+               <para>The
+                  <literal>BaseEvictionAlgorithm</literal>
+                  class maintains a processing
+                  structure. It will process the ADD, REMOVE, and VISIT events queued
+                  by the region first. It also maintains an collection of
+                  items that were not properly evicted during the last go around
+                  because of held locks. That list is pruned. Finally, the
+                  EvictionQueue itself is pruned for entries that should be evicted
+                  based upon the configured eviction rules for the region.
+               </para>
+            </listitem>
+            <listitem>
+               <para>The
+                  <literal>BaseSortedEvictionAlgorithm</literal>
+                  class will maintain a boolean
+                  through the algorithm processing that will determine if any new
+                  nodes were added or visited. This allows the Algorithm to determine
+                  whether to resort the eviction queue items (in first to evict order)
+                  or to skip the potentially expensive sorting if there have been no
+                  changes to the cache in this region.
+               </para>
+            </listitem>
+            <listitem>
+               <para>The
+                  <literal>SortedEvictionQueue</literal>
+                  interface defines the contract used by
+                  the
+                  <literal>BaseSortedEvictionAlgorithm</literal>
+                  abstract class that is used to
+                  resort the underlying queue. Again, the queue sorting should be
+                  sorted in first to evict order. The first entry in the list should
+                  evict before the last entry in the queue. The last entry in the
+                  queue should be the last entry that will require eviction.
+               </para>
+            </listitem>
+         </itemizedlist>
+      </section>
+   </section>
+</chapter>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/modules/introduction.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/introduction.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/introduction.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter id="introduction">
+   <title>Overview</title>
+
+   <section>
+      <title>What is JBoss Cache?</title>
+
+      <para>
+         JBoss Cache is a tree-structured, clustered, transactional cache. It is
+         the backbone for many fundamental JBoss Application Server clustering services, including - in certain
+         versions - clustering JNDI, HTTP and EJB sessions.
+      </para>
+      <para>
+         JBoss Cache can also be used as a standalone transactional and clustered caching library or even an object
+         oriented data store. It can even be embedded in other enterprise Java frameworks and application servers
+         such as BEA WebLogic or IBM WebSphere, Tomcat, Spring, Hibernate, and many others. It is also very commonly
+         used directly by standalone Java applications that do not run from within an application server, to maintain
+         clustered state.
+      </para>
+      <section>
+         <title>And what is Pojo Cache?</title>
+         <para>
+            Pojo Cache is an extension of the core JBoss Cache API. Pojo Cache offers additional functionality such as:
+            <itemizedlist>
+               <listitem>maintaining object references even after replication or persistence.</listitem>
+               <listitem>fine grained replication, where only modified object fields are replicated.</listitem>
+               <listitem>"API-less" clustering model where pojos are simply annotated as being clustered.</listitem>
+            </itemizedlist>
+         </para>
+         <para>
+            Pojo Cache has a complete and separate set of documentation, including a user guide, FAQ and tutorial and
+            as such, Pojo Cache is not discussed further in this book.
+         </para>
+      </section>
+
+   </section>
+
+   <section>
+      <title>Summary of Features</title>
+
+      <para>
+         JBoss Cache offers a simple and straightforward API, where data (simple Java objects) can be placed in the
+         cache and, based on configuration options selected, this data may be one or all of:
+         <itemizedlist>
+            <listitem>replicated to some or all cache instances in a cluster.</listitem>
+            <listitem>persisted to disk and/or a remote cluster ("far-cache").</listitem>
+            <listitem>garbage collected from memory when memory runs low, and passivated to disk so state isn't lost.
+            </listitem>
+         </itemizedlist>
+         In addition, JBoss Cache offers a rich set of enterprise-class features:
+         <itemizedlist>
+            <listitem>being able to participate in JTA transactions (works with Java EE compliant TransactionManagers).
+            </listitem>
+            <listitem>attach to JMX servers and provide runtime statistics on the state of the cache.</listitem>
+            <listitem>allow client code to attach listeners and receive notifications on cache events.</listitem>
+         </itemizedlist>
+      </para>
+
+      <para>A cache is organised as a tree, with a single root. Each node in the tree essentially contains a Map,
+         which acts as a store for key/value pairs. The only requirement placed on objects that are cached is that
+         they implement
+         <literal>java.io.Serializable</literal>
+         . Note that this requirement does not exist for Pojo Cache.
+      </para>
+
+      <para>JBoss Cache
+         can be either local or replicated. Local trees exist
+         only inside the JVM in which they are created, whereas replicated trees
+         propagate any changes to some or all other trees in the same cluster. A
+         cluster may span different hosts on a network or just different JVMs
+         on a single host.
+      </para>
+
+      <para>When a change is made to an object in the cache and that change is done in
+         the context of a transaction, the replication of changes is deferred until the transaction
+         commits successfully. All modifications are kept in a list associated with
+         the transaction for the caller. When the transaction commits, we replicate the
+         changes. Otherwise, (on a rollback) we simply undo the changes locally
+         resulting in zero network traffic and overhead. For example, if a caller
+         makes 100 modifications and then rolls back the transaction, we will not replicate
+         anything, resulting in no network traffic.
+      </para>
+
+      <para>If a caller has no transaction associated with it (and isolation level is not
+         NONE - more about this later), we will replicate right after each modification, e.g. in the above
+         case we would send 100 messages, plus an additional message for the
+         rollback. In this sense, running without a transaction can be thought of as analogous as running with
+         auto-commit switched on in JDBC terminology, where each operation is committed automatically.
+      </para>
+
+      <para>
+         JBoss Cache works out of the box with most popular transaction managers, and even provides an API where
+         custom transaction manager lookups can be written.
+      </para>
+
+      <para>
+         The cache is also completely thread-safe. It uses a pessimistic locking scheme for nodes in the tree by
+         default, with an optimistic locking scheme as a configurable option. With pessimistic locking, the degree
+         of concurrency can be tuned using a number of isolation levels, corresponding to database-style
+         transaction isolation levels, i.e., SERIALIZABLE, REPEATABLE_READ, READ_COMMITTED, READ_UNCOMMITTED and NONE.
+         Concurrency, locking and isolation levels will be discussed later.
+      </para>
+   </section>
+
+   <section>
+      <title>
+         Requirements
+      </title>
+      <para>
+         JBoss Cache requires Java 5.0 (or newer).
+      </para>
+      <para>
+         However, there is a way to build JBoss Cache as a Java 1.4.x compatible binary using
+         <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossRetro">JBossRetro</ulink>
+         to retroweave the Java 5.0 binaries. However, Red Hat Inc. does not offer professional support around the
+         retroweaved
+         binary at this time and the Java 1.4.x compatible binary is not in the binary distribution. See
+         <ulink url="http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHabaneroJava1.4">this wiki</ulink>
+         page for
+         details on building the retroweaved binary for yourself.
+      </para>
+      <para>
+         In addition to Java 5.0, at a minimum, JBoss Cache has dependencies on
+         <ulink url="http://www.jgroups.org">JGroups</ulink>
+         , and Apache's
+         <ulink
+                 url="http://jakarta.apache.org/commons/logging/">commons-logging
+         </ulink>
+         . JBoss Cache ships with all dependent libraries necessary to run out of the box.
+      </para>
+   </section>
+
+   <section>
+      <title>License</title>
+      <para>
+         JBoss Cache is an open source product, using the business and OEM-friendly
+         <ulink url="http://www.opensource.org/">OSI-approved</ulink>
+         <ulink url="http://www.gnu.org/copyleft/lesser.html">LGPL license.</ulink>
+         Commercial development support, production support and training for JBoss Cache is available through
+         <ulink url="http://www.jboss.com">JBoss, a division of Red Hat Inc.</ulink>
+         JBoss Cache is a part of JBoss Professional Open Source
+         <ulink url="http://www.jboss.comindex">JEMS</ulink>
+         (JBoss Enterprise Middleware Suite).
+      </para>
+   </section>
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/jmx_reference.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/jmx_reference.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/jmx_reference.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,308 @@
+<chapter id="jmx_reference">
+   <title>JMX References</title>
+   <section id="jmx_reference.statistics">
+      <title>JBoss Cache Statistics</title>
+      <para>
+         The following table describes the statistics currently available and may be collected via JMX.
+      </para>
+      <table>
+         <title>JBoss Cache Management Statistics</title>
+         <tgroup cols="4">
+            <colspec colnum="1" colwidth="2*"/>
+            <colspec colnum="2" colwidth="2*"/>
+            <colspec colnum="3" colwidth="1*"/>
+            <colspec colnum="4" colwidth="3*"/>
+            <thead>
+               <row>
+                  <entry>MBean Name</entry>
+                  <entry>Attribute</entry>
+                  <entry>Type</entry>
+                  <entry>Description</entry>
+               </row>
+            </thead>
+            <tbody>
+               <row>
+                  <entry>ActivationInterceptor</entry>
+                  <entry>Activations</entry>
+                  <entry>long</entry>
+                  <entry>Number of passivated nodes that have been activated.</entry>
+               </row>
+               <row>
+                  <entry>CacheLoaderInterceptor</entry>
+                  <entry>CacheLoaderLoads</entry>
+                  <entry>long</entry>
+                  <entry>Number of nodes loaded through a cache loader.</entry>
+               </row>
+               <row>
+                  <entry>CacheLoaderInterceptor</entry>
+                  <entry>CacheLoaderMisses</entry>
+                  <entry>long</entry>
+                  <entry>Number of unsuccessful attempts to load a node through a cache loader.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>Hits</entry>
+                  <entry>long</entry>
+                  <entry>Number of successful attribute retrievals.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>Misses</entry>
+                  <entry>long</entry>
+                  <entry>Number of unsuccessful attribute retrievals.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>Stores</entry>
+                  <entry>long</entry>
+                  <entry>Number of attribute store operations.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>Evictions</entry>
+                  <entry>long</entry>
+                  <entry>Number of node evictions.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>NumberOfAttributes</entry>
+                  <entry>int</entry>
+                  <entry>Number of attributes currently cached.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>NumberOfNodes</entry>
+                  <entry>int</entry>
+                  <entry>Number of nodes currently cached.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>ElapsedTime</entry>
+                  <entry>long</entry>
+                  <entry>Number of seconds that the cache has been running.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>TimeSinceReset</entry>
+                  <entry>long</entry>
+                  <entry>Number of seconds since the cache statistics have been reset.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>AverageReadTime</entry>
+                  <entry>long</entry>
+                  <entry>Average time in milliseconds to retrieve a cache attribute, including unsuccessful
+                     attribute retrievals.
+                  </entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>AverageWriteTime</entry>
+                  <entry>long</entry>
+                  <entry>Average time in milliseconds to write a cache attribute.</entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>HitMissRatio</entry>
+                  <entry>double</entry>
+                  <entry>Ratio of hits to hits and misses. A hit is a get attribute operation that results in an object
+                     being
+                     returned to the client. The retrieval may be from a cache loader if the entry isn't in the local
+                     cache.
+                  </entry>
+               </row>
+               <row>
+                  <entry>CacheMgmtInterceptor</entry>
+                  <entry>ReadWriteRatio</entry>
+                  <entry>double</entry>
+                  <entry>Ratio of read operations to write operations. This is the ratio of cache hits and misses to
+                     cache stores.
+                  </entry>
+               </row>
+               <row>
+                  <entry>CacheStoreInterceptor</entry>
+                  <entry>CacheLoaderStores</entry>
+                  <entry>long</entry>
+                  <entry>Number of nodes written to the cache loader.</entry>
+               </row>
+               <row>
+                  <entry>InvalidationInterceptor</entry>
+                  <entry>Invalidations</entry>
+                  <entry>long</entry>
+                  <entry>Number of cached nodes that have been invalidated.</entry>
+               </row>
+               <row>
+                  <entry>PassivationInterceptor</entry>
+                  <entry>Passivations</entry>
+                  <entry>long</entry>
+                  <entry>Number of cached nodes that have been passivated.</entry>
+               </row>
+               <row>
+                  <entry>TxInterceptor</entry>
+                  <entry>Prepares</entry>
+                  <entry>long</entry>
+                  <entry>Number of transaction prepare operations performed by this interceptor.</entry>
+               </row>
+               <row>
+                  <entry>TxInterceptor</entry>
+                  <entry>Commits</entry>
+                  <entry>long</entry>
+                  <entry>Number of transaction commit operations performed by this interceptor.</entry>
+               </row>
+               <row>
+                  <entry>TxInterceptor</entry>
+                  <entry>Rollbacks</entry>
+                  <entry>long</entry>
+                  <entry>Number of transaction rollbacks operations performed by this interceptor.</entry>
+               </row>
+            </tbody>
+         </tgroup>
+      </table>
+   </section>
+
+   <section id="jmx_reference.notifications">
+      <title>JMX MBean Notifications</title>
+      <para>The following table depicts the JMX notifications available for JBoss Cache as well as the cache events to
+         which they correspond. These are the notifications that can be received through the
+         <literal>CacheJmxWrapper</literal>
+         MBean.
+         Each notification represents a single event published by JBoss Cache and provides user data corresponding to
+         the parameters of the event.
+      </para>
+      <table>
+         <title>JBoss Cache MBean Notifications</title>
+         <tgroup cols="3">
+            <thead>
+               <row>
+                  <entry>Notification Type</entry>
+                  <entry>Notification Data</entry>
+                  <entry>CacheListener Event</entry>
+               </row>
+            </thead>
+            <tbody>
+               <row>
+                  <entry>org.jboss.cache.CacheStarted</entry>
+                  <entry>String : cache service name</entry>
+                  <entry>cacheStarted</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.CacheStopped</entry>
+                  <entry>String : cache service name</entry>
+                  <entry>cacheStopped</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeCreated</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeCreated</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeEvicted</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeEvicted</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeLoaded</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeLoaded</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeModifed</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeModifed</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeRemoved</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeRemoved</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeVisited</entry>
+                  <entry>String : fqn</entry>
+                  <entry>NodeVisited</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.ViewChange</entry>
+                  <entry>String : view</entry>
+                  <entry>ViewChange</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeActivate</entry>
+                  <entrytbl cols="1">
+                     <tbody>
+                        <row>
+                           <entry rowsep="0">Object[0]=String: fqn</entry>
+                        </row>
+                        <row>
+                           <entry>Object[1]=Boolean: pre</entry>
+                        </row>
+                     </tbody>
+                  </entrytbl>
+                  <entry>NodeActivate</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeEvict</entry>
+                  <entrytbl cols="1">
+                     <tbody>
+                        <row>
+                           <entry rowsep="0">Object[0]=String: fqn</entry>
+                        </row>
+                        <row>
+                           <entry>Object[1]=Boolean: pre</entry>
+                        </row>
+                     </tbody>
+                  </entrytbl>
+                  <entry>NodeEvict</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeModify</entry>
+                  <entrytbl cols="1">
+                     <tbody>
+                        <row>
+                           <entry rowsep="0">Object[0]=String: fqn</entry>
+                        </row>
+                        <row>
+                           <entry rowsep="0">Object[1]=Boolean: pre</entry>
+                        </row>
+                        <row>
+                           <entry>Object[2]=Boolean: isLocal</entry>
+                        </row>
+                     </tbody>
+                  </entrytbl>
+                  <entry>NodeModify</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodePassivate</entry>
+                  <entrytbl cols="1">
+                     <tbody>
+                        <row>
+                           <entry rowsep="0">Object[0]=String: fqn</entry>
+                        </row>
+                        <row>
+                           <entry>Object[1]=Boolean: pre</entry>
+                        </row>
+                     </tbody>
+                  </entrytbl>
+                  <entry>NodePassivate</entry>
+               </row>
+               <row>
+                  <entry>org.jboss.cache.NodeRemove</entry>
+                  <entrytbl cols="1">
+                     <tbody>
+                        <row>
+                           <entry rowsep="0">Object[0]=String: fqn</entry>
+                        </row>
+                        <row>
+                           <entry rowsep="0">Object[1]=Boolean: pre</entry>
+                        </row>
+                        <row>
+                           <entry>Object[2]=Boolean: isLocal</entry>
+                        </row>
+                     </tbody>
+                  </entrytbl>
+                  <entry>NodeRemove</entry>
+               </row>
+            </tbody>
+         </tgroup>
+      </table>
+   </section>
+</chapter>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/modules/preface.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/preface.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/preface.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,48 @@
+<preface id="preface">
+   <title>Preface</title>
+
+   <para>
+      This is the official JBoss Cache user guide. Along with its accompanying documents (an FAQ, a tutorial and a
+      whole set of documents on PojoCache), this is freely available on the JBoss Cache <ulink url="http://labs.jboss.com/jbosscache">documentation site.</ulink>
+   </para>
+   <para>
+      When used, JBoss Cache refers to JBoss Cache Core, a tree-structured, clustered, transactional cache.
+      Pojo Cache, also a part of the JBoss Cache distribution, is documented separately. (Pojo Cache is a cache that
+      deals with Plain Old Java Objects, complete with object relationships, with the ability to cluster such pojos
+      while maintaining their relationships. Please see the Pojo Cache documentation for more information about this.)
+   </para>
+
+   <para>
+      This book is targeted at both developers wishing to use JBoss Cache as a clustering and caching library in
+      their codebase, as well as people who wish to "OEM" JBoss Cache by building on and extending its features. As
+      such,
+      this book is split into two major sections - one detailing the "User" API and the other going much deeper into
+      specialist topics and the JBoss Cache architecture.
+   </para>
+
+   <para>
+      In general, a good knowledge of the Java programming language along with a strong appreciation and understanding
+      of transactions and concurrent threads is necessary. No prior knowledge of JBoss Application Server is expected
+      or required.
+   </para>
+
+   <para>
+      For further discussion, use the
+      <ulink url="http://www.jboss.com/index.html?module=bb&amp;op=viewforum&amp;f=157">user forum</ulink>
+      linked on the JBoss Cache <ulink url="http://labs.jboss.com/jbosscache">website.</ulink>  We also provide a mechanism for
+      tracking bug reports and feature requests on the JBoss Cache <ulink url="http://jira.jboss.com/jira/browse/JBCACHE">JIRA issue tracker.</ulink>
+
+      If you are interested in the development of JBoss Cache or in translating this documentation into other languages,
+      we'd love
+      to hear from you. Please post a message on the
+      <ulink url="http://www.jboss.com/index.html?module=bb&amp;op=viewforum&amp;f=157">user forum</ulink>
+      or contact us by using the JBoss Cache <ulink url="https://lists.jboss.org/mailman/listinfo/jbosscache-dev">developer mailing list.</ulink>
+   </para>
+
+   <para>
+      This book is specifically targeted at the JBoss Cache release of the same version number. It may not apply to
+      older or newer releases of JBoss Cache. It is important that you use the documentation appropriate to the version
+      of JBoss Cache you intend to use.
+   </para>
+
+</preface>
\ No newline at end of file

Added: pojo/trunk/src/main/docbook/userguide/en/modules/replication.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/replication.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/replication.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,730 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter id="clustering">
+   <title>Clustering</title>
+
+   <para>This chapter talks about aspects around clustering JBoss Cache.</para>
+
+   <section>
+      <title>Cache Replication Modes</title>
+
+      <para>JBoss Cache can be configured to be either local (standalone) or
+         clustered. If in a cluster, the cache can be configured to replicate
+         changes, or to invalidate changes. A detailed discussion on this
+         follows.
+      </para>
+
+      <section>
+         <title>Local Mode</title>
+
+         <para>Local caches don't join a cluster and don't communicate with other
+            caches in a cluster. Therefore their elements don't need to be
+            serializable - however, we recommend making them serializable, enabling
+            a user to change the cache mode at any time. The dependency on the
+            JGroups library is still there, although a JGroups channel is not
+            started.
+         </para>
+      </section>
+
+      <section>
+         <title>Replicated Caches</title>
+
+         <para>Replicated caches replicate all changes to some or all of the other cache
+            instances in the cluster. Replication can either happen after each
+            modification (no transactions), or at the end of a transaction (commit
+            time).
+         </para>
+
+         <para>Replication can be synchronous or asynchronous . Use of either one
+            of the options is application dependent. Synchronous replication blocks
+            the caller (e.g. on a
+            <literal>put()</literal>
+            ) until the modifications
+            have been replicated successfully to all nodes in a cluster.
+            Asynchronous replication performs replication in the background (the
+            <literal>put()</literal>
+            returns immediately). JBoss Cache also offers a
+            replication queue, where modifications are replicated periodically (i.e.
+            interval-based), or when the queue size exceeds a number of elements, or
+            a combination thereof.
+         </para>
+
+         <para>Asynchronous replication is faster (no caller blocking), because
+            synchronous replication requires acknowledgments from all nodes in a
+            cluster that they received and applied the modification successfully
+            (round-trip time). However, when a synchronous replication returns
+            successfully, the caller knows for sure that all modifications have been
+            applied to all cache instances, whereas this is not be the case with asynchronous
+            replication. With asynchronous replication, errors are simply written to
+            a log. Even when using transactions, a transaction may succeed but
+            replication may not succeed on all cache instances.
+         </para>
+
+         <section id="replication.tx">
+            <title>Replicated Caches and Transactions</title>
+
+            <para>When using transactions, replication only occurs at the
+               transaction boundary - i.e., when a transaction commits. This results
+               in minimising replication traffic since a single modification is
+               broadcast rather than a series of individual modifications, and can be
+               a lot more efficient than not using transactions. Another effect of
+               this is that if a transaction were to roll back, nothing is broadcast
+               across a cluster.
+            </para>
+
+            <para>Depending on whether you are running your cluster in
+               asynchronous or synchronous mode, JBoss Cache will use either a single
+               phase or
+               <ulink
+                     url="http://en.wikipedia.org/wiki/Two-phase_commit_protocol">two phase
+                  commit
+               </ulink>
+               protocol, respectively.
+            </para>
+
+            <section>
+               <title>One Phase Commits</title>
+
+               <para>Used when your cache mode is REPL_ASYNC. All modifications are
+                  replicated in a single call, which instructs remote caches to apply
+                  the changes to their local in-memory state and commit locally.
+                  Remote errors/rollbacks are never fed back to the originator of the
+                  transaction since the communication is asynchronous.
+               </para>
+            </section>
+
+            <section>
+               <title>Two Phase Commits</title>
+
+               <para>Used when your cache mode is REPL_SYNC. Upon committing your
+                  transaction, JBoss Cache broadcasts a prepare call, which carries
+                  all modifications relevant to the transaction. Remote caches then
+                  acquire local locks on their in-memory state and apply the
+                  modifications. Once all remote caches respond to the prepare call,
+                  the originator of the transaction broadcasts a commit. This
+                  instructs all remote caches to commit their data. If any of the
+                  caches fail to respond to the prepare phase, the originator
+                  broadcasts a rollback.
+               </para>
+
+               <para>Note that although the prepare phase is synchronous, the
+                  commit and rollback phases are asynchronous. This is because
+                  <ulink
+                        url="http://java.sun.com/products/jta/">Sun's JTA
+                     specification
+                  </ulink>
+                  does not specify how transactional resources
+                  should deal with failures at this stage of a transaction; and other
+                  resources participating in the transaction may have indeterminate
+                  state anyway. As such, we do away with the overhead of synchronous
+                  communication for this phase of the transaction. That said, they can
+                  be forced to be synchronous using the
+                  <literal>SyncCommitPhase</literal>
+                  and
+                  <literal>SyncRollbackPhase</literal>
+                  configuration
+                  attributes.
+               </para>
+            </section>
+         </section>
+
+         <section id="br">
+            <title>Buddy Replication</title>
+
+            <para>Buddy Replication allows you to suppress replicating your data
+               to all instances in a cluster. Instead, each instance picks one or
+               more 'buddies' in the cluster, and only replicates to these specific
+               buddies. This greatly helps scalability as there is no longer a memory
+               and network traffic impact every time another instance is added to a
+               cluster.
+            </para>
+
+            <para>One of the most common use cases of Buddy Replication is when a
+               replicated cache is used by a servlet container to store HTTP session
+               data. One of the pre-requisites to buddy replication working well and
+               being a real benefit is the use of
+               <emphasis>session
+                  affinity
+               </emphasis>
+               , more casually known as
+               <emphasis>sticky
+                  sessions
+               </emphasis>
+               in HTTP session replication speak. What this means
+               is that if certain data is frequently accessed, it is desirable that
+               this is always accessed on one instance rather than in a round-robin
+               fashion as this helps the cache cluster optimise how it chooses
+               buddies, where it stores data, and minimises replication
+               traffic.
+            </para>
+
+            <para>If this is not possible, Buddy Replication may prove to be more
+               of an overhead than a benefit.
+            </para>
+
+            <section>
+               <title>Selecting Buddies</title>
+
+               <figure>
+                  <title>BuddyLocator</title>
+
+                  <mediaobject>
+                     <imageobject>
+                        <imagedata fileref="BuddyReplication.png"/>
+                     </imageobject>
+                  </mediaobject>
+               </figure>
+
+               <para>Buddy Replication uses an instance of a
+                  <literal>BuddyLocator</literal>
+                  which contains the logic used to
+                  select buddies in a network. JBoss Cache currently ships with a
+                  single implementation,
+                  <literal>NextMemberBuddyLocator</literal>
+                  ,
+                  which is used as a default if no implementation is provided. The
+                  <literal>NextMemberBuddyLocator</literal>
+                  selects the next member in
+                  the cluster, as the name suggests, and guarantees an even spread of
+                  buddies for each instance.
+               </para>
+
+               <para>The
+                  <literal>NextMemberBuddyLocator</literal>
+                  takes in 2
+                  parameters, both optional.
+                  <itemizedlist>
+                     <listitem>
+
+
+                        <literal>numBuddies</literal>
+
+                        - specifies how many buddies each instance should pick to back its data onto. This defaults to
+                        1.
+                     </listitem>
+
+                     <listitem>
+
+
+                        <literal>ignoreColocatedBuddies</literal>
+
+                        - means that each instance will
+
+                        <emphasis>try</emphasis>
+
+                        to select a buddy on a different physical host. If not able to do so though, it will fall back
+                        to colocated instances. This defaults to
+
+                        <literal>true</literal>
+
+                        .
+                     </listitem>
+                  </itemizedlist>
+               </para>
+            </section>
+
+            <section>
+               <title>BuddyPools</title>
+
+               <para>Also known as
+                  <emphasis>replication groups</emphasis>
+                  , a buddy
+                  pool is an optional construct where each instance in a cluster may
+                  be configured with a buddy pool name. Think of this as an 'exclusive
+                  club membership' where when selecting buddies,
+                  <literal>BuddyLocator</literal>
+                  s that support buddy pools would try
+                  and select buddies sharing the same buddy pool name. This allows
+                  system administrators a degree of flexibility and control over how
+                  buddies are selected. For example, a sysadmin may put two instances
+                  on two separate physical servers that may be on two separate
+                  physical racks in the same buddy pool. So rather than picking an
+                  instance on a different host on the same rack,
+                  <literal>BuddyLocator</literal>
+                  s would rather pick the instance in
+                  the same buddy pool, on a separate rack which may add a degree of
+                  redundancy.
+               </para>
+            </section>
+
+            <section>
+               <title>Failover</title>
+
+               <para>In the unfortunate event of an instance crashing, it is
+                  assumed that the client connecting to the cache (directly or
+                  indirectly, via some other service such as HTTP session replication)
+                  is able to redirect the request to any other random cache instance
+                  in the cluster. This is where a concept of Data Gravitation comes
+                  in.
+               </para>
+
+               <para>Data Gravitation is a concept where if a request is made on a
+                  cache in the cluster and the cache does not contain this
+                  information, it asks other instances in the cluster for the
+                  data. In other words, data is lazily transferred, migrating
+                  <emphasis>only</emphasis>
+                  when other nodes ask for it. This strategy
+                  prevents a network storm effect where lots of data is pushed around
+                  healthy nodes because only one (or a few) of them die.
+               </para>
+
+               <para>If the data is not found in the primary section of some node,
+                  it would (optionally) ask other instances to check in the backup
+                  data they store for other caches.
+                  This means that even if a cache containing your session dies, other
+                  instances will still be able to access this data by asking the cluster
+                  to search through their backups for this data.
+               </para>
+
+               <para>Once located, this data is transferred to the instance
+                  which requested it and is added to this instance's data tree.
+                  The data is then (optionally) removed from all other instances
+                  (and backups) so that if session affinity is used, the affinity
+                  should now be to this new cache instance which has just
+                  <emphasis>taken
+                     ownership
+                  </emphasis>
+                  of this data.
+               </para>
+
+               <para>Data Gravitation is implemented as an interceptor. The
+                  following (all optional) configuration properties pertain to data
+                  gravitation.
+                  <itemizedlist>
+                     <listitem>
+
+
+                        <literal>dataGravitationRemoveOnFind</literal>
+
+                        - forces all remote caches that own the data or hold backups for the data to remove that data,
+                        thereby making the requesting cache the new data owner. This removal, of course, only happens
+                        after the new owner finishes replicating data to its buddy. If set to
+
+                        <literal>false</literal>
+
+                        an evict is broadcast instead of a remove, so any state persisted in cache loaders will remain.
+                        This is useful if you have a shared cache loader configured. Defaults to
+
+                        <literal>true</literal>
+
+                        .
+                     </listitem>
+
+                     <listitem>
+
+
+                        <literal>dataGravitationSearchBackupTrees</literal>
+
+                        - Asks remote instances to search through their backups as well as main data trees. Defaults to
+
+                        <literal>true</literal>
+
+                        . The resulting effect is that if this is
+
+                        <literal>true</literal>
+
+                        then backup nodes can respond to data gravitation requests in addition to data owners.
+                     </listitem>
+
+                     <listitem>
+
+
+                        <literal>autoDataGravitation</literal>
+
+                        - Whether data gravitation occurs for every cache miss. By default this is set to
+
+                        <literal>false</literal>
+
+                        to prevent unnecessary network calls. Most use cases will know when it may need to gravitate
+                        data and will pass in an
+
+                        <literal>Option</literal>
+
+                        to enable data gravitation on a per-invocation basis. If
+
+                        <literal>autoDataGravitation</literal>
+
+                        is
+
+                        <literal>true</literal>
+
+                        this
+
+                        <literal>Option</literal>
+
+                        is unnecessary.
+                     </listitem>
+                  </itemizedlist>
+               </para>
+            </section>
+
+            <section>
+               <title>Configuration</title>
+
+               <para>
+                  <programlisting>
+                     <![CDATA[
+<!-- Buddy Replication config -->
+<attribute name="BuddyReplicationConfig">
+   <config>
+
+      <!-- Enables buddy replication. This is the ONLY mandatory configuration element here. -->
+      <buddyReplicationEnabled>true</buddyReplicationEnabled>
+
+      <!-- These are the default values anyway -->
+      <buddyLocatorClass>org.jboss.cache.buddyreplication.NextMemberBuddyLocator</buddyLocatorClass>
+
+      <!--  numBuddies is the number of backup nodes each node maintains. ignoreColocatedBuddies means
+            that each node will *try* to select a buddy on a different physical host. If not able to do so though,
+            it will fall back to colocated nodes. -->
+      <buddyLocatorProperties>
+         numBuddies = 1
+         ignoreColocatedBuddies = true
+      </buddyLocatorProperties>
+
+      <!-- A way to specify a preferred replication group. If specified, we try and pick a buddy which shares
+           the same pool name (falling back to other buddies if not available). This allows the sysdmin to
+           hint at backup buddies are picked, so for example, nodes may be hinted topick buddies on a different
+           physical rack or power supply for added fault tolerance. -->
+      <buddyPoolName>myBuddyPoolReplicationGroup</buddyPoolName>
+
+      <!-- Communication timeout for inter-buddy group organisation messages (such as assigning to and
+           removing from groups, defaults to 1000. -->
+      <buddyCommunicationTimeout>2000</buddyCommunicationTimeout>
+
+      <!-- Whether data is removed from old owners when gravitated to a new owner. Defaults to true. -->
+      <dataGravitationRemoveOnFind>true</dataGravitationRemoveOnFind>
+
+      <!-- Whether backup nodes can respond to data gravitation requests, or only the data owner is
+           supposed to respond.  Defaults to true. -->
+      <dataGravitationSearchBackupTrees>true</dataGravitationSearchBackupTrees>
+
+      <!-- Whether all cache misses result in a data gravitation request. Defaults to false, requiring
+           callers to enable data gravitation on a per-invocation basis using the Options API. -->
+      <autoDataGravitation>false</autoDataGravitation>
+
+   </config>
+</attribute>
+
+]]>
+                  </programlisting>
+               </para>
+            </section>
+         </section>
+      </section>
+   </section>
+
+   <section>
+      <title>Invalidation</title>
+
+      <para>If a cache is configured for invalidation rather than replication,
+         every time data is changed in a cache other caches in the cluster receive
+         a message informing them that their data is now stale and should be
+         evicted from memory. Invalidation, when used with a shared cache loader
+         (see chapter on Cache Loaders) would cause remote caches to refer to the
+         shared cache loader to retrieve modified data. The benefit of this is
+         twofold: network traffic is minimised as invalidation messages are very
+         small compared to replicating updated data, and also that other caches in
+         the cluster look up modified data in a lazy manner, only when
+         needed.
+      </para>
+
+      <para>Invalidation messages are sent after each modification (no
+         transactions), or at the end of a transaction, upon successful commit.
+         This is usually more efficient as invalidation messages can be optimised
+         for the transaction as a whole rather than on a per-modification
+         basis.
+      </para>
+
+      <para>Invalidation too can be synchronous or asynchronous, and just as in
+         the case of replication, synchronous invalidation blocks until all caches
+         in the cluster receive invalidation messages and have evicted stale data
+         while asynchronous invalidation works in a 'fire-and-forget' mode, where
+         invalidation messages are broadcast but doesn't block and wait for
+         responses.
+      </para>
+   </section>
+
+   <section>
+      <title>State Transfer</title>
+
+      <para>
+         <emphasis>State Transfer</emphasis>
+         refers to the process by which a
+         JBoss Cache instance prepares itself to begin providing a service by
+         acquiring the current state from another cache instance and integrating
+         that state into its own state.
+      </para>
+
+      <section>
+         <title>State Transfer Types</title>
+
+         <para>There are three divisions of state transfer types depending on a
+            point of view related to state transfer. First, in the context of
+            particular state transfer implementation, the underlying plumbing, there
+            are two starkly different state transfer types: byte array and streaming
+            based state transfer. Second, state transfer can be full or partial
+            state transfer depending on a subtree being transferred. Entire cache
+            tree transfer represents full transfer while transfer of a particular
+            subtree represents partial state transfer. And finally state transfer
+            can be "in-memory" and "persistent" transfer depending on a particular
+            use of cache.
+         </para>
+      </section>
+
+      <section>
+         <title>Byte array and streaming based state transfer</title>
+
+         <para>Byte array based transfer was a default and only transfer
+            methodology for cache in all previous releases up to 2.0. Byte array
+            based transfer loads entire state transferred into a byte array and
+            sends it to a state receiving member. Major limitation of this approach
+            is that the state transfer that is very large (&gt;1GB) would likely
+            result in OutOfMemoryException. Streaming state transfer provides an
+            InputStream to a state reader and an OutputStream to a state writer.
+            OutputStream and InputStream abstractions enable state transfer in byte
+            chunks thus resulting in smaller memory requirements. For example, if
+            application state is represented as a tree whose aggregate size is 1GB,
+            rather than having to provide a 1GB byte array streaming state transfer
+            transfers the state in chunks of N bytes where N is user
+            configurable.
+         </para>
+
+         <para>Byte array and streaming based state transfer are completely API
+            transparent, interchangeable, and statically configured through a
+            standard cache configuration XML file. Refer to JGroups documentation on
+            how to change from one type of transfer to another.
+         </para>
+      </section>
+
+      <section>
+         <title>Full and partial state transfer</title>
+
+         <para>If either in-memory or persistent state transfer is enabled, a
+            full or partial state transfer will be done at various times, depending
+            on how the cache is used. "Full" state transfer refers to the transfer
+            of the state related to the entire tree -- i.e. the root node and all
+            nodes below it. A "partial" state transfer is one where just a portion
+            of the tree is transferred -- i.e. a node at a given Fqn and all nodes
+            below it.
+         </para>
+
+         <para>If either in-memory or persistent state transfer is enabled, state
+            transfer will occur at the following times:
+         </para>
+
+         <orderedlist>
+            <listitem>
+               <para>Initial state transfer. This occurs when the cache is first
+                  started (as part of the processing of the
+                  <literal>start()</literal>
+                  method). This is a full state transfer. The state is retrieved from
+                  the cache instance that has been operational the longest.
+                  <footnote>
+                     <para>The longest operating cache instance is always, in JGroups
+                        terms, the coordinator.
+                     </para>
+                  </footnote>
+                  If there is any problem receiving or integrating the state, the cache
+                  will not start.
+               </para>
+
+               <para>Initial state transfer will occur unless:</para>
+
+               <orderedlist>
+                  <listitem>
+                     <para>The cache's
+                        <literal>InactiveOnStartup</literal>
+                        property
+                        is
+                        <literal>true</literal>
+                        . This property is used in
+                        conjunction with region-based marshalling.
+                     </para>
+                  </listitem>
+
+                  <listitem>
+                     <para>Buddy replication is used. See below for more on state
+                        transfer with buddy replication.
+                     </para>
+                  </listitem>
+               </orderedlist>
+            </listitem>
+
+            <listitem>
+               <para>Partial state transfer following region activation. When
+                  region-based marshalling is used, the application needs to register
+                  a specific class loader with the cache. This class loader is used
+                  to unmarshall the state for a specific region (subtree) of the cache.
+               </para>
+
+               <para>After registration, the application calls
+                  <literal>cache.getRegion(fqn, true).activate()</literal>
+                  ,
+                  which initiates a partial state transfer of the relevant subtree's
+                  state. The request is first made to the oldest cache instance in the
+                  cluster. However, if that instance responds with no state, it is then
+                  requested from each instance in turn until one either provides state
+                  or all instances have been queried.
+               </para>
+
+               <para>Typically when region-based marshalling is used, the cache's
+                  <literal>InactiveOnStartup</literal>
+                  property is set to
+                  <literal>true</literal>
+                  . This suppresses initial state transfer,
+                  which would fail due to the inability to deserialize the transferred
+                  state.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>Buddy replication. When buddy replication is used, initial
+                  state transfer is disabled. Instead, when a cache instance joins the
+                  cluster, it becomes the buddy of one or more other instances, and
+                  one or more other instances become its buddy. Each time an instance
+                  determines it has a new buddy providing backup for it, it pushes
+                  it's current state to the new buddy. This "pushing" of state to the
+                  new buddy is slightly different from other forms of state transfer,
+                  which are based on a "pull" approach (i.e. recipient asks for and
+                  receives state). However, the process of preparing and integrating
+                  the state is the same.
+               </para>
+
+               <para>This "push" of state upon buddy group formation only occurs if
+                  the
+                  <literal>InactiveOnStartup</literal>
+                  property is set to
+                  <literal>false</literal>
+                  . If it is
+                  <literal>true</literal>
+                  , state
+                  transfer amongst the buddies only occurs when the application
+                  activates the region on the various members of the group.
+               </para>
+
+               <para>Partial state transfer following a region activation call is
+                  slightly different in the buddy replication case as well. Instead of
+                  requesting the partial state from one cache instance, and trying all
+                  instances until one responds, with buddy replication the instance
+                  that is activating a region will request partial state from each
+                  instance for which it is serving as a backup.
+               </para>
+            </listitem>
+         </orderedlist>
+      </section>
+
+      <section>
+         <title>Transient ("in-memory") and persistent state transfer</title>
+
+         <para>The state that is acquired and integrated can consist of two basic
+            types:
+         </para>
+
+         <orderedlist>
+            <listitem>
+               <para>"Transient" or "in-memory" state. This consists of the actual
+                  in-memory state of another cache instance - the contents of the
+                  various in-memory nodes in the cache that is providing state are
+                  serialized and transferred; the recipient deserializes the data,
+                  creates corresponding nodes in its own in-memory tree, and populates
+                  them with the transferred data.
+               </para>
+
+               <para>"In-memory" state transfer is enabled by setting the cache's
+                  <literal>FetchInMemoryState</literal>
+                  configuration attribute to
+                  <literal>true</literal>
+                  .
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>"Persistent" state. Only applicable if a non-shared cache
+                  loader is used. The state stored in the state-provider cache's
+                  persistent store is deserialized and transferred; the recipient
+                  passes the data to its own cache loader, which persists it to the
+                  recipient's persistent store.
+               </para>
+
+               <para>"Persistent" state transfer is enabled by setting a cache
+                  loader's
+                  <literal>fetchPersistentState</literal>
+                  attribute to
+                  <literal>true</literal>
+                  . If multiple cache loaders are configured
+                  in a chain, only one can have this property set to true; otherwise
+                  you will get an exception at startup.
+               </para>
+
+               <para>Persistent state transfer with a shared cache loader does not
+                  make sense, as the same persistent store that provides the data will
+                  just end up receiving it. Therefore, if a shared cache loader is
+                  used, the cache will not allow a persistent state transfer even if a
+                  cache loader has
+                  <literal>fetchPersistentState</literal>
+                  set to
+                  <literal>true</literal>
+                  .
+               </para>
+            </listitem>
+         </orderedlist>
+
+         <para>Which of these types of state transfer is appropriate depends on
+            the usage of the cache.
+         </para>
+
+         <orderedlist>
+            <listitem>
+               <para>If a write-through cache loader is used, the current cache
+                  state is fully represented by the persistent state. Data may have
+                  been evicted from the in-memory state, but it will still be in the
+                  persistent store. In this case, if the cache loader is not shared,
+                  persistent state transfer is used to ensure the new cache has the
+                  correct state. In-memory state can be transferred as well if the
+                  desire is to have a "hot" cache -- one that has all relevant data in
+                  memory when the cache begins providing service. (Note that the
+                  <literal><![CDATA[<cacheloader><preload>]]></literal>
+                  element in the
+                  <literal>CacheLoaderConfig</literal>
+                  configuration parameter can be used as well to
+                  provide a "warm" or "hot" cache without requiring an in-memory state
+                  transfer. This approach somewhat reduces the burden on the cache
+                  instance providing state, but increases the load on the persistent
+                  store on the recipient side.)
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>If a cache loader is used with passivation, the full
+                  representation of the state can only be obtained by combining the
+                  in-memory (i.e. non-passivated) and persistent (i.e. passivated)
+                  states. Therefore an in-memory state transfer is necessary. A
+                  persistent state transfer is necessary if the cache loader is not
+                  shared.
+               </para>
+            </listitem>
+
+            <listitem>
+               <para>If no cache loader is used and the cache is solely a
+                  write-aside cache (i.e. one that is used to cache data that can also
+                  be found in a persistent store, e.g. a database), whether or not
+                  in-memory state should be transferred depends on whether or not a
+                  "hot" cache is desired.
+               </para>
+            </listitem>
+         </orderedlist>
+      </section>
+      <section>
+         <title>Configuring State Transfer</title>
+         <para>
+            To ensure state transfer behaves as expected, it is important that all nodes in the cluster are configured
+            with
+            the same settings for persistent and transient state. This is because byte array based transfers, when
+            requested,
+            rely only on the requester's configuration while stream based transfers rely on both the requester and
+            sender's
+            configuration, and this is expected to be identical.
+         </para>
+      </section>
+   </section>
+</chapter>

Added: pojo/trunk/src/main/docbook/userguide/en/modules/transactions.xml
===================================================================
--- pojo/trunk/src/main/docbook/userguide/en/modules/transactions.xml	                        (rev 0)
+++ pojo/trunk/src/main/docbook/userguide/en/modules/transactions.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,345 @@
+<chapter id="transactions">
+   <title>Transactions and Concurrency</title>
+   <section>
+      <title>Concurrent Access</title>
+
+      <para>JBoss Cache is a thread safe caching API, and uses its own efficient mechanisms of controlling concurrent
+         access. It uses a pessimistic locking scheme by default for this purpose. Optimistic locking may alternatively
+         be used, and is discussed later.
+      </para>
+
+      <section>
+         <title>Locks</title>
+         <para>Locking is done internally, on a node-level. For example when we
+            want to access "/a/b/c", a lock will be acquired for nodes "a", "b" and
+            "c". When the same transaction wants to access "/a/b/c/d", since we
+            already hold locks for "a", "b" and "c", we only need to acquire a lock
+            for "d".
+         </para>
+         <para>Lock owners are either transactions (call is made within the scope of an existing transaction)
+            or threads (no transaction associated with the call).
+            Regardless, a transaction or a thread is internally transformed into
+            an instance of
+            <literal>GlobalTransaction</literal>
+            , which is used as a globally unique identifier
+            for modifications across a cluster. E.g. when we run a two-phase commit
+            protocol across the cluster, the
+            <literal>GlobalTransaction</literal>
+            uniquely identifies a unit of work across a cluster.
+         </para>
+
+         <para>Locks can be read or write locks. Write locks serialize read and
+            write access, whereas read-only locks only serialize read access. When a
+            write lock is held, no other write or read locks can be acquired. When a
+            read lock is held, others can acquire read locks. However, to acquire
+            write locks, one has to wait until all read locks have been released. When
+            scheduled concurrently, write locks always have precedence over read
+            locks. Note that (if enabled) read locks can be upgraded to write
+            locks.
+         </para>
+
+         <para>Using read-write locks helps in the following scenario: consider a
+            tree with entries "/a/b/n1" and "/a/b/n2". With write-locks, when Tx1
+            accesses "/a/b/n1", Tx2 cannot access "/a/b/n2" until Tx1 has completed
+            and released its locks. However, with read-write locks this is possible,
+            because Tx1 acquires read-locks for "/a/b" and a read-write lock for
+            "/a/b/n1". Tx2 is then able to acquire read-locks for "/a/b" as well, plus
+            a read-write lock for "/a/b/n2". This allows for more concurrency in
+            accessing the cache.
+         </para>
+      </section>
+
+      <section>
+         <title>Pessimistic locking</title>
+         <para>By default, JBoss Cache uses pessimistic locking. Locking is not exposed directly to user. Instead, a
+            transaction isolation level which provides different locking behaviour is configurable.
+         </para>
+         <section>
+            <title>Isolation levels</title>
+            <para>JBoss Cache supports the following transaction isolation levels, analogous to database ACID isolation
+               levels. A user can configure an instance-wide isolation level of NONE, READ_UNCOMMITTED, READ_COMMITTED,
+               REPEATABLE_READ, or SERIALIZABLE. REPEATABLE_READ is the default isolation level used.
+            </para>
+
+            <orderedlist>
+               <listitem>
+                  <para>NONE. No transaction support is needed. There is no locking at
+                     this level, e.g., users will have to manage the data integrity.
+                     Implementations use no locks.
+                  </para>
+               </listitem>
+
+               <listitem>
+                  <para>READ_UNCOMMITTED. Data can be read anytime while write
+                     operations are exclusive. Note that this level doesn't prevent the
+                     so-called "dirty read" where data modified in Tx1 can be read in Tx2
+                     before Tx1 commits. In other words, if you have the following
+                     sequence,
+                     <programlisting>
+                        <![CDATA[
+   Tx1     Tx2
+    W
+            R
+]]>
+                     </programlisting>
+
+                     using this isolation level will not prevent Tx2 read operation.
+                     Implementations typically use an exclusive lock for writes while reads
+                     don't need to acquire a lock.
+                  </para>
+               </listitem>
+
+               <listitem>
+                  <para>READ_COMMITTED. Data can be read any time as long as there is no
+                     write. This level prevents the dirty read. But it doesn’t prevent the
+                     so-called ‘non-repeatable read’ where one thread reads the data twice
+                     can produce different results. For example, if you have the following
+                     sequence,
+                     <programlisting>
+                        <![CDATA[
+   Tx1     Tx2
+    R
+            W
+    R
+]]>
+                     </programlisting>
+                  </para>
+
+                  <para>where the second read in Tx1 thread will produce different
+                     result.
+                  </para>
+
+                  <para>Implementations usually use a read-write lock; reads succeed
+                     acquiring the lock when there are only reads, writes have to wait
+                     until there are no more readers holding the lock, and readers are
+                     blocked acquiring the lock until there are no more writers holding the
+                     lock. Reads typically release the read-lock when done, so that a
+                     subsequent read to the same data has to re-acquire a read-lock; this
+                     leads to nonrepeatable reads, where 2 reads of the same data might
+                     return different values. Note that, the write only applies regardless
+                     of transaction state (whether it has been committed or not).
+                  </para>
+               </listitem>
+
+               <listitem>
+                  <para>REPEATABLE_READ. Data can be read while there is no write and
+                     vice versa. This level prevents "non-repeatable read" but it does not
+                     completely prevent the so-called "phantom read" where new data can be
+                     inserted into the tree from another transaction. Implementations
+                     typically use a read-write lock. This is the default isolation level used.
+                  </para>
+               </listitem>
+
+               <listitem>
+                  <para>SERIALIZABLE. Data access is synchronized with exclusive locks.
+                     Only 1 writer or reader can have the lock at any given time. Locks are
+                     released at the end of the transaction. Regarded as very poor for performance and
+                     thread/transaction concurrency.
+                  </para>
+               </listitem>
+            </orderedlist>
+
+         </section>
+
+         <section>
+            <title>Insertion and Removal of Nodes</title>
+
+            <para>
+               By default, before inserting a new node into the tree or removing an existing node from the
+               tree, JBoss Cache will only attempt to acquire a read lock on the new node's parent node.
+               This approach does not treat child nodes as an integral part of a parent node's state.
+               This approach allows greater concurrency if nodes are frequently added or removed, but
+               at a cost of lesser correctness. For use cases where greater correctness is necessary, JBoss
+               Cache provides a configuration option
+               <literal>LockParentForChildInsertRemove</literal>
+               .
+               If this is set to
+               <literal>true</literal>
+               , insertions and removals of child nodes
+               require the acquisition of a
+               <emphasis>write lock</emphasis>
+               on the parent node.
+            </para>
+         </section>
+      </section>
+
+      <section>
+         <title>Optimistic Locking</title>
+         <para>The motivation for optimistic locking is to improve concurrency. When a lot of threads have a lot of
+            contention for access to the data tree, it can be inefficient to lock portions of the tree - for reading or
+            writing - for the entire duration of a transaction as we do in pessimistic locking. Optimistic locking
+            allows for greater concurrency of threads and transactions by using a technique called data versioning,
+            explained here. Note that isolation levels (if configured) are ignored if optimistic locking is enabled.
+         </para>
+         <section>
+            <title>Architecture</title>
+            <para>Optimistic locking treats all method calls as transactional
+               <footnote>
+                  <para>Because of this requirement, you must always have a transaction manager configured when using
+                     optimistic locking.
+                  </para>
+               </footnote>
+               . Even if you do not invoke a call within the scope of an ongoing transaction, JBoss Cache creates an
+               <emphasis>implicit transaction</emphasis>
+               and commits this transaction when the invocation completes. Each transaction
+               maintains a transaction workspace, which contains a copy of the data used within the transaction.
+            </para>
+            <para>For example, if a transaction calls
+               <literal>cache.getRoot().getChild( Fqn.fromString("/a/b/c") )</literal>
+               ,
+               nodes a, b and c are copied from the main data tree
+               and into the workspace. The data is versioned and all calls in the transaction work on the copy of the
+               data rather than the actual data. When the transaction commits, its workspace is merged back into the
+               underlying tree by matching versions. If there is a version mismatch - such as when the actual data tree
+               has a higher version than the workspace, perhaps if another transaction were to access the same data,
+               change it and commit before the first transaction can finish - the transaction throws a
+               <literal>RollbackException</literal>
+               when committing and the commit fails.
+            </para>
+            <para>Optimistic locking uses the same locks we speak of above, but the locks are only held for a very short
+               duration - at the start of a transaction to build a workspace, and when the transaction commits and has
+               to merge data back into the tree.
+            </para>
+            <para>
+               So while optimistic locking may occasionally fail if version validations fail or may run slightly slower
+               than pessimistic locking due to the inevitable overhead and extra processing of maintaining workspaces,
+               versioned data and validating on commit, it does buy you a near-SERIALIZABLE degree of data integrity
+               while maintaining a very high level of concurrency.
+            </para>
+         </section>
+         <section>
+            <title>Data Versioning</title>
+            <mediaobject>
+               <imageobject>
+                  <imagedata fileref="DataVersions.png" format="PNG"/>
+               </imageobject>
+            </mediaobject>
+            <para>
+               Optimistic locking makes use of the
+               <literal>DataVersion</literal>
+               interface (and an internal and default
+               <literal>DefaultDataVersion</literal>
+               implementation to keep a track of node versioning. In certain cases,
+               where cached data is an in-memory representation of data from an external source such as a database,
+               it makes sense to align the versions used in JBoss Cache with the versions used externally. As such,
+               using the
+               <link linkend="configuration.options">options API</link>
+               , it is possible to set the
+               <literal>DataVersion</literal>
+               you wish to use on a per-invocation basis, allowing you to implement the
+               <literal>DataVersion</literal>
+               interface to hold the versioning information obtained externally before putting your data into the
+               cache.
+            </para>
+         </section>
+         <section>
+            <title>Configuration</title>
+            Optimistic locking is enabled by using the NodeLockingScheme XML attribute, and setting it to "OPTIMISTIC":
+            <programlisting>
+               <![CDATA[
+   ...
+   <!--
+   Node locking scheme:
+   OPTIMISTIC
+   PESSIMISTIC (default)
+   -->
+   <attribute name="NodeLockingScheme">OPTIMISTIC</attribute>
+   ...
+   ]]>
+            </programlisting>
+         </section>
+      </section>
+   </section>
+
+
+   <section>
+      <title>Transactional Support</title>
+
+      <para>JBoss Cache can be configured to use and participate in JTA compliant transactions. Alternatively, if
+         transaction support is disabled, it is equivalent to setting AutoCommit to
+         on where modifications are potentially
+         <footnote>
+            <para>Depending on whether interval-based asynchronous replication is used</para>
+         </footnote>
+         replicated after every change (if replication is
+         enabled).
+      </para>
+
+      <para>What JBoss Cache does on every incoming call is:</para>
+      <orderedlist>
+         <listitem>
+            <para>Retrieve the current
+               <literal>javax.transaction.Transaction</literal>
+               associated with the thread
+            </para>
+         </listitem>
+         <listitem>
+            <para>If not already done, register a
+               <literal>javax.transaction.Synchronization</literal>
+               with the transaction manager to be notified when a transaction commits
+               or is rolled back.
+            </para>
+         </listitem>
+      </orderedlist>
+      <para>
+         In order to do this, the cache has to be provided with a 
+         reference to environment's 
+         <literal>javax.transaction.TransactionManager</literal>
+         .  This is usually done by configuring the cache
+         with the class name of an implementation of the
+         <literal>TransactionManagerLookup</literal>
+         interface. When the cache starts, it will create an instance of this
+         class and invoke its <literal>getTransactionManager()</literal>
+         method, which returns a reference to the
+         <literal>TransactionManager</literal>
+         .
+      </para>
+
+      <mediaobject>
+         <imageobject>
+            <imagedata fileref="TransactionLookup.png" format="PNG"/>
+         </imageobject>
+      </mediaobject>
+
+      <para>JBoss Cache ships with
+         <literal>JBossTransactionManagerLookup</literal>
+         and
+         <literal>GenericTransactionManagerLookup</literal>
+         . The
+         <literal>JBossTransactionManagerLookup</literal>
+         is able to bind to a running JBoss AS instance and retrieve a
+         <literal>TransactionManager</literal>
+         while the
+         <literal>GenericTransactionManagerLookup</literal>
+         is able to bind to most popular Java EE application servers and provide the same functionality. A dummy
+         implementation -
+         <literal>DummyTransactionManagerLookup</literal>
+         - is also provided, primarily for unit tests. Being a dummy, this is just for demo and testing purposes and is
+         not recommended for production use.
+      </para>
+      
+      <para>
+         An alternative to configuring a <literal>TransactionManagerLookup</literal>
+         is to programatically inject a reference to the <literal>TransactionManager</literal>
+         into the <literal>Configuration</literal> object's <literal>RuntimeConfig</literal> element:
+      </para>
+      
+      <programlisting>
+         TransactionManager tm = getTransactionManager(); // magic method
+         cache.getConfiguration().getRuntimeConfig().setTransactionManager(tm);         
+      </programlisting>
+      
+      <para>
+         Injecting the <literal>TransactionManager</literal> is the recommended
+         approach when the <literal>Configuration</literal> is built by some sort of
+         IOC container that already has a reference to the TM.
+      </para>
+      
+      <para>When the transaction commits, we initiate either a one- two-phase commit
+         protocol. See
+         <link linkend="replication.tx">replicated caches and transactions</link>
+         for details.
+      </para>
+
+   </section>
+</chapter>

Added: pojo/trunk/src/main/java/org/jboss/cache/MyClass.java
===================================================================
--- pojo/trunk/src/main/java/org/jboss/cache/MyClass.java	                        (rev 0)
+++ pojo/trunk/src/main/java/org/jboss/cache/MyClass.java	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,60 @@
+package org.jboss.cache;
+
+import org.jboss.kernel.plugins.bootstrap.standalone.StandaloneBootstrap;
+
+/**
+ * // TODO: Add Javadocs
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+public class MyClass
+{
+   private int x, y;
+
+
+   public MyClass()
+   {
+	// some dummy dependency
+	//
+	
+	org.jgroups.Address addr = new org.jgroups.stack.IpAddress();
+   }
+
+   public MyClass(int x, int y)
+   {
+      this.x = x;
+      this.y = y;
+   }
+
+
+   public int getX()
+   {
+      return x;
+   }
+
+   public void setX(int x)
+   {
+      this.x = x;
+   }
+
+   public int getY()
+   {
+      return y;
+   }
+
+   public void setY(int y)
+   {
+      this.y = y;
+   }
+
+   public int add()
+   {
+      return x + y;
+   }
+
+   public int multiply()
+   {
+      return x * y;
+   }
+}

Added: pojo/trunk/src/main/resources/replSync-service.xml
===================================================================
--- pojo/trunk/src/main/resources/replSync-service.xml	                        (rev 0)
+++ pojo/trunk/src/main/resources/replSync-service.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample TreeCache Service Configuration                               -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+
+   <!-- ==================================================================== -->
+   <!-- Defines TreeCache configuration                                      -->
+   <!-- ==================================================================== -->
+
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+          name="jboss.cache:service=TreeCache">
+
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+
+      <!--
+          Configure the TransactionManager
+      -->
+      <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+
+      <!--
+          Isolation level : SERIALIZABLE
+                            REPEATABLE_READ (default)
+                            READ_COMMITTED
+                            READ_UNCOMMITTED
+                            NONE
+      -->
+      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+      <!--
+           Valid modes are LOCAL
+                           REPL_ASYNC
+                           REPL_SYNC
+                           INVALIDATION_ASYNC
+                           INVALIDATION_SYNC
+      -->
+      <attribute name="CacheMode">REPL_SYNC</attribute>
+
+      <!--
+      Just used for async repl: use a replication queue
+      -->
+      <attribute name="UseReplQueue">false</attribute>
+
+      <!--
+          Replication interval for replication queue (in ms)
+      -->
+      <attribute name="ReplQueueInterval">0</attribute>
+
+      <!--
+          Max number of elements which trigger replication
+      -->
+      <attribute name="ReplQueueMaxElements">0</attribute>
+
+      <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+           cluster in order to find each other.
+      -->
+      <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+      <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS.  -->
+      <!--
+      <depends>jgroups.mux:name=Multiplexer</depends>
+      <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+      <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+      -->
+
+      <!-- JGroups protocol stack properties.
+         ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+      -->
+      <attribute name="ClusterConfig">
+         <config>
+            <UDP mcast_addr="228.10.10.10"
+                 mcast_port="45588"
+                 tos="8"
+                 ucast_recv_buf_size="20000000"
+                 ucast_send_buf_size="640000"
+                 mcast_recv_buf_size="25000000"
+                 mcast_send_buf_size="640000"
+                 loopback="false"
+                 discard_incompatible_packets="true"
+                 max_bundle_size="64000"
+                 max_bundle_timeout="30"
+                 use_incoming_packet_handler="true"
+                 ip_ttl="2"
+                 enable_bundling="false"
+                 enable_diagnostics="true"
+
+                 use_concurrent_stack="true"
+
+                 thread_naming_pattern="pl"
+
+                 thread_pool.enabled="true"
+                 thread_pool.min_threads="1"
+                 thread_pool.max_threads="25"
+                 thread_pool.keep_alive_time="30000"
+                 thread_pool.queue_enabled="true"
+                 thread_pool.queue_max_size="10"
+                 thread_pool.rejection_policy="Run"
+
+                 oob_thread_pool.enabled="true"
+                 oob_thread_pool.min_threads="1"
+                 oob_thread_pool.max_threads="4"
+                 oob_thread_pool.keep_alive_time="10000"
+                 oob_thread_pool.queue_enabled="true"
+                 oob_thread_pool.queue_max_size="10"
+                 oob_thread_pool.rejection_policy="Run"/>
+
+            <PING timeout="2000" num_initial_members="3"/>
+            <MERGE2 max_interval="30000" min_interval="10000"/>
+            <FD_SOCK/>
+            <FD timeout="10000" max_tries="5" shun="true"/>
+            <VERIFY_SUSPECT timeout="1500"/>
+            <pbcast.NAKACK max_xmit_size="60000"
+                           use_mcast_xmit="false" gc_lag="0"
+                           retransmit_timeout="300,600,1200,2400,4800"
+                           discard_delivered_msgs="true"/>
+            <UNICAST timeout="300,600,1200,2400,3600"/>
+            <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                           max_bytes="400000"/>
+            <pbcast.GMS print_local_addr="true" join_timeout="5000"
+                        join_retry_timeout="2000" shun="false"
+                        view_bundling="true" view_ack_collection_timeout="5000"/>
+            <FRAG2 frag_size="60000"/>
+            <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+            <!-- <pbcast.STATE_TRANSFER/> -->
+            <pbcast.FLUSH timeout="0"/>
+         </config>
+      </attribute>
+
+
+      <!--
+       Whether or not to fetch state on joining a cluster
+       NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+      -->
+      <attribute name="FetchInMemoryState">true</attribute>
+
+      <!--
+          The max amount of time (in milliseconds) we wait until the
+          state (ie. the contents of the cache) are retrieved from
+          existing members in a clustered environment
+      -->
+      <attribute name="StateRetrievalTimeout">15000</attribute>
+
+      <!--
+          Number of milliseconds to wait until all responses for a
+          synchronous call have been received.
+      -->
+      <attribute name="SyncReplTimeout">15000</attribute>
+
+      <!-- Max number of milliseconds to wait for a lock acquisition -->
+      <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+      <!--
+         Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+         class loader, e.g., inside an application server. Default is "false".
+      -->
+      <attribute name="UseRegionBasedMarshalling">true</attribute>
+   </mbean>
+
+
+   <!--  Uncomment to get a graphical view of the TreeCache MBean above -->
+   <!--   <mbean code="org.jboss.cache.TreeCacheView" name="jboss.cache:service=TreeCacheView">-->
+   <!--      <depends>jboss.cache:service=TreeCache</depends>-->
+   <!--      <attribute name="CacheService">jboss.cache:service=TreeCache</attribute>-->
+   <!--   </mbean>-->
+
+
+</server>

Added: pojo/trunk/src/test/java/org/jboss/cache/MyClassTest.java
===================================================================
--- pojo/trunk/src/test/java/org/jboss/cache/MyClassTest.java	                        (rev 0)
+++ pojo/trunk/src/test/java/org/jboss/cache/MyClassTest.java	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,48 @@
+package org.jboss.cache;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterClass;
+
+/**
+ * // TODO: Add Javadocs
+ *
+ * @author <a href="mailto:manik at jboss.org">Manik Surtani</a>
+ * @since 2.0.0
+ */
+ at Test
+public class MyClassTest
+{
+   private MyClass mc = null;
+
+   @BeforeTest
+   public void create()
+   {
+      mc = new MyClass();
+   }
+
+   @AfterClass
+   public void destroy()
+   {
+      mc = null;
+   }
+
+   @Test
+   public void multiplication()
+   {
+      mc.setX(5);
+      mc.setY(2);
+
+      assert 10 == mc.multiply();
+   }
+
+   @Test
+   public void addition()
+   {
+      mc.setX(5);
+      mc.setY(2);
+
+      assert 7 == mc.add();
+   }
+
+}

Added: pojo/trunk/src/test/resources/replSync-service-test.xml
===================================================================
--- pojo/trunk/src/test/resources/replSync-service-test.xml	                        (rev 0)
+++ pojo/trunk/src/test/resources/replSync-service-test.xml	2007-08-14 16:26:14 UTC (rev 4247)
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ===================================================================== -->
+<!--                                                                       -->
+<!--  Sample TreeCache Service Configuration                               -->
+<!--                                                                       -->
+<!-- ===================================================================== -->
+
+<server>
+
+   <!-- ==================================================================== -->
+   <!-- Defines TreeCache configuration                                      -->
+   <!-- ==================================================================== -->
+
+   <mbean code="org.jboss.cache.jmx.CacheJmxWrapper"
+          name="jboss.cache:service=TreeCache">
+
+      <depends>jboss:service=Naming</depends>
+      <depends>jboss:service=TransactionManager</depends>
+
+      <!--
+          Configure the TransactionManager
+      -->
+      <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup
+      </attribute>
+
+      <!--
+          Isolation level : SERIALIZABLE
+                            REPEATABLE_READ (default)
+                            READ_COMMITTED
+                            READ_UNCOMMITTED
+                            NONE
+      -->
+      <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
+
+      <!--
+           Valid modes are LOCAL
+                           REPL_ASYNC
+                           REPL_SYNC
+                           INVALIDATION_ASYNC
+                           INVALIDATION_SYNC
+      -->
+      <attribute name="CacheMode">REPL_SYNC</attribute>
+
+      <!--
+      Just used for async repl: use a replication queue
+      -->
+      <attribute name="UseReplQueue">false</attribute>
+
+      <!--
+          Replication interval for replication queue (in ms)
+      -->
+      <attribute name="ReplQueueInterval">0</attribute>
+
+      <!--
+          Max number of elements which trigger replication
+      -->
+      <attribute name="ReplQueueMaxElements">0</attribute>
+
+      <!-- Name of cluster. Needs to be the same for all TreeCache nodes in a
+           cluster in order to find each other.
+      -->
+      <attribute name="ClusterName">JBossCache-Cluster</attribute>
+
+      <!--Uncomment next three statements to enable JGroups multiplexer.
+This configuration is dependent on the JGroups multiplexer being
+registered in an MBean server such as JBossAS.  -->
+      <!--
+      <depends>jgroups.mux:name=Multiplexer</depends>
+      <attribute name="MultiplexerService">jgroups.mux:name=Multiplexer</attribute>
+      <attribute name="MultiplexerStack">fc-fast-minimalthreads</attribute>
+      -->
+
+      <!-- JGroups protocol stack properties.
+         ClusterConfig isn't used if the multiplexer is enabled and successfully initialized.
+      -->
+      <attribute name="ClusterConfig">
+         <config>
+            <UDP mcast_addr="228.10.10.10"
+                 mcast_port="45588"
+                 tos="8"
+                 ucast_recv_buf_size="20000000"
+                 ucast_send_buf_size="640000"
+                 mcast_recv_buf_size="25000000"
+                 mcast_send_buf_size="640000"
+                 loopback="false"
+                 discard_incompatible_packets="true"
+                 max_bundle_size="64000"
+                 max_bundle_timeout="30"
+                 use_incoming_packet_handler="true"
+                 ip_ttl="2"
+                 enable_bundling="false"
+                 enable_diagnostics="true"
+
+                 use_concurrent_stack="true"
+
+                 thread_naming_pattern="pl"
+
+                 thread_pool.enabled="true"
+                 thread_pool.min_threads="1"
+                 thread_pool.max_threads="25"
+                 thread_pool.keep_alive_time="30000"
+                 thread_pool.queue_enabled="true"
+                 thread_pool.queue_max_size="10"
+                 thread_pool.rejection_policy="Run"
+
+                 oob_thread_pool.enabled="true"
+                 oob_thread_pool.min_threads="1"
+                 oob_thread_pool.max_threads="4"
+                 oob_thread_pool.keep_alive_time="10000"
+                 oob_thread_pool.queue_enabled="true"
+                 oob_thread_pool.queue_max_size="10"
+                 oob_thread_pool.rejection_policy="Run"/>
+
+            <PING timeout="2000" num_initial_members="3"/>
+            <MERGE2 max_interval="30000" min_interval="10000"/>
+            <FD_SOCK/>
+            <FD timeout="10000" max_tries="5" shun="true"/>
+            <VERIFY_SUSPECT timeout="1500"/>
+            <pbcast.NAKACK max_xmit_size="60000"
+                           use_mcast_xmit="false" gc_lag="0"
+                           retransmit_timeout="300,600,1200,2400,4800"
+                           discard_delivered_msgs="true"/>
+            <UNICAST timeout="300,600,1200,2400,3600"/>
+            <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
+                           max_bytes="400000"/>
+            <pbcast.GMS print_local_addr="true" join_timeout="5000"
+                        join_retry_timeout="2000" shun="false"
+                        view_bundling="true" view_ack_collection_timeout="5000"/>
+            <FRAG2 frag_size="60000"/>
+            <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+            <!-- <pbcast.STATE_TRANSFER/> -->
+            <pbcast.FLUSH timeout="0"/>
+         </config>
+      </attribute>
+
+
+      <!--
+       Whether or not to fetch state on joining a cluster
+       NOTE this used to be called FetchStateOnStartup and has been renamed to be more descriptive.
+      -->
+      <attribute name="FetchInMemoryState">true</attribute>
+
+      <!--
+          The max amount of time (in milliseconds) we wait until the
+          state (ie. the contents of the cache) are retrieved from
+          existing members in a clustered environment
+      -->
+      <attribute name="StateRetrievalTimeout">15000</attribute>
+
+      <!--
+          Number of milliseconds to wait until all responses for a
+          synchronous call have been received.
+      -->
+      <attribute name="SyncReplTimeout">15000</attribute>
+
+      <!-- Max number of milliseconds to wait for a lock acquisition -->
+      <attribute name="LockAcquisitionTimeout">10000</attribute>
+
+      <!--
+         Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped
+         class loader, e.g., inside an application server. Default is "false".
+      -->
+      <attribute name="UseRegionBasedMarshalling">true</attribute>
+   </mbean>
+
+
+   <!--  Uncomment to get a graphical view of the TreeCache MBean above -->
+   <!--   <mbean code="org.jboss.cache.TreeCacheView" name="jboss.cache:service=TreeCacheView">-->
+   <!--      <depends>jboss.cache:service=TreeCache</depends>-->
+   <!--      <attribute name="CacheService">jboss.cache:service=TreeCache</attribute>-->
+   <!--   </mbean>-->
+
+
+</server>




More information about the jbosscache-commits mailing list