Class DefaultMirrorSelector
- java.lang.Object
-
- org.eclipse.aether.util.repository.DefaultMirrorSelector
-
- All Implemented Interfaces:
MirrorSelector
public final class DefaultMirrorSelector extends java.lang.Object implements MirrorSelector
A simple mirror selector that selects mirrors based on repository identifiers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DefaultMirrorSelector.MirrorDef
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
EXTERNAL_WILDCARD
private java.util.List<DefaultMirrorSelector.MirrorDef>
mirrors
private static java.lang.String
WILDCARD
-
Constructor Summary
Constructors Constructor Description DefaultMirrorSelector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DefaultMirrorSelector
add(java.lang.String id, java.lang.String url, java.lang.String type, boolean repositoryManager, java.lang.String mirrorOfIds, java.lang.String mirrorOfTypes)
Adds the specified mirror to this selector.private DefaultMirrorSelector.MirrorDef
findMirror(RemoteRepository repository)
RemoteRepository
getMirror(RemoteRepository repository)
Selects a mirror for the specified repository.(package private) static boolean
isExternalRepo(RemoteRepository repository)
Checks the URL to see if this repository refers to an external repository.(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.
-
-
-
Field Detail
-
WILDCARD
private static final java.lang.String WILDCARD
- See Also:
- Constant Field Values
-
EXTERNAL_WILDCARD
private static final java.lang.String EXTERNAL_WILDCARD
- See Also:
- Constant Field Values
-
mirrors
private final java.util.List<DefaultMirrorSelector.MirrorDef> mirrors
-
-
Method Detail
-
add
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)
Adds the specified mirror to this selector.- Parameters:
id
- The identifier of the mirror, must not benull
.url
- The URL of the mirror, must not benull
.type
- The content type of the mirror, must not benull
.repositoryManager
- A flag whether the mirror is a repository manager or a simple server.mirrorOfIds
- The identifier(s) of remote repositories to mirror, must not benull
. Multiple identifiers can be separated by comma and additionally the wildcards "*" 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 benull
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".- Returns:
- This selector for chaining, never
null
.
-
getMirror
public RemoteRepository getMirror(RemoteRepository repository)
Description copied from interface:MirrorSelector
Selects a mirror for the specified repository.- Specified by:
getMirror
in interfaceMirrorSelector
- Parameters:
repository
- The repository to select a mirror for, must not benull
.- Returns:
- The selected mirror or
null
if none. - See Also:
RemoteRepository.getMirroredRepositories()
-
findMirror
private DefaultMirrorSelector.MirrorDef findMirror(RemoteRepository repository)
-
matchPattern
static boolean matchPattern(RemoteRepository repository, java.lang.String pattern)
This method checks if the pattern matches the originalRepository. Valid patterns: * = everything external:* = everything not on the localhost and not file based. repo,repo1 = repo or repo1 *,!repo1 = everything except repo1- Parameters:
repository
- to compare for a match.pattern
- used for match. Currently only '*' is supported.- Returns:
- true if the repository is a match to this pattern.
-
isExternalRepo
static boolean isExternalRepo(RemoteRepository repository)
Checks the URL to see if this repository refers to an external repository.- Parameters:
repository
- The repository to check, must not benull
.- Returns:
true
if external,false
otherwise.
-
matchesType
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.- Parameters:
repoType
- The type of the repository, may benull
.mirrorType
- The types supported by the mirror, may benull
.- Returns:
true
if the types associated with the mirror match the type of the original repository,false
otherwise.
-
-