use of org.eclipse.ecf.pubsub.PublishedServiceDescriptor in project ecf by eclipse.
the class DiscoveryAgent method connected.
protected void connected() {
if (isPrimary()) {
try {
config.getContext().sendCreate(null, new ReplicaSharedObjectDescription(getClass(), config.getSharedObjectID()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
ArrayList published = new ArrayList();
ISharedObjectContext ctx = config.getContext();
ISharedObjectManager mgr = ctx.getSharedObjectManager();
ID[] ids = mgr.getSharedObjectIDs();
ID containerID = ctx.getLocalContainerID();
for (int i = 0; i < ids.length; ++i) {
Object object = mgr.getSharedObject(ids[i]);
if (object instanceof IPublishedService) {
IPublishedService svc = (IPublishedService) object;
Map props = svc.getProperties();
published.add(new PublishedServiceDescriptor(containerID, ids[i], props));
}
}
if (published.isEmpty())
return;
PublishedServiceDescriptor[] descriptors = new PublishedServiceDescriptor[published.size()];
published.toArray(descriptors);
try {
ctx.sendMessage(config.getHomeContainerID(), SerializationUtil.serialize(new DiscoveryMessage(DiscoveryMessage.ADDED, descriptors)));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
use of org.eclipse.ecf.pubsub.PublishedServiceDescriptor in project ecf by eclipse.
the class PublishedServiceDirectory method addReplicatedServiceListener.
public synchronized void addReplicatedServiceListener(final IPublishedServiceDirectoryListener listener) {
listeners.add(listener);
PublishedServiceDescriptor[] buf = new PublishedServiceDescriptor[services.values().size()];
services.values().toArray(buf);
final PublishedServiceDirectoryChangeEvent event = new PublishedServiceDirectoryChangeEvent(this, PublishedServiceDirectoryChangeEvent.ADDED, buf);
SafeRunner.run(new ISafeRunnable() {
public void run() throws Exception {
listener.publishedServiceDirectoryChanged(event);
}
public void handleException(Throwable exception) {
// TODO Auto-generated method stub
exception.printStackTrace();
}
});
}
Aggregations