/** * Constructs a JChannel instance with the protocol stack configuration indicated by the specified URL. * @param properties A URL pointing to a JGroups XML protocol stack configuration. */ public JChannel(URL properties) throws Exception { this(ConfiguratorFactory.getStackConfigurator(properties)); }
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 at the specified URL. * * @param url a URL pointing to 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(URL url) throws Exception { checkForNullConfiguration(url); checkJAXPAvailability(); return XmlConfigurator.getInstance(url); }
/** * 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); }
/** * Returns a protocol stack configurator based on the provided properties string. * @param properties a string representing a system resource containing a JGroups XML configuration, a URL pointing * to a JGroups XML configuration or a string representing a file name that contains a JGroups * XML configuration. */ public static ProtocolStackConfigurator getStackConfigurator(String properties) throws Exception { if(properties == null) properties=Global.DEFAULT_PROTOCOL_STACK; // Attempt to treat the properties string as a pointer to an XML configuration. XmlConfigurator configurator = null; checkForNullConfiguration(properties); configurator=getXmlConfigurator(properties); if(configurator != null) // did the properties string point to a JGroups XML configuration ? return configurator; throw new IllegalStateException(String.format("configuration %s not found or invalid", properties)); }
/** * 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</code> containing the stack * configuration. * * @throws ChannelException if problems occur during the configuration of * the protocol stack. */ public static ProtocolStackConfigurator getStackConfigurator(File file) throws ChannelException { ProtocolStackConfigurator returnValue; if (propertiesOverride != null) { returnValue = getStackConfigurator(propertiesOverride); } else { try { checkJAXPAvailability(); InputStream input=getConfigStream(file); returnValue=XmlConfigurator.getInstance(input); } catch(Exception ex) { throw createChannelConfigurationException(ex); } } return returnValue; }
/** * Returns a protocol stack configurator based on the XML configuration * provided at the specified URL. * * @param url a URL pointing to a JGroups XML configuration. * * @return a <code>ProtocolStackConfigurator</code> containing the stack * configuration. * * @throws ChannelException if problems occur during the configuration of * the protocol stack. */ public static ProtocolStackConfigurator getStackConfigurator(URL url) throws ChannelException { ProtocolStackConfigurator returnValue; if (propertiesOverride != null) { returnValue = getStackConfigurator(propertiesOverride); } else { checkForNullConfiguration(url); checkJAXPAvailability(); try { returnValue=XmlConfigurator.getInstance(url); } catch (IOException ioe) { throw createChannelConfigurationException(ioe); } } return returnValue; }
returnValue = getStackConfigurator(propertiesOverride); checkForNullConfiguration(element); 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 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); } }
properties=JChannel.DEFAULT_PROTOCOL_STACK; checkForNullConfiguration(properties); configurator=getXmlConfigurator(properties); throw createChannelConfigurationException(ioe);
public static InputStream getConfigStream(File file) throws Exception { checkForNullConfiguration(file); return new FileInputStream(file); }
public static InputStream getConfigStream(URL url) throws Exception { checkJAXPAvailability(); return url.openStream(); }
/** * 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; }
/** * Returns a protocol stack configurator based on the provided properties string. * @param properties a string representing a system resource containing a JGroups XML configuration, a URL pointing * to a JGroups XML configuration or a string representing a file name that contains a JGroups * XML configuration. */ public static ProtocolStackConfigurator getStackConfigurator(String properties) throws Exception { if(properties == null) properties=Global.DEFAULT_PROTOCOL_STACK; // Attempt to treat the properties string as a pointer to an XML configuration. XmlConfigurator configurator = null; checkForNullConfiguration(properties); configurator=getXmlConfigurator(properties); if(configurator != null) // did the properties string point to a JGroups XML configuration ? return configurator; throw new IllegalStateException(String.format("configuration %s not found or invalid", properties)); }
/** * Returns a protocol stack configurator based on the XML configuration provided by the specified XML element. * * @param element a XML element containing 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(Element element) throws Exception { checkForNullConfiguration(element); return XmlConfigurator.getInstance(element); }
public static InputStream getConfigStream(URL url) throws Exception { checkJAXPAvailability(); return url.openStream(); }
/** * Creates a channel with a configuration based on an input stream. * @param input An input stream, pointing to a streamed configuration */ public JChannel(InputStream input) throws Exception { this(ConfiguratorFactory.getStackConfigurator(input)); }
protected void parseConfig(String filename) throws Exception { InputStream input=null; try { input=ConfiguratorFactory.getConfigStream(filename); parseRules(input); } 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); }