当前位置: 首页>>代码示例>>Java>>正文


Java XmlConfigBuilder类代码示例

本文整理汇总了Java中com.hazelcast.config.XmlConfigBuilder的典型用法代码示例。如果您正苦于以下问题:Java XmlConfigBuilder类的具体用法?Java XmlConfigBuilder怎么用?Java XmlConfigBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XmlConfigBuilder类属于com.hazelcast.config包,在下文中一共展示了XmlConfigBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: tenantConfigurationHazelcast

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Bean(TENANT_CONFIGURATION_HAZELCAST)
public HazelcastInstance tenantConfigurationHazelcast() throws IOException {
    log.info("{}", appProps.getHazelcast());

    Properties props = new Properties();
    props.putAll(appProps.getHazelcast());
    props.put(HAZELCAST_LOCAL_LOCAL_ADDRESS, InetUtils.getFirstNonLoopbackHostInfo().getIpAddress());

    String hazelcastConfigUrl = appProps.getHazelcast().get(HAZELCAST_CONFIG_URL_PROPERTY);
    InputStream in = context.getResource(hazelcastConfigUrl).getInputStream();

    Config config = new XmlConfigBuilder(in).setProperties(props).build();
    config.getNetworkConfig().setInterfaces(buildInterfaces(appProps.getHazelcast().get(INTERFACES)));
    HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);
    return hazelcastInstance;
}
 
开发者ID:xm-online,项目名称:xm-commons,代码行数:17,代码来源:XmConfigHazelcastConfiguration.java

示例2: hazelcastInstance

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
/**
 * Hazelcast instance that is used by the spring session
 * repository to broadcast session events. The name
 * of this bean must be left untouched.
 *
 * @return the hazelcast instance
 */
