public final class DefaultMirrorSelector extends java.lang.Object implements MirrorSelector
Modifier and Type | Class and Description |
---|---|
(package private) static class |
DefaultMirrorSelector.MirrorDef |
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
EXTERNAL_HTTP_WILDCARD |
private static java.lang.String |
EXTERNAL_WILDCARD |
private java.util.List<DefaultMirrorSelector.MirrorDef> |
mirrors |
private static java.lang.String |
WILDCARD |
Constructor and Description |
---|
DefaultMirrorSelector() |
Modifier and Type | Method and Description |
---|---|
DefaultMirrorSelector |
add(java.lang.String id,
java.lang.String url,
java.lang.String type,
boolean repositoryManager,
boolean blocked,
java.lang.String mirrorOfIds,
java.lang.String mirrorOfTypes)
Adds the specified mirror to this selector.
|
DefaultMirrorSelector |
add(java.lang.String id,
java.lang.String url,
java.lang.String type,
boolean repositoryManager,
java.lang.String mirrorOfIds,
java.lang.String mirrorOfTypes)
Deprecated.
|
private DefaultMirrorSelector.MirrorDef |
findMirror(RemoteRepository repository) |
RemoteRepository |
getMirror(RemoteRepository repository)
Selects a mirror for the specified repository.
|
(package private) static boolean |
isExternalHttpRepo(RemoteRepository repository)
Checks the URL to see if this repository refers to a non-localhost repository using HTTP.
|
(package private) static boolean |
isExternalRepo(RemoteRepository repository)
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 |
matchesType(java.lang.String repoType,
java.lang.String mirrorType)
Checks whether the types configured for a mirror match with the type of the repository.
|
(package private) static boolean |
matchPattern(RemoteRepository repository,
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
private final java.util.List<DefaultMirrorSelector.MirrorDef> mirrors
@Deprecated public DefaultMirrorSelector add(java.lang.String id, java.lang.String url, java.lang.String type, boolean repositoryManager, java.lang.String mirrorOfIds, java.lang.String mirrorOfTypes)
public DefaultMirrorSelector add(java.lang.String id, java.lang.String url, java.lang.String type, boolean repositoryManager, boolean blocked, java.lang.String mirrorOfIds, java.lang.String mirrorOfTypes)
id
- The identifier of the mirror, must not be null
.url
- The URL of the mirror, must not be null
.type
- The content type of the mirror, must not be null
.repositoryManager
- A flag whether the mirror is a repository manager or a simple server.blocked
- A flag whether the mirror is blocked from performing any download requests.mirrorOfIds
- The identifier(s) of remote repositories to mirror, must not be null
. Multiple
identifiers can be separated by comma and additionally the wildcards "*", "external:http:*" and
"external:*" can be used to match all (external) repositories, prefixing a repo id with an
exclamation mark allows to express an exclusion. For example "external:*,!central".mirrorOfTypes
- The content type(s) of remote repositories to mirror, may be null
or empty to match
any content type. Similar to the repo id specification, multiple types can be comma-separated, the
wildcard "*" and the "!" negation syntax are supported. For example "*,!p2".null
.public RemoteRepository getMirror(RemoteRepository repository)
MirrorSelector
getMirror
in interface MirrorSelector
repository
- The repository to select a mirror for, must not be null
.null
if none.RemoteRepository.getMirroredRepositories()
private DefaultMirrorSelector.MirrorDef findMirror(RemoteRepository repository)
static boolean matchPattern(RemoteRepository repository, 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
.repository
- to compare for a match.pattern
- used for match.static boolean isExternalRepo(RemoteRepository repository)
repository
- The repository to check, must not be null
.true
if external, false
otherwise.private static boolean isLocal(java.lang.String host)
static boolean isExternalHttpRepo(RemoteRepository repository)
repository
- The repository to check, must not be null
.true
if external, false
otherwise.static boolean matchesType(java.lang.String repoType, java.lang.String mirrorType)
repoType
- The type of the repository, may be null
.mirrorType
- The types supported by the mirror, may be null
.true
if the types associated with the mirror match the type of the original repository,
false
otherwise.