Search in sources :

Example 11 with ITransportFactory

use of org.eclipse.epp.mpc.core.service.ITransportFactory in project epp.mpc by eclipse.

the class MappedTransportFactory method register.

public void register() throws IllegalStateException {
    ITransportFactory transportFactory = ServiceHelper.getTransportFactory();
    if (transportFactory != this) {
        unregister();
        ITransportFactory delegate = transportFactory;
        if (delegate instanceof MappedTransportFactory) {
            delegate = ((MappedTransportFactory) delegate).getDelegate();
        }
        this.delegate = delegate;
        Dictionary<String, Object> maxServiceRanking = new Hashtable<String, Object>(Collections.singletonMap(Constants.SERVICE_RANKING, Integer.MAX_VALUE));
        registration = MarketplaceClientCorePlugin.getBundle().getBundleContext().registerService(ITransportFactory.class, this, maxServiceRanking);
        transportFactory = ServiceHelper.getTransportFactory();
        if (transportFactory != this) {
            throw new IllegalStateException("Factory not selected after registration");
        }
    }
}
Also used : Hashtable(java.util.Hashtable) ITransportFactory(org.eclipse.epp.mpc.core.service.ITransportFactory)

Aggregations

ITransportFactory (org.eclipse.epp.mpc.core.service.ITransportFactory)11 BundleContext (org.osgi.framework.BundleContext)5 HttpClientTransportFactory (org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransportFactory)4 FallbackTransportFactory (org.eclipse.epp.internal.mpc.core.util.FallbackTransportFactory)4 ServiceReference (org.osgi.framework.ServiceReference)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Hashtable (java.util.Hashtable)2 LinkedHashSet (java.util.LinkedHashSet)2 IStatus (org.eclipse.core.runtime.IStatus)2 HttpClientTransport (org.eclipse.epp.internal.mpc.core.transport.httpclient.HttpClientTransport)2 TransportFactory (org.eclipse.epp.internal.mpc.core.util.TransportFactory)2 ITransport (org.eclipse.epp.mpc.core.service.ITransport)2 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1