public void setProperties(String properties) throws IOException { if (properties == null) return; testImmutability("properties"); // JBCACHE-531: escape all backslash characters // replace any "\" that is not preceded by a backslash with "\\" properties = XmlConfigHelper.escapeBackslashes(properties); ByteArrayInputStream is = new ByteArrayInputStream(properties.trim().getBytes("ISO8859_1")); this.properties = new TypedProperties(); this.properties.load(is); is.close(); }
@Override public FileCacheStoreConfig adapt() { FileCacheStoreConfig config = new FileCacheStoreConfig(); LegacyConfigurationAdaptor.adapt(this, config); config.fsyncInterval(fsyncInterval); config.fsyncMode(FileCacheStoreConfig.FsyncMode.valueOf(fsyncMode.name())); config.streamBufferSize(streamBufferSize); config.location(location); XmlConfigHelper.setValues(config, properties(), false, true); return config; }
// 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); } } }