com.hazelcast.config.Config.getClassLoader()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中com.hazelcast.config.Config.getClassLoader()方法的一些代码示例,展示了Config.getClassLoader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.getClassLoader()方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:getClassLoader

Config.getClassLoader介绍

[英]Returns the class-loader that will be used in serialization.

If null, then thread context class-loader will be used instead.
[中]返回将在序列化中使用的类加载器。
如果为null,则将使用线程上下文类加载器。

代码示例

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public ClassLoader getClassLoader() {
  return staticConfig.getClassLoader();
}

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public ClassLoader getClassLoader() {
  return staticConfig.getClassLoader();
}

代码示例来源:origin: hazelcast/hazelcast-jet

private static ClassLoader getConfigClassloader(Config config) {
  UserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
  ClassLoader classLoader;
  if (userCodeDeploymentConfig.isEnabled()) {
    ClassLoader parent = config.getClassLoader();
    final ClassLoader theParent = parent == null ? Node.class.getClassLoader() : parent;
    classLoader = doPrivileged(new PrivilegedAction<UserCodeDeploymentClassLoader>() {
      @Override
      public UserCodeDeploymentClassLoader run() {
        return new UserCodeDeploymentClassLoader(theParent);
      }
    });
  } else {
    classLoader = config.getClassLoader();
  }
  return classLoader;
}

代码示例来源:origin: com.hazelcast/hazelcast-all

private static ClassLoader getConfigClassloader(Config config) {
  UserCodeDeploymentConfig userCodeDeploymentConfig = config.getUserCodeDeploymentConfig();
  ClassLoader classLoader;
  if (userCodeDeploymentConfig.isEnabled()) {
    ClassLoader parent = config.getClassLoader();
    final ClassLoader theParent = parent == null ? Node.class.getClassLoader() : parent;
    classLoader = doPrivileged(new PrivilegedAction<UserCodeDeploymentClassLoader>() {
      @Override
      public UserCodeDeploymentClassLoader run() {
        return new UserCodeDeploymentClassLoader(theParent);
      }
    });
  } else {
    classLoader = config.getClassLoader();
  }
  return classLoader;
}

代码示例来源:origin: jerrinot/subzero

private static ClassLoader tryToGetClassLoader(HazelcastInstance hz) {
    try {
      Config config = hz.getConfig();
      return config.getClassLoader();
    } catch (UnsupportedOperationException e) {
      //ok, this is a client instance -> it does not support getConfig()
      try {
        Method getClientConfigMethod = hz.getClass().getMethod("getClientConfig");
        ClientConfig clientConfig = (ClientConfig) getClientConfigMethod.invoke(hz);
        return clientConfig.getClassLoader();
      } catch (NoSuchMethodException e1) {
        throw new IllegalArgumentException("Unknown instance object " + hz, e1);
      } catch (IllegalAccessException e1) {
        throw new IllegalArgumentException("Unknown instance object " + hz, e1);
      } catch (InvocationTargetException e1) {
        throw new IllegalArgumentException("Unknown instance object " + hz, e1);
      }
    }
  }
}

代码示例来源:origin: hazelcast/hazelcast-code-samples

clusterA.getConfig().getClassLoader(), properties);
CacheConfig config = new CacheConfig(clusterA.getConfig().getCacheConfig("default"));
ICache<Object, Object> cache = manager.getOrCreateCache("default", config);

代码示例来源:origin: hazelcast/hazelcast-code-samples

clusterB.getConfig().getClassLoader(), properties);
CacheConfig cacheConfig = new CacheConfig(clusterB.getConfig().getCacheConfig("default"));
ICache<Object, Object> cache = manager.getOrCreateCache("default", cacheConfig);

代码示例来源:origin: com.hazelcast/hazelcast-all

ServiceConfigurationParser parser = ClassLoaderUtil.newInstance(config.getClassLoader(), parserClass);
Object obj = parser.parse((Element) n);
serviceConfig.setConfigObject(obj);

代码示例来源:origin: hazelcast/hazelcast-jet

ServiceConfigurationParser parser = ClassLoaderUtil.newInstance(config.getClassLoader(), parserClass);
Object obj = parser.parse((Element) n);
serviceConfig.setConfigObject(obj);

代码示例来源:origin: hazelcast/hazelcast-jet

String className = checkHasText(getTextContent(node), "map-eviction-policy-class-name cannot be null or empty");
try {
  MapEvictionPolicy mapEvictionPolicy = ClassLoaderUtil.newInstance(config.getClassLoader(), className);
  mapConfig.setMapEvictionPolicy(mapEvictionPolicy);
} catch (Exception e) {

代码示例来源:origin: com.hazelcast/hazelcast-all

String className = checkHasText(getTextContent(node), "map-eviction-policy-class-name cannot be null or empty");
try {
  MapEvictionPolicy mapEvictionPolicy = ClassLoaderUtil.newInstance(config.getClassLoader(), className);
  mapConfig.setMapEvictionPolicy(mapEvictionPolicy);
} catch (Exception e) {

代码示例来源:origin: hazelcast/hazelcast-jet

@Override
public AddressPicker createAddressPicker(Node node) {
  Config config = node.getConfig();
  MemberAddressProviderConfig memberAddressProviderConfig = config.getNetworkConfig().getMemberAddressProviderConfig();
  final ILogger addressPickerLogger = node.getLogger(AddressPicker.class);
  if (!memberAddressProviderConfig.isEnabled()) {
    return new DefaultAddressPicker(config, addressPickerLogger);
  }
  MemberAddressProvider implementation = memberAddressProviderConfig.getImplementation();
  if (implementation != null) {
    return new DelegatingAddressPicker(implementation, config.getNetworkConfig(), addressPickerLogger);
  }
  ClassLoader classLoader = config.getClassLoader();
  String classname = memberAddressProviderConfig.getClassName();
  Class<? extends MemberAddressProvider> clazz = loadMemberAddressProviderClass(classLoader, classname);
  ILogger memberAddressProviderLogger = node.getLogger(clazz);
  Properties properties = memberAddressProviderConfig.getProperties();
  MemberAddressProvider memberAddressProvider = newMemberAddressProviderInstance(clazz,
      memberAddressProviderLogger, properties);
  return new DelegatingAddressPicker(memberAddressProvider, config.getNetworkConfig(), addressPickerLogger);
}

代码示例来源:origin: com.hazelcast/hazelcast-all

@Override
public AddressPicker createAddressPicker(Node node) {
  Config config = node.getConfig();
  MemberAddressProviderConfig memberAddressProviderConfig = config.getNetworkConfig().getMemberAddressProviderConfig();
  final ILogger addressPickerLogger = node.getLogger(AddressPicker.class);
  if (!memberAddressProviderConfig.isEnabled()) {
    return new DefaultAddressPicker(config, addressPickerLogger);
  }
  MemberAddressProvider implementation = memberAddressProviderConfig.getImplementation();
  if (implementation != null) {
    return new DelegatingAddressPicker(implementation, config.getNetworkConfig(), addressPickerLogger);
  }
  ClassLoader classLoader = config.getClassLoader();
  String classname = memberAddressProviderConfig.getClassName();
  Class<?> clazz = loadMemberAddressProviderClass(classLoader, classname);
  Constructor<?> constructor = findMemberAddressProviderConstructor(clazz);
  Properties properties = memberAddressProviderConfig.getProperties();
  MemberAddressProvider memberAddressProvider = newMemberAddressProviderInstance(constructor, properties);
  return new DelegatingAddressPicker(memberAddressProvider, config.getNetworkConfig(), addressPickerLogger);
}

相关文章

Config类方法