// This is per CM, so the CL in use should be the CM CL private void buildChannel() { // in order of preference - we first look for an external JGroups file, then a set of XML // properties, and // finally the legacy JGroups String properties. String cfg; if (props != null) { if (props.containsKey(CHANNEL_LOOKUP)) { String channelLookupClassName = props.getProperty(CHANNEL_LOOKUP); try { JGroupsChannelLookup lookup = (JGroupsChannelLookup) Util.getInstance(channelLookupClassName, configuration.getClassLoader()); channel = lookup.getJGroupsChannel(props); startChannel = lookup.shouldStartAndConnect(); stopChannel = lookup.shouldStopAndDisconnect(); } catch (ClassCastException e) { log.wrongTypeForJGroupsChannelLookup(channelLookupClassName, e); throw new CacheException(e); } catch (Exception e) { log.errorInstantiatingJGroupsChannelLookup(channelLookupClassName, e); throw new CacheException(e); } if (configuration.isStrictPeerToPeer() && !startChannel) { log.warnStrictPeerToPeerWithInjectedChannel(); } } if (channel == null && props.containsKey(CONFIGURATION_FILE)) { cfg = props.getProperty(CONFIGURATION_FILE); try { channel = new JChannel( FileLookupFactory.newInstance() .lookupFileLocation(cfg, configuration.getClassLoader())); } catch (Exception e) { log.errorCreatingChannelFromConfigFile(cfg); throw new CacheException(e); } } if (channel == null && props.containsKey(CONFIGURATION_XML)) { cfg = props.getProperty(CONFIGURATION_XML); try { channel = new JChannel(XmlConfigHelper.stringToElement(cfg)); } catch (Exception e) { log.errorCreatingChannelFromXML(cfg); throw new CacheException(e); } } if (channel == null && props.containsKey(CONFIGURATION_STRING)) { cfg = props.getProperty(CONFIGURATION_STRING); try { channel = new JChannel(cfg); } catch (Exception e) { log.errorCreatingChannelFromConfigString(cfg); throw new CacheException(e); } } } if (channel == null) { log.unableToUseJGroupsPropertiesProvided(props); try { channel = new JChannel( FileLookupFactory.newInstance() .lookupFileLocation( DEFAULT_JGROUPS_CONFIGURATION_FILE, configuration.getClassLoader())); } catch (Exception e) { throw new CacheException("Unable to start JGroups channel", e); } } }