Search in sources :

Example 51 with ContainerTypeDescription

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);
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription)

Example 52 with ContainerTypeDescription

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;
}
Also used : IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 53 with ContainerTypeDescription

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);
    }
}
Also used : ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) Hashtable(java.util.Hashtable) SSLGenericContainerInstantiator(org.eclipse.ecf.provider.generic.SSLGenericContainerInstantiator) GenericContainerInstantiator(org.eclipse.ecf.provider.generic.GenericContainerInstantiator) SSLGenericContainerInstantiator(org.eclipse.ecf.provider.generic.SSLGenericContainerInstantiator)

Example 54 with ContainerTypeDescription

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());
    }
}
Also used : Dictionary(java.util.Dictionary) ServiceFactory(org.osgi.framework.ServiceFactory) ServiceTracker(org.osgi.util.tracker.ServiceTracker) ContainerTypeDescription(org.eclipse.ecf.core.ContainerTypeDescription) Bundle(org.osgi.framework.Bundle) ExtensionRegistryRunnable(org.eclipse.ecf.core.util.ExtensionRegistryRunnable) Properties(java.util.Properties) ZooDiscoveryNamespace(org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryNamespace) ZooDiscoveryContainer(org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainer) ZooDiscoveryNamespace(org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryNamespace) Namespace(org.eclipse.ecf.core.identity.Namespace) ZooDiscoveryContainerInstantiator(org.eclipse.ecf.provider.zookeeper.core.ZooDiscoveryContainerInstantiator) ServiceReference(org.osgi.framework.ServiceReference) LogService(org.osgi.service.log.LogService) ServiceRegistration(org.osgi.framework.ServiceRegistration)

Aggregations

ContainerTypeDescription (org.eclipse.ecf.core.ContainerTypeDescription)54 IContainer (org.eclipse.ecf.core.IContainer)20 List (java.util.List)5 Namespace (org.eclipse.ecf.core.identity.Namespace)5 ExtensionRegistryRunnable (org.eclipse.ecf.core.util.ExtensionRegistryRunnable)5 ArrayList (java.util.ArrayList)3 Dictionary (java.util.Dictionary)3 Properties (java.util.Properties)3 IContainerManager (org.eclipse.ecf.core.IContainerManager)3 IRemoteServiceContainer (org.eclipse.ecf.remoteservice.IRemoteServiceContainer)3 URI (java.net.URI)2 URL (java.net.URL)2 Hashtable (java.util.Hashtable)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)2 ID (org.eclipse.ecf.core.identity.ID)2 IConnectHandlerPolicy (org.eclipse.ecf.core.security.IConnectHandlerPolicy)2 RestClientContainer (org.eclipse.ecf.remoteservice.rest.client.RestClientContainer)2 RpcClientContainer (org.eclipse.ecf.remoteservice.rpc.client.RpcClientContainer)2 Bundle (org.osgi.framework.Bundle)2 ServiceFactory (org.osgi.framework.ServiceFactory)2