[jboss-cvs] JBossCache/src/org/jboss/cache ...
Brian Stansberry
brian.stansberry at jboss.com
Fri Nov 10 01:00:03 EST 2006
User: bstansberry
Date: 06/11/10 01:00:03
Modified: src/org/jboss/cache TreeCache.java
Log:
Injection of TransactionManager and JChannelFactory via RuntimeConfig
Revision Changes Path
1.264 +66 -61 JBossCache/src/org/jboss/cache/TreeCache.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TreeCache.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/TreeCache.java,v
retrieving revision 1.263
retrieving revision 1.264
diff -u -b -r1.263 -r1.264
--- TreeCache.java 10 Nov 2006 02:46:45 -0000 1.263
+++ TreeCache.java 10 Nov 2006 06:00:03 -0000 1.264
@@ -15,6 +15,7 @@
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.InterceptorChainFactory;
import org.jboss.cache.factories.NodeFactory;
import org.jboss.cache.interceptors.Interceptor;
@@ -51,6 +52,7 @@
import org.jgroups.View;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RpcDispatcher;
+import org.jgroups.jmx.JChannelFactoryMBean;
import org.jgroups.stack.IpAddress;
import org.jgroups.util.Rsp;
import org.jgroups.util.RspList;
@@ -91,7 +93,7 @@
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
* @author Brian Stansberry
* @author Daniel Huang (dhuang at jboss.org)
- * @version $Id: TreeCache.java,v 1.263 2006/11/10 02:46:45 bstansberry Exp $
+ * @version $Id: TreeCache.java,v 1.264 2006/11/10 06:00:03 bstansberry Exp $
* <p/>
* @see <a href="http://labs.jboss.com/portal/jbosscache/docs">JBossCache doc</a>
*/
@@ -585,6 +587,12 @@
setUseReplQueue(configuration.isUseReplQueue());
setIsolationLevel(configuration.getIsolationLevel());
+
+ // See if we had a TransactionManager injected into our config
+ this.tm = configuration.getRuntimeConfig().getTransactionManager();
+ if (tm == null)
+ {
+ // Nope. See if we can look it up from JNDI
if (this.tm_lookup == null && configuration.getTransactionManagerLookupClass() != null)
{
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(configuration.getTransactionManagerLookupClass());
@@ -596,6 +604,7 @@
if (tm_lookup != null)
{
tm = tm_lookup.getTransactionManager();
+ configuration.getRuntimeConfig().setTransactionManager(tm);
}
else
{
@@ -606,6 +615,7 @@
{
log.debug("failed looking up TransactionManager, will not use transactions", e);
}
+ }
// create cache loader
if ((configuration.getCacheLoaderConfig() != null || cloaderConfig != null) && cacheLoaderManager == null)
@@ -630,10 +640,10 @@
log.info("channel is already running");
return;
}
- if (configuration.getMultiplexerService() != null)
- {
- channel = getMultiplexerChannel(configuration.getMultiplexerService(), configuration.getMultiplexerStack());
- }
+
+ // Try to create a multiplexer channel
+ channel = getMultiplexerChannel();
+
if (channel != null)
{ // mux channel
if (log.isDebugEnabled())
@@ -4069,14 +4079,30 @@
// END: Methods to provide backward compatibility with older cache loader config settings
// ---------------------------------------------------------------
- private JChannel getMultiplexerChannel(String serviceName, String stackName)
+ private JChannel getMultiplexerChannel()
+ {
+ String stackName = configuration.getMultiplexerStack();
+
+ RuntimeConfig rtc = configuration.getRuntimeConfig();
+ JChannelFactoryMBean channelFactory = rtc.getMuxChannelFactory();
+ try
+ {
+ if (channelFactory != null)
+ {
+ return (JChannel) channelFactory.createMultiplexerChannel(stackName, configuration.getClusterName());
+ }
+ else
{
+ // FIXME -- why do we support this? Move into a specialized JMX class
+ // meant for dealing with old-style config files
+ String serviceName = configuration.getMultiplexerService();
+
if (serviceName == null || serviceName.length() == 0)
{
return null;
}
- MBeanServer mbserver = JmxUtil.getMBeanServer();
+ MBeanServer mbserver = rtc.getMbeanServer();
if (mbserver == null)
{
log.warn("Multiplexer service specified but MBean server not found." +
@@ -4084,8 +4110,6 @@
return null;
}
- try
- {
ObjectName muxName = new ObjectName(serviceName);
// see if Multiplexer service is registered
@@ -4096,30 +4120,11 @@
return null;
}
- // see if createMultiplexerChannel() is supported
- boolean muxFound = false;
- MBeanOperationInfo[] ops = mbserver.getMBeanInfo(muxName).getOperations();
- for (int i = 0; i < ops.length; i++)
- {
- MBeanOperationInfo op = ops[i];
- if (op.getName().equals(CREATE_MUX_CHANNEL))
- {
- muxFound = true;
- break;
- }
- }
- if (!muxFound)
- {
- log.warn("Multiplexer service registered but method '" + CREATE_MUX_CHANNEL + "' not found." +
- " Multiplexer will not be used for cache cluster " + configuration.getClusterName() + "." +
- " Ensure that you are using JGroups version 2.3 or later.");
- return null;
- }
-
// create the multiplexer channel and return as a JChannel instance
Object[] params = {stackName, configuration.getClusterName()};
return (JChannel) mbserver.invoke(muxName, CREATE_MUX_CHANNEL, params, MUX_TYPES);
}
+ }
catch (Exception e)
{
log.error("Multiplexer channel creation failed." +
More information about the jboss-cvs-commits
mailing list