Search in sources :

Example 6 with ISharedObjectContainer

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

the class AbstractChatRoomSOAddTest method testAddTwoSharedObjects.

public void testAddTwoSharedObjects() 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 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 7 with ISharedObjectContainer

use of org.eclipse.ecf.core.sharedobject.ISharedObjectContainer 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 8 with ISharedObjectContainer

use of org.eclipse.ecf.core.sharedobject.ISharedObjectContainer 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 9 with ISharedObjectContainer

use of org.eclipse.ecf.core.sharedobject.ISharedObjectContainer 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 10 with ISharedObjectContainer

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

the class SendSharedObjectMessageWithCustomSerializerTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    createServerAndClients();
    connectClients();
    // Setup custom serializer
    ISharedObjectContainer soContainer = getClientSOContainer(0);
    soContainer.setSharedObjectMessageSerializer(new ISharedObjectMessageSerializer() {

        public Object deserializeMessage(byte[] data) throws IOException, ClassNotFoundException {
            return deserialize(data);
        }

        public byte[] serializeMessage(ID sharedObjectId, Object message) throws IOException {
            return serialize(message);
        }
    });
    ISharedObjectContainer serverContainer = getServerSOContainer();
    serverContainer.setSharedObjectMessageSerializer(new ISharedObjectMessageSerializer() {

        public Object deserializeMessage(byte[] data) throws IOException, ClassNotFoundException {
            return deserialize(data);
        }

        public byte[] serializeMessage(ID sharedObjectId, Object message) throws IOException {
            return serialize(message);
        }
    });
    // Add test messaging shared object
    sharedObjectID = addClientSharedObject(0, IDFactory.getDefault().createStringID("foo0"), new TestMessagingSharedObject(TEST_USERNAME0, new IMessageReceiver() {

        public void handleMessage(ID fromID, Object message) {
            System.out.println("received fromId=" + fromID + " message=" + message);
        }
    }), null);
    sharedObject = (TestMessagingSharedObject) getClientSOManager(0).getSharedObject(sharedObjectID);
    sleep(2000);
}
Also used : ISharedObjectContainer(org.eclipse.ecf.core.sharedobject.ISharedObjectContainer) IOException(java.io.IOException) ID(org.eclipse.ecf.core.identity.ID) ISharedObjectMessageSerializer(org.eclipse.ecf.core.sharedobject.util.ISharedObjectMessageSerializer)

Aggregations

ISharedObjectContainer (org.eclipse.ecf.core.sharedobject.ISharedObjectContainer)12 ID (org.eclipse.ecf.core.identity.ID)8 IContainer (org.eclipse.ecf.core.IContainer)5 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)5 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)4 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 IContainerFactory (org.eclipse.ecf.core.IContainerFactory)1 ISharedObjectMessageSerializer (org.eclipse.ecf.core.sharedobject.util.ISharedObjectMessageSerializer)1 XMPPChatClient (org.eclipse.ecf.example.clients.XMPPChatClient)1 EclipseCollabSharedObject (org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject)1 SharedObjectContainerUI (org.eclipse.ecf.internal.example.collab.ui.SharedObjectContainerUI)1 IChatID (org.eclipse.ecf.presence.im.IChatID)1