use of org.sonatype.aether.repository.ProxySelector in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManagerTest method testProxySelector.
@Test
public void testProxySelector() {
final RemoteRepository repo = newRepo("a", "http://", false, "", "");
final Proxy proxy = new Proxy("http", "host", 2011, null);
session.setProxySelector(new ProxySelector() {
public Proxy getProxy(RemoteRepository repository) {
return proxy;
}
});
session.setMirrorSelector(new MirrorSelector() {
public RemoteRepository getMirror(RemoteRepository repository) {
return null;
}
});
List<RemoteRepository> result = manager.aggregateRepositories(session, Collections.<RemoteRepository>emptyList(), Arrays.asList(repo), true);
assertEquals(1, result.size());
assertEquals("http", result.get(0).getProxy().getType());
assertEquals("host", result.get(0).getProxy().getHost());
assertEquals(2011, result.get(0).getProxy().getPort());
}
use of org.sonatype.aether.repository.ProxySelector in project sonatype-aether by sonatype.
the class DefaultRemoteRepositoryManager method aggregateRepositories.
public List<RemoteRepository> aggregateRepositories(RepositorySystemSession session, List<RemoteRepository> dominantRepositories, List<RemoteRepository> recessiveRepositories, boolean recessiveIsRaw) {
if (recessiveRepositories.isEmpty()) {
return dominantRepositories;
}
MirrorSelector mirrorSelector = session.getMirrorSelector();
AuthenticationSelector authSelector = session.getAuthenticationSelector();
ProxySelector proxySelector = session.getProxySelector();
List<RemoteRepository> result = new ArrayList<RemoteRepository>(dominantRepositories);
next: for (RemoteRepository recessiveRepository : recessiveRepositories) {
RemoteRepository repository = recessiveRepository;
if (recessiveIsRaw) {
RemoteRepository mirrorRepository = mirrorSelector.getMirror(recessiveRepository);
if (mirrorRepository == null) {
repository = recessiveRepository;
} else {
logger.debug("Using mirror " + mirrorRepository.getId() + " (" + mirrorRepository.getUrl() + ") for " + recessiveRepository.getId() + " (" + recessiveRepository.getUrl() + ").");
repository = mirrorRepository;
}
}
String key = getKey(repository);
for (ListIterator<RemoteRepository> it = result.listIterator(); it.hasNext(); ) {
RemoteRepository dominantRepository = it.next();
if (key.equals(getKey(dominantRepository))) {
if (!dominantRepository.getMirroredRepositories().isEmpty() && !repository.getMirroredRepositories().isEmpty()) {
RemoteRepository mergedRepository = mergeMirrors(session, dominantRepository, repository);
if (mergedRepository != dominantRepository) {
it.set(mergedRepository);
}
}
continue next;
}
}
if (recessiveIsRaw) {
Authentication auth = authSelector.getAuthentication(repository);
if (auth != null) {
repository.setAuthentication(auth);
}
Proxy proxy = proxySelector.getProxy(repository);
if (proxy != null) {
repository.setProxy(proxy);
}
}
result.add(repository);
}
return result;
}
Aggregations