* Create a new description.
*/
@Activate
protected void activate() {
logger.debug("NoClusterDiscoveryService started.");
final InstanceDescription myDescription = new InstanceDescription() {
public boolean isLocal() {
return true;
}
public boolean isLeader() {
return true;
}
public String getSlingId() {
return settingsService.getSlingId();
}
public String getProperty(final String name) {
synchronized(lock) {
return cachedProperties.get(name);
}
}
public Map<String, String> getProperties() {
synchronized(lock) {
return Collections.unmodifiableMap(cachedProperties);
}
}
public ClusterView getClusterView() {
final Collection<ClusterView> clusters = topologyView.getClusterViews();
if (clusters==null || clusters.size()==0) {
return null;
}
return clusters.iterator().next();
}
};
final Set<InstanceDescription> instances = new HashSet<InstanceDescription>();
instances.add(myDescription);
final TopologyEventListener[] registeredServices;
synchronized ( lock ) {
registeredServices = this.listeners;
final ClusterView clusterView = new ClusterView() {
public InstanceDescription getLeader() {
return myDescription;
}
public List<InstanceDescription> getInstances() {
return new LinkedList<InstanceDescription>(instances);
}
public String getId() {
return "0";
}
};
this.topologyView = new TopologyView() {
public InstanceDescription getLocalInstance() {
return myDescription;
}
public boolean isCurrent() {
return true;
}
public Set<InstanceDescription> getInstances() {
return instances;
}
public Set<InstanceDescription> findInstances(InstanceFilter picker) {
Set<InstanceDescription> result = new HashSet<InstanceDescription>();
for (Iterator<InstanceDescription> it = getTopology().getInstances().iterator(); it.hasNext();) {
InstanceDescription instance = it.next();
if (picker.accept(instance)) {
result.add(instance);
}
}
return result;