use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class ContainerFactoryDescriptionsTest method addDescription.
protected void addDescription() {
description = createContainerTypeDescription();
ContainerTypeDescription add = getFixture().addDescription(description);
assertNull(add);
}
use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class AbstractHostContainerSelector method createAndConfigureHostContainers.
/**
* @param serviceReference service reference
* @param properties overriding properties
* @param serviceExportedInterfaces service exported interfaces to select for
* @param requiredConfigs service exported configs to select for
* @param requiredIntents intents to select for
* @return Collection of host containers
* @throws SelectContainerException if container cannot be created or configured
* @since 2.0
*/
protected Collection createAndConfigureHostContainers(ServiceReference serviceReference, Map<String, Object> properties, String[] serviceExportedInterfaces, String[] requiredConfigs, String[] serviceIntents) throws SelectContainerException {
List results = new ArrayList();
ContainerTypeDescription[] descriptions = getContainerTypeDescriptions();
if (descriptions == null)
return Collections.EMPTY_LIST;
// If there are no required configs specified, then create any defaults
if (requiredConfigs == null || requiredConfigs.length == 0) {
createAndAddDefaultContainers(serviceReference, properties, serviceExportedInterfaces, serviceIntents, descriptions, results);
} else {
// See if we have a match
for (int i = 0; i < descriptions.length; i++) {
// $NON-NLS-1$ //$NON-NLS-2$
trace("createAndConfigureHostContainers", "Considering description=" + descriptions[i]);
IRemoteServiceContainer matchingContainer = createMatchingContainer(descriptions[i], serviceReference, properties, serviceExportedInterfaces, requiredConfigs, serviceIntents);
if (matchingContainer != null)
results.add(matchingContainer);
}
}
return results;
}
use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class ProviderPlugin method start.
/**
* This method is called upon plug-in activation
*/
public void start(final BundleContext context1) throws Exception {
this.context = context1;
SafeRunner.run(new ExtensionRegistryRunnable(this.context) {
protected void runWithoutRegistry() throws Exception {
// $NON-NLS-1$
context1.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(GenericContainerInstantiator.TCPSERVER_NAME, new GenericContainerInstantiator(), "ECF Generic Server", true, false), null);
// $NON-NLS-1$
context1.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(GenericContainerInstantiator.TCPCLIENT_NAME, new GenericContainerInstantiator(), "ECF Generic Client", true, true), null);
// $NON-NLS-1$
context1.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(SSLGenericContainerInstantiator.SSLSERVER_NAME, new SSLGenericContainerInstantiator(), "ECF SSL Generic Server", true, false), null);
// $NON-NLS-1$
context1.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(SSLGenericContainerInstantiator.SSLCLIENT_NAME, new SSLGenericContainerInstantiator(), "ECF SSL Generic Client", true, true), null);
}
});
if (genericClassResolverOverride) {
Hashtable<String, Object> props = new Hashtable<String, Object>();
props.put(IClassResolver.BUNDLE_PROP_NAME, PLUGIN_ID);
this.context.registerService(IClassResolver.class, new BundleClassResolver(context.getBundle()), props);
}
}
use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class DiscoveryActivator method start.
public void start(final BundleContext ctxt) {
context = ctxt;
SafeRunner.run(new ExtensionRegistryRunnable(ctxt) {
protected void runWithoutRegistry() throws Exception {
ctxt.registerService(Namespace.class, new ZooDiscoveryNamespace(), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ZooDiscoveryContainerInstantiator.NAME, new ZooDiscoveryContainerInstantiator(), "Zookeeper Discovery Container"), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ZooDiscoveryContainerInstantiator.NAME + ".advertiser", new ZooDiscoveryContainerInstantiator(), "Zookeeper Discovery Advertiser Container"), null);
ctxt.registerService(ContainerTypeDescription.class, new ContainerTypeDescription(ZooDiscoveryContainerInstantiator.NAME + ".locator", new ZooDiscoveryContainerInstantiator(), "Zookeeper Discovery Locator Container"), null);
}
});
final Properties props = new Properties();
props.put(IDiscoveryLocator.CONTAINER_NAME, ZooDiscoveryContainerInstantiator.NAME);
props.put(IDiscoveryAdvertiser.CONTAINER_NAME, ZooDiscoveryContainerInstantiator.NAME);
// register ourselves using a service factory
discoveryRegistration = ctxt.registerService(new String[] { IDiscoveryLocator.class.getName(), IDiscoveryAdvertiser.class.getName() }, new ServiceFactory() {
private volatile ZooDiscoveryContainer zdc;
public Object getService(Bundle bundle, ServiceRegistration registration) {
if (zdc == null) {
zdc = ZooDiscoveryContainer.getSingleton();
zdc.setDiscoveryProperties(props);
}
return zdc;
}
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
}
}, (Dictionary) props);
// setup and open log service tracker
logServiceTracker = new ServiceTracker(ctxt, org.osgi.service.log.LogService.class.getName(), null) {
public Object addingService(ServiceReference reference) {
Logger.bindLogService((LogService) context.getService(reference));
return super.addingService(reference);
}
public void removedService(ServiceReference reference, Object service) {
Logger.unbindLogService((LogService) service);
super.removedService(reference, service);
}
};
logServiceTracker.open(true);
// Autostart by consuming our own service
if (ZooDiscoveryContainer.autoStart()) {
ctxt.getService(discoveryRegistration.getReference());
}
}
Aggregations