Search in sources :

Example 1 with Transport

use of org.eclipse.equinox.internal.p2.repository.Transport in project epp.mpc by eclipse.

the class AbstractP2TransportFactory method invokeStream.

@Override
protected InputStream invokeStream(URI location, IProgressMonitor monitor) throws Exception {
    Transport repositoryTransport = getTransportService();
    Method streamMethod = repositoryTransport.getClass().getMethod(STREAM_METHOD, URI.class, IProgressMonitor.class);
    Object stream = streamMethod.invoke(repositoryTransport, location, monitor);
    return (InputStream) stream;
}
Also used : InputStream(java.io.InputStream) Method(java.lang.reflect.Method) Transport(org.eclipse.equinox.internal.p2.repository.Transport)

Example 2 with Transport

use of org.eclipse.equinox.internal.p2.repository.Transport in project epp.mpc by eclipse.

the class Eclipse36TransportFactory method getTransportService.

@Override
protected Transport getTransportService() throws Exception {
    try {
        Bundle bundle = Platform.getBundle(P2_REPOSITORY_BUNDLE);
        Class<?> clazz = bundle.loadClass(REPOSITORY_TRANSPORT_CLASS);
        Method method = clazz.getDeclaredMethod(GET_INSTANCE_METHOD);
        Object transportInstance = method.invoke(null);
        return (Transport) transportInstance;
    } catch (Exception e) {
        return null;
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Method(java.lang.reflect.Method) Transport(org.eclipse.equinox.internal.p2.repository.Transport)

Example 3 with Transport

use of org.eclipse.equinox.internal.p2.repository.Transport in project tycho by eclipse.

the class SiteDependenciesAction method perform.

@Override
public IStatus perform(IPublisherInfo publisherInfo, IPublisherResult results, IProgressMonitor monitor) {
    try {
        // don't need transport to read local site.xml
        Transport transport = null;
        updateSite = UpdateSite.load(location.toURI(), transport, monitor);
    } catch (ProvisionException e) {
        return new Status(IStatus.ERROR, Activator.ID, "Error generating site xml action.", e);
    }
    return super.perform(publisherInfo, results, monitor);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) Transport(org.eclipse.equinox.internal.p2.repository.Transport)

Example 4 with Transport

use of org.eclipse.equinox.internal.p2.repository.Transport in project epp.mpc by eclipse.

the class P2TransportFactory method getTransportService.

@Override
public Transport getTransportService() throws Exception {
    BundleContext bundleContext = Platform.getBundle(MarketplaceClientCore.BUNDLE_ID).getBundleContext();
    ServiceReference<?> serviceReference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME);
    if (serviceReference != null) {
        IProvisioningAgent agent = (IProvisioningAgent) bundleContext.getService(serviceReference);
        if (agent != null) {
            return (Transport) agent.getService(getTransportServiceName());
        }
    }
    return null;
}
Also used : IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) Transport(org.eclipse.equinox.internal.p2.repository.Transport) BundleContext(org.osgi.framework.BundleContext)

Example 5 with Transport

use of org.eclipse.equinox.internal.p2.repository.Transport in project tycho by eclipse.

the class RemoteAgent method createConfiguredProvisioningAgent.

private static IProvisioningAgent createConfiguredProvisioningAgent(MavenContext mavenContext, boolean disableP2Mirrors, MavenRepositorySettings mavenRepositorySettings) throws ProvisionException {
    // TODO set a temporary folder as persistence location
    AgentBuilder agent = new AgentBuilder(Activator.newProvisioningAgent());
    // suppress p2.index access
    final Transport transport;
    if (mavenContext.isOffline()) {
        transport = new OfflineTransport();
        agent.registerService(Transport.class, transport);
    } else {
        transport = agent.getService(Transport.class);
    }
    // cache indices of p2 repositories in the local Maven repository
    RemoteRepositoryCacheManager cacheMgr = new RemoteRepositoryCacheManager(transport, mavenContext);
    agent.registerService(CacheManager.class, cacheMgr);
    if (disableP2Mirrors) {
        addP2MirrorDisablingRepositoryManager(agent, mavenContext.getLogger());
    }
    if (mavenRepositorySettings != null) {
        addMavenAwareRepositoryManagers(agent, mavenRepositorySettings, mavenContext.getLogger());
    }
    makeCompositeRepositoryLoadingAtomicByDefault();
    return agent.getAgent();
}
Also used : Transport(org.eclipse.equinox.internal.p2.repository.Transport)

Aggregations

Transport (org.eclipse.equinox.internal.p2.repository.Transport)5 Method (java.lang.reflect.Method)2 InputStream (java.io.InputStream)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1