3.2. Creating a Configuration

As discussed in the Section 2.2, “Instantiating and Starting the Cache”, before a Cache can be created, the CacheFactory must be provided with a Configuration object or with a file name or input stream to use to parse a Configuration from XML. The following sections describe how to accomplish this.

3.2.1. Parsing an XML-based Configuration File

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.
The simplest example of a configuration XML file, a cache configured to run in LOCAL mode, looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns="urn:jboss:jbosscache-core:config:3.2">
</jbosscache>


This file uses sensible defaults for isolation levels, lock acquisition timeouts, locking modes, etc. Another, more complete, sample XML file is included in the Section 12.1, “Sample XML Configuration File” section of this book, along with Section 12.2, “Configuration File Quick Reference” explaining the various options.