use of org.eclipse.ecf.core.sharedobject.SharedObjectDescription in project ecf by eclipse.
the class PubSubAdapterFactory method getDirectory.
protected IPublishedServiceDirectory getDirectory(ISharedObjectContainer container) {
ID directoryID;
try {
directoryID = IDFactory.getDefault().createStringID(PublishedServiceDirectory.SHARED_OBJECT_ID);
} catch (IDCreateException e) {
throw new RuntimeException(e);
}
final ISharedObjectManager mgr = container.getSharedObjectManager();
IPublishedServiceDirectory directory = (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
if (directory != null)
return directory;
try {
SharedObjectDescription desc = createDirectoryDescription(directoryID);
mgr.createSharedObject(desc);
return (IPublishedServiceDirectory) mgr.getSharedObject(directoryID);
} catch (SharedObjectCreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
use of org.eclipse.ecf.core.sharedobject.SharedObjectDescription in project ecf by eclipse.
the class RssClientSOContainer method createChannel.
public IMergeableChannel createChannel(IChannelConfig newChannelConfig) throws ECFException {
final IChannelListener listener = newChannelConfig.getListener();
final SharedObjectDescription sodesc = new SharedObjectDescription(FeedSharedObject.class, IDFactory.getDefault().createGUID(), new HashMap());
final SharedObjectTypeDescription sotypedesc = sodesc.getTypeDescription();
ISharedObject sharedObject = null;
if (sotypedesc.getName() != null) {
sharedObject = SharedObjectFactory.getDefault().createSharedObject(sotypedesc, new Object[] { listener });
} else {
sharedObject = createSharedObject(sotypedesc, listener);
}
final IMergeableChannel channel = (IMergeableChannel) sharedObject.getAdapter(IMergeableChannel.class);
if (channel == null) {
throw new SharedObjectCreateException("Cannot coerce object " + channel + " to be of type IChannel");
}
ID newID = sodesc.getID();
if (newID == null) {
newID = IDFactory.getDefault().createGUID();
}
Map properties = sodesc.getProperties();
if (properties == null) {
properties = new HashMap();
}
// Now add channel to container...this will block
getSharedObjectManager().addSharedObject(newID, sharedObject, properties);
return channel;
}
use of org.eclipse.ecf.core.sharedobject.SharedObjectDescription in project ecf by eclipse.
the class PublishedServiceDirectory method createDiscoveryAgentDescription.
protected SharedObjectDescription createDiscoveryAgentDescription() {
HashMap props = new HashMap(1);
props.put(DiscoveryAgent.DIRECTORY_KEY, this);
return new SharedObjectDescription(DiscoveryAgent.class, discoveryAgentID, props);
}
use of org.eclipse.ecf.core.sharedobject.SharedObjectDescription in project ecf by eclipse.
the class ServiceRequestor method createSubscriptionDescription.
protected SharedObjectDescription createSubscriptionDescription(ID containerID, ID sharedObjectID, ISubscriptionCallback callback) {
Map props = new HashMap(3);
props.put(SubscriptionAgent.CONTAINER_ID_KEY, containerID);
props.put(SubscriptionAgent.SHARED_OBJECT_ID_KEY, sharedObjectID);
props.put(SubscriptionAgent.CALLBACK_KEY, callback);
ID id;
try {
id = IDFactory.getDefault().createGUID();
} catch (IDCreateException e) {
throw new RuntimeException(e);
}
return new SharedObjectDescription(SubscriptionAgent.class, id, props);
}
Aggregations