public static InputStream getConfigStream(Object properties) throws IOException { InputStream input=null; // added by bela: for null String props we use the default properties if(properties == null) properties=Global.DEFAULT_PROTOCOL_STACK; if(properties instanceof URL) { try { input=((URL)properties).openStream(); } catch(Throwable t) { } } // if it is a string, then it could be a plain string or a url if(input == null && properties instanceof String) input=getConfigStream((String)properties); // try a regular file if(input == null && properties instanceof File) { try { input=new FileInputStream((File)properties); } catch(Throwable t) { } } if(input != null) return input; if(properties instanceof Element) { return getConfigStream(properties); } return new ByteArrayInputStream(((String)properties).getBytes()); }
/** * Returns a protocol stack configurator based on the XML configuration provided by the specified File. * * @param file a File with a JGroups XML configuration. * @return a {@code ProtocolStackConfigurator} containing the stack configuration. * @throws Exception if problems occur during the configuration of the protocol stack. */ public static ProtocolStackConfigurator getStackConfigurator(File file) throws Exception { checkJAXPAvailability(); InputStream input=getConfigStream(file); return XmlConfigurator.getInstance(input); }
protected void parseConfig(String filename) throws Exception { InputStream input=null; try { input=ConfiguratorFactory.getConfigStream(filename); parseRules(input); } finally { Util.close(input); } }
/** * Parses the configuration by reading the config file. * @throws Exception */ protected void parseSiteConfiguration(final Map<String,RelayConfig.SiteConfig> map) throws Exception { InputStream input=null; try { input=ConfiguratorFactory.getConfigStream(config); RelayConfig.parse(input, map); } finally { Util.close(input); } }
/** * Returns an XmlConfigurator based on the provided properties string (if possible). * * @param properties a string representing a system resource containing a JGroups XML configuration, a string * representing a URL pointing to a JGroups ML configuration, or a string representing a file * name that contains a JGroups XML configuration. * @return an XmlConfigurator instance based on the provided properties string; {@code null} if the provided * properties string does not point to an XML configuration. * @throws IOException if the provided properties string appears to be a valid URL but is unreachable, or if the * JGroups XML configuration pointed to by the URL can not be parsed. */ static XmlConfigurator getXmlConfigurator(String properties) throws IOException { XmlConfigurator returnValue=null; InputStream configStream=getConfigStream(properties); if(configStream == null && properties.endsWith("xml")) throw new FileNotFoundException(String.format(Util.getMessage("FileNotFound"), properties)); if (configStream != null) { checkJAXPAvailability(); returnValue=XmlConfigurator.getInstance(configStream); } return returnValue; }
@ManagedOperation(description="Reads logical-physical address mappings and logical name mappings from a " + "file (or URL) and adds them to the local caches") public void addToCache(String filename) throws Exception { InputStream in=ConfiguratorFactory.getConfigStream(filename); List<PingData> list=read(in); if(list != null) for(PingData data: list) addDiscoveryResponseToCaches(data.getAddress(), data.getLogicalName(), data.getPhysicalAddr()); }
/** * {@link #parse(InputStream) Parses} an input stream created from * <code>properties</code> and then adds the resulting protocol stack * configurations to the set available for use. * * @param properties URL which must contain XML content in the JGroups * <code>stacks.xml</code> format * @param replace <code>true</code> if a configuration with the same * stack name as an already registered configuration should * replace that configuration; <code>false</code> if it * should be discarded. */ public void setMultiplexerConfig(URL url, boolean replace) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(url); addConfigs(input, url.toString(), replace); }
/** * {@link #parse(InputStream) Parses} an input stream created from * <code>properties</code> and then adds the resulting protocol stack * configurations to the set available for use. * * @param properties file which must contain XML content in the JGroups * <code>stacks.xml</code> format * @param replace <code>true</code> if a configuration with the same * stack name as an already registered configuration should * replace that configuration; <code>false</code> if it * should be discarded. */ public void setMultiplexerConfig(File properties, boolean replace) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(properties); addConfigs(input, properties.toString(), replace); }
/** * {@link #parse(InputStream) Parses} an input stream created from * <code>properties</code> and then adds the resulting protocol stack * configurations to the set available for use. * * @param properties object that can be {@link ConfiguratorFactory#getConfigStream(Object) converted into a stream} * which must contain XML content in the JGroups * <code>stacks.xml</code> format * @param replace <code>true</code> if a configuration with the same * stack name as an already registered configuration should * replace that configuration; <code>false</code> if it * should be discarded. */ public void setMultiplexerConfig(Object properties, boolean replace) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(properties); addConfigs(input, properties.toString(), replace); }
/** * {@link #parse(InputStream) Parses} an input stream created from * <code>properties</code> and then adds the resulting protocol stack * configurations to the set available for use. * * @param properties string that can be {@link ConfiguratorFactory#getConfigStream(String) converted into a stream} * which must contain XML content in the JGroups * <code>stacks.xml</code> format * @param replace <code>true</code> if a configuration with the same * stack name as an already registered configuration should * replace that configuration; <code>false</code> if it * should be discarded. */ @Override public void setMultiplexerConfig(String properties, boolean replace) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(properties); addConfigs(input, properties, replace); }
public void setMultiplexerConfig(File file) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(file); if(input == null) throw new FileNotFoundException(file.toString()); try { parse(input); } catch(Exception ex) { throw new Exception("failed parsing " + file.toString(), ex); } finally { Util.close(input); } }
public void setMultiplexerConfig(URL url) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(url); if(input == null) throw new FileNotFoundException(url.toString()); try { parse(input); } catch(Exception ex) { throw new Exception("failed parsing " + url.toString(), ex); } finally { Util.close(input); } }
public void setMultiplexerConfig(Object properties) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(properties); if(input == null) throw new FileNotFoundException(properties.toString()); try { parse(input); } catch(Exception ex) { throw new Exception("failed parsing " + properties, ex); } finally { Util.close(input); } }
public static InputStream getConfigStream(File file) throws Exception { if(propertiesOverride != null) return getConfigStream(propertiesOverride); checkForNullConfiguration(file); try { return new FileInputStream(file); } catch(IOException ioe) { throw createChannelConfigurationException(ioe); } }
public static InputStream getConfigStream(URL url) throws Exception { if (propertiesOverride != null) return getConfigStream(propertiesOverride); try { checkJAXPAvailability(); return url.openStream(); } catch(Exception ex) { throw createChannelConfigurationException(ex); } }
public void setMultiplexerConfig(String properties) throws Exception { InputStream input=ConfiguratorFactory.getConfigStream(properties); if(input == null) throw new FileNotFoundException(properties); try { parse(input); this.config=properties; } catch(Exception ex) { throw new Exception("failed parsing " + properties, ex); } finally { Util.close(input); } }
/** * Returns a protocol stack configurator based on the XML configuration provided by the specified File. * * @param file a File with a JGroups XML configuration. * @return a {@code ProtocolStackConfigurator} containing the stack configuration. * @throws Exception if problems occur during the configuration of the protocol stack. */ public static ProtocolStackConfigurator getStackConfigurator(File file) throws Exception { checkJAXPAvailability(); InputStream input=getConfigStream(file); return XmlConfigurator.getInstance(input); }
protected void parseConfig(String filename) throws Exception { InputStream input=null; try { input=ConfiguratorFactory.getConfigStream(filename); parseRules(input); } finally { Util.close(input); } }
/** * Parses the configuration by reading the config file. * @throws Exception */ protected void parseSiteConfiguration(final Map<String,RelayConfig.SiteConfig> map) throws Exception { InputStream input=null; try { input=ConfiguratorFactory.getConfigStream(config); RelayConfig.parse(input, map); } finally { Util.close(input); } }
@ManagedOperation(description="Reads logical-physical address mappings and logical name mappings from a " + "file (or URL) and adds them to the local caches") public void addToCache(String filename) throws Exception { InputStream in=ConfiguratorFactory.getConfigStream(filename); List<PingData> list=read(in); if(list != null) for(PingData data: list) addDiscoveryResponseToCaches(data.getAddress(), data.getLogicalName(), data.getPhysicalAddr()); }