Infinispan, How to configure Jboss As managed cache manager
dinoop.p1 Mar 7, 2014 4:02 AMI am trying to use Jboss AS managed Infinispan in my application, so that I can use Jboss Admin console to manage it.
I have tried the following steps based on Infinispan documentation,
1) Created a class named Config
import javax.annotation.Resource; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.inject.Produces; import org.infinispan.manager.EmbeddedCacheManager; public class Config { @Produces @ApplicationScoped @Resource(lookup = "java:jboss/infinispan/test") private EmbeddedCacheManager defaultCacheManager; public void printObject() { System.out.println("defaultCacheManager:"+defaultCacheManager); } }
2) created a servlet just for making Config object and calling printObject() method
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class TestServlet extends HttpServlet{ /** * */ private static final long serialVersionUID = 3200037917839533696L; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doIt(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doIt(req, resp); } protected void doIt(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { Config config = new Config(); config.printObject(); } catch (Exception e) { e.printStackTrace(); } } }
3) Added the application dependencies via standalone.xml global configuration
<subsystem xmlns="urn:jboss:domain:ee:1.0"> <global-modules> <module name="org.infinispan" slot="main"/> <module name="javax.enterprise.api" slot="main"/> <module name="javax.faces.api" slot="main"/> <module name="javax.inject.api" slot="main"/> <module name="javax.annotation.api" slot="main"/> </global-modules> </subsystem>
4)Added new cache container in subsystem named test
<subsystem xmlns="urn:jboss:domain:infinispan:1.2" default-cache-container="test"> <cache-container name="test" default-cache="entity" start="EAGER"> <local-cache name="entity"/> </cache-container> </subsystem>
5)Removed all Infinispan related jars from my application
But, When I try to call the printObject() method from servel it is printing null
13:37:24,206 INFO [stdout] (http--127.0.0.1-9090-1) defaultCacheManager:null
Why it is happening , please correct me if any thing missed from my side.