Search in sources :

Example 6 with ReplicaSharedObjectDescription

use of org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription in project ecf by eclipse.

the class TestTransactionSharedObject method getReplicaDescription.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.core.sharedobject.BaseSharedObject#getReplicaDescription(org.eclipse.ecf.core.identity.ID)
	 */
protected ReplicaSharedObjectDescription getReplicaDescription(ID receiver) {
    // Put primary state into properties and include in replica description
    final Map properties = new HashMap();
    properties.put(NAME_PROPERTY, name);
    return new ReplicaSharedObjectDescription(this.getClass(), getConfig().getSharedObjectID(), getConfig().getHomeContainerID(), properties);
}
Also used : HashMap(java.util.HashMap) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription) Map(java.util.Map) HashMap(java.util.HashMap)

Example 7 with ReplicaSharedObjectDescription

use of org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription 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();
        }
    }
}
Also used : PublishedServiceDescriptor(org.eclipse.ecf.pubsub.PublishedServiceDescriptor) ArrayList(java.util.ArrayList) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) IOException(java.io.IOException) IPublishedService(org.eclipse.ecf.pubsub.IPublishedService) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription) ISharedObjectContext(org.eclipse.ecf.core.sharedobject.ISharedObjectContext) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) PlatformObject(org.eclipse.core.runtime.PlatformObject) ID(org.eclipse.ecf.core.identity.ID) Map(java.util.Map)

Example 8 with ReplicaSharedObjectDescription

use of org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription in project ecf by eclipse.

the class SubscriptionAgent method createReplicaDescription.

protected ReplicaSharedObjectDescription createReplicaDescription() {
    Map props = new HashMap(1);
    props.put(SHARED_OBJECT_ID_KEY, sharedObjectID);
    return new ReplicaSharedObjectDescription(getClass(), config.getSharedObjectID(), config.getHomeContainerID(), props);
}
Also used : HashMap(java.util.HashMap) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with ReplicaSharedObjectDescription

use of org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription in project ecf by eclipse.

the class SharedModelFactory method createLocalAgentDescription.

protected SharedObjectDescription createLocalAgentDescription(ID sharedObjectID, ID homeContainerID, Object data, String updaterID) {
    HashMap props = new HashMap(2);
    props.put(INITIAL_DATA_KEY, data);
    props.put(MODEL_UPDATER_KEY, updaterID);
    return new ReplicaSharedObjectDescription(LocalAgent.class, sharedObjectID, homeContainerID, props);
}
Also used : HashMap(java.util.HashMap) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription)

Example 10 with ReplicaSharedObjectDescription

use of org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription in project ecf by eclipse.

the class LocalAgent method createRemoteAgentDescription.

protected ReplicaSharedObjectDescription createRemoteAgentDescription(ID requestorID) {
    Map props = new HashMap(3);
    try {
        props.put(INITIAL_DATA_KEY, SerializationUtil.serialize(data));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    props.put(MODEL_UPDATER_KEY, updaterID);
    props.put(REQUESTOR_ID, requestorID);
    return new ReplicaSharedObjectDescription(RemoteAgent.class, config.getSharedObjectID(), config.getHomeContainerID(), props);
}
Also used : HashMap(java.util.HashMap) IOException(java.io.IOException) ReplicaSharedObjectDescription(org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ReplicaSharedObjectDescription (org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription)11 HashMap (java.util.HashMap)8 Map (java.util.Map)6 IOException (java.io.IOException)4 ID (org.eclipse.ecf.core.identity.ID)3 ArrayList (java.util.ArrayList)2 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)2 URISyntaxException (java.net.URISyntaxException)1 PermissionCollection (java.security.PermissionCollection)1 List (java.util.List)1 PlatformObject (org.eclipse.core.runtime.PlatformObject)1 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)1 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)1 ISharedObjectContainerGroupManager (org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager)1 ISharedObjectContext (org.eclipse.ecf.core.sharedobject.ISharedObjectContext)1 ISharedObjectPolicy (org.eclipse.ecf.core.sharedobject.security.ISharedObjectPolicy)1 GenericSharedObject (org.eclipse.ecf.example.collab.share.GenericSharedObject)1 SOContainerConfig (org.eclipse.ecf.provider.generic.SOContainerConfig)1 IPublishedService (org.eclipse.ecf.pubsub.IPublishedService)1 PublishedServiceDescriptor (org.eclipse.ecf.pubsub.PublishedServiceDescriptor)1