本文整理汇总了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);
}
示例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);
}
示例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);
}
}