JvmTransportGenerator.java
package org.microspace.transport.specific;
import java.util.HashMap;
import java.util.Map;
import org.microspace.space.ClusterTransportGenerator;
import org.microspace.transport.ClusterTransport;
/**
* ClusterTransportGenerator for Jvm Based Transports.
* @author Gaspar Sinai - {@literal gaspar.sinai@microspace.org}
* @version 2016-06-26
*/
public class JvmTransportGenerator implements ClusterTransportGenerator {
Map<String, JvmCluster> clusters = new HashMap<String, JvmCluster> ();
/**
* {@inheritDoc}
*/
@Override
public ClusterTransport newClusterTransport(String clusterName) {
synchronized (clusters) {
JvmCluster cluster = clusters.get(clusterName);
if (cluster == null) {
cluster = new JvmCluster(clusterName);
clusters.put(clusterName, cluster);
}
JvmTransport ret = new JvmTransport(cluster);
return ret;
}
}
public JvmCluster getCluster(String clusterName) {
synchronized (clusters) {
JvmCluster cluster = clusters.get(clusterName);
return cluster;
}
}
}