Search in sources :

Example 1 with ISharedObjectManager

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

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

the class SharedModelFactory method createSharedDataSource.

public IMasterModel createSharedDataSource(ISharedObjectContainer container, final ID id, Object data, String updaterID) throws SharedObjectCreateException {
    final ISharedObjectManager mgr = container.getSharedObjectManager();
    final Object[] result = new Object[1];
    final Object monitor = new Object();
    IContainerListener listener = new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof ISharedObjectActivatedEvent) {
                ISharedObjectActivatedEvent e = (ISharedObjectActivatedEvent) event;
                if (e.getActivatedID().equals(id)) {
                    result[0] = mgr.getSharedObject(id);
                    synchronized (monitor) {
                        monitor.notify();
                    }
                }
            }
        }
    };
    try {
        container.addListener(listener);
        /*			SharedObjectDescription desc = createLocalAgentDescription(id, container.getID(), data, updaterID);
			synchronized (monitor) {
				mgr.createSharedObject(desc);
				if (result[0] == null)
					monitor.wait(getCreationTimeout());
			}
*/
        synchronized (monitor) {
            addSharedObject(mgr, id, data, updaterID);
            if (result[0] == null)
                monitor.wait(getCreationTimeout());
        }
    } catch (InterruptedException e) {
        throw new SharedObjectCreateException(e);
    } finally {
        container.removeListener(listener);
    }
    return (IMasterModel) result[0];
}
Also used : ISharedObjectActivatedEvent(org.eclipse.ecf.core.sharedobject.events.ISharedObjectActivatedEvent) SharedObjectCreateException(org.eclipse.ecf.core.sharedobject.SharedObjectCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager) IContainerListener(org.eclipse.ecf.core.IContainerListener)

Example 3 with ISharedObjectManager

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

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

the class PublishedServiceDirectory method activated.

protected void activated(final ID sharedObjectID) {
    if (sharedObjectID.equals(config.getSharedObjectID())) {
        ISharedObjectManager mgr = config.getContext().getSharedObjectManager();
        if (discoveryAgentID == null) {
            try {
                discoveryAgentID = IDFactory.getDefault().createGUID();
                mgr.createSharedObject(createDiscoveryAgentDescription());
            } catch (ECFException e) {
                // TODO Log me!
                e.printStackTrace();
            }
        }
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) ISharedObjectManager(org.eclipse.ecf.core.sharedobject.ISharedObjectManager)

Example 5 with ISharedObjectManager

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

Aggregations

ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)13 ID (org.eclipse.ecf.core.identity.ID)11 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)9 IContainer (org.eclipse.ecf.core.IContainer)4 ISharedObjectContainer (org.eclipse.ecf.core.sharedobject.ISharedObjectContainer)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 ISharedObjectContext (org.eclipse.ecf.core.sharedobject.ISharedObjectContext)2 ReplicaSharedObjectDescription (org.eclipse.ecf.core.sharedobject.ReplicaSharedObjectDescription)2 SharedObjectCreateException (org.eclipse.ecf.core.sharedobject.SharedObjectCreateException)2 IPublishedService (org.eclipse.ecf.pubsub.IPublishedService)2 URISyntaxException (java.net.URISyntaxException)1 PermissionCollection (java.security.PermissionCollection)1 List (java.util.List)1 Map (java.util.Map)1 PlatformObject (org.eclipse.core.runtime.PlatformObject)1 IContainerListener (org.eclipse.ecf.core.IContainerListener)1 IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)1