[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Wed May 23 16:24:16 EDT 2007
User: bstansberry
Date: 07/05/23 16:24:16
Modified: src/org/jboss/cache/pojo/jmx
PojoCacheJmxWrapperMBean.java
PojoCacheJmxWrapper.java
Removed: src/org/jboss/cache/pojo/jmx
PojoCacheLegacyJmxWrapperMBean.java
PojoCacheLegacyJmxWrapper.java
Log:
[JBCACHE-1056] Merge PojoCacheLegacyJmxWrapper into PojoCacheJmxWrapper
Revision Changes Path
1.7 +3 -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.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- PojoCacheJmxWrapperMBean.java 23 May 2007 19:24:37 -0000 1.6
+++ PojoCacheJmxWrapperMBean.java 23 May 2007 20:24:16 -0000 1.7
@@ -24,6 +24,7 @@
import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.jmx.LegacyConfiguration;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
import org.jboss.cache.pojo.PojoCacheException;
@@ -32,9 +33,9 @@
* StandardMBean interface for {@link PojoCacheJmxWrapperMBean}.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
-public interface PojoCacheJmxWrapperMBean
+public interface PojoCacheJmxWrapperMBean extends LegacyConfiguration
{
/**
* Lifecycle method to start PojoCache.
1.11 +357 -11 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.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- PojoCacheJmxWrapper.java 23 May 2007 19:26:53 -0000 1.10
+++ PojoCacheJmxWrapper.java 23 May 2007 20:24:16 -0000 1.11
@@ -25,19 +25,28 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheStatus;
+import org.jboss.cache.config.BuddyReplicationConfig;
+import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.RuntimeConfig;
+import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.pojo.PojoCache;
import org.jboss.cache.pojo.PojoCacheAlreadyDetachedException;
import org.jboss.cache.pojo.PojoCacheException;
import org.jboss.cache.pojo.PojoCacheFactory;
import org.jboss.cache.pojo.impl.PojoCacheImpl;
+import org.jgroups.Channel;
+import org.jgroups.ChannelFactory;
+import org.w3c.dom.Element;
import javax.management.JMException;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import javax.transaction.TransactionManager;
public class PojoCacheJmxWrapper
implements PojoCacheJmxWrapperMBean, MBeanRegistration
@@ -48,14 +57,20 @@
private Configuration config;
private MBeanServer server;
private String cacheObjectName;
- private Boolean manageCacheLifecycle;
- private boolean selfConstructed;
private PojoCache pojoCache;
private CacheJmxWrapper plainCacheWrapper;
private boolean registerPlainCache = true;
private boolean plainCacheRegistered;
private CacheStatus cacheStatus;
+ // Legacy config support
+
+ private Element buddyReplConfig;
+ private Element evictionConfig;
+ private Element cacheLoaderConfig;
+ private Element clusterConfig;
+ private ObjectName multiplexerService;
+
/**
* Default constructor.
*/
@@ -84,7 +99,12 @@
public Configuration getConfiguration()
{
- return config;
+ Configuration cfg = (pojoCache == null ? config : pojoCache.getCache().getConfiguration());
+ if (cfg == null)
+ {
+ cfg = config = new Configuration();
+ }
+ return cfg;
}
public String getInternalLocation(Object pojo) throws PojoCacheAlreadyDetachedException
@@ -252,14 +272,306 @@
this.registerInterceptors = register;
}
- public boolean getManageCacheLifecycle()
+ // ---------------------------------------------------- LegacyConfiguration
+
+ public Element getBuddyReplicationConfig()
+ {
+ return buddyReplConfig;
+ }
+
+ public Element getCacheLoaderConfiguration()
+ {
+ return cacheLoaderConfig;
+ }
+
+ public String getCacheMode()
+ {
+ return getConfiguration().getCacheModeString();
+ }
+
+ public String getClusterName()
+ {
+ return getConfiguration().getClusterName();
+ }
+
+ public String getClusterProperties()
+ {
+ return getConfiguration().getClusterConfig();
+ }
+
+ public Element getClusterConfig()
+ {
+ return clusterConfig;
+ }
+
+ public Element getEvictionPolicyConfig()
+ {
+ return evictionConfig;
+ }
+
+ public boolean getExposeManagementStatistics()
+ {
+ return getConfiguration().getExposeManagementStatistics();
+ }
+
+ public boolean getFetchInMemoryState()
+ {
+ return getConfiguration().isFetchInMemoryState();
+ }
+
+ public long getInitialStateRetrievalTimeout()
+ {
+ return getConfiguration().getInitialStateRetrievalTimeout();
+ }
+
+ public String getIsolationLevel()
+ {
+ return getConfiguration().getIsolationLevelString();
+ }
+
+ public long getLockAcquisitionTimeout()
+ {
+ return getConfiguration().getLockAcquisitionTimeout();
+ }
+
+ /**
+ * @deprecated directly inject the ChannelFactory via {@link #setMuxChannelFactory(ChannelFactory)}
+ */
+ public ObjectName getMultiplexerService()
+ {
+ return multiplexerService;
+ }
+
+ public String getMultiplexerStack()
+ {
+ return getConfiguration().getMultiplexerStack();
+ }
+
+ public ChannelFactory getMuxChannelFactory()
+ {
+ return getConfiguration().getRuntimeConfig().getMuxChannelFactory();
+ }
+
+ public String getNodeLockingScheme()
+ {
+ return getConfiguration().getNodeLockingSchemeString();
+ }
+
+ public long getReplQueueInterval()
+ {
+ return getConfiguration().getReplQueueInterval();
+ }
+
+ public int getReplQueueMaxElements()
+ {
+ return getConfiguration().getReplQueueMaxElements();
+ }
+
+ public String getReplicationVersion()
+ {
+ return getConfiguration().getReplVersionString();
+ }
+
+ public boolean getSyncCommitPhase()
+ {
+ return getConfiguration().isSyncCommitPhase();
+ }
+
+ public long getSyncReplTimeout()
+ {
+ return getConfiguration().getSyncReplTimeout();
+ }
+
+ public boolean getSyncRollbackPhase()
+ {
+ return getConfiguration().isSyncRollbackPhase();
+ }
+
+ public TransactionManager getTransactionManager()
+ {
+ return getConfiguration().getRuntimeConfig().getTransactionManager();
+ }
+
+ public String getTransactionManagerLookupClass()
+ {
+ return getConfiguration().getTransactionManagerLookupClass();
+ }
+
+ public boolean getUseRegionBasedMarshalling()
+ {
+ return getConfiguration().isUseRegionBasedMarshalling();
+ }
+
+ public boolean getUseReplQueue()
+ {
+ return getConfiguration().isUseReplQueue();
+ }
+
+ public boolean isInactiveOnStartup()
+ {
+ return getConfiguration().isInactiveOnStartup();
+ }
+
+ public void setBuddyReplicationConfig(Element config)
+ {
+ BuddyReplicationConfig brc = null;
+ if (config != null)
+ {
+ brc = XmlConfigurationParser.parseBuddyReplicationConfig(config);
+ }
+ getConfiguration().setBuddyReplicationConfig(brc);
+ this.buddyReplConfig = config;
+ }
+
+ public void setCacheLoaderConfiguration(Element cache_loader_config)
+ {
+ CacheLoaderConfig clc = null;
+ if (cache_loader_config != null)
+ {
+ clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
+ }
+ getConfiguration().setCacheLoaderConfig(clc);
+ this.cacheLoaderConfig = cache_loader_config;
+ }
+
+ public void setCacheMode(String mode) throws Exception
+ {
+ getConfiguration().setCacheModeString(mode);
+ }
+
+ public void setClusterConfig(Element config)
+ {
+ String props = null;
+ if (config != null)
+ {
+ props = XmlConfigurationParser.parseClusterConfigXml(config);
+ }
+ getConfiguration().setClusterConfig(props);
+ this.clusterConfig = config;
+ }
+
+ public void setClusterName(String name)
+ {
+ getConfiguration().setClusterName(name);
+ }
+
+ public void setClusterProperties(String cluster_props)
+ {
+ getConfiguration().setClusterConfig(cluster_props);
+ }
+
+ public void setEvictionPolicyConfig(Element config)
+ {
+ EvictionConfig ec = null;
+ if (config != null)
+ {
+ ec = XmlConfigurationParser.parseEvictionConfig(config);
+ }
+ getConfiguration().setEvictionConfig(ec);
+ this.evictionConfig = config;
+ }
+
+ public void setExposeManagementStatistics(boolean expose)
+ {
+ getConfiguration().setExposeManagementStatistics(expose);
+ }
+
+ public void setFetchInMemoryState(boolean flag)
+ {
+ getConfiguration().setFetchInMemoryState(flag);
+ }
+
+ public void setInactiveOnStartup(boolean inactiveOnStartup)
+ {
+ getConfiguration().setInactiveOnStartup(inactiveOnStartup);
+ }
+
+ public void setInitialStateRetrievalTimeout(long timeout)
+ {
+ getConfiguration().setInitialStateRetrievalTimeout(timeout);
+ }
+
+ public void setIsolationLevel(String level)
+ {
+ getConfiguration().setIsolationLevelString(level);
+ }
+
+ public void setLockAcquisitionTimeout(long timeout)
+ {
+ getConfiguration().setLockAcquisitionTimeout(timeout);
+ }
+
+ /**
+ * @deprecated directly inject the ChannelFactory via {@link #setMuxChannelFactory(ChannelFactory)}
+ */
+ public void setMultiplexerService(ObjectName muxService)
+ {
+ this.multiplexerService = muxService;
+ }
+
+ public void setMultiplexerStack(String stackName)
+ {
+ getConfiguration().setMultiplexerStack(stackName);
+ }
+
+ public void setMuxChannelFactory(ChannelFactory factory)
+ {
+ getConfiguration().getRuntimeConfig().setMuxChannelFactory(factory);
+ }
+
+ public void setNodeLockingScheme(String nodeLockingScheme)
{
- return manageCacheLifecycle == null ? selfConstructed : manageCacheLifecycle.booleanValue();
+ getConfiguration().setNodeLockingSchemeString(nodeLockingScheme);
}
- public void setManageCacheLifecycle(boolean manageCacheLifecycle)
+ public void setReplQueueInterval(long interval)
{
- this.manageCacheLifecycle = manageCacheLifecycle ? Boolean.TRUE : Boolean.FALSE;
+ getConfiguration().setReplQueueInterval(interval);
+ }
+
+ public void setReplQueueMaxElements(int max_elements)
+ {
+ getConfiguration().setReplQueueMaxElements(max_elements);
+ }
+
+ public void setReplicationVersion(String version)
+ {
+ getConfiguration().setReplVersionString(version);
+ }
+
+ public void setSyncCommitPhase(boolean sync_commit_phase)
+ {
+ getConfiguration().setSyncCommitPhase(sync_commit_phase);
+ }
+
+ public void setSyncReplTimeout(long timeout)
+ {
+ getConfiguration().setSyncReplTimeout(timeout);
+ }
+
+ public void setSyncRollbackPhase(boolean sync_rollback_phase)
+ {
+ getConfiguration().setSyncRollbackPhase(sync_rollback_phase);
+ }
+
+ public void setTransactionManager(TransactionManager manager)
+ {
+ getConfiguration().getRuntimeConfig().setTransactionManager(manager);
+ }
+
+ public void setTransactionManagerLookupClass(String cl) throws Exception
+ {
+ getConfiguration().setTransactionManagerLookupClass(cl);
+ }
+
+ public void setUseRegionBasedMarshalling(boolean isTrue)
+ {
+ getConfiguration().setUseRegionBasedMarshalling(isTrue);
+ }
+
+ public void setUseReplQueue(boolean flag)
+ {
+ getConfiguration().setUseReplQueue(flag);
}
// ------------------------------------------------------ MBeanRegistration
@@ -361,16 +673,18 @@
// --------------------------------------------------------------- Private methods
- protected void constructCache() throws ConfigurationException
+ private void constructCache() throws ConfigurationException
{
pojoCache = (PojoCacheImpl) PojoCacheFactory.createCache(config, false);
plainCacheWrapper = buildPlainCacheWrapper(pojoCache);
-
- selfConstructed = true;
+ if (multiplexerService != null)
+ {
+ injectMuxChannel();
+ }
}
- protected CacheJmxWrapper buildPlainCacheWrapper(PojoCache pojoCache)
+ private CacheJmxWrapper buildPlainCacheWrapper(PojoCache pojoCache)
{
CacheJmxWrapper plainCache = new CacheJmxWrapper();
plainCache.setRegisterInterceptors(getRegisterInterceptors());
@@ -418,6 +732,38 @@
}
}
+ private void injectMuxChannel() throws CacheException
+ {
+ Configuration cfg = getConfiguration();
+ RuntimeConfig rtcfg = cfg.getRuntimeConfig();
+
+ // Only inject if there isn't already a channel or factory
+ if (rtcfg.getMuxChannelFactory() != null && rtcfg.getChannel() != null)
+ {
+ MBeanServer mbs = getMBeanServer();
+ if (mbs != null)
+ {
+ Channel ch;
+ try
+ {
+ ch = (Channel) mbs.invoke(multiplexerService, "createMultiplexerChannel", new Object[]{cfg.getMultiplexerStack(), cfg.getClusterName()}, new String[]{String.class.getName(), String.class.getName()});
+ }
+ catch (Exception e)
+ {
+ throw new CacheException("Exception creating multiplexed channel", e);
+ }
+ rtcfg.setChannel(ch);
+ }
+ else
+ {
+ throw new CacheException("Cannot access " + multiplexerService +
+ " as no MBeanServer is available. Register this MBean with " +
+ "the JMX server before calling create()");
+ }
+ }
+
+ }
+
/**
* Sets the cacheStatus to FAILED and rethrows the problem as one
* of the declared types. Converts any non-RuntimeException Exception
More information about the jboss-cvs-commits
mailing list