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.transport().strictPeerToPeer() && !startChannel) {
log.warnStrictPeerToPeerWithInjectedChannel();
}
}
if (channel == null && props.containsKey(CONFIGURATION_FILE)) {
cfg = props.getProperty(CONFIGURATION_FILE);
URL conf = FileLookupFactory.newInstance().lookupFileLocation(cfg, configuration.classLoader());
if (conf == null) {
throw new CacheConfigurationException(CONFIGURATION_FILE
+ " property specifies value " + cfg + " that could not be read!",
new FileNotFoundException(cfg));
}
try {
channel = new JChannel(conf);
} 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.classLoader()));
} catch (Exception e) {
throw new CacheException("Unable to start JGroups channel", e);
}
}
}