[jboss-cvs] JBossAS SVN: r58588 - trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Nov 18 06:44:18 EST 2006


Author: bstansberry at jboss.com
Date: 2006-11-18 06:44:17 -0500 (Sat, 18 Nov 2006)
New Revision: 58588

Modified:
   trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheCluster.java
Log:
Update to JBC 2.0 API

Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheCluster.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheCluster.java	2006-11-18 11:43:27 UTC (rev 58587)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/tc6/session/JBossCacheCluster.java	2006-11-18 11:44:17 UTC (rev 58588)
@@ -45,9 +45,11 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.jboss.cache.BatchModeTransactionManagerLookup;
-import org.jboss.cache.PropertyConfigurator;
-import org.jboss.cache.aop.PojoCache;
-import org.jboss.cache.aop.PojoCacheMBean;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.XmlConfigurationParser;
+import org.jboss.cache.pojo.PojoCacheFactory;
+import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapper;
+import org.jboss.cache.pojo.jmx.PojoCacheJmxWrapperMBean;
 import org.jboss.mx.util.MBeanProxyExt;
 import org.jboss.mx.util.MBeanServerLocator;
 
@@ -106,13 +108,13 @@
    private LifecycleSupport lifecycle = new LifecycleSupport(this);
 
    /** Our tree cache */
-   private PojoCacheMBean treeCache = null;
+   private PojoCacheJmxWrapperMBean pojoCache = null;
    
    /** Name under which our TreeCache is registered in JMX */
-   private String treeCacheObjectName = "jboss.cache:service=TomcatClusteringCache";
+   private String pojoCacheObjectName = "jboss.cache:service=TomcatClusteringCache";
    
    /** Did we create the tree cache, or was it already registered in JMX? */
-   private boolean treeCacheLocal = false;
+   private boolean pojoCacheLocal = false;
    
    /** Name of the tree cache's JGroups channel */
    private String clusterName = null;
@@ -183,7 +185,7 @@
     */
    public String getCacheObjectName()
    {
-      return treeCacheObjectName;
+      return pojoCacheObjectName;
    }
 
    /**
@@ -195,7 +197,7 @@
     */
    public void setCacheObjectName(String objectName)
    {
-      this.treeCacheObjectName = objectName;
+      this.pojoCacheObjectName = objectName;
    }
 
    /**
@@ -624,7 +626,7 @@
       manager.setSnapshotInterval(snapshotInterval);
       manager.setUseJK(useJK);
       manager.setUseLocalCache(useLocalCache);
-      manager.setCacheObjectNameString(treeCacheObjectName);
+      manager.setCacheObjectNameString(pojoCacheObjectName);
       
       // Only set replication attributes if they were not
       // already set via a <Manager> element in an XML config file
@@ -670,16 +672,16 @@
          MBeanServerLocator.setJBoss(getMBeanServer());
          
          // Initialize the tree cache
-         PojoCacheMBean cache = getTreeCache();
+         PojoCacheJmxWrapperMBean cache = getTreeCache();
+
+         registerMBeans();
          
-         if (treeCacheLocal)
+         if (pojoCacheLocal)
          {
-            cache.createService();
-            cache.startService();
+            cache.create();
+            cache.start();
          }
 
-         registerMBeans();
-
          started = true;
          
          // Notify our interested LifecycleListeners
@@ -713,10 +715,10 @@
       // Notify our interested LifecycleListeners
       lifecycle.fireLifecycleEvent(BEFORE_STOP_EVENT, this);
       
-      if (treeCacheLocal)
+      if (pojoCacheLocal)
       {
-         treeCache.stopService();
-         treeCache.destroyService();
+         pojoCache.stop();
+         pojoCache.destroy();
       }
 
       started = false;
@@ -756,30 +758,29 @@
     * Gets our TreeCache, either from a local reference or the JMX
     * server.  If one is not found, creates and configures it.
     */
