Search in sources :

Example 46 with IContainer

use of org.eclipse.ecf.core.IContainer in project ecf by eclipse.

the class ContainerManagerServiceTest method testGetContainerN.

public void testGetContainerN() throws Exception {
    IContainer[] c = createContainers(10);
    assertNotNull(c);
    for (int i = 0; i < 10; i++) {
        IContainer container = containerManager.getContainer(c[i].getID());
        assertNotNull(container);
        assertTrue(container.getID().equals(c[i].getID()));
    }
}
Also used : IContainer(org.eclipse.ecf.core.IContainer)

Example 47 with IContainer

use of org.eclipse.ecf.core.IContainer in project ecf by eclipse.

the class ContainerManagerServiceTest method testGetContainerOne.

public void testGetContainerOne() throws Exception {
    IContainer[] c = createContainers(1);
    assertNotNull(c);
    IContainer container = containerManager.getContainer(c[0].getID());
    assertNotNull(container);
    assertTrue(container.getID().equals(c[0].getID()));
}
Also used : IContainer(org.eclipse.ecf.core.IContainer)

Example 48 with IContainer

use of org.eclipse.ecf.core.IContainer in project ecf by eclipse.

the class TrivialClient method run.

public void run() {
    try {
        // Create instance of trivial container
        IContainer container = ContainerFactory.getDefault().createContainer("ecf.container.trivial");
        // Get appropriate container adapter...e.g. IChannelContainerAdapter
        // IChannelContainerAdapter containerAdapter =
        // (IChannelContainerAdapter)
        // container.getAdapter(IChannelContainerAdapter.class);
        // Connect
        ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), "myid");
        container.connect(targetID, null);
    } catch (ECFException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 49 with IContainer

use of org.eclipse.ecf.core.IContainer in project ecf by eclipse.

the class RemoteServiceAdmin method createExportEndpointDescriptionProperties.

private Map<String, Object> createExportEndpointDescriptionProperties(ServiceReference serviceReference, Map<String, Object> overridingProperties, String[] exportedInterfaces, String[] serviceIntents, IRemoteServiceContainer rsContainer) {
    IContainer container = rsContainer.getContainer();
    ID containerID = container.getID();
    Map<String, Object> endpointDescriptionProperties = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    // OSGi properties
    // OBJECTCLASS set to exportedInterfaces
    endpointDescriptionProperties.put(org.osgi.framework.Constants.OBJECTCLASS, exportedInterfaces);
    // Service interface versions
    for (int i = 0; i < exportedInterfaces.length; i++) {
        String packageName = getPackageName(exportedInterfaces[i]);
        String packageVersionKey = org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + packageName;
        // If it's pre-set...by registration or by overridingProperties,
        // then use that value
        String packageVersion = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, packageVersionKey);
        if (packageVersion == null) {
            Version version = getPackageVersion(serviceReference, exportedInterfaces[i], packageName);
            if (version != null && !version.equals(Version.emptyVersion))
                packageVersion = version.toString();
        }
        // Only set the package version if we have a non-null value
        if (packageVersion != null)
            endpointDescriptionProperties.put(packageVersionKey, packageVersion);
    }
    // ENDPOINT_ID
    String endpointId = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID);
    if (endpointId == null)
        endpointId = UUID.randomUUID().toString();
    endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_ID, endpointId);
    // ECF ENDPOINT ID
    String ecfEndpointId = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, RemoteConstants.ENDPOINT_ID);
    if (ecfEndpointId == null)
        ecfEndpointId = containerID.getName();
    endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_ID, ecfEndpointId);
    // ENDPOINT_SERVICE_ID
    // This is always set to the value from serviceReference as per 122.5.1
    Long serviceId = (Long) serviceReference.getProperty(org.osgi.framework.Constants.SERVICE_ID);
    endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_SERVICE_ID, serviceId);
    // ENDPOINT_FRAMEWORK_ID
    String frameworkId = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID);
    if (frameworkId == null)
        frameworkId = Activator.getDefault().getFrameworkUUID();
    endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.ENDPOINT_FRAMEWORK_UUID, frameworkId);
    // REMOTE_CONFIGS_SUPPORTED
    String[] remoteConfigsSupported = getSupportedConfigs(container.getID());
    if (remoteConfigsSupported == null)
        remoteConfigsSupported = new String[0];
    endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED, remoteConfigsSupported);
    // SERVICE_IMPORTED_CONFIGS...set to constant value for all ECF
    // providers
    // supported (which is computed
    // for the exporting ECF container
    endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED_CONFIGS, remoteConfigsSupported);
    // SERVICE_INTENTS
    Object intents = PropertiesUtil.getPropertyValue(null, overridingProperties, org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS);
    if (intents == null)
        intents = serviceIntents;
    if (intents != null)
        endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_INTENTS, intents);
    // REMOTE_INTENTS_SUPPORTED
    String[] remoteIntentsSupported = getSupportedIntents(container.getID());
    if (remoteIntentsSupported != null)
        endpointDescriptionProperties.put(org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED, remoteIntentsSupported);
    // ECF properties
    // ID namespace
    String idNamespace = containerID.getNamespace().getName();
    endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_CONTAINER_ID_NAMESPACE, idNamespace);
    // timestamp
    endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_TIMESTAMP, System.currentTimeMillis());
    // ENDPOINT_CONNECTTARGET_ID
    String connectTarget = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, RemoteConstants.ENDPOINT_CONNECTTARGET_ID);
    if (connectTarget == null && isClient(container)) {
        ID connectedID = container.getConnectedID();
        if (connectedID != null && !connectedID.equals(containerID))
            connectTarget = connectedID.getName();
    }
    if (connectTarget != null)
        endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_CONNECTTARGET_ID, connectTarget);
    // ENDPOINT_IDFILTER_IDS
    String[] idFilter = (String[]) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, RemoteConstants.ENDPOINT_IDFILTER_IDS);
    if (idFilter != null && idFilter.length > 0)
        endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_IDFILTER_IDS, idFilter);
    // ENDPOINT_REMOTESERVICE_FILTER
    String rsFilter = (String) PropertiesUtil.getPropertyValue(serviceReference, overridingProperties, RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER);
    if (rsFilter != null)
        endpointDescriptionProperties.put(RemoteConstants.ENDPOINT_REMOTESERVICE_FILTER, rsFilter);
    Map<String, Object> nonReservedProps = PropertiesUtil.copyNonReservedProperties(overridingProperties, endpointDescriptionProperties);
    // Finally, copy all non-reserved properties
    return PropertiesUtil.removePrivateConfigProperties(remoteConfigsSupported, nonReservedProps);
}
Also used : Version(org.osgi.framework.Version) ID(org.eclipse.ecf.core.identity.ID) IRemoteServiceID(org.eclipse.ecf.remoteservice.IRemoteServiceID) UUID(java.util.UUID) StringID(org.eclipse.ecf.core.identity.StringID) IContainer(org.eclipse.ecf.core.IContainer) TreeMap(java.util.TreeMap)

