Search in sources :

Example 1 with RepositoryConnectorFactory

use of org.sonatype.aether.spi.connector.RepositoryConnectorFactory in project sonatype-aether by sonatype.

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "async-http");
    assertNotNull(factory);
    assertEquals(AsyncRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Example 2 with RepositoryConnectorFactory

use of org.sonatype.aether.spi.connector.RepositoryConnectorFactory in project sonatype-aether by sonatype.

the class DefaultRemoteRepositoryManager method getRepositoryConnector.

public RepositoryConnector getRepositoryConnector(RepositorySystemSession session, RemoteRepository repository) throws NoRepositoryConnectorException {
    if (repository == null) {
        throw new IllegalArgumentException("remote repository has not been specified");
    }
    List<RepositoryConnectorFactory> factories = new ArrayList<RepositoryConnectorFactory>(connectorFactories);
    Collections.sort(factories, COMPARATOR);
    for (RepositoryConnectorFactory factory : factories) {
        try {
            RepositoryConnector connector = factory.newInstance(session, repository);
            if (logger.isDebugEnabled()) {
                StringBuilder buffer = new StringBuilder(256);
                buffer.append("Using connector ").append(connector.getClass().getSimpleName());
                buffer.append(" with priority ").append(factory.getPriority());
                buffer.append(" for ").append(repository.getUrl());
                Authentication auth = repository.getAuthentication();
                if (auth != null) {
                    buffer.append(" as ").append(auth.getUsername());
                }
                Proxy proxy = repository.getProxy();
                if (proxy != null) {
                    buffer.append(" via ").append(proxy.getHost()).append(':').append(proxy.getPort());
                    auth = proxy.getAuthentication();
                    if (auth != null) {
                        buffer.append(" as ").append(auth.getUsername());
                    }
                }
                logger.debug(buffer.toString());
            }
            return connector;
        } catch (NoRepositoryConnectorException e) {
        // continue and try next factory
        }
    }
    StringBuilder buffer = new StringBuilder(256);
    buffer.append("No connector available to access repository ");
    buffer.append(repository.getId());
    buffer.append(" (").append(repository.getUrl());
    buffer.append(") of type ").append(repository.getContentType());
    buffer.append(" using the available factories ");
    for (ListIterator<RepositoryConnectorFactory> it = factories.listIterator(); it.hasNext(); ) {
        RepositoryConnectorFactory factory = it.next();
        buffer.append(factory.getClass().getSimpleName());
        if (it.hasNext()) {
            buffer.append(", ");
        }
    }
    throw new NoRepositoryConnectorException(repository, buffer.toString());
}
Also used : Proxy(org.sonatype.aether.repository.Proxy) Authentication(org.sonatype.aether.repository.Authentication) NoRepositoryConnectorException(org.sonatype.aether.transfer.NoRepositoryConnectorException) ArrayList(java.util.ArrayList) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory) RepositoryConnector(org.sonatype.aether.spi.connector.RepositoryConnector)

Example 3 with RepositoryConnectorFactory

use of org.sonatype.aether.spi.connector.RepositoryConnectorFactory in project sonatype-aether by sonatype.

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "file");
    assertNotNull(factory);
    assertEquals(FileRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Example 4 with RepositoryConnectorFactory

use of org.sonatype.aether.spi.connector.RepositoryConnectorFactory in project sonatype-aether by sonatype.

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new SysoutLogger(), Logger.class, null);
    getContainer().addComponent(new TestFileProcessor(), FileProcessor.class, null);
    RepositoryConnectorFactory factory = lookup(RepositoryConnectorFactory.class, "wagon");
    assertNotNull(factory);
    assertEquals(WagonRepositoryConnectorFactory.class, factory.getClass());
}
Also used : TestFileProcessor(org.sonatype.aether.test.impl.TestFileProcessor) SysoutLogger(org.sonatype.aether.test.impl.SysoutLogger) RepositoryConnectorFactory(org.sonatype.aether.spi.connector.RepositoryConnectorFactory)

Aggregations

RepositoryConnectorFactory (org.sonatype.aether.spi.connector.RepositoryConnectorFactory)4 SysoutLogger (org.sonatype.aether.test.impl.SysoutLogger)3 TestFileProcessor (org.sonatype.aether.test.impl.TestFileProcessor)3 ArrayList (java.util.ArrayList)1 Authentication (org.sonatype.aether.repository.Authentication)1 Proxy (org.sonatype.aether.repository.Proxy)1 RepositoryConnector (org.sonatype.aether.spi.connector.RepositoryConnector)1 NoRepositoryConnectorException (org.sonatype.aether.transfer.NoRepositoryConnectorException)1