@Component(role=MirrorSelector.class) public class DefaultMirrorSelector extends java.lang.Object implements MirrorSelector
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
EXTERNAL_HTTP_WILDCARD |
private static java.lang.String |
EXTERNAL_WILDCARD |
private static java.lang.String |
WILDCARD |
Constructor and Description |
---|
DefaultMirrorSelector() |
Modifier and Type | Method and Description |
---|---|
Mirror |
getMirror(ArtifactRepository repository,
java.util.List<Mirror> mirrors)
Determines the mirror for the specified repository.
|
(package private) static boolean |
isExternalHttpRepo(ArtifactRepository originalRepository)
Checks the URL to see if this repository refers to a non-localhost repository using HTTP.
|
(package private) static boolean |
isExternalRepo(ArtifactRepository originalRepository)
Checks the URL to see if this repository refers to an external repository
|
private static boolean |
isLocal(java.lang.String host) |
(package private) static boolean |
matchesLayout(ArtifactRepository repository,
Mirror mirror) |
(package private) static boolean |
matchesLayout(java.lang.String repoLayout,
java.lang.String mirrorLayout)
Checks whether the layouts configured for a mirror match with the layout of the repository.
|
(package private) static boolean |
matchPattern(ArtifactRepository originalRepository,
java.lang.String pattern)
This method checks if the pattern matches the originalRepository.
|
private static final java.lang.String WILDCARD
private static final java.lang.String EXTERNAL_WILDCARD
private static final java.lang.String EXTERNAL_HTTP_WILDCARD
public Mirror getMirror(ArtifactRepository repository, java.util.List<Mirror> mirrors)
MirrorSelector
getMirror
in interface MirrorSelector
repository
- The repository to determine the mirror for, must not be null
.mirrors
- The available mirrors, may be null
.null
if no mirror matched.static boolean matchPattern(ArtifactRepository originalRepository, java.lang.String pattern)
*
= everything,external:*
= everything not on the localhost and not file based,external:http:*
= any repository not on the localhost using HTTP,repo,repo1
= repo
or repo1
,*,!repo1
= everything except repo1
.originalRepository
- to compare for a match.pattern
- used for match. Currently only '*' is supported.static boolean isExternalRepo(ArtifactRepository originalRepository)
originalRepository
- private static boolean isLocal(java.lang.String host)
static boolean isExternalHttpRepo(ArtifactRepository originalRepository)
originalRepository
- static boolean matchesLayout(ArtifactRepository repository, Mirror mirror)
static boolean matchesLayout(java.lang.String repoLayout, java.lang.String mirrorLayout)
repoLayout
- The layout of the repository, may be null
.mirrorLayout
- The layouts supported by the mirror, may be null
.true
if the layouts associated with the mirror match the layout of the original repository,
false
otherwise.