Search in sources :

Example 1 with RemoteServiceContainer

use of org.eclipse.ecf.remoteservice.RemoteServiceContainer 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 2 with RemoteServiceContainer

use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.

the class SSLSimpleConcatClient 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 3 with RemoteServiceContainer

use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.

the class AbstractHostContainerSelector method selectExistingHostContainers.

/**
 * @param serviceReference service reference
 * @param overridingProperties overriding properties
 * @param serviceExportedInterfaces service exported interfaces to select for
 * @param serviceExportedConfigs service exported configs to select for
 * @param serviceIntents service exported intents to select for
 * @return Collection of existing host containers
 * @since 2.0
 */
protected Collection selectExistingHostContainers(ServiceReference serviceReference, Map<String, Object> overridingProperties, String[] serviceExportedInterfaces, String[] serviceExportedConfigs, String[] serviceIntents) {
    List results = new ArrayList();
    // Get all existing containers
    IContainer[] containers = getContainers();
    // If nothing there, then return empty array
    if (containers == null || containers.length == 0)
        return results;
    for (int i = 0; i < containers.length; i++) {
        ID cID = containers[i].getID();
        // $NON-NLS-1$ //$NON-NLS-2$
        trace("selectExistingHostContainers", "Considering existing container=" + cID);
        // Check to make sure it's a rs container adapter. If it's not go
        // onto next one
        IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
        if (adapter == null) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            trace("selectExistingHostContainers", "Existing container=" + cID + " does not implement IRemoteServiceContainerAdapter");
            continue;
        }
        // Get container type description and intents
        ContainerTypeDescription description = getContainerTypeDescription(containers[i]);
        // If it has no description go onto next
        if (description == null) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            trace("selectExistingHostContainers", "Existing container=" + cID + " does not have container type description");
            continue;
        }
        // http://bugs.eclipse.org/331532
        if (!description.isServer()) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            trace("selectExistingHostContainers", "Existing container=" + cID + " is not server");
            continue;
        }
        if (matchExistingHostContainer(serviceReference, overridingProperties, containers[i], adapter, description, serviceExportedConfigs, serviceIntents)) {
            trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
            "INCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
            " configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
            Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
            " intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
            Arrays.asList(serviceIntents).toString()));
            results.add(new RemoteServiceContainer(containers[i], adapter));
        } else {
            trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
            "EXCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
            " configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
            Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
            " intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
            Arrays.asList(serviceIntents).toString()));
        }
    }
    return results;
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) RemoteServiceContainer(org.eclipse.ecf.remoteservice.RemoteServiceContainer) IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) ArrayList(java.util.ArrayList) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) ArrayList(java.util.ArrayList) List(java.util.List) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 4 with RemoteServiceContainer

use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.

the class AbstractConsumerContainerSelector method createContainer.

/**
 * @param containerTypeDescription containerTypeDescription
 * @param containerTypeDescriptionName containerTypeDescriptionName
 * @param properties properties
 * @return IRemoteServiceContainer created container.  Should not be <code>null</code>
 * @throws SelectContainerException thrown if container cannot be created or configured
 * @since 2.0
 */
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, Map properties) throws SelectContainerException {
    try {
        IContainer container = (properties == null) ? getContainerFactory().createContainer(containerTypeDescriptionName) : getContainerFactory().createContainer(containerTypeDescriptionName, properties);
        IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
        if (adapter == null)
            throw new SelectContainerException("Container config id=" + containerTypeDescriptionName + " does not implement IRemoteServiceContainerAdapter", null, // $NON-NLS-1$ //$NON-NLS-2$
            containerTypeDescription);
        return new RemoteServiceContainer(container);
    } catch (ContainerCreateException e) {
        String message = // $NON-NLS-1$
        "Cannot create container config id=" + containerTypeDescriptionName;
        logException(message, e);
        throw new SelectContainerException(message, e, containerTypeDescription);
    }
}
Also used : RemoteServiceContainer(org.eclipse.ecf.remoteservice.RemoteServiceContainer) IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) ContainerCreateException(org.eclipse.ecf.core.ContainerCreateException) IContainer(org.eclipse.ecf.core.IContainer)

Example 5 with RemoteServiceContainer

use of org.eclipse.ecf.remoteservice.RemoteServiceContainer in project ecf by eclipse.

the class AbstractHostContainerSelector method createRSContainer.

/**
 * @param serviceReference serviceReference
 * @param properties properties
 * @param containerTypeDescription container type description
 * @return IRemoteServiceContainer created remote service container
 * @throws SelectContainerException if could not be created
 * @since 4.6
 */
protected IRemoteServiceContainer createRSContainer(ServiceReference serviceReference, Map<String, Object> properties, ContainerTypeDescription containerTypeDescription, String[] intents) throws SelectContainerException {
    trace(// $NON-NLS-1$
    "createRSContainer", // $NON-NLS-1$ //$NON-NLS-2$
    "Creating container instance for ref=" + serviceReference + ";properties=" + properties + ";description=" + containerTypeDescription.getName() + // $NON-NLS-1$ //$NON-NLS-2$
    ";intents=" + // $NON-NLS-1$
    ((intents == null) ? "" : Arrays.asList(intents).toString()));
    IContainer container = createContainer(serviceReference, properties, containerTypeDescription, intents);
    if (container == null)
        return null;
    IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container.getAdapter(IRemoteServiceContainerAdapter.class);
    if (adapter == null)
        throw new SelectContainerException("Container does not implement IRemoteServiceContainerAdapter", null, // $NON-NLS-1$
        containerTypeDescription);
    return new RemoteServiceContainer(container, adapter);
}
Also used : RemoteServiceContainer(org.eclipse.ecf.remoteservice.RemoteServiceContainer) IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IRemoteServiceContainerAdapter(org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

IContainer (org.eclipse.ecf.core.IContainer)5 IRemoteServiceContainer (org.eclipse.ecf.remoteservice.IRemoteServiceContainer)5 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)5 RemoteServiceContainer (org.eclipse.ecf.remoteservice.RemoteServiceContainer)5 ID (org.eclipse.ecf.core.identity.ID)3 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)2 IConcatService (org.eclipse.ecf.tests.remoteservice.IConcatService)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ContainerCreateException (org.eclipse.ecf.core.ContainerCreateException)1 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)1