use of com.hazelcast.wan.WanReplicationEndpoint in project hazelcast by hazelcast.
the class WanReplicationServiceImpl method getWanReplicationPublisher.
@Override
@SuppressWarnings("SynchronizeOnThis")
public WanReplicationPublisher getWanReplicationPublisher(String name) {
WanReplicationPublisherDelegate wr = wanReplications.get(name);
if (wr != null) {
return wr;
}
synchronized (this) {
wr = wanReplications.get(name);
if (wr != null) {
return wr;
}
WanReplicationConfig wanReplicationConfig = node.getConfig().getWanReplicationConfig(name);
if (wanReplicationConfig == null) {
return null;
}
List<WanPublisherConfig> publisherConfigs = wanReplicationConfig.getWanPublisherConfigs();
WanReplicationEndpoint[] targetEndpoints = new WanReplicationEndpoint[publisherConfigs.size()];
int count = 0;
for (WanPublisherConfig publisherConfig : publisherConfigs) {
WanReplicationEndpoint target;
try {
if (publisherConfig.getImplementation() != null) {
target = (WanReplicationEndpoint) publisherConfig.getImplementation();
} else {
target = ClassLoaderUtil.newInstance(node.getConfigClassLoader(), publisherConfig.getClassName());
}
} catch (Exception e) {
throw ExceptionUtil.rethrow(e);
}
target.init(node, wanReplicationConfig, publisherConfig);
targetEndpoints[count++] = target;
}
wr = new WanReplicationPublisherDelegate(name, targetEndpoints);
wanReplications.put(name, wr);
return wr;
}
}
Aggregations