Search in sources :

Example 1 with SharedObjectDescription

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;
    }
}
Also used : IPublishedServiceDirectory(org.eclipse.ecf.pubsub.IPublishedServiceDirectory) SharedObjectDescription(org.eclipse.ecf.core.sharedobject.SharedObjectDescription) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID)

Example 2 with SharedObjectDescription

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;
}
Also used : SharedObjectDescription(org.eclipse.ecf.core.sharedobject.SharedObjectDescription) IChannelListener(org.eclipse.ecf.datashare.IChannelListener) HashMap(java.util.HashMap) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) SharedObjectTypeDescription(org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IMergeableChannel(org.eclipse.ecf.datashare.mergeable.IMergeableChannel) ID(org.eclipse.ecf.core.identity.ID) StringID(org.eclipse.ecf.core.identity.StringID) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with SharedObjectDescription

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);
}
Also used : SharedObjectDescription(org.eclipse.ecf.core.sharedobject.SharedObjectDescription) HashMap(java.util.HashMap)

Example 4 with SharedObjectDescription

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);
}
Also used : SharedObjectDescription(org.eclipse.ecf.core.sharedobject.SharedObjectDescription) HashMap(java.util.HashMap) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ID(org.eclipse.ecf.core.identity.ID) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

SharedObjectDescription (org.eclipse.ecf.core.sharedobject.SharedObjectDescription)4 HashMap (java.util.HashMap)3 ID (org.eclipse.ecf.core.identity.ID)3 Map (java.util.Map)2 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)2 SharedObjectCreateException (org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)2 StringID (org.eclipse.ecf.core.identity.StringID)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)1 SharedObjectTypeDescription (org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription)1 IChannelListener (org.eclipse.ecf.datashare.IChannelListener)1 IMergeableChannel (org.eclipse.ecf.datashare.mergeable.IMergeableChannel)1 IPublishedServiceDirectory (org.eclipse.ecf.pubsub.IPublishedServiceDirectory)1