Infinispan RESTful interface


Using a custom Infinispan cache configuration

Out of the box, Inifinispan uses a default cache configuration. To set a custom configuration, create an Infinispan XML configuration file and set the PATH to it in your web.xml file, under the key infinispan.config.

The infinispan configuration file is dictated by the Init Servlet which contains the name and the path where the configuration is stored:


   <!-- Specify your cache configuration file -->

. . . . .

As it is, drop the following infinispan.xml file into WEB-INF/classes of your application:


   <namedCache name="cacheX" />


So now you can reference cacheX from your RESTful clients.

Last minute addition:

I'm adding a pure javascript code (no jQuery) for interacting with REStful services, you can have a try on it if you like:


var url = "http://localhost:8080/infinispan/rest/cacheX/bucket1";
var representationOfDesiredState = "Adding this to the cache";

var client = new XMLHttpRequest();"PUT", url, false);

client.setRequestHeader("Content-Type", "text/plain");


if (client.status == 200)
 alert("The request succeeded!\n\nThe response representation was:\n\n" + client.responseText)
 alert("The request did not succeed!\n\nThe response status was: " + client.status + " " + client.statusText + ".");


Related articles available on

Follow us on Twitter