[jboss-cvs] JBossCache/src/org/jboss/cache/pojo/jmx ...
Brian Stansberry
brian.stansberry at jboss.com
Fri May 11 18:40:59 EDT 2007
User: bstansberry
Date: 07/05/11 18:40:59
Added: src/org/jboss/cache/pojo/jmx
PojoCacheLegacyJmxWrapperMBean.java
PojoCacheLegacyJmxWrapper.java
Log:
[JBCACHE-1056] Wrapper class to allow PojoCache deployment via legacy AS ServiceController
Revision Changes Path
1.1 date: 2007/05/11 22:40:59; author: bstansberry; state: Exp;JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheLegacyJmxWrapperMBean.java
Index: PojoCacheLegacyJmxWrapperMBean.java
===================================================================
/*
* JBoss, Home of Professional Open Source.
* Copyright 2007, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.jmx;
import org.jboss.cache.jmx.LegacyConfiguration;
/**
* StandardMBean interface for {@link PojoCacheLegacyJmxWrapper}. Extends
* <code>PojoCacheJmxWrapperMBean</code> by adding the
* {@link LegacyConfiguration legacy configuration} attributes from JBC 1.x.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
* @version $Revision: 1.1 $
*/
public interface PojoCacheLegacyJmxWrapperMBean
extends PojoCacheJmxWrapperMBean, LegacyConfiguration
{
}
1.1 date: 2007/05/11 22:40:59; author: bstansberry; state: Exp;JBossCache/src/org/jboss/cache/pojo/jmx/PojoCacheLegacyJmxWrapper.java
Index: PojoCacheLegacyJmxWrapper.java
===================================================================
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.cache.pojo.jmx;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.transaction.TransactionManager;
import org.jboss.cache.CacheException;
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.jgroups.Channel;
import org.jgroups.ChannelFactory;
import org.w3c.dom.Element;
/**
* {@link PojoCacheJmxWrapper} subclass that supports building the
* {@link Configuration} from MBean attribute injection. Allows
* configuration of the cache using the JBoss AS 4.x JMX microkernel.
*
* @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
* @version $Revision: 1.1 $
*/
public class PojoCacheLegacyJmxWrapper extends PojoCacheJmxWrapper
implements PojoCacheLegacyJmxWrapperMBean
{
private Element buddyReplConfig;
private Element evictionConfig;
private Element cacheLoaderConfig;
private ObjectName multiplexerService;
public PojoCacheLegacyJmxWrapper()
{
super();
setConfiguration(new Configuration());
}
public Configuration getConfiguration()
{
Configuration result = super.getConfiguration();
if (result == null)
{
result = new Configuration();
setConfiguration(result);
}
return result;
}
@Override
protected void constructCache() throws ConfigurationException
{
super.constructCache();
if (multiplexerService != null)
{
injectMuxChannel();
}
}
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()");
}
}
}
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 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);
}
public void setCacheLoaderConfiguration(Element cache_loader_config)
{
CacheLoaderConfig clc = null;
if (cache_loader_config != null)
{
clc = XmlConfigurationParser.parseCacheLoaderConfig(cache_loader_config);
}
getConfiguration().setCacheLoaderConfig(clc);
}
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);
}
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);
}
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)
{
getConfiguration().setNodeLockingSchemeString(nodeLockingScheme);
}
public void setReplQueueInterval(long interval)
{
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);
}
}
More information about the jboss-cvs-commits
mailing list