/** * Constructs an interface to allow access to a remote repository. * * @param remote the remote to connect to * @param remoteHints hints for the remote repo, like read-only, etc. * @return an {@link Optional} of the interface to the remote repository, or * {@link Optional#absent()} if a connection to the remote could not be established. */ public static Optional<IRemoteRepo> newRemote(Remote remote, @Nullable Hints remoteHints) { if (remoteHints == null) { remoteHints = new Hints(); } Iterator<RemoteResolver> resolvers = ServiceLoader.load(RemoteResolver.class).iterator(); while (resolvers.hasNext()) { RemoteResolver resolver = resolvers.next(); Optional<IRemoteRepo> resolved = resolver.resolve(remote, remoteHints); if (resolved.isPresent()) { return resolved; } } return Optional.absent(); } }
/** * Constructs an interface to allow access to a remote repository. * * @param remote the remote to connect to * @param remoteHints hints for the remote repo, like read-only, etc. * @return an {@link Optional} of the interface to the remote repository, or * {@link Optional#absent()} if a connection to the remote could not be established. */ public static Optional<IRemoteRepo> newRemote(Remote remote, @Nullable Hints remoteHints) { if (remoteHints == null) { remoteHints = new Hints(); } Iterator<RemoteResolver> resolvers = ServiceLoader .load(RemoteResolver.class, RemoteResolver.class.getClassLoader()).iterator(); while (resolvers.hasNext()) { RemoteResolver resolver = resolvers.next(); Optional<IRemoteRepo> resolved = resolver.resolve(remote, remoteHints); if (resolved.isPresent()) { return resolved; } } return Optional.absent(); } }