@Named public class DefaultOfflineController extends java.lang.Object implements OfflineController, Service
Modifier and Type | Field and Description |
---|---|
(package private) static java.lang.String |
CONFIG_PROP_OFFLINE_HOSTS |
(package private) static java.lang.String |
CONFIG_PROP_OFFLINE_PROTOCOLS |
private Logger |
logger |
private static java.util.regex.Pattern |
SEP |
Constructor and Description |
---|
DefaultOfflineController() |
DefaultOfflineController(LoggerFactory loggerFactory) |
Modifier and Type | Method and Description |
---|---|
void |
checkOffline(RepositorySystemSession session,
RemoteRepository repository)
Determines whether the specified repository is accessible if the system was in offline mode.
|
private java.lang.String[] |
getConfig(RepositorySystemSession session,
java.lang.String key) |
void |
initService(ServiceLocator locator)
Provides the opportunity to initialize this service and to acquire other services for its operation from the
locator.
|
private boolean |
isOfflineHost(RepositorySystemSession session,
RemoteRepository repository) |
private boolean |
isOfflineProtocol(RepositorySystemSession session,
RemoteRepository repository) |
DefaultOfflineController |
setLoggerFactory(LoggerFactory loggerFactory) |
static final java.lang.String CONFIG_PROP_OFFLINE_PROTOCOLS
static final java.lang.String CONFIG_PROP_OFFLINE_HOSTS
private static final java.util.regex.Pattern SEP
private Logger logger
public DefaultOfflineController()
@Inject DefaultOfflineController(LoggerFactory loggerFactory)
public void initService(ServiceLocator locator)
Service
initService
in interface Service
locator
- The service locator, must not be null
.public DefaultOfflineController setLoggerFactory(LoggerFactory loggerFactory)
public void checkOffline(RepositorySystemSession session, RemoteRepository repository) throws RepositoryOfflineException
OfflineController
RepositoryOfflineException
to block all remote repository
access when in offline mode. More sophisticated implementations might inspect
configuration properties
of the session to check for some
kind of whitelist that allows certain remote repositories even when offline. At any rate, the session's current
offline state
is irrelevant to the outcome of the check.checkOffline
in interface OfflineController
session
- The repository session during which the check is made, must not be null
.repository
- The remote repository to check for offline access, must not be null
.RepositoryOfflineException
- If the repository is not accessible in offline mode. If the method returns
normally, the repository is considered accessible even in offline mode.RepositorySystemSession.isOffline()
private boolean isOfflineProtocol(RepositorySystemSession session, RemoteRepository repository)
private boolean isOfflineHost(RepositorySystemSession session, RemoteRepository repository)
private java.lang.String[] getConfig(RepositorySystemSession session, java.lang.String key)