Search in sources :

Example 6 with ISharedObject

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

the class AbstractChatRoomSOAddTest method testAddSharedObject1.

public void testAddSharedObject1() throws Exception {
    if (chatRoomContainer[0] == null)
        return;
    final IContainer client0Container = chatRoomContainer[1];
    assertNotNull(client0Container);
    // 
    final ISharedObjectContainer socontainer = (ISharedObjectContainer) client0Container.getAdapter(ISharedObjectContainer.class);
    final ISharedObjectManager manager = socontainer.getSharedObjectManager();
    assertNotNull(manager);
    final ID objectID = createSharedObjectID();
    final ID id = manager.addSharedObject(objectID, createSharedObject(objectID), null);
    assertNotNull(id);
    final ISharedObject sharedObject = manager.getSharedObject(id);
    assertNotNull(sharedObject);
    sleep(5000);
}
Also used : ISharedObjectContainer(org.eclipse.ecf.core.sharedobject.ISharedObjectContainer) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IContainer(org.eclipse.ecf.core.IContainer)

Example 7 with ISharedObject

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

the class AbstractChatRoomSOAddTest method testAddSharedObject.

public void testAddSharedObject() throws Exception {
    if (chatRoomContainer[0] == null)
        return;
    final IContainer client0Container = chatRoomContainer[0];
    assertNotNull(client0Container);
    // 
    final ISharedObjectContainer socontainer = (ISharedObjectContainer) client0Container.getAdapter(ISharedObjectContainer.class);
    final ISharedObjectManager manager = socontainer.getSharedObjectManager();
    assertNotNull(manager);
    final ID objectID = createSharedObjectID();
    final ID id = manager.addSharedObject(objectID, createSharedObject(objectID), null);
    assertNotNull(id);
    final ISharedObject sharedObject = manager.getSharedObject(id);
    assertNotNull(sharedObject);
    sleep(5000);
}
Also used : ISharedObjectContainer(org.eclipse.ecf.core.sharedobject.ISharedObjectContainer) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IContainer(org.eclipse.ecf.core.IContainer)

Example 8 with ISharedObject

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

the class AbstractChatRoomSOAddTest method testAddTwoSharedObjects1.

public void testAddTwoSharedObjects1() throws Exception {
    if (chatRoomContainer[0] == null)
        return;
    final IContainer client0Container = chatRoomContainer[1];
    assertNotNull(client0Container);
    final ISharedObjectContainer socontainer = (ISharedObjectContainer) client0Container.getAdapter(ISharedObjectContainer.class);
    final ISharedObjectManager manager = socontainer.getSharedObjectManager();
    assertNotNull(manager);
    final ID objectID0 = createSharedObjectID();
    final ID id0 = manager.addSharedObject(objectID0, createSharedObject(objectID0), null);
    assertNotNull(id0);
    final ID objectID1 = createSharedObjectID();
    final ID id1 = manager.addSharedObject(objectID1, createSharedObject(objectID1), null);
    assertNotNull(id1);
    final ISharedObject sharedObject0 = manager.getSharedObject(id0);
    assertNotNull(sharedObject0);
    final ISharedObject sharedObject1 = manager.getSharedObject(id1);
    assertNotNull(sharedObject1);
    sleep(5000);
}
Also used : ISharedObjectContainer(org.eclipse.ecf.core.sharedobject.ISharedObjectContainer) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) IContainer(org.eclipse.ecf.core.IContainer)

Example 9 with ISharedObject

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

the class AddSharedObjectTest method testAddTwoSharedObjects.

public void testAddTwoSharedObjects() throws Exception {
    final ISharedObjectManager manager = getClientSOManager(0);
    assertNotNull(manager);
    final ID id0 = manager.addSharedObject(IDFactory.getDefault().createStringID("foo0"), new TestSharedObject(TEST_USERNAME0), null);
    assertNotNull(id0);
    final ID id1 = manager.addSharedObject(IDFactory.getDefault().createStringID("foo1"), new TestSharedObject(TEST_USERNAME1), null);
    assertNotNull(id1);
    final ISharedObject sharedObject0 = manager.getSharedObject(id0);
    assertNotNull(sharedObject0);
    final ISharedObject sharedObject1 = manager.getSharedObject(id1);
    assertNotNull(sharedObject1);
    sleep(1000);
}
Also used : ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject)

Example 10 with ISharedObject

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

the class SubscriptionAgent method activated.

protected void activated() {
    ISharedObjectContext ctx = config.getContext();
    if (isPrimary()) {
        try {
            ctx.sendCreate(containerID, createReplicaDescription());
        } catch (IOException e) {
            callback.requestFailed(e);
            ctx.getSharedObjectManager().removeSharedObject(config.getSharedObjectID());
        }
        return;
    }
    ISharedObjectManager mgr = ctx.getSharedObjectManager();
    ISharedObject so = mgr.getSharedObject(sharedObjectID);
    try {
        ID homeContainerID = config.getHomeContainerID();
        if (so instanceof IPublishedService) {
            IPublishedService svc = (IPublishedService) so;
            svc.subscribe(homeContainerID, config.getSharedObjectID());
        } else {
            ctx.sendCreateResponse(homeContainerID, new IllegalArgumentException("Not an IPublishedService."), -1);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        ctx.getSharedObjectManager().removeSharedObject(config.getSharedObjectID());
    }
}
Also used : ISharedObjectContext(org.eclipse.ecf.core.sharedobject.ISharedObjectContext) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) IOException(java.io.IOException) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) ID(org.eclipse.ecf.core.identity.ID) IPublishedService(org.eclipse.ecf.pubsub.IPublishedService)

Aggregations

ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)11 ID (org.eclipse.ecf.core.identity.ID)9 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)8 ISharedObjectContainer (org.eclipse.ecf.core.sharedobject.ISharedObjectContainer)5 IContainer (org.eclipse.ecf.core.IContainer)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 SharedObjectCreateException (org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)2 IChannelListener (org.eclipse.ecf.datashare.IChannelListener)2 Constructor (java.lang.reflect.Constructor)1 Map (java.util.Map)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 StringID (org.eclipse.ecf.core.identity.StringID)1 ISharedObjectContext (org.eclipse.ecf.core.sharedobject.ISharedObjectContext)1 SharedObjectDescription (org.eclipse.ecf.core.sharedobject.SharedObjectDescription)1 SharedObjectTypeDescription (org.eclipse.ecf.core.sharedobject.SharedObjectTypeDescription)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IMergeableChannel (org.eclipse.ecf.datashare.mergeable.IMergeableChannel)1 EclipseCollabSharedObject (org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject)1 ConnectionCreateException (org.eclipse.ecf.provider.comm.ConnectionCreateException)1