-   private PojoCacheMBean getTreeCache() throws Exception
+   private PojoCacheJmxWrapperMBean getTreeCache() throws Exception
    {
-      if (treeCache == null) {
+      if (pojoCache == null) {
          
          MBeanServer server = getMBeanServer();
-         ObjectName objName = new ObjectName(treeCacheObjectName);
+         ObjectName objName = new ObjectName(pojoCacheObjectName);
          if (server.isRegistered(objName))
          {
             // Get a proxy to the existing TreeCache
-            treeCache = (PojoCacheMBean) 
-                  MBeanProxyExt.create(PojoCacheMBean.class, objName);
+            pojoCache = (PojoCacheJmxWrapperMBean) 
+                           MBeanProxyExt.create(PojoCacheJmxWrapperMBean.class, objName);
          }
          else
          {
-            // Create our own tree cache
-            treeCache = new PojoCache();
-            
             // See if there is an XML descriptor file to configure the cache
             InputStream configIS = getCacheConfigStream();
             
+            Configuration config = null;
+            
             if (configIS != null)
             {
-               PropertyConfigurator config = new PropertyConfigurator();
-               config.configure(treeCache, configIS);
+               XmlConfigurationParser parser = new XmlConfigurationParser();
+               config = parser.parseStream(configIS);
                try 
                {
                   configIS.close();
@@ -794,7 +795,7 @@
                   // Override the XML config with the name provided in
                   // server.xml.  Method setClusterName is specified in the
                   // Cluster interface, otherwise we would not do this
-                  treeCache.setClusterName(clusterName);
+                  config.setClusterName(clusterName);
                }
             }
             else
@@ -802,19 +803,22 @@
                // User did not try to configure the cache.
                // Configure it using defaults.  Only exception
                // is the clusterName, which user can specify in server.xml.
+               config = new Configuration();
                String channelName = (clusterName == null) ? DEFAULT_CLUSTER_NAME
                                                           : clusterName;
-               treeCache.setClusterName(channelName);
-               treeCache.setIsolationLevel(DEFAULT_ISOLATION_LEVEL);
-               treeCache.setCacheMode(DEFAULT_CACHE_MODE);
-               treeCache.setLockAcquisitionTimeout(DEFAULT_LOCK_TIMEOUT);
-               treeCache.setTransactionManagerLookupClass(DEFAULT_TM_LOOKUP);
+               config.setClusterName(channelName);
+               config.setIsolationLevel(DEFAULT_ISOLATION_LEVEL);
+               config.setCacheMode(DEFAULT_CACHE_MODE);
+               config.setLockAcquisitionTimeout(DEFAULT_LOCK_TIMEOUT);
+               config.setTransactionManagerLookupClass(DEFAULT_TM_LOOKUP);
             }
+
+            pojoCache = new PojoCacheJmxWrapper(PojoCacheFactory.createCache(config, false));
             
-            treeCacheLocal = true;
+            pojoCacheLocal = true;
          }
       }
-      return treeCache;
+      return pojoCache;
    }   
    
    
@@ -894,10 +898,10 @@
             server.registerMBean(this, objectName);
          }
 
-         if (treeCacheLocal)
+         if (pojoCacheLocal)
          {
             // Register the treeCache
-            ObjectName treeCacheName = new ObjectName(treeCacheObjectName);
+            ObjectName treeCacheName = new ObjectName(pojoCacheObjectName);
             server.registerMBean(getTreeCache(), treeCacheName);
          }
 
@@ -920,9 +924,9 @@
             if (objectName != null) {
                mserver.unregisterMBean(objectName);
             }
-            if (treeCacheLocal)
+            if (pojoCacheLocal)
             {
-               mserver.unregisterMBean(new ObjectName(treeCacheObjectName));
+               mserver.unregisterMBean(new ObjectName(pojoCacheObjectName));
             }
          }
          catch (Exception e)




More information about the jboss-cvs-commits mailing list