use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class ServiceIDTest method testServiceIDFactory2.
/*
* org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String, String)
*/
public void testServiceIDFactory2() {
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
ServiceTypeID serviceTypeID = new ServiceTypeID(new TestNamespace(), "_service._ecf._foo._bar._tcp.ecf.eclipse.org._IANA");
IServiceTypeID aServiceTypeID = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, serviceTypeID);
assertNotNull(aServiceTypeID);
// members should be the same
assertEquals(aServiceTypeID.getNamingAuthority(), serviceTypeID.getNamingAuthority());
assertTrue(Arrays.equals(aServiceTypeID.getServices(), serviceTypeID.getServices()));
assertTrue(Arrays.equals(aServiceTypeID.getScopes(), serviceTypeID.getScopes()));
assertTrue(Arrays.equals(aServiceTypeID.getProtocols(), serviceTypeID.getProtocols()));
assertSame(namespaceByName, aServiceTypeID.getNamespace());
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class ServiceIDTest method testServiceIDFactoryDefaults.
/*
* org.eclipse.ecf.discovery.identity.IServiceIDFactory.createServiceID(Namespace, String[], String)
*/
public void testServiceIDFactoryDefaults() {
Namespace namespaceByName = IDFactory.getDefault().getNamespaceByName(namespace);
IServiceTypeID serviceType = ServiceIDFactory.getDefault().createServiceTypeID(namespaceByName, services, protocols);
assertNotNull(serviceType);
assertTrue(Arrays.equals(services, serviceType.getServices()));
assertEquals(IServiceTypeID.DEFAULT_NA, serviceType.getNamingAuthority());
assertTrue(Arrays.equals(IServiceTypeID.DEFAULT_SCOPE, serviceType.getScopes()));
assertTrue(Arrays.equals(protocols, serviceType.getProtocols()));
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class Activator method start.
/*
* (non-Javadoc)
* @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
this.context = context;
plugin = this;
SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
protected void runWithoutRegistry() throws Exception {
// If we don't have a registry, then register trivial namespace
Activator.this.context.registerService(Namespace.class, new TrivialNamespace(TrivialNamespace.NAME), null);
// And create and register ContainerTypeDescription
Activator.this.context.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(TrivialContainerInstantiator.NAME, (IContainerInstantiator) new TrivialContainerInstantiator()), null);
}
});
}
use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.
the class Activator method start.
public void start(final BundleContext ctxt) throws Exception {
this.context = ctxt;
SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
protected void runWithoutRegistry() throws Exception {
// $NON-NLS-1$
ctxt.registerService(Namespace.class, new RemoteServiceNamespace(org.eclipse.ecf.provider.remoteservice.generic.RemoteServiceNamespace.NAME, "Generic remote service namespace"), null);
IAdapterManager am = getAdapterManager(ctxt);
if (am != null) {
rscAdapterFactories = new ArrayList();
IAdapterFactory af = new RemoteServiceContainerAdapterFactory();
am.registerAdapters(af, org.eclipse.ecf.provider.generic.SSLServerSOContainer.class);
rscAdapterFactories.add(af);
af = new RemoteServiceContainerAdapterFactory();
am.registerAdapters(af, org.eclipse.ecf.provider.generic.TCPServerSOContainer.class);
rscAdapterFactories.add(af);
af = new RemoteServiceContainerAdapterFactory();
am.registerAdapters(af, org.eclipse.ecf.provider.generic.SSLClientSOContainer.class);
rscAdapterFactories.add(af);
af = new RemoteServiceContainerAdapterFactory();
am.registerAdapters(af, org.eclipse.ecf.provider.generic.TCPClientSOContainer.class);
rscAdapterFactories.add(af);
}
}
});
}
use of org.eclipse.ecf.core.identity.Namespace 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;
}
Aggregations