@Bean
public HazelcastInstance hazelcastInstance() {
    final Resource hzConfigResource = casProperties.getWebflow().getSession().getHzLocation();
    try {
        final URL configUrl = hzConfigResource.getURL();
        final Config config = new XmlConfigBuilder(hzConfigResource.getInputStream()).build();
        config.setConfigurationUrl(configUrl);
        config.setInstanceName(this.getClass().getSimpleName())
                .setProperty("hazelcast.logging.type", "slf4j")
                .setProperty("hazelcast.max.no.heartbeat.seconds", "300");
        return Hazelcast.newHazelcastInstance(config);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:23,代码来源:HazelcastSessionConfiguration.java

示例3: main

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
public static void main(String[] args) {
	try {
		// 获取配置文件磁盘路径
		final String path = Thread.currentThread().getContextClassLoader().getResource("").toString() + DEF_CONFIG_FILE;
		// 构建XML配置
		XmlConfigBuilder builder = new XmlConfigBuilder(path);
		// 配置对应的properties解析参数
		builder.setProperties(getProperties());
		// 创建Config
		Config config = builder.build();
		// 输出Config参数
		System.out.println(config.getGroupConfig().getName());
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
}
 
开发者ID:chkui,项目名称:hazelcast-demo,代码行数:17,代码来源:HazelcastConfigVariable.java

示例4: testExternalRegistration

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Test
public void testExternalRegistration(){
    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList());
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("self-registration", "false");

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);
    HazelcastInstance hz2 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(2, hz1);
    assertClusterSizeEventually(2, hz2);

    verify(requestHandler, after(5000).never()).register(any(InstanceInfo.class));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:20,代码来源:HazelcastClientTestCase.java

示例5: testNamespaceRegistration

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Test
public void testNamespaceRegistration(){
    final String appName = "other";
    final String namespace = "hz";
    configure(namespace, appName);

    EurekaHttpResponse<Applications> response = generateMockResponse(Collections.<InstanceInfo>emptyList(), appName);
    when(requestHandler.getApplications()).thenReturn(response);

    Config config = new XmlConfigBuilder().build();
    DiscoveryConfig discoveryConfig = config.getNetworkConfig().getJoin().getDiscoveryConfig();
    DiscoveryStrategyConfig strategyConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();
    strategyConfig.addProperty("namespace", namespace);

    HazelcastInstance hz1 = factory.newHazelcastInstance(config);

    assertClusterSizeEventually(1, hz1);

    ArgumentCaptor<InstanceInfo> captor = ArgumentCaptor.forClass(InstanceInfo.class);
    verify(requestHandler, timeout(5000).atLeastOnce()).register(captor.capture());

    String actual = captor.getValue().getAppName().toLowerCase();
    assertThat(actual, is(appName));

}
 
开发者ID:hazelcast,项目名称:hazelcast-eureka,代码行数:26,代码来源:HazelcastClientTestCase.java

示例6: createConfig

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
private Config createConfig() {
	Config config;
	try {
		config = new XmlConfigBuilder(Application.class.getClassLoader().getResource(CONFIG_NAME)).build();
	}
	catch (IOException e) {
		logger.error(e.getMessage(), e);
		throw new Error(e);
	}

	config.getSerializationConfig().addDataSerializableFactory(SerializableFactory.ID, new SerializableFactory());

	config.getSerializationConfig().getSerializerConfigs().add(new SerializerConfig().setTypeClass(JsonNode.class)
			.setImplementation(JsonSerializer.makePlain(JsonNode.class)));

	return config;
}
 
开发者ID:anyflow,项目名称:lannister,代码行数:18,代码来源:Hazelcast.java

示例7: createHazelcastFullInstance

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
/**
 * Create hazelcast full instance.
 *
 * @param configLocation the config location
 * @return the hazelcast instance
 */
public static HazelcastInstance createHazelcastFullInstance(String configLocation) {
    Config config;
    try {
        if (configLocation == null) {
            config = new XmlConfigBuilder().build();
        } else {
            config = ConfigLoader.load(configLocation);
        }
    } catch (IOException e) {
        throw new RuntimeException("failed to load config", e);
    }

    checkNotNull(config, "failed to find configLocation: " + configLocation);

    config.setInstanceName(DEFAULT_INSTANCE_NAME);
    return Hazelcast.getOrCreateHazelcastInstance(config);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jetty-sessionmanager,代码行数:24,代码来源:JettySessionUtils.java

示例8: configure

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Override
public void configure(final Properties props) {
    String instanceName = CacheEnvironment.getInstanceName(props);

    if (!StringUtil.isNullOrEmptyAfterTrim(instanceName)) {
        LOGGER.info("Using existing HazelcastInstance [" + instanceName + "].");
        this.existingInstanceName = instanceName;
    } else {
        String configResourcePath = CacheEnvironment.getConfigFilePath(props);
        if (!StringUtil.isNullOrEmptyAfterTrim(configResourcePath)) {
            try {
                this.config = ConfigLoader.load(configResourcePath);
            } catch (IOException e) {
                LOGGER.warning("IOException: " + e.getMessage());
            }
            if (config == null) {
                throw new CacheException("Could not find configuration file: " + configResourcePath);
            }
        } else {
            this.config = new XmlConfigBuilder().build();
        }
    }

    this.shutDown = CacheEnvironment.shutdownOnStop(props, (instanceName == null));
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate5,代码行数:26,代码来源:HazelcastInstanceLoader.java

示例9: configure

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Override
public void configure(Properties props) {
    String instanceName = CacheEnvironment.getInstanceName(props);

    if (!StringUtil.isNullOrEmptyAfterTrim(instanceName)) {
        LOGGER.info("Using existing HazelcastInstance [" + instanceName + "].");
        this.existingInstanceName = instanceName;
    } else {
        String configResourcePath = CacheEnvironment.getConfigFilePath(props);
        if (!StringUtil.isNullOrEmptyAfterTrim(configResourcePath)) {
            try {
                this.config = ConfigLoader.load(configResourcePath);
            } catch (IOException e) {
                LOGGER.warning("IOException: " + e.getMessage());
            }
            if (config == null) {
                throw new CacheException("Could not find configuration file: " + configResourcePath);
            }
        } else {
            this.config = new XmlConfigBuilder().build();
        }
    }

    this.shutDown = CacheEnvironment.shutdownOnStop(props, (instanceName == null));
}
 
开发者ID:hazelcast,项目名称:hazelcast-hibernate,代码行数:26,代码来源:HazelcastInstanceLoader.java

示例10: discoveryStrategyFactoryTest

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Test
public void discoveryStrategyFactoryTest() {
    JCloudsDiscoveryStrategyFactory jCloudsDiscoveryStrategyFactory = new JCloudsDiscoveryStrategyFactory();
    String xmlFileName = "test-jclouds-config.xml";
    InputStream xmlResource = JCloudsDiscoveryFactoryTest.class.getClassLoader().getResourceAsStream(xmlFileName);
    Config config = new XmlConfigBuilder(xmlResource).build();

    JoinConfig joinConfig = config.getNetworkConfig().getJoin();
    DiscoveryConfig discoveryConfig = joinConfig.getDiscoveryConfig();
    DiscoveryStrategyConfig providerConfig = discoveryConfig.getDiscoveryStrategyConfigs().iterator().next();

    assertEquals(jCloudsDiscoveryStrategyFactory.getDiscoveryStrategyType(), JCloudsDiscoveryStrategy.class);
    assertEquals(JCloudsDiscoveryStrategy.class.getName(), providerConfig.getClassName());
    assertEquals(jCloudsDiscoveryStrategyFactory.getConfigurationProperties().size(), providerConfig.getProperties().size());
    assertTrue(jCloudsDiscoveryStrategyFactory.
            newDiscoveryStrategy(null, null, new HashMap<String, Comparable>()) instanceof DiscoveryStrategy);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:18,代码来源:JCloudsDiscoveryFactoryTest.java

示例11: doStart

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Override
protected void doStart() throws Exception {
    if (maximumRedeliveries < 0) {
        throw new IllegalArgumentException("Maximum redelivery retries must be zero or a positive integer.");
    }
    if (recoveryInterval < 0) {
        throw new IllegalArgumentException("Recovery interval must be zero or a positive integer.");
    }
    ObjectHelper.notEmpty(mapName, "repositoryName");
    if (useLocalHzInstance)  {
        Config cfg = new XmlConfigBuilder().build();
        cfg.setProperty("hazelcast.version.check.enabled", "false");
        hzInstance = Hazelcast.newHazelcastInstance(cfg);
    } else {
        ObjectHelper.notNull(hzInstance, "hzInstanse");
    }
    cache = hzInstance.getMap(mapName);
    if (useRecovery) {
        persistedCache = hzInstance.getMap(persistenceMapName);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:HazelcastAggregationRepository.java

示例12: test_simple_sequencer_initialization_declarative

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Test
public void test_simple_sequencer_initialization_declarative()
        throws Exception {

    ClassLoader classLoader = BasicTestCase.class.getClassLoader();
    InputStream stream = classLoader.getResourceAsStream("hazelcast-node-configuration.xml");
    Config config = new XmlConfigBuilder(stream).build();

    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance(config);

    try {
        Snowcast snowcast = SnowcastSystem.snowcast(hazelcastInstance);
        SnowcastSequencer sequencer = buildSnowcastSequencer(snowcast);

        assertNotNull(sequencer);
    } finally {
        factory.shutdownAll();
    }
}
 
开发者ID:noctarius,项目名称:snowcast,代码行数:21,代码来源:BasicTestCase.java

示例13: newHazelcastInstanceProxy

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
public static HazelcastInstanceProxy newHazelcastInstanceProxy(Config config) {
    if (config == null) {
        config = new XmlConfigBuilder().build();
    }
    String name = config.getInstanceName();
    if (name == null || name.trim().length() == 0) {
        name = "_hzInstance_" + factoryIdGen.incrementAndGet() + "_" + config.getGroupConfig().getName();
        return newHazelcastInstanceProxy(config, name);
    } else {
        synchronized (INIT_LOCK) {
            if (factories.containsKey(name)) {
                throw new DuplicateInstanceNameException("HazelcastInstance with name '" + name + "' already exists!");
            }
            return newHazelcastInstanceProxy(config, name);
        }
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:18,代码来源:FactoryImpl.java

示例14: testEvictedEntryNotNullAfterLockAndGet

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
/**
 * Test for Issue 710
 */
@Test
public void testEvictedEntryNotNullAfterLockAndGet() throws Exception {
    String mapName = "testLock";
    Config config = new XmlConfigBuilder().build();
    MapConfig mapConfig = new MapConfig();
    mapConfig.setName(mapName);
    mapConfig.setTimeToLiveSeconds(3);
    config.addMapConfig(mapConfig);
    HazelcastInstance h1 = Hazelcast.newHazelcastInstance(config);
    IMap<Object, Object> m1 = h1.getMap(mapName);
    m1.put(1, 1);
    assertEquals(1, m1.get(1));
    Thread.sleep(5000);
    assertEquals(null, m1.get(1));
    m1.lock(1);
    assertEquals(null, m1.get(1));
    m1.put(1, 1);
    assertEquals(1, m1.get(1));
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:23,代码来源:ClusterLockTest.java

示例15: issue371NearCachePutGetRemove

import com.hazelcast.config.XmlConfigBuilder; //导入依赖的package包/类
@Ignore
@Test
public void issue371NearCachePutGetRemove() throws Exception {
    // looks like passed ok
    final HazelcastInstance hz = Hazelcast.newHazelcastInstance(new XmlConfigBuilder(ClassLoader.getSystemResourceAsStream("hazelcast-issue371.xml")).build());
    IMap<Object, Object> cache = hz.getMap("ipp-2nd-level-cache-near");
    assertNotNull(cache);
    Object value = cache.get("my-key");
    assertNull(value);
    value = cache.put("my-key", "my-value");
    assertNull(value);
    value = cache.get("my-key");
    assertEquals("my-value", value);
    value = cache.remove("my-key");
    assertEquals("my-value", value);
    value = cache.get("my-key");
    assertNull(value);
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:19,代码来源:UnresolvedIssues.java


注:本文中的com.hazelcast.config.XmlConfigBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。