use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class ContainerFactoryServiceCreateTest method testContainerTypeDescriptionGetName.
public void testContainerTypeDescriptionGetName() {
final ContainerTypeDescription desc = getContainerFactoryService().getDescriptionByName(CONTAINER_TYPE_NAME);
assertTrue(desc.getName().equals(CONTAINER_TYPE_NAME));
}
use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class ContainerFactoryServiceDescriptionsTest method testGetDescriptionByName.
public void testGetDescriptionByName() {
ContainerTypeDescription desc = getFixture().getDescriptionByName(getDescription().getName());
assertNotNull(desc);
}
use of org.eclipse.ecf.core.ContainerTypeDescription 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.ContainerTypeDescription in project ecf by eclipse.
the class Activator method start.
/*
* (non-Javadoc)
*
* @see
* org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext )
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
Activator.instance = this;
this.exportedRegistrations = new ArrayList<ExportRegistration>();
this.importedRegistrations = new ArrayList<ImportRegistration>();
// start dependent bundles first
initializeDependents();
// initialize the RSA proxy service factory bundle...so that we
// can get/use *that bundle's BundleContext for registering the
// proxy ServiceFactory.
// See osgi-dev thread here for info about this
// approach/using the ServiceFactory extender approach for this purpose:
// https://mail.osgi.org/pipermail/osgi-dev/2011-February/003000.html
initializeProxyServiceFactoryBundle();
// Start distribution providers if not already started
initializeProviders(context.getBundle(), DistributionNamespace.DISTRIBUTION_NAMESPACE, // $NON-NLS-1$
"Could not start distribution provider. ");
// Start distribution providers if not already started
initializeProviders(context.getBundle(), DiscoveryNamespace.DISCOVERY_NAMESPACE, // $NON-NLS-1$
"Could not start discovery provider. ");
// make remote service admin available
rsaProps = new Properties();
rsaProps.put(RemoteServiceAdmin.SERVICE_PROP, new Boolean(true));
// Register Remote Service Admin factory, with rsaProps
remoteServiceAdminRegistration = context.registerService(org.osgi.service.remoteserviceadmin.RemoteServiceAdmin.class.getName(), new ServiceFactory() {
public Object getService(Bundle bundle, ServiceRegistration registration) {
RemoteServiceAdmin result = null;
synchronized (remoteServiceAdmins) {
result = remoteServiceAdmins.get(bundle);
if (result == null) {
result = new RemoteServiceAdmin(bundle, exportedRegistrations, importedRegistrations);
remoteServiceAdmins.put(bundle, result);
}
}
return result;
}
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
synchronized (remoteServiceAdmins) {
RemoteServiceAdmin rsa = remoteServiceAdmins.remove(bundle);
if (rsa != null)
rsa.close();
}
}
}, (Dictionary) rsaProps);
ctdTracker = new ServiceTracker<ContainerTypeDescription, ContainerTypeDescription>(context, ContainerTypeDescription.class, new ServiceTrackerCustomizer<ContainerTypeDescription, ContainerTypeDescription>() {
public ContainerTypeDescription addingService(ServiceReference<ContainerTypeDescription> reference) {
ContainerTypeDescription ctd = null;
if (reference != null && context != null) {
ctd = context.getService(reference);
if (ctd != null) {
// Add any new supported configs to rsaProps
addSupportedConfigsAndIntents(ctd);
if (remoteServiceAdminRegistration != null)
// Set the new properties for
// remoteServiceRegistration
remoteServiceAdminRegistration.setProperties(rsaProps);
}
}
return ctd;
}
public void modifiedService(ServiceReference<ContainerTypeDescription> reference, ContainerTypeDescription service) {
}
public void removedService(ServiceReference<ContainerTypeDescription> reference, ContainerTypeDescription service) {
if (remoteServiceAdminRegistration != null && service != null) {
// Remove supported configs and intents from
// rsaProps
removeSupportedConfigsAndIntents(service);
// Reset properties for remoteServiceAdmin
remoteServiceAdminRegistration.setProperties(rsaProps);
}
}
});
ctdTracker.open();
// create endpoint description locator
endpointDescriptionLocator = new EndpointDescriptionLocator(context);
// create and register endpoint description advertiser
final Properties properties = new Properties();
properties.put(Constants.SERVICE_RANKING, new Integer(Integer.MIN_VALUE));
iServiceInfoFactoryRegistration = context.registerService(IServiceInfoFactory.class.getName(), new ServiceInfoFactory(), (Dictionary) properties);
// start endpointDescriptionLocator
endpointDescriptionLocator.start();
}
use of org.eclipse.ecf.core.ContainerTypeDescription in project ecf by eclipse.
the class AbstractHostContainerSelector method selectExistingHostContainers.
/**
* @param serviceReference service reference
* @param overridingProperties overriding properties
* @param serviceExportedInterfaces service exported interfaces to select for
* @param serviceExportedConfigs service exported configs to select for
* @param serviceIntents service exported intents to select for
* @return Collection of existing host containers
* @since 2.0
*/
protected Collection selectExistingHostContainers(ServiceReference serviceReference, Map<String, Object> overridingProperties, String[] serviceExportedInterfaces, String[] serviceExportedConfigs, String[] serviceIntents) {
List results = new ArrayList();
// Get all existing containers
IContainer[] containers = getContainers();
// If nothing there, then return empty array
if (containers == null || containers.length == 0)
return results;
for (int i = 0; i < containers.length; i++) {
ID cID = containers[i].getID();
// $NON-NLS-1$ //$NON-NLS-2$
trace("selectExistingHostContainers", "Considering existing container=" + cID);
// Check to make sure it's a rs container adapter. If it's not go
// onto next one
IRemoteServiceContainerAdapter adapter = hasRemoteServiceContainerAdapter(containers[i]);
if (adapter == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " does not implement IRemoteServiceContainerAdapter");
continue;
}
// Get container type description and intents
ContainerTypeDescription description = getContainerTypeDescription(containers[i]);
// If it has no description go onto next
if (description == null) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " does not have container type description");
continue;
}
// http://bugs.eclipse.org/331532
if (!description.isServer()) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
trace("selectExistingHostContainers", "Existing container=" + cID + " is not server");
continue;
}
if (matchExistingHostContainer(serviceReference, overridingProperties, containers[i], adapter, description, serviceExportedConfigs, serviceIntents)) {
trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
"INCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
" configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
" intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceIntents).toString()));
results.add(new RemoteServiceContainer(containers[i], adapter));
} else {
trace("selectExistingHostContainers", // $NON-NLS-1$ //$NON-NLS-2$
"EXCLUDING containerID=" + containers[i].getID() + // $NON-NLS-1$
" configs=" + ((serviceExportedConfigs == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceExportedConfigs).toString()) + // $NON-NLS-1$
" intents=" + ((serviceIntents == null) ? "null" : // $NON-NLS-1$
Arrays.asList(serviceIntents).toString()));
}
}
return results;
}
Aggregations