use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetServices.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices()}.
* @throws ContainerConnectException
*/
public void testGetServices() throws ContainerConnectException {
registerService();
final IServiceInfo[] services = discoveryLocator.getServices();
assertTrue("IServiceInfo[] is empty", services.length >= 1);
for (int i = 0; i < services.length; i++) {
IServiceInfo iServiceInfo = services[i];
if (comparator.compare(iServiceInfo, serviceInfo) == 0) {
return;
}
}
fail("Self registered service not found");
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetServiceInfo.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)}.
* @throws ContainerConnectException
*/
public void testGetServiceInfo() throws ContainerConnectException {
registerService();
final IServiceInfo info = discoveryLocator.getServiceInfo(serviceInfo.getServiceID());
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + info, comparator.compare(info, serviceInfo) == 0);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetAsyncServices.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices()}.
* @throws ContainerConnectException
* @throws InterruptedException
* @throws OperationCanceledException
*/
public void testGetAsyncServices() throws ContainerConnectException, OperationCanceledException, InterruptedException {
registerService();
final IFuture aFuture = discoveryLocator.getAsyncServices();
final Object object = aFuture.get();
assertTrue(object instanceof IServiceInfo[]);
final IServiceInfo[] services = (IServiceInfo[]) object;
assertTrue("Found: " + services.length + Arrays.asList(services), services.length == eventsToExpect);
for (int i = 0; i < services.length; i++) {
IServiceInfo iServiceInfo = services[i];
if (comparator.compare(iServiceInfo, serviceInfo) == 0) {
return;
}
}
fail("Self registered service not found");
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class ServiceInfoFactory method createServiceInfo.
/**
* @since 3.0
*/
public IServiceInfo createServiceInfo(IDiscoveryAdvertiser advertiser, org.osgi.service.remoteserviceadmin.EndpointDescription endpointDescription) {
try {
IServiceTypeID serviceTypeID = createServiceTypeID(endpointDescription, advertiser);
String serviceName = createServiceName(endpointDescription, advertiser, serviceTypeID);
URI uri = createURI(endpointDescription, advertiser, serviceTypeID, serviceName);
IServiceProperties serviceProperties = createServiceProperties(endpointDescription, advertiser, serviceTypeID, serviceName, uri);
Map edProperties = endpointDescription.getProperties();
int priority = PropertiesUtil.getIntWithDefault(edProperties, RemoteConstants.DISCOVERY_SERVICE_PRIORITY, ServiceInfo.DEFAULT_PRIORITY);
int weight = PropertiesUtil.getIntWithDefault(edProperties, RemoteConstants.DISCOVERY_SERVICE_WEIGHT, ServiceInfo.DEFAULT_WEIGHT);
Long ttl = PropertiesUtil.getLongWithDefault(edProperties, RemoteConstants.DISCOVERY_SERVICE_TTL, ServiceInfo.DEFAULT_TTL);
return new ServiceInfo(uri, serviceName, serviceTypeID, priority, weight, serviceProperties, ttl);
} catch (Exception e) {
logError(// $NON-NLS-1$
"createServiceInfo", // $NON-NLS-1$
"Exception creating service info for endpointDescription=" + endpointDescription + ",advertiser=" + // $NON-NLS-1$
advertiser, e);
return null;
}
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class EndpointDescriptionLocator method processInitialLocatorServices.
private void processInitialLocatorServices(final IDiscoveryLocator locator, final LocatorServiceListener locatorListener) {
IProgressRunnable runnable = new IProgressRunnable() {
public Object run(IProgressMonitor arg0) throws Exception {
IServiceInfo[] serviceInfos = null;
try {
serviceInfos = locator.getServices();
} catch (Exception e) {
logError("processInitialLocatorServices", "Exception in locator.getServices()", // $NON-NLS-1$ //$NON-NLS-2$
e);
}
if (serviceInfos != null)
for (int i = 0; i < serviceInfos.length; i++) {
locatorListener.handleService(serviceInfos[i], true);
}
return null;
}
};
executor.execute(runnable, null);
}
Aggregations