Example 50 with IContainer

use of org.eclipse.ecf.core.IContainer in project ecf by eclipse.

the class AbstractConsumerContainerSelector method connectContainerToTarget.

protected void connectContainerToTarget(IRemoteServiceContainer rsContainer, ID connectTargetID) {
    if (connectTargetID == null)
        return;
    IContainer container = rsContainer.getContainer();
    ID connectedID = container.getConnectedID();
    // it's not already connected
    if (connectedID == null) {
        // connect to target
        try {
            connectContainer(container, connectTargetID, getConnectContext(container, connectTargetID));
        } catch (ContainerConnectException e) {
            logException(// $NON-NLS-1$
            "Exception connecting container id=" + container.getID() + // $NON-NLS-1$
            " to connectTargetID=" + connectTargetID, e);
        }
    }
}
Also used : ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

IContainer (org.eclipse.ecf.core.IContainer)121 ID (org.eclipse.ecf.core.identity.ID)29 ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)20 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)9 IRoster (org.eclipse.ecf.presence.roster.IRoster)8 IChannelContainerAdapter (org.eclipse.ecf.datashare.IChannelContainerAdapter)7 IRemoteServiceContainer (org.eclipse.ecf.remoteservice.IRemoteServiceContainer)7 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)7 ISharedObjectContainer (org.eclipse.ecf.core.sharedobject.ISharedObjectContainer)5 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)5 RemoteServiceContainer (org.eclipse.ecf.remoteservice.RemoteServiceContainer)5 Action (org.eclipse.jface.action.Action)5 IAction (org.eclipse.jface.action.IAction)5 URL (java.net.URL)4 Job (org.eclipse.core.runtime.jobs.Job)4 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)4 IContainerManager (org.eclipse.ecf.core.IContainerManager)4 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)4 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)4 RestClientContainer (org.eclipse.ecf.remoteservice.rest.client.RestClientContainer)4