Infinispan RESTful interface
In this article, we will show you how to deploy Infinispan on JBoss AS 6. The application deployed is the RESTful interface to Infinispan which can be used by every kind of client to get/put elements in the cache.
If you need to access the Infinispan data grid from any kind of client (which is able to consume a RESTful service), then Infinispan REST server is what you need !
Download Infinispan server-rest application from here
This tutorial has been tested with the release 4.2.1 of Infinispan and JBoss AS 6
Now unzip the file infinispan-4.2.1.FINAL-server-rest.zip and extract the file infinispan.war which will be deployed on JBoss AS 6.
Please note, due to issues with the VFS of JBoss AS 6, some libraries (namely scala-library-2.8.1.jar) cause the application deployment to fail. In order to solve this issue you can add to your WEB-INF folder of infinispan.war a JBoss AS metadata file (jboss-scanning.xml) which excludes scala library from the deployment.
Here's jboss-scanning.xml
This is how your infinispan.war archive will look like:
infinispan.war
--WEB-INF
lib
classes
--- web.xml
--- jboss-scanning.xml
Ok. Now launch JBoss AS 6 and point your browser to the infinispan REST server:
http://localhost:8080/inifinispan
You will hit a welcome page which describes how basically the REST server works:
In order to insert elements in the cache, you can issue an HTTP PUT and POST request.
PUT /{cacheName}/{cacheKey}
POST /{cacheName}/{cacheKey}
In order to retrieve elements from the cache you can use HTTP GET request:
GET /{cacheName}/{cacheKey}
In order to delete elements from the cache you can issue an HTTP DELETE request:
DELETE /{cacheName}/{cacheKey}
By default infinispan has just the "___defaultcache" registered, so if you want to try out of the box the REST server, just create a REST client.
Following here is a jQuery client which puts an entry in the cache:
And here's the corresponding page which performs a get on the bucket1 key:
Do I need to download jQuery to run this sample ? no at all. jQuery is accessed on the cloud via <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>. If you cannot reach the web from there, of course download jquery.js and place it on the server's path.

