[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Wed May 9 14:22:36 EDT 2007
User: bstansberry
Date: 07/05/09 14:22:36
Modified: src/org/jboss/cache/pojo/jmx PojoCacheJmxWrapperMBean.java
PojoCacheJmxWrapper.java
Log:
[JBCACHE-856] Rationalize top-level mbean classes
[JBCACHE-1047] JMX wrappers allow explicit control of whether to control cache lifecycle
Revision Changes Path
1.3 +87 -2 JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheJmxWrapperMBean.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapperMBean.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- PojoCacheJmxWrapperMBean.java 19 Jan 2007 02:04:32 -0000 1.2
+++ PojoCacheJmxWrapperMBean.java 9 May 2007 18:22:36 -0000 1.3
@@ -25,15 +25,16 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.jmx.LifeCycle;
import org.jboss.cache.pojo.PojoCache;
+import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
/**
* StandardMBean interface for {@link PojoCacheJmxWrapperMBean}.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public interface PojoCacheJmxWrapperMBean
- extends PojoCacheMBean
+ extends LifeCycle
{
/**
* Returns the PojoCache.
@@ -84,4 +85,88 @@
* Default is <code>true</code>.
*/
void setRegisterInterceptors(boolean register);
+
+ /**
+ * Gets whether this object should call through to the underlying
+ * {@link PojoCache} when any of the {@link Lifecycle} methods are invoked.
+ * <p>
+ * The value returned from this method will be determined as follows:
+ *
+ * <ol>
+ * <li>If {@link #setManageCacheLifecycle(boolean)} has been called, the
+ * provided value will be returned.</li>
+ * <li>If a <code>PojoCache</code> has been injected into the object implementing
+ * this interface, this method will return <code>false</code> (i.e. assume
+ * whatever code injected the <code>PojoCache</code> will manage its lifecycle.)</li>
+ * <li>If the object implementing this interface itself constructed the
+ * <code>PojoCache</code> (using an injected <code>Configuration</code>), this
+ * method will return <code>true</code> (i.e. assume since we created
+ * the <code>PojoCache</code> we will manage its lifecycle.)</li>
+ * </ol>
+ * </p>
+ *
+ * @return <code>true</code> if calls to the lifecycle methods will be
+ * passed through to the underlying cache, <code>false</code>
+ * otherwise
+ */
+ boolean getManageCacheLifecycle();
+
+ /**
+ * Sets whether this object should call through to the underlying
+ * {@link PojoCache} when any of the {@link Lifecycle} methods are invoked.
+ * <p>
+ * See {@link #getManageCacheLifecycle()} for an explanation of the
+ * default values of this property.
+ *
+ * @param manage <code>true</code> if calls to the lifecycle methods should
+ * be passed through to the underlying cache, <code>false</code>
+ * otherwise
+ */
+ void setManageCacheLifecycle(boolean manage);
+
+ /**
+ * 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();
}
1.4 +15 -4 JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PojoCacheJmxWrapper.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheJmxWrapper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- PojoCacheJmxWrapper.java 6 Apr 2007 01:23:16 -0000 1.3
+++ PojoCacheJmxWrapper.java 9 May 2007 18:22:36 -0000 1.4
@@ -44,6 +44,7 @@
private Configuration config;
private MBeanServer server;
private String cacheObjectName;
+ private Boolean manageCacheLifecycle;
private boolean selfConstructed;
private PojoCache pojoCache;
private CacheJmxWrapper plainCacheWrapper;
@@ -105,7 +106,7 @@
constructCache();
}
- if (selfConstructed)
+ if (getManageCacheLifecycle())
{
pojoCache.create();
}
@@ -117,7 +118,7 @@
public void start() throws Exception
{
- if (selfConstructed)
+ if (getManageCacheLifecycle())
{
pojoCache.start();
}
@@ -125,7 +126,7 @@
public void stop()
{
- if (selfConstructed)
+ if (getManageCacheLifecycle())
{
pojoCache.stop();
}
@@ -133,7 +134,7 @@
public void destroy()
{
- if (selfConstructed)
+ if (getManageCacheLifecycle())
{
pojoCache.destroy();
}
@@ -166,6 +167,16 @@
this.registerInterceptors = register;
}
+ public boolean getManageCacheLifecycle()
+ {
+ return manageCacheLifecycle == null ? selfConstructed : manageCacheLifecycle.booleanValue();
+ }
+
+ public void setManageCacheLifecycle(boolean manageCacheLifecycle)
+ {
+ this.manageCacheLifecycle = manageCacheLifecycle ? Boolean.TRUE : Boolean.FALSE;
+ }
+
// ------------------------------------------------------ MBeanRegistration
/**
More information about the jboss-cvs-commits
mailing list