use of com.hazelcast.config.XmlConfigBuilder in project spring-boot by spring-projects.
the class HazelcastInstanceFactory method getConfig.
private Config getConfig(Resource configLocation) throws IOException {
URL configUrl = configLocation.getURL();
Config config = new XmlConfigBuilder(configUrl).build();
if (ResourceUtils.isFileURL(configUrl)) {
config.setConfigurationFile(configLocation.getFile());
} else {
config.setConfigurationUrl(configUrl);
}
return config;
}
use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.
the class HazelcastServerCachingProvider method getConfig.
private Config getConfig(URL configURL, ClassLoader theClassLoader, String instanceName) throws IOException {
Config config = new XmlConfigBuilder(configURL).build();
config.setClassLoader(theClassLoader);
if (instanceName != null) {
// If instance name is specified via properties use it
// even though instance name is specified in the config.
config.setInstanceName(instanceName);
} else if (config.getInstanceName() == null) {
// Use config url as instance name if instance name is not specified.
config.setInstanceName(configURL.toString());
}
return config;
}
use of com.hazelcast.config.XmlConfigBuilder in project hazelcast by hazelcast.
the class ClientToMemberDiscoveryTest method setup.
@Before
public void setup() {
String serverXmlFileName = "hazelcast-multicast-plugin.xml";
String clientXmlFileName = "hazelcast-client-multicast-plugin.xml";
InputStream xmlResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(serverXmlFileName);
serverConfig = new XmlConfigBuilder(xmlResource).build();
InputStream xmlClientResource = MulticastDiscoveryStrategy.class.getClassLoader().getResourceAsStream(clientXmlFileName);
clientConfig = new XmlClientConfigBuilder(xmlClientResource).build();
}
use of com.hazelcast.config.XmlConfigBuilder in project camel by apache.
the class HazelcastComponent method getOrCreateHzInstance.
private HazelcastInstance getOrCreateHzInstance(CamelContext context, Map<String, Object> parameters) throws Exception {
HazelcastInstance hzInstance = null;
Config config = null;
// Query param named 'hazelcastInstance' (if exists) overrides the instance that was set
hzInstance = resolveAndRemoveReferenceParameter(parameters, HAZELCAST_INSTANCE_PARAM, HazelcastInstance.class);
// Check if an already created instance is given then just get instance by its name.
if (hzInstance == null && parameters.get(HAZELCAST_INSTANCE_NAME_PARAM) != null) {
hzInstance = Hazelcast.getHazelcastInstanceByName((String) parameters.get(HAZELCAST_INSTANCE_NAME_PARAM));
}
// as reference or as xml configuration file.
if (hzInstance == null) {
config = resolveAndRemoveReferenceParameter(parameters, HAZELCAST_CONFIGU_PARAM, Config.class);
if (config == null) {
String configUri = getAndRemoveParameter(parameters, HAZELCAST_CONFIGU_URI_PARAM, String.class);
if (configUri != null) {
configUri = getCamelContext().resolvePropertyPlaceholders(configUri);
}
if (configUri != null) {
InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, configUri);
config = new XmlConfigBuilder(is).build();
}
}
if (hazelcastInstance == null && config == null) {
config = new XmlConfigBuilder().build();
// Disable the version check
config.getProperties().setProperty("hazelcast.version.check.enabled", "false");
config.getProperties().setProperty("hazelcast.phone.home.enabled", "false");
hzInstance = Hazelcast.newHazelcastInstance(config);
} else if (config != null) {
if (ObjectHelper.isNotEmpty(config.getInstanceName())) {
hzInstance = Hazelcast.getOrCreateHazelcastInstance(config);
} else {
hzInstance = Hazelcast.newHazelcastInstance(config);
}
}
if (hzInstance != null) {
if (this.customHazelcastInstances.add(hzInstance)) {
LOGGER.debug("Add managed HZ instance {}", hzInstance.getName());
}
}
}
return hzInstance == null ? hazelcastInstance : hzInstance;
}
use of com.hazelcast.config.XmlConfigBuilder in project camel by apache.
the class HazelcastUtil method newInstance.
public static HazelcastInstance newInstance() {
Config cfg = new XmlConfigBuilder().build();
// hazelcast.version.check.enabled is deprecated
cfg.setProperty("hazelcast.phone.home.enabled", System.getProperty("hazelcast.phone.home.enabled", "false"));
cfg.setProperty("hazelcast.logging.type", System.getProperty("hazelcast.logging.type", "slf4j"));
return newInstance(cfg);
}
Aggregations