If JBoss Cache is run inside of JBoss AS (as an MBean), we can bind it into JNDI using JrmpProxyFactory, just like any other MBean. Below is an example of how to do this:
<mbean
code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
name="mydomain:service=proxyFactory,type=jrmp,target=factory">
<attribute
name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
<attribute
name="TargetName">jboss.cache:service=TreeCache</attribute>
<attribute name="JndiName">MyCache</attribute> <attribute
name="InvokeTargetMethod">true</attribute> <attribute
name="ExportedInterface">org.jboss.cache.TreeCacheMBean</attribute>
<attribute name="ClientInterceptors"> <iterceptors>
<interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
<interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
<interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
</iterceptors> </attribute>
<depends>jboss:service=invoker,type=jrmp</depends>
<depends>jboss.cache:service=TreeCache</depends>
</mbean>
The InvokerName attribute needs to point to a valid JBoss invoker MBean. TargetName is the JMX name of the MBean that needs to be bound into JNDI. JndiName is the name under which the MBean will be bound, and ExportedInterface is the interface name of the MBean.