use of com.hazelcast.client.impl.ClientConnectionManagerFactory in project hazelcast by hazelcast.
the class TestHazelcastFactory method newHazelcastClient.
public HazelcastInstance newHazelcastClient(ClientConfig config) {
if (!mockNetwork) {
return HazelcastClient.newHazelcastClient(config);
}
if (config == null) {
config = new XmlClientConfigBuilder().build();
}
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
HazelcastClientProxy proxy;
try {
if (tccl == ClassLoader.getSystemClassLoader()) {
Thread.currentThread().setContextClassLoader(HazelcastClient.class.getClassLoader());
}
ClientConnectionManagerFactory clientConnectionManagerFactory = clientRegistry.createClientServiceFactory("127.0.0.1", CLIENT_PORTS);
AddressProvider testAddressProvider = createAddressProvider(config);
HazelcastClientInstanceImpl client = new HazelcastClientInstanceImpl(config, clientConnectionManagerFactory, testAddressProvider);
client.start();
clients.add(client);
OutOfMemoryErrorDispatcher.registerClient(client);
proxy = new HazelcastClientProxy(client);
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
return proxy;
}
use of com.hazelcast.client.impl.ClientConnectionManagerFactory in project hazelcast by hazelcast.
the class HazelcastClientManager method newHazelcastClient.
@SuppressWarnings("unchecked")
public static HazelcastInstance newHazelcastClient(ClientConfig config, HazelcastClientFactory hazelcastClientFactory) {
if (config == null) {
config = new XmlClientConfigBuilder().build();
}
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
HazelcastClientProxy proxy;
try {
Thread.currentThread().setContextClassLoader(HazelcastClient.class.getClassLoader());
ClientConnectionManagerFactory clientConnectionManagerFactory = new DefaultClientConnectionManagerFactory();
final HazelcastClientInstanceImpl client = hazelcastClientFactory.createHazelcastInstanceClient(config, clientConnectionManagerFactory);
client.start();
OutOfMemoryErrorDispatcher.registerClient(client);
proxy = hazelcastClientFactory.createProxy(client);
if (INSTANCE.clients.putIfAbsent(client.getName(), proxy) != null) {
throw new DuplicateInstanceNameException("HazelcastClientInstance with name '" + client.getName() + "' already exists!");
}
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
return proxy;
}
Aggregations