29.2.2. Deployment Via a -service.xml File

As in JBoss Enterprise Application Platform 4.x, you can also deploy a JBoss Cache instance as an MBean service via a -service.xml file. The primary difference from JBoss Enterprise Application Platform 4.x is the value of the code attribute in the mbean element. In JBoss Enterprise Application Platform 4.x, this was org.jboss.cache.TreeCache; in JBoss Enterprise Application Platform 5.x it is org.jboss.cache.jmx.CacheJmxWrapper. Here's an example:
<?xml version="1.0" encoding="UTF-8"?>

<server>
  <mbean code="org.jboss.cache.jmx.CacheJmxWrapper" 
         name="foo:service=ExampleCacheJmxWrapper">
      
     <attribute name="TransactionManagerLookupClass">
       org.jboss.cache.transaction.JBossTransactionManagerLookup
     </attribute>
     
     <attribute name="MuxChannelFactory"><inject bean="JChannelFactory"/></attribute>
     
     <attribute name="MultiplexerStack">udp</attribute>
     <attribute name="ClusterName">Example-EntityCache</attribute>        
     <attribute name="IsolationLevel">REPEATABLE_READ</attribute>
     <attribute name="CacheMode">REPL_SYNC</attribute>
     <attribute name="InitialStateRetrievalTimeout">15000</attribute>
     <attribute name="SyncReplTimeout">20000</attribute>
     <attribute name="LockAcquisitionTimeout">15000</attribute>
     <attribute name="ExposeManagementStatistics">true</attribute>
         
  </mbean>
</server>
The CacheJmxWrapper is not the cache itself (i.e. you can not store stuff in it). Rather, as it's name implies, it's a wrapper around an org.jboss.cache.Cache that handles integration with JMX. CacheJmxWrapper exposes the org.jboss.cache.Cache via its CacheJmxWrapperMBean MBean interfaces Cache attribute; services that need the cache can obtain a reference to it via that attribute.