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()));
}
}
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()));
}
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();
}
}
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);
}
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);
}
}
}
Aggregations