/** * Creates new Config which is loaded from the given url. * * @param url the URL pointing to the Hazelcast XML file * @param properties the properties for replacing variables * @throws IOException if something fails while loading the resource * @throws IllegalArgumentException if the url or properties is {@code null} * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public UrlXmlConfig(URL url, Properties properties) throws IOException { if (url == null) { throw new IllegalArgumentException("url can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + url.toString() + "'."); InputStream in = url.openStream(); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a config which is loaded from a classpath resource. * * @param classLoader the ClassLoader used to load the resource * @param resource the resource, an XML configuration file from the classpath * @param properties the properties used to resolve variables in the XML * @throws IllegalArgumentException if classLoader or resource is {@code null}, or if the resource is not found * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public ClasspathXmlConfig(ClassLoader classLoader, String resource, Properties properties) { if (classLoader == null) { throw new IllegalArgumentException("classLoader can't be null"); } if (resource == null) { throw new IllegalArgumentException("resource can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + resource + "'."); InputStream in = classLoader.getResourceAsStream(resource); if (in == null) { throw new IllegalArgumentException("Specified resource '" + resource + "' could not be found!"); } new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a Config based on a Hazelcast XML file. * * @param configFile the path of the Hazelcast xml configuration file * @param properties the Properties to resolve variables in the XML * @throws IllegalArgumentException if configFile or properties is {@code null} * @throws FileNotFoundException if the file doesn't exist * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public FileSystemXmlConfig(File configFile, Properties properties) throws FileNotFoundException { if (configFile == null) { throw new IllegalArgumentException("configFile can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + configFile.getAbsolutePath() + "'."); InputStream in = new FileInputStream(configFile); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates new Config which is loaded from the given url. * * @param url the URL pointing to the Hazelcast XML file * @param properties the properties for replacing variables * @throws IOException if something fails while loading the resource * @throws IllegalArgumentException if the url or properties is {@code null} * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public UrlXmlConfig(URL url, Properties properties) throws IOException { if (url == null) { throw new IllegalArgumentException("url can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + url.toString() + "'."); InputStream in = url.openStream(); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a Config based on a Hazelcast XML file. * * @param configFile the path of the Hazelcast xml configuration file * @param properties the Properties to resolve variables in the XML * @throws IllegalArgumentException if configFile or properties is {@code null} * @throws FileNotFoundException if the file doesn't exist * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public FileSystemXmlConfig(File configFile, Properties properties) throws FileNotFoundException { if (configFile == null) { throw new IllegalArgumentException("configFile can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + configFile.getAbsolutePath() + "'."); InputStream in = new FileInputStream(configFile); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a Config from the provided XML string and properties to resolve the variables in the XML. * * @param xml the XML content as a Hazelcast XML String * @throws IllegalArgumentException if the XML is null or empty or if properties is null * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public InMemoryXmlConfig(String xml, Properties properties) { LOGGER.info("Configuring Hazelcast from 'in-memory xml'."); if (xml == null || "".equals(xml.trim())) { throw new IllegalArgumentException("XML configuration is null or empty! Please use a well-structured xml."); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } InputStream in = new ByteArrayInputStream(stringToBytes(xml)); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a Config from the provided XML string and properties to resolve the variables in the XML. * * @param xml the XML content as a Hazelcast XML String * @throws IllegalArgumentException if the XML is null or empty or if properties is null * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public InMemoryXmlConfig(String xml, Properties properties) { LOGGER.info("Configuring Hazelcast from 'in-memory xml'."); if (xml == null || "".equals(xml.trim())) { throw new IllegalArgumentException("XML configuration is null or empty! Please use a well-structured xml."); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } InputStream in = new ByteArrayInputStream(stringToBytes(xml)); new XmlConfigBuilder(in).setProperties(properties).build(this); } }
/** * Creates a config which is loaded from a classpath resource. * * @param classLoader the ClassLoader used to load the resource * @param resource the resource, an XML configuration file from the classpath * @param properties the properties used to resolve variables in the XML * @throws IllegalArgumentException if classLoader or resource is {@code null}, or if the resource is not found * @throws com.hazelcast.core.HazelcastException if the XML content is invalid */ public ClasspathXmlConfig(ClassLoader classLoader, String resource, Properties properties) { if (classLoader == null) { throw new IllegalArgumentException("classLoader can't be null"); } if (resource == null) { throw new IllegalArgumentException("resource can't be null"); } if (properties == null) { throw new IllegalArgumentException("properties can't be null"); } LOGGER.info("Configuring Hazelcast from '" + resource + "'."); InputStream in = classLoader.getResourceAsStream(resource); if (in == null) { throw new IllegalArgumentException("Specified resource '" + resource + "' could not be found!"); } new XmlConfigBuilder(in).setProperties(properties).build(this); } }