? patch Index: CacheFactory.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheFactory.java,v retrieving revision 1.7 diff -r1.7 CacheFactory.java 11a12 > import org.jgroups.Channel; 111a113,131 > > /** > * Creates {@link Cache} instance, by passing in a pre-configured {@link org.jgroups.JChannel} > * and optionally starts it based on the boolean start value. The new cache's configuration > * will be based on a {@link org.jboss.cache.config.Configuration} passed in. > *

> * Ensure that the Configuration you pass in is not used by another cache instance in the same JVM, > * as it may be concurrently modified. Clone the configuration, if shared, using > * {@link org.jboss.cache.config.Configuration#clone()}. > * > * @param configuration the {@link org.jgroups.JChannel} to use (cast to simple channel). > * @param configuration the {@link Configuration} object that is passed in to setCache the {@link Cache}. > * @param start if true, the cache is started before returning. > * @return an optionally running {@link Cache} instance > * @throws org.jboss.cache.config.ConfigurationException > * if there are problems with the configuration > */ > Cache createCache(Channel ch, Configuration configuration, boolean start) throws ConfigurationException; > Index: CacheImpl.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/CacheImpl.java,v retrieving revision 1.57 diff -r1.57 CacheImpl.java 238c238,245 < --- > > /** > * Have we gotten a channel passed in from the > * implementation? We set this to false in the > * constructor if so. Ordinarily isMyChannel is always true. > */ > private boolean isMyChannel = true; > 260a268,282 > /** > * Constructs an uninitialized CacheImpl with a provided channel > */ > protected CacheImpl(Channel ch) throws Exception > { > isMyChannel = false; > if(ch instanceof JChannel){ > channel = (JChannel)ch; > } > else{ > throw new Exception("Not a JChannel!"); > } > notifier = new Notifier(this); > regionManager = new RegionManager(this); > } 643c665,669 < if (channel != null) --- > > // We have to test both the channel and disp here, in > // case we've passed in our own channel. The dispatcher > // must be created in either case. > if ((channel != null) && (disp != null)) 649,653c675,686 < // Try to create a multiplexer channel < channel = getMultiplexerChannel(); < < if (channel != null) < { --- > // Try to create a multiplexer channel if we didnt get a channel passed in > if(isMyChannel){ > channel = getMultiplexerChannel(); > } > > if ((channel != null) && isMyChannel) > { > > // Success creating the multiplexer channel. > // Now we have to let the config know about our joy. > // Note that we never do this if we've passed in a channel, > // even if that channel is multiplexed. 676,680c709,712 < try < { < channel = new JChannel(configuration.getClusterConfig()); < } < catch (Exception e) --- > > // If we've not passed in a channel > // we need to create a non-multiplexed one now > if (isMyChannel) 682,683c714,720 < throw new CacheException("Unable to create JGroups channel", e); < } --- > try { > channel = new JChannel(configuration.getClusterConfig()); > } catch (Exception e) { > throw new CacheException( > "Unable to create JGroups channel", e); > } > } Index: DefaultCacheFactory.java =================================================================== RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/DefaultCacheFactory.java,v retrieving revision 1.6 diff -r1.6 DefaultCacheFactory.java 11a12 > import org.jgroups.Channel; 102a104,135 > /** > * This implementation clones the configuration passed in before using it. > * It also allows the client to pass in its own channel. > * > * @param ch the pre-configured JChannel to use > * @param configuration to use. We assume that the channel has been setup using this > * @param start whether to start the cache > * @return a cache > * @throws ConfigurationException if there are problems with the cfg > */ > public Cache createCache(Channel ch, Configuration configuration, boolean start) throws ConfigurationException > { > try > { > CacheImpl cache = new CacheImpl(ch); > cache.setConfiguration(configuration); > if (start) cache.start(); > return cache; > } > catch (ConfigurationException ce) > { > throw ce; > } > catch (RuntimeException re) > { > throw re; > } > catch (Exception e) > { > throw new RuntimeException(e); > } > }