[jboss-cvs] JBossCache/src/org/jboss/cache/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Fri May 11 18:42:10 EDT 2007
User: bstansberry
Date: 07/05/11 18:42:10
Modified: src/org/jboss/cache/jmx JmxUtil.java CacheJmxWrapper.java
Log:
JMX cleanups
Revision Changes Path
1.13 +24 -14 JBossCache/src/org/jboss/cache/jmx/JmxUtil.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JmxUtil.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/JmxUtil.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- JmxUtil.java 11 May 2007 16:48:57 -0000 1.12
+++ JmxUtil.java 11 May 2007 22:42:10 -0000 1.13
@@ -35,17 +35,22 @@
*
* @author Jerry Gauthier
* @author Manik Surtani
- * @version $Id: JmxUtil.java,v 1.12 2007/05/11 16:48:57 bstansberry Exp $
+ * @version $Id: JmxUtil.java,v 1.13 2007/05/11 22:42:10 bstansberry Exp $
*/
public class JmxUtil
{
- public static final String MBEAN_CLASS_SUFFIX = "MBean";
- public static final String MBEAN_KEY = ",cache-interceptor=";
+ public static final String JBOSS_SERVER_DOMAIN = "jboss";
public static final String JBOSS_CACHE_DOMAIN = "jboss.cache";
- public static final String PREFIX = JBOSS_CACHE_DOMAIN + ":service=Cache,clusterName=";
- private static final String JBOSS_SERVER_DOMAIN = "jboss";
- public static final String CACHE_TYPE_KEY = "cacheType=";
- public static final String PLAIN_CACHE_TYPE = "cacheType=Cache";
+ public static final String SERVICE_KEY_NAME = "service";
+ public static final String BASE_PREFIX = JBOSS_CACHE_DOMAIN + ":" + SERVICE_KEY_NAME + "=JBossCache";
+ public static final String CLUSTER_KEY = "cluster";
+ public static final String PREFIX = BASE_PREFIX + "," + CLUSTER_KEY + "=";
+ public static final String UNIQUE_ID_KEY = "uniqueId";
+ public static final String NO_CLUSTER_PREFIX = BASE_PREFIX + "," + UNIQUE_ID_KEY + "=";
+ public static final String CACHE_TYPE_KEY = "cacheType";
+ public static final String PLAIN_CACHE_TYPE = "Cache";
+ public static final String MBEAN_CLASS_SUFFIX = "MBean";
+ public static final String INTERCEPTOR_KEY = ",cache-interceptor=";
public static void registerCacheMBean(MBeanServer server, CacheJmxWrapperMBean cache, String cacheObjectName)
throws Exception
@@ -95,7 +100,7 @@
// for JDK 1.4, must parse name and remove package prefix
// for JDK 1.5, can use getSimpleName() to establish class name without package prefix
String className = interceptor.getClass().getName();
- String serviceName = cacheObjectName + MBEAN_KEY + className.substring(className.lastIndexOf('.') + 1);
+ String serviceName = cacheObjectName + INTERCEPTOR_KEY + className.substring(className.lastIndexOf('.') + 1);
ObjectName objName = new ObjectName(serviceName);
if (!server.isRegistered(objName))
@@ -112,19 +117,19 @@
}
}
- public static String getCacheObjectName(org.jboss.cache.Cache cache)
+ public static String getDefaultCacheObjectName(org.jboss.cache.Cache cache)
{
// get the cache's registration name
- return getCacheObjectName(cache.getConfiguration(), cache.getClass().getName());
+ return getDefaultCacheObjectName(cache.getConfiguration(), cache.getClass().getName());
}
- public static String getCacheObjectName(Configuration config, String cacheSPIClass)
+ public static String getDefaultCacheObjectName(Configuration config, String cacheImplClass)
{
// get the cache's registration name
String tmpName = null;
if (config.getClusterName() == null)
{
- tmpName = PREFIX + cacheSPIClass + System.currentTimeMillis();
+ tmpName = NO_CLUSTER_PREFIX + getUniqueId(cacheImplClass);
}
else
{
@@ -134,6 +139,11 @@
return tmpName;
}
+ public static String getUniqueId(String cacheImplClass)
+ {
+ return cacheImplClass + System.currentTimeMillis();
+ }
+
public static void unregisterCacheMBean(MBeanServer server, String cacheObjectName)
throws Exception
{
@@ -164,7 +174,7 @@
// for JDK 1.4, must parse name and remove package prefix
// for JDK 1.5, can use getSimpleName() to establish class name without package prefix
String className = interceptor.getClass().getName();
- String serviceName = cacheObjectName + MBEAN_KEY + className.substring(className.lastIndexOf('.') + 1);
+ String serviceName = cacheObjectName + INTERCEPTOR_KEY + className.substring(className.lastIndexOf('.') + 1);
ObjectName objName = new ObjectName(serviceName);
if (server.isRegistered(objName))
1.18 +10 -2 JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CacheJmxWrapper.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/jmx/CacheJmxWrapper.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- CacheJmxWrapper.java 10 May 2007 17:30:52 -0000 1.17
+++ CacheJmxWrapper.java 11 May 2007 22:42:10 -0000 1.18
@@ -43,6 +43,14 @@
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.interceptors.Interceptor;
+/**
+ * Wrapper class that provides exposes a
+ * {@link CacheJmxWrapperMBean JMX management interface} for an instance of
+ * {@link CacheImpl}.
+ *
+ * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
+ * @version $Revision: 1.18 $
+ */
public class CacheJmxWrapper
extends NotificationBroadcasterSupport
implements CacheJmxWrapperMBean, MBeanRegistration, CacheNotificationBroadcaster
@@ -315,7 +323,7 @@
{
if (cacheObjectName == null)
{
- cacheObjectName = JmxUtil.getCacheObjectName(config, CacheImpl.class.getName());
+ cacheObjectName = JmxUtil.getDefaultCacheObjectName(config, CacheImpl.class.getName());
}
return cacheObjectName;
}
@@ -382,7 +390,7 @@
// ------------------------------------------------------ Protected Methods
- protected void constructCache() throws Exception
+ protected void constructCache() throws ConfigurationException
{
log.debug("Constructing Cache");
setCache(DefaultCacheFactory.getInstance().createCache(config, false));
More information about the jboss-cvs-commits
mailing list