connectChannel = lookup.shouldConnect();
disconnectChannel = lookup.shouldDisconnect();
closeChannel = lookup.shouldClose();
} catch (ClassCastException e) {
log.wrongTypeForJGroupsChannelLookup(channelLookupClassName, e);
throw new CacheException(e);
} catch (Exception e) {
log.errorInstantiatingJGroupsChannelLookup(channelLookupClassName, e);
throw new CacheException(e);
}
}
if (channel == null && props.containsKey(CONFIGURATION_FILE)) {
cfg = props.getProperty(CONFIGURATION_FILE);
Collection<URL> confs = null;
try {
confs = fileLookup.lookupFileLocations(cfg, configuration.classLoader());
} catch (IOException io) {
//ignore, we check confs later for various states
}
if (confs.isEmpty()) {
throw new CacheConfigurationException(CONFIGURATION_FILE
+ " property specifies value " + cfg + " that could not be read!",
new FileNotFoundException(cfg));
} else if (confs.size() > 1) {
log.ambiguousConfigurationFiles(Util.toStr(confs));
}
try {
channel = new JChannel(confs.iterator().next());
} 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(fileLookup.lookupFileLocation(DEFAULT_JGROUPS_CONFIGURATION_FILE, configuration.classLoader()));
} catch (Exception e) {
throw new CacheException("Unable to start JGroups channel", e);
}
}
}