use of org.eclipse.ecf.discovery.IServiceProperties in project ecf by eclipse.
the class JSLPTestComparator method compare.
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
public int compare(final Object arg0, final Object arg1) {
if (arg0 instanceof IServiceInfo && arg1 instanceof IServiceInfo) {
final IServiceInfo first = (IServiceInfo) arg0;
final IServiceInfo second = (IServiceInfo) arg1;
final IServiceID firstID = first.getServiceID();
final IServiceID secondID = second.getServiceID();
final IServiceTypeID firstTypeID = firstID.getServiceTypeID();
final IServiceTypeID secondTypeID = secondID.getServiceTypeID();
final boolean protocolsSame = Arrays.equals(firstTypeID.getProtocols(), secondTypeID.getProtocols());
final boolean weightSame = first.getWeight() == second.getWeight();
final boolean prioSame = first.getPriority() == second.getPriority();
final String firstName = firstID.getName();
final String secondName = secondID.getName();
final boolean nameSame = firstName.equals(secondName);
final String[] firstServices = firstTypeID.getServices();
final String[] secondServices = secondTypeID.getServices();
final boolean serviceSame = Arrays.equals(firstServices, secondServices);
final Namespace firstNamespace = firstID.getNamespace();
final Namespace secondNamespace = secondID.getNamespace();
final boolean namespaceSame = firstNamespace.equals(secondNamespace);
final String firstNA = firstTypeID.getNamingAuthority();
final String secondsSA = secondTypeID.getNamingAuthority();
final boolean naSame = firstNA.equals(secondsSA);
final URI firstLocation = first.getLocation();
final URI secondLocation = second.getLocation();
final boolean locationSame = firstLocation.equals(secondLocation);
final boolean scopesSame = Arrays.equals(firstTypeID.getScopes(), secondTypeID.getScopes());
final IServiceProperties firstProperty = first.getServiceProperties();
final IServiceProperties secondProperty = second.getServiceProperties();
final boolean propertySame = firstProperty.equals(secondProperty);
final boolean result = protocolsSame && weightSame && prioSame && nameSame && namespaceSame && serviceSame && naSame && locationSame && scopesSame && propertySame;
if (result == true) {
return 0;
}
}
return -1;
}
use of org.eclipse.ecf.discovery.IServiceProperties 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;
}
}
Aggregations