Search in sources :

Example 1 with LocalRepositoryManagerFactory

use of org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory in project sonatype-aether by sonatype.

the class DefaultLocalRepositoryProvider method newLocalRepositoryManager.

public LocalRepositoryManager newLocalRepositoryManager(LocalRepository localRepository) throws NoLocalRepositoryManagerException {
    List<LocalRepositoryManagerFactory> factories = new ArrayList<LocalRepositoryManagerFactory>(managerFactories);
    Collections.sort(factories, COMPARATOR);
    for (LocalRepositoryManagerFactory factory : factories) {
        try {
            LocalRepositoryManager manager = factory.newInstance(localRepository);
            if (logger.isDebugEnabled()) {
                StringBuilder buffer = new StringBuilder(256);
                buffer.append("Using manager ").append(manager.getClass().getSimpleName());
                buffer.append(" with priority ").append(factory.getPriority());
                buffer.append(" for ").append(localRepository.getBasedir());
                logger.debug(buffer.toString());
            }
            return manager;
        } catch (NoLocalRepositoryManagerException e) {
        // continue and try next factory
        }
    }
    StringBuilder buffer = new StringBuilder(256);
    buffer.append("No manager available for local repository ");
    buffer.append(localRepository.getBasedir());
    buffer.append(" of type ").append(localRepository.getContentType());
    buffer.append(" using the available factories ");
    for (ListIterator<LocalRepositoryManagerFactory> it = factories.listIterator(); it.hasNext(); ) {
        LocalRepositoryManagerFactory factory = it.next();
        buffer.append(factory.getClass().getSimpleName());
        if (it.hasNext()) {
            buffer.append(", ");
        }
    }
    throw new NoLocalRepositoryManagerException(localRepository, buffer.toString());
}
Also used : LocalRepositoryManagerFactory(org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory) LocalRepositoryManager(org.sonatype.aether.repository.LocalRepositoryManager) ArrayList(java.util.ArrayList) NoLocalRepositoryManagerException(org.sonatype.aether.repository.NoLocalRepositoryManagerException)

Example 2 with LocalRepositoryManagerFactory

use of org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory in project sonatype-aether by sonatype.

the class PlexusSupportTest method testExistenceOfPlexusComponentMetadata.

public void testExistenceOfPlexusComponentMetadata() throws Exception {
    getContainer().addComponent(new StubVersionRangeResolver(), VersionRangeResolver.class, null);
    getContainer().addComponent(new StubVersionResolver(), VersionResolver.class, null);
    getContainer().addComponent(new StubArtifactDescriptorReader(), ArtifactDescriptorReader.class, null);
    RepositorySystem repoSystem = lookup(RepositorySystem.class);
    assertNotNull(repoSystem);
    assertSame(repoSystem, lookup(RepositorySystem.class));
    List<LocalRepositoryManagerFactory> lrmfs = getContainer().lookupList(LocalRepositoryManagerFactory.class);
    assertNotNull(lrmfs);
    assertEquals(2, lrmfs.size());
}
Also used : RepositorySystem(org.sonatype.aether.RepositorySystem) LocalRepositoryManagerFactory(org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory)

Aggregations

LocalRepositoryManagerFactory (org.sonatype.aether.spi.localrepo.LocalRepositoryManagerFactory)2 ArrayList (java.util.ArrayList)1 RepositorySystem (org.sonatype.aether.RepositorySystem)1 LocalRepositoryManager (org.sonatype.aether.repository.LocalRepositoryManager)1 NoLocalRepositoryManagerException (org.sonatype.aether.repository.NoLocalRepositoryManagerException)1