Search in sources :

Example 1 with ISharedObject

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

the class PresenceContainerAdapterFactory method getAdapter.

public Object getAdapter(Object adaptableObject, Class adapterType) {
    if (adapterType.equals(IPresenceContainerAdapter.class)) {
        TCPClientSOContainer container = (TCPClientSOContainer) adaptableObject;
        ISharedObjectManager manager = container.getSharedObjectManager();
        ID[] ids = manager.getSharedObjectIDs();
        for (int i = 0; i < ids.length; i++) {
            ISharedObject object = manager.getSharedObject(ids[i]);
            if (object instanceof EclipseCollabSharedObject) {
                EclipseCollabSharedObject ecso = (EclipseCollabSharedObject) object;
                return ecso.getPresenceContainer();
            }
        }
    }
    return null;
}
Also used : EclipseCollabSharedObject(org.eclipse.ecf.example.collab.share.EclipseCollabSharedObject) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) ID(org.eclipse.ecf.core.identity.ID) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) TCPClientSOContainer(org.eclipse.ecf.provider.generic.TCPClientSOContainer)

Example 2 with ISharedObject

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

the class AddSharedObjectTest method testAddSharedObject.

public void testAddSharedObject() throws Exception {
    final ISharedObjectManager manager = getClientSOManager(0);
    assertNotNull(manager);
    final ID id = manager.addSharedObject(IDFactory.getDefault().createStringID("foo"), new TestSharedObject(TEST_USERNAME0), null);
    assertNotNull(id);
    final ISharedObject sharedObject = manager.getSharedObject(id);
    assertNotNull(sharedObject);
    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 3 with ISharedObject

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

the class RssClientSOContainer method createSharedObject.

private ISharedObject createSharedObject(SharedObjectTypeDescription sotypedesc, IChannelListener listener) throws SharedObjectCreateException {
    Class clazz;
    try {
        clazz = Class.forName(sotypedesc.getClassName());
    } catch (final ClassNotFoundException e) {
        throw new SharedObjectCreateException("No constructor for shared object of class " + sotypedesc.getClassName(), e);
    }
    Constructor cons = null;
    try {
        cons = clazz.getDeclaredConstructor(new Class[] { IChannelListener.class });
    } catch (final NoSuchMethodException e) {
        throw new SharedObjectCreateException("No constructor for shared object of class " + sotypedesc.getClassName(), e);
    }
    ISharedObject so = null;
    try {
        so = (ISharedObject) cons.newInstance(new Object[] { listener });
    } catch (final Exception e) {
        throw new SharedObjectCreateException("Cannot create instance of class " + sotypedesc.getClassName(), e);
    }
    return so;
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) Constructor(java.lang.reflect.Constructor) ISharedObject(org.eclipse.ecf.core.sharedobject.ISharedObject) ECFException(org.eclipse.ecf.core.util.ECFException) ConnectionCreateException(org.eclipse.ecf.provider.comm.ConnectionCreateException) ParseException(org.eclipse.higgins.rsse.parser.ParseException) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IOException(java.io.IOException) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)

Example 4 with ISharedObject

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

use of org.eclipse.ecf.core.sharedobject.ISharedObject 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)

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