[jboss-cvs] JBossCache/src-50/org/jboss/cache/pojo/jmx ...
Ben Wang
bwang at jboss.com
Mon Sep 25 01:50:52 EDT 2006
User: bwang
Date: 06/09/25 01:50:52
Added: src-50/org/jboss/cache/pojo/jmx JmxUtil.java
PojoCache.java PojoCacheMBean.java
Log:
1. Modify useInterceptorMbeans to useMbean
2. Added PojoCache jmx framework
3. added test
Revision Changes Path
1.1 date: 2006/09/25 05:50:52; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/jmx/JmxUtil.java
Index: JmxUtil.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.pojo.jmx;
import org.jboss.cache.CacheSPI;
import javax.management.MBeanServer;
import javax.management.ObjectName;
/**
* Various JMX related utilities
*
* @author Ben Wang
* @version $Id: JmxUtil.java,v 1.1 2006/09/25 05:50:52 bwang Exp $
*/
public class JmxUtil extends org.jboss.cache.jmx.JmxUtil
{
public static final String PC_PREFIX = "jboss.pojocache:service=";
/*
*/
public static void registerPojoCache(MBeanServer server, org.jboss.cache.pojo.PojoCache cache)
throws Exception
{
if (server == null || cache == null)
return;
String tmpName = getPojoCacheObjectName(cache);
// register the cache
ObjectName tmpObj = new ObjectName(tmpName);
if (!server.isRegistered(tmpObj))
server.registerMBean(
new org.jboss.cache.pojo.jmx.PojoCache(
(org.jboss.cache.pojo.impl.PojoCacheImpl)cache),
tmpObj);
}
public static String getPojoCacheObjectName(org.jboss.cache.pojo.PojoCache cache)
{
// get the cache's registration name
String tmpName = getCacheObjectName((CacheSPI)cache.getCache());
String newName = tmpName.replaceFirst(PREFIX, PC_PREFIX);
return newName;
}
/*
*/
public static void unregisterPojoCache(MBeanServer server, org.jboss.cache.pojo.PojoCache pcache)
throws Exception
{
if (server == null || pcache == null)
return;
// get the cache's registration name
String tmpName = getPojoCacheObjectName(pcache);
ObjectName tmpObj = new ObjectName(tmpName);
if (server.isRegistered(tmpObj))
server.unregisterMBean(tmpObj);
}
}
1.1 date: 2006/09/25 05:50:52; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/jmx/PojoCache.java
Index: PojoCache.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.pojo.jmx;
import org.jboss.cache.jmx.LifeCycle;
import org.jboss.cache.pojo.jmx.JmxUtil;
import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
import org.jboss.cache.CacheSPI;
/**
* @author Ben Wang
* @since 2.0
*/
public class PojoCache implements PojoCacheMBean
{
PojoCacheImpl cache_;
public PojoCache(PojoCacheImpl cache)
{
cache_ = cache;
}
public String getInternalLocation(Object pojo) throws PojoCacheAlreadyDetachedException
{
return null;
}
public String getUnderlyingCacheObjectName()
{
CacheSPI spi =(CacheSPI)cache_.getCache();
// get the cache's registration name
String tmpName = JmxUtil.getCacheObjectName(spi);
return tmpName;
}
public void create() throws Exception
{
cache_.create();
}
public void start() throws Exception
{
cache_.start();
}
public void stop()
{
cache_.stop();
}
public void destroy()
{
cache_.destroy();
}
}
1.1 date: 2006/09/25 05:50:52; author: bwang; state: Exp;JBossCache/src-50/org/jboss/cache/pojo/jmx/PojoCacheMBean.java
Index: PojoCacheMBean.java
===================================================================
/*
* JBoss, Home of Professional Open Source
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.pojo.jmx;
import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.PojoCacheListener;
import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
import org.jboss.cache.Cache;
import org.jboss.cache.jmx.LifeCycle;
import java.util.Map;
import java.util.Collection;
/**
* @author Ben Wang
* @since 2.0
*/
public interface PojoCacheMBean extends LifeCycle
{
/**
* Return number of POJO attach operations for this particular id.
* @return Number of attach operation.
*/
// public long getNumberOfAttach();
/**
* Return number of POJO detach operations for this particular id.
* @return Number of detach operation.
*/
// public long getNumberOfDetach();
/**
* Return number of POJO field read operations for this particulxar id.
* @param pojo That is associated with this POJO. If null, it means all POJOs in this cache system.
* @return Number of field read operation.
* @throws PojoCacheAlreadyDetachedException if pojo has been detached already.
*/
// public long getNumberOfFieldRead(Object pojo) throws PojoCacheAlreadyDetachedException;
/**
* Return number of POJO field write operations for this particular id.
* @param pojo That is associated with this POJO. If null, it means all POJOs in this cache system.
* @return Number of field read operation.
* @throws PojoCacheAlreadyDetachedException if pojo has been detached already.
*/
// public long getNumberOfFieldWrite(Object pojo) throws PojoCacheAlreadyDetachedException;
/**
* Reset all stats.
*/
// public void reset();
/**
* Obtain the internal location of this pojo stored under PojoCache.
* @param pojo That is associated with this POJO. If null, it means all POJOs in this cache system.
* @return String that indicates the location.
* @throws PojoCacheAlreadyDetachedException if pojo has been detached already.
*/
public String getInternalLocation(Object pojo) throws PojoCacheAlreadyDetachedException;
/**
* Get the MBean object name that the underlying replicated cache is using.
*/
public String getUnderlyingCacheObjectName();
}
More information about the jboss-cvs-commits
mailing list