private volatile boolean live = false;
public ClientConnectionManagerImpl(HazelcastClient client, LoadBalancer loadBalancer) {
this.client = client;
final ClientConfig config = client.getClientConfig();
final ClientNetworkConfig networkConfig = config.getNetworkConfig();
final GroupConfig groupConfig = config.getGroupConfig();
final ClientSecurityConfig securityConfig = config.getSecurityConfig();
Credentials c = securityConfig.getCredentials();
if (c == null) {
final String credentialsClassname = securityConfig.getCredentialsClassname();
//todo: Should be moved to a reflection utility.
if (credentialsClassname != null) {
try {
c = ClassLoaderUtil.newInstance(config.getClassLoader(), credentialsClassname);
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
}
}
if (c == null) {
c = new UsernamePasswordCredentials(groupConfig.getName(), groupConfig.getPassword());
}
this.smartRouting = networkConfig.isSmartRouting();
this.executionService = (ClientExecutionServiceImpl) client.getClientExecutionService();
this.credentials = c;
router = new Router(loadBalancer);
inSelector = new ClientInSelectorImpl(client.getThreadGroup());
outSelector = new ClientOutSelectorImpl(client.getThreadGroup());
//init socketInterceptor
SocketInterceptorConfig sic = networkConfig.getSocketInterceptorConfig();
SocketInterceptor implementation = null;
if (sic != null && sic.isEnabled()) {
implementation = (SocketInterceptor) sic.getImplementation();
if (implementation == null && sic.getClassName() != null) {
try {
implementation = (SocketInterceptor) Class.forName(sic.getClassName()).newInstance();
} catch (Throwable e) {
logger.severe("SocketInterceptor class cannot be instantiated!" + sic.getClassName(), e);
}
}
}
socketInterceptor = implementation;
if (socketInterceptor != null) {
logger.info("SocketInterceptor is enabled");
socketInterceptor.init(sic.getProperties());
}
socketOptions = networkConfig.getSocketOptions();
SSLConfig sslConfig = networkConfig.getSSLConfig(); //ioService.getSSLConfig(); TODO
if (sslConfig != null && sslConfig.isEnabled()) {
socketChannelWrapperFactory = new SSLSocketChannelWrapperFactory(sslConfig);
logger.info("SSL is enabled");
} else {
socketChannelWrapperFactory = new DefaultSocketChannelWrapperFactory();