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


Java FilteringClassLoader类代码示例

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


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

示例1: createIsolatedNode

import com.hazelcast.util.FilteringClassLoader; //导入依赖的package包/类
static Object createIsolatedNode(Thread thread, FilteringClassLoader cl) throws Exception {
    thread.setContextClassLoader(cl);
    Class<?> jetConfigClazz = cl.loadClass("com.hazelcast.jet.config.JetConfig");
    Class<?> hazelcastConfigClazz = cl.loadClass("com.hazelcast.config.Config");
    Object config = jetConfigClazz.newInstance();
    Method getHazelcastConfig = jetConfigClazz.getDeclaredMethod("getHazelcastConfig");
    Object hazelcastConfig = getHazelcastConfig.invoke(config);
    Method setClassLoader = hazelcastConfigClazz.getDeclaredMethod("setClassLoader", ClassLoader.class);
    setClassLoader.invoke(hazelcastConfig, cl);

    Class<?> jetClazz = cl.loadClass("com.hazelcast.jet.Jet");
    Method newJetInstance = jetClazz.getDeclaredMethod("newJetInstance", jetConfigClazz);
    return newJetInstance.invoke(jetClazz, config);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:15,代码来源:AbstractDeploymentTest.java

示例2: createCluster

import com.hazelcast.util.FilteringClassLoader; //导入依赖的package包/类
@Override
protected void createCluster() {
    Thread thread = Thread.currentThread();
    ClassLoader tccl = thread.getContextClassLoader();
    String host;
    Integer port;
    try {
        FilteringClassLoader cl = new FilteringClassLoader(singletonList("deployment"), "com.hazelcast");
        isolatedNode = createIsolatedNode(thread, cl);
        Class<?> jetInstanceClazz = cl.loadClass("com.hazelcast.jet.JetInstance");
        Method getCluster = jetInstanceClazz.getDeclaredMethod("getCluster");
        Object clusterObj = getCluster.invoke(isolatedNode);
        Class<?> cluster = cl.loadClass("com.hazelcast.core.Cluster");
        Method getLocalMember = cluster.getDeclaredMethod("getLocalMember");
        Object memberObj = getLocalMember.invoke(clusterObj);
        Class<?> member = cl.loadClass("com.hazelcast.core.Member");
        Method getAddress = member.getDeclaredMethod("getAddress");
        Object addressObj = getAddress.invoke(memberObj);
        Class<?> address = cl.loadClass("com.hazelcast.nio.Address");
        Method getHost = address.getDeclaredMethod("getHost");
        Method getPort = address.getDeclaredMethod("getPort");
        host = (String) getHost.invoke(addressObj);
        port = (Integer) getPort.invoke(addressObj);
    } catch (Exception e) {
        throw new RuntimeException("Could not start isolated Hazelcast instance", e);
    } finally {
        thread.setContextClassLoader(tccl);
    }
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getGroupConfig().setName("jet");
    clientConfig.getGroupConfig().setPassword("jet-pass");
    clientConfig.getNetworkConfig().setAddresses(singletonList(host + ":" + port));
    client = Jet.newJetClient(clientConfig);
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:35,代码来源:ClientDeploymentTest.java

示例3: createCluster

import com.hazelcast.util.FilteringClassLoader; //导入依赖的package包/类
@Override
protected void createCluster() {
    JetConfig jetConfig = new JetConfig();
    instance = Jet.newJetInstance(jetConfig);
    Thread thread = Thread.currentThread();
    ClassLoader tccl = thread.getContextClassLoader();
    try {
        isolatedNode = createIsolatedNode(thread,
                new FilteringClassLoader(Collections.singletonList("deployment"), "com.hazelcast"));
    } catch (Exception e) {
        throw new RuntimeException("Could not start isolated Hazelcast instance", e);
    } finally {
        thread.setContextClassLoader(tccl);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:16,代码来源:DeploymentTest.java


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