[jboss-cvs] JBossCache/src/org/jboss/cache/config ...
Brian Stansberry
brian.stansberry at jboss.com
Wed May 9 14:24:09 EDT 2007
User: bstansberry
Date: 07/05/09 14:24:09
Modified: src/org/jboss/cache/config RuntimeConfig.java
Log:
[JBCACHE-934] Remove ChannelFactory JMX lookup from CacheImpl
[JBCACHE--1023] Inject preconfigured Channel
Revision Changes Path
1.9 +79 -21 JBossCache/src/org/jboss/cache/config/RuntimeConfig.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: RuntimeConfig.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/config/RuntimeConfig.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- RuntimeConfig.java 26 Apr 2007 16:36:34 -0000 1.8
+++ RuntimeConfig.java 9 May 2007 18:24:09 -0000 1.9
@@ -8,9 +8,9 @@
import org.jboss.cache.NodeFactory;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jgroups.jmx.JChannelFactoryMBean;
+import org.jgroups.Channel;
+import org.jgroups.ChannelFactory;
-import javax.management.MBeanServer;
import javax.transaction.TransactionManager;
public class RuntimeConfig extends ConfigurationComponent
@@ -21,8 +21,8 @@
private static final long serialVersionUID = 5626847485703341794L;
private transient TransactionManager transactionManager;
- private transient JChannelFactoryMBean muxChannelFactory;
- private transient MBeanServer mbeanServer;
+ private transient Channel channel;
+ private transient ChannelFactory muxChannelFactory;
private transient NodeFactory nodeFactory;
private transient BuddyGroup buddyGroup;
@@ -36,42 +36,100 @@
*/
public void reset()
{
- // only reset the node factory for now.
+ // only reset the node factory and channel for now.
nodeFactory = null;
+ channel = null;
}
- public JChannelFactoryMBean getMuxChannelFactory()
+ /**
+ * Gets the factory the cache will use to create a multiplexed channel.
+ *
+ * @return the channel, or <code>null</code> if not set
+ */
+ public ChannelFactory getMuxChannelFactory()
{
return muxChannelFactory;
}
- public void setMuxChannelFactory(JChannelFactoryMBean multiplexerChannelFactory)
+ /**
+ * Sets the factory the cache should use to create a multiplexed channel.
+ * Ignored if a Channel is directly configured via
+ * {@link {@link #setChannel(Channel)}. If the channel factory is set,
+ * {@link Configuration#setMultiplexerStack(String)} must also be set, or
+ * a <code>CacheException</code> will be thrown during cache startup.
+ *
+ * @param multiplexerChannelFactory
+ */
+ public void setMuxChannelFactory(ChannelFactory multiplexerChannelFactory)
{
testImmutability("muxChannelFactory");
this.muxChannelFactory = multiplexerChannelFactory;
}
- public TransactionManager getTransactionManager()
+ /**
+ * Gets the channel the cache is using.
+ * <p>
+ * External callers should use extreme care if they access the channel.
+ * The cache expects it has exclusive access to the channel; external code
+ * trying to send or receive messages via the channel will almost certainly
+ * disrupt the operation of the cache.
+ * </p>
+ *
+ * @see #setChannel(Channel)
+ *
+ * @return the channel. May return <code>null</code> if the channel was
+ * not externally set via {@link #setChannel(Channel)} and the
+ * cache has not yet been started.
+ */
+ public Channel getChannel()
{
- return transactionManager;
+ return channel;
}
- public void setTransactionManager(TransactionManager transactionManager)
+ /**
+ * Sets the channel the cache will use. The channel should not be
+ * connected or closed.
+ * <p>
+ * External callers should use extreme care if they access the channel.
+ * The cache expects it has exclusive access to the channel; external code
+ * trying to send or receive messages via the channel will almost certainly
+ * disrupt the operation of the cache.
+ * </p>
+ * <p>
+ * If an application wishes to send and receive messages using the same
+ * underlying channel as the <ocde>Cache</code>, a multiplexed channel should
+ * be used. Two separate mux channels should be created from the same
+ * <code>ChannelFactory</code> using the same <i>stack name</i> but different
+ * <code>id</code>s.
+ * See {@link ChannelFactory#createMultiplexerChannel(String, String, boolean, String)}.
+ * These two mux channels will share the same underlying channel. One of the
+ * two mux channels can be injected into the cache; the other can be used by
+ * the application. The cache will not see the application messages and vice versa.
+ * </p>
+ * <p>
+ * Configuring the cache to use a mux channel can also be done by configuring
+ * {@link #setMuxChannelFactory(ChannelFactory) the channel factory} and the
+ * {@link Configuration#setMultiplexerStack(String) stack name}, in which case
+ * the cache will create and use a mux channel.
+ * </p>
+ *
+ * @param channel
+ */
+ public void setChannel(Channel channel)
{
- testImmutability("transactionManager");
- this.transactionManager = transactionManager;
+ this.channel = channel;
}
- public MBeanServer getMbeanServer()
+ public TransactionManager getTransactionManager()
{
- return mbeanServer;
+ return transactionManager;
}
- public void setMbeanServer(MBeanServer mbeanServer)
+ public void setTransactionManager(TransactionManager transactionManager)
{
- testImmutability("mbeanServer");
- this.mbeanServer = mbeanServer;
+ testImmutability("transactionManager");
+ this.transactionManager = transactionManager;
}
public NodeFactory getNodeFactory()
@@ -97,7 +155,7 @@
RuntimeConfig other = (RuntimeConfig) obj;
return safeEquals(transactionManager, other.transactionManager)
&& safeEquals(muxChannelFactory, other.muxChannelFactory)
- && safeEquals(mbeanServer, other.mbeanServer);
+ && safeEquals(channel, other.channel);
}
return false;
@@ -109,7 +167,7 @@
int result = 17;
result = result * 29 + (transactionManager == null ? 0 : transactionManager.hashCode());
result = result * 29 + (muxChannelFactory == null ? 0 : muxChannelFactory.hashCode());
- result = result * 29 + (mbeanServer == null ? 0 : mbeanServer.hashCode());
+ result = result * 29 + (channel == null ? 0 : channel.hashCode());
return result;
}
More information about the jboss-cvs-commits
mailing list