Search in sources :

Example 31 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class SimpleConcatClient method start.

public void start(int port) throws Exception {
    IContainer client = ContainerFactory.getDefault().createContainer(CLIENT_TYPE);
    // Get adapter for accessing remote services
    IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) client.getAdapter(IRemoteServiceContainerAdapter.class);
    rsContainer = new RemoteServiceContainer(client, adapter);
    System.out.println("Client created with ID=" + client.getID());
    ID connectTargetID = IDFactory.getDefault().createStringID(NLS.bind(SERVER_ID, new Integer(port)));
    System.out.println("Attempting connect to id=" + connectTargetID);
    client.connect(connectTargetID, null);
    System.out.println("Client connected to connectTargetID=" + connectTargetID);
    Thread.sleep(1000);
    // Get remote service reference
    IRemoteServiceReference[] refs = adapter.getRemoteServiceReferences((ID[]) null, IConcatService.class.getName(), null);
    rsReference = refs[0];
    System.out.println("Remote service with ref=" + refs[0]);
}
Also used : IRemoteServiceReference(org.eclipse.ecf.remoteservice.IRemoteServiceReference) IConcatService(org.eclipse.ecf.tests.remoteservice.IConcatService) RemoteServiceContainer(org.eclipse.ecf.remoteservice.RemoteServiceContainer) IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 32 with ID

use of org.eclipse.ecf.core.identity.ID 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 33 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class ConnectRemoteServicehandler method getJob.

protected Job getJob(final ExecutionEvent event) throws ExecutionException {
    final ID createConnectId = RemoteServiceHandlerUtil.getActiveConnectIDChecked(event);
    final IContainer container = RemoteServiceHandlerUtil.getActiveIRemoteServiceContainerChecked(event);
    // decouple the long running connect call from the ui thread
    return new // $NON-NLS-1$
    Job(// $NON-NLS-1$
    NLS.bind("Connecting {0}", createConnectId.getName())) {

        protected IStatus run(IProgressMonitor monitor) {
            try {
                if (container != null)
                    container.connect(createConnectId, null);
            } catch (ContainerConnectException e) {
                showException(e);
                return Status.CANCEL_STATUS;
            }
            return Status.OK_STATUS;
        }
    };
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) Job(org.eclipse.core.runtime.jobs.Job)

Example 34 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class DisonnectRemoteServicehandler method getJob.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ecf.internal.remoteservices.ui.handlers.ConnectionHandler
	 * #getJob()
	 */
protected Job getJob(final ExecutionEvent event) throws ExecutionException {
    final ID createConnectId = RemoteServiceHandlerUtil.getActiveConnectIDChecked(event);
    final IContainer container = RemoteServiceHandlerUtil.getActiveIRemoteServiceContainerChecked(event);
    // decouple the long running connect call from the ui thread
    return new // $NON-NLS-1$
    Job(// $NON-NLS-1$
    NLS.bind("Connecting {0}", createConnectId.getName())) {

        protected IStatus run(IProgressMonitor monitor) {
            if (container == null)
                return Status.OK_STATUS;
            container.disconnect();
            return Status.OK_STATUS;
        }
    };
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer) Job(org.eclipse.core.runtime.jobs.Job)

Example 35 with ID

use of org.eclipse.ecf.core.identity.ID in project ecf by eclipse.

the class ConnectedTester method getContainerByConnectID.

/**
 * @param connectID
 *            The conected ID for which an IContainer is to be returned
 * @return a IContainer instance of null
 */
// TODO push this functionality down into the ContainerManager
private IContainer getContainerByConnectID(ID connectID) {
    final IContainerManager containerManager = Activator.getDefault().getContainerManager();
    final IContainer[] containers = containerManager.getAllContainers();
    if (containers == null) {
        return null;
    }
    for (int i = 0; i < containers.length; i++) {
        ID connectedId = containers[i].getConnectedID();
        if (connectedId != null && connectedId.equals(connectID)) {
            return containers[i];
        }
    }
    return null;
}
Also used : IContainerManager(org.eclipse.ecf.core.IContainerManager) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

ID (org.eclipse.ecf.core.identity.ID)256 IContainer (org.eclipse.ecf.core.IContainer)29 IOException (java.io.IOException)19 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)18 UUID (java.util.UUID)17 HashMap (java.util.HashMap)12 ArrayList (java.util.ArrayList)11 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)11 GUID (org.eclipse.ecf.core.identity.GUID)11 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)11 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)11 Namespace (org.eclipse.ecf.core.identity.Namespace)10 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)10 Map (java.util.Map)9 Matcher (java.util.regex.Matcher)9 ECFException (org.eclipse.ecf.core.util.ECFException)9 List (java.util.List)8 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)8 IChannel (org.eclipse.ecf.datashare.IChannel)8 Iterator (java.util.Iterator)7