Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 196   Methods: 16
NCLOC: 102   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RuntimeConfig.java 33.3% 75% 87.5% 69.6%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.config;
 8   
 9    import org.jboss.cache.NodeFactory;
 10    import org.jboss.cache.RPCManager;
 11    import org.jboss.cache.buddyreplication.BuddyGroup;
 12    import org.jgroups.Channel;
 13    import org.jgroups.ChannelFactory;
 14   
 15    import javax.transaction.TransactionManager;
 16   
 17    public class RuntimeConfig extends ConfigurationComponent
 18    {
 19    /**
 20    * The serialVersionUID
 21    */
 22    private static final long serialVersionUID = 5626847485703341794L;
 23   
 24    private transient TransactionManager transactionManager;
 25    private transient Channel channel;
 26    private transient ChannelFactory muxChannelFactory;
 27    private transient NodeFactory nodeFactory;
 28    private transient BuddyGroup buddyGroup;
 29    private RPCManager rpcManager;
 30   
 31  2786 public RuntimeConfig()
 32    {
 33    // needs a public ctor for DI frameworks to instantiate.
 34    }
 35   
 36    /**
 37    * Resets the runtime to default values.
 38    */
 39  24 public void reset()
 40    {
 41    // only reset the node factory and channel for now.
 42  24 nodeFactory = null;
 43  24 channel = null;
 44    }
 45   
 46   
 47    /**
 48    * Gets the factory the cache will use to create a multiplexed channel.
 49    *
 50    * @return the channel, or <code>null</code> if not set
 51    */
 52  1100 public ChannelFactory getMuxChannelFactory()
 53    {
 54  1100 return muxChannelFactory;
 55    }
 56   
 57    /**
 58    * Sets the factory the cache should use to create a multiplexed channel.
 59    * Ignored if a Channel is directly configured via
 60    * {@link {@link #setChannel(Channel)}. If the channel factory is set,
 61    * {@link Configuration#setMultiplexerStack(String)} must also be set, or
 62    * a <code>CacheException</code> will be thrown during cache startup.
 63    *
 64    * @param multiplexerChannelFactory
 65    */
 66  72 public void setMuxChannelFactory(ChannelFactory multiplexerChannelFactory)
 67    {
 68  72 testImmutability("muxChannelFactory");
 69  72 this.muxChannelFactory = multiplexerChannelFactory;
 70    }
 71   
 72    /**
 73    * Gets the channel the cache is using.
 74    * <p/>
 75    * External callers should use extreme care if they access the channel.
 76    * The cache expects it has exclusive access to the channel; external code
 77    * trying to send or receive messages via the channel will almost certainly
 78    * disrupt the operation of the cache.
 79    * </p>
 80    *
 81    * @return the channel. May return <code>null</code> if the channel was
 82    * not externally set via {@link #setChannel(Channel)} and the
 83    * cache has not yet been started.
 84    * @see #setChannel(Channel)
 85    */
 86  1444 public Channel getChannel()
 87    {
 88  1444 return channel;
 89    }
 90   
 91    /**
 92    * Sets the channel the cache will use. The channel should not be
 93    * connected or closed.
 94    * <p/>
 95    * External callers should use extreme care if they access the channel.
 96    * The cache expects it has exclusive access to the channel; external code
 97    * trying to send or receive messages via the channel will almost certainly
 98    * disrupt the operation of the cache.
 99    * </p>
 100    * <p/>
 101    * If an application wishes to send and receive messages using the same
 102    * underlying channel as the <ocde>Cache</code>, a multiplexed channel should
 103    * be used. Two separate mux channels should be created from the same
 104    * <code>ChannelFactory</code> using the same <i>stack name</i> but different
 105    * <code>id</code>s.
 106    * See {@link ChannelFactory#createMultiplexerChannel(String,String,boolean,String)}.
 107    * These two mux channels will share the same underlying channel. One of the
 108    * two mux channels can be injected into the cache; the other can be used by
 109    * the application. The cache will not see the application messages and vice versa.
 110    * </p>
 111    * <p/>
 112    * Configuring the cache to use a mux channel can also be done by configuring
 113    * {@link #setMuxChannelFactory(ChannelFactory) the channel factory} and the
 114    * {@link Configuration#setMultiplexerStack(String) stack name}, in which case
 115    * the cache will create and use a mux channel.
 116    * </p>
 117    *
 118    * @param channel
 119    */
 120  2177 public void setChannel(Channel channel)
 121    {
 122  2178 this.channel = channel;
 123    }
 124   
 125  3051 public TransactionManager getTransactionManager()
 126    {
 127  3051 return transactionManager;
 128    }
 129   
 130  2515 public void setTransactionManager(TransactionManager transactionManager)
 131    {
 132  2515 testImmutability("transactionManager");
 133  2515 this.transactionManager = transactionManager;
 134    }
 135   
 136  173106 public NodeFactory getNodeFactory()
 137    {
 138  173106 return nodeFactory;
 139    }
 140   
 141  2806 public void setNodeFactory(NodeFactory nodeFactory)
 142    {
 143  2806 this.nodeFactory = nodeFactory;
 144    }
 145   
 146  0 @Override
 147    public boolean equals(Object obj)
 148    {
 149  0 if (this == obj)
 150    {
 151  0 return true;
 152    }
 153   
 154  0 if (obj instanceof RuntimeConfig)
 155    {
 156  0 RuntimeConfig other = (RuntimeConfig) obj;
 157  0 return safeEquals(transactionManager, other.transactionManager)
 158    && safeEquals(muxChannelFactory, other.muxChannelFactory)
 159    && safeEquals(rpcManager, other.rpcManager)
 160    && safeEquals(channel, other.channel);
 161    }
 162   
 163  0 return false;
 164    }
 165   
 166  4 @Override
 167    public int hashCode()
 168    {
 169  4 int result = 17;
 170  4 result = result * 29 + (transactionManager == null ? 0 : transactionManager.hashCode());
 171  4 result = result * 29 + (muxChannelFactory == null ? 0 : muxChannelFactory.hashCode());
 172  4 result = result * 29 + (rpcManager == null ? 0 : rpcManager.hashCode());
 173  4 result = result * 29 + (channel == null ? 0 : channel.hashCode());
 174  4 return result;
 175    }
 176   
 177  224 public void setBuddyGroup(BuddyGroup buddyGroup)
 178    {
 179  224 this.buddyGroup = buddyGroup;
 180    }
 181   
 182  0 public BuddyGroup getBuddyGroup()
 183    {
 184  0 return buddyGroup;
 185    }
 186   
 187  1118 public void setRPCManager(RPCManager rpcManager)
 188    {
 189  1118 this.rpcManager = rpcManager;
 190    }
 191   
 192  244792 public RPCManager getRPCManager()
 193    {
 194  244792 return rpcManager;
 195    }
 196    }