org.sonatype.aether.util
Class DefaultRepositorySystemSession

java.lang.Object
  extended by org.sonatype.aether.util.DefaultRepositorySystemSession
All Implemented Interfaces:
RepositorySystemSession

public class DefaultRepositorySystemSession
extends Object
implements RepositorySystemSession

A simple repository system session. Note: This class is not thread-safe. It is assumed that the mutators get only called during an initialize phase and the session itself is not changed when being used by the repository system.

Author:
Benjamin Bentmann

Constructor Summary
DefaultRepositorySystemSession()
          Creates an uninitialized session.
DefaultRepositorySystemSession(RepositorySystemSession session)
          Creates a shallow copy of the specified session.
 
Method Summary
 ArtifactTypeRegistry getArtifactTypeRegistry()
           
 AuthenticationSelector getAuthenticationSelector()
           
 RepositoryCache getCache()
           
 String getChecksumPolicy()
           
 Map<String,Object> getConfigProperties()
           
 SessionData getData()
           
 DependencyGraphTransformer getDependencyGraphTransformer()
           
 DependencyManager getDependencyManager()
           
 DependencySelector getDependencySelector()
           
 DependencyTraverser getDependencyTraverser()
           
 LocalRepository getLocalRepository()
           
 LocalRepositoryManager getLocalRepositoryManager()
           
 MirrorSelector getMirrorSelector()
           
 ProxySelector getProxySelector()
           
 RepositoryListener getRepositoryListener()
           
 Map<String,String> getSystemProperties()
           
 TransferListener getTransferListener()
           
 String getUpdatePolicy()
           
 Map<String,String> getUserProperties()
           
 WorkspaceReader getWorkspaceReader()
           
 boolean isIgnoreInvalidArtifactDescriptor()
           
 boolean isIgnoreMissingArtifactDescriptor()
           
 boolean isNotFoundCachingEnabled()
           
 boolean isOffline()
           
 boolean isTransferErrorCachingEnabled()
           
 DefaultRepositorySystemSession setArtifactTypeRegistry(ArtifactTypeRegistry artifactTypeRegistry)
          Sets the registry of artifact types recognized by this session.
 DefaultRepositorySystemSession setAuthenticationSelector(AuthenticationSelector authenticationSelector)
          Sets the authentication selector to use for repositories discovered in artifact descriptors.
 DefaultRepositorySystemSession setCache(RepositoryCache cache)
          Sets the cache the repository system may use to save data for future reuse during the session.
 DefaultRepositorySystemSession setChecksumPolicy(String checksumPolicy)
          Sets the global checksum policy.
 DefaultRepositorySystemSession setConfigProperties(Map<String,Object> configProperties)
          Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling, connector-specific behavior, etc.)
 DefaultRepositorySystemSession setConfigProperty(String key, Object value)
          Sets the specified configuration property.
 DefaultRepositorySystemSession setConfigProps(Map<?,?> configProperties)
          Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling, connector-specific behavior, etc.)
 DefaultRepositorySystemSession setData(SessionData data)
          Sets the custom data associated with this session.
 DefaultRepositorySystemSession setDependencyGraphTransformer(DependencyGraphTransformer dependencyGraphTransformer)
          Sets the dependency graph transformer to use for building dependency graphs.
 DefaultRepositorySystemSession setDependencyManager(DependencyManager dependencyManager)
          Sets the dependency manager to use for building dependency graphs.
 DefaultRepositorySystemSession setDependencySelector(DependencySelector dependencySelector)
          Sets the dependency selector to use for building dependency graphs.
 DefaultRepositorySystemSession setDependencyTraverser(DependencyTraverser dependencyTraverser)
          Sets the dependency traverser to use for building dependency graphs.
 DefaultRepositorySystemSession setIgnoreInvalidArtifactDescriptor(boolean ignoreInvalidArtifactDescriptor)
          Controls whether invalid artifact descriptors are silently ignored.
 DefaultRepositorySystemSession setIgnoreMissingArtifactDescriptor(boolean ignoreMissingArtifactDescriptor)
          Controls whether missing artifact descriptors are silently ignored.
 DefaultRepositorySystemSession setLocalRepositoryManager(LocalRepositoryManager localRepositoryManager)
          Sets the local repository manager used during this session.
 DefaultRepositorySystemSession setMirrorSelector(MirrorSelector mirrorSelector)
          Sets the mirror selector to use for repositories discovered in artifact descriptors.
 DefaultRepositorySystemSession setNotFoundCachingEnabled(boolean notFoundCachingEnabled)
          Controls whether missing artifacts/metadata from resolution attempts should be cached in the local repository.
 DefaultRepositorySystemSession setOffline(boolean offline)
          Controls whether the repository system operates in offline mode and avoids/refuses any access to remote repositories.
 DefaultRepositorySystemSession setProxySelector(ProxySelector proxySelector)
          Sets the proxy selector to use for repositories discovered in artifact descriptors.
 DefaultRepositorySystemSession setRepositoryListener(RepositoryListener repositoryListener)
          Sets the listener being notified of actions in the repository system.
 DefaultRepositorySystemSession setSystemProperties(Map<String,String> systemProperties)
          Sets the system properties to use, e.g. for processing of artifact descriptors.
 DefaultRepositorySystemSession setSystemProperty(String key, String value)
          Sets the specified system property.
 DefaultRepositorySystemSession setSystemProps(Hashtable<?,?> systemProperties)
          Sets the system properties to use, e.g. for processing of artifact descriptors.
 DefaultRepositorySystemSession setTransferErrorCachingEnabled(boolean transferErrorCachingEnabled)
          Controls whether transfer errors (e.g. unreachable host, bad authentication) from resolution attempts should be cached in the local repository.
 DefaultRepositorySystemSession setTransferListener(TransferListener transferListener)
          Sets the listener being notified of uploads/downloads by the repository system.
 DefaultRepositorySystemSession setUpdatePolicy(String updatePolicy)
          Sets the global update policy.
 DefaultRepositorySystemSession setUserProperties(Map<String,String> userProperties)
          Sets the user properties to use, e.g. for processing of artifact descriptors.
 DefaultRepositorySystemSession setUserProperty(String key, String value)
          Sets the specified user property.
 DefaultRepositorySystemSession setUserProps(Map<?,?> userProperties)
          Sets the user properties to use, e.g. for processing of artifact descriptors.
 DefaultRepositorySystemSession setWorkspaceReader(WorkspaceReader workspaceReader)
          Sets the workspace reader used during this session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRepositorySystemSession

public DefaultRepositorySystemSession()
Creates an uninitialized session.


DefaultRepositorySystemSession

public DefaultRepositorySystemSession(RepositorySystemSession session)
Creates a shallow copy of the specified session.

Parameters:
session - The session to copy, must not be null.
Method Detail

isOffline

public boolean isOffline()
Specified by:
isOffline in interface RepositorySystemSession

setOffline

public DefaultRepositorySystemSession setOffline(boolean offline)
Controls whether the repository system operates in offline mode and avoids/refuses any access to remote repositories.

Parameters:
offline - true if the repository system is in offline mode, false otherwise.
Returns:
This session for chaining, never null.

isTransferErrorCachingEnabled

public boolean isTransferErrorCachingEnabled()
Specified by:
isTransferErrorCachingEnabled in interface RepositorySystemSession

setTransferErrorCachingEnabled

public DefaultRepositorySystemSession setTransferErrorCachingEnabled(boolean transferErrorCachingEnabled)
Controls whether transfer errors (e.g. unreachable host, bad authentication) from resolution attempts should be cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy for the affected resource has expired.

Parameters:
transferErrorCachingEnabled - true to cache transfer errors, false to always reattempt downloading.
Returns:
This session for chaining, never null.

isNotFoundCachingEnabled

public boolean isNotFoundCachingEnabled()
Specified by:
isNotFoundCachingEnabled in interface RepositorySystemSession

setNotFoundCachingEnabled

public DefaultRepositorySystemSession setNotFoundCachingEnabled(boolean notFoundCachingEnabled)
Controls whether missing artifacts/metadata from resolution attempts should be cached in the local repository. If caching is enabled, resolution will not be reattempted until the update policy for the affected resource has expired.

Parameters:
notFoundCachingEnabled - true if to cache missing resources, false to always reattempt downloading.
Returns:
This session for chaining, never null.

isIgnoreMissingArtifactDescriptor

public boolean isIgnoreMissingArtifactDescriptor()
Specified by:
isIgnoreMissingArtifactDescriptor in interface RepositorySystemSession

setIgnoreMissingArtifactDescriptor

public DefaultRepositorySystemSession setIgnoreMissingArtifactDescriptor(boolean ignoreMissingArtifactDescriptor)
Controls whether missing artifact descriptors are silently ignored. If enabled and no artifact descriptor is available, an empty stub descriptor is used instead.

Parameters:
ignoreMissingArtifactDescriptor - true if to ignore missing artifact descriptors, false to fail the operation with an exception.
Returns:
This session for chaining, never null.

isIgnoreInvalidArtifactDescriptor

public boolean isIgnoreInvalidArtifactDescriptor()
Specified by:
isIgnoreInvalidArtifactDescriptor in interface RepositorySystemSession

setIgnoreInvalidArtifactDescriptor

public DefaultRepositorySystemSession setIgnoreInvalidArtifactDescriptor(boolean ignoreInvalidArtifactDescriptor)
Controls whether invalid artifact descriptors are silently ignored. If enabled and an artifact descriptor is invalid, an empty stub descriptor is used instead.

Parameters:
ignoreInvalidArtifactDescriptor - true if to ignore invalid artifact descriptors, false to fail the operation with an exception.
Returns:
This session for chaining, never null.

getChecksumPolicy

public String getChecksumPolicy()
Specified by:
getChecksumPolicy in interface RepositorySystemSession

setChecksumPolicy

public DefaultRepositorySystemSession setChecksumPolicy(String checksumPolicy)
Sets the global checksum policy. If set, the global checksum policy overrides the checksum policies of the remote repositories being used for resolution.

Parameters:
checksumPolicy - The global checksum policy, may be null/empty to apply the per-repository policies.
Returns:
This session for chaining, never null.
See Also:
RepositoryPolicy.CHECKSUM_POLICY_FAIL, RepositoryPolicy.CHECKSUM_POLICY_IGNORE, RepositoryPolicy.CHECKSUM_POLICY_WARN

getUpdatePolicy

public String getUpdatePolicy()
Specified by:
getUpdatePolicy in interface RepositorySystemSession

setUpdatePolicy

public DefaultRepositorySystemSession setUpdatePolicy(String updatePolicy)
Sets the global update policy. If set, the global update policy overrides the update policies of the remote repositories being used for resolution.

Parameters:
updatePolicy - The global update policy, may be null/empty to apply the per-repository policies.
Returns:
This session for chaining, never null.
See Also:
RepositoryPolicy.UPDATE_POLICY_ALWAYS, RepositoryPolicy.UPDATE_POLICY_DAILY, RepositoryPolicy.UPDATE_POLICY_NEVER

getLocalRepository

public LocalRepository getLocalRepository()
Specified by:
getLocalRepository in interface RepositorySystemSession

getLocalRepositoryManager

public LocalRepositoryManager getLocalRepositoryManager()
Specified by:
getLocalRepositoryManager in interface RepositorySystemSession

setLocalRepositoryManager

public DefaultRepositorySystemSession setLocalRepositoryManager(LocalRepositoryManager localRepositoryManager)
Sets the local repository manager used during this session. Eventually, a valid session must have a local repository manager set.

Parameters:
localRepositoryManager - The local repository manager used during this session, may be null.
Returns:
This session for chaining, never null.

getWorkspaceReader

public WorkspaceReader getWorkspaceReader()
Specified by:
getWorkspaceReader in interface RepositorySystemSession

setWorkspaceReader

public DefaultRepositorySystemSession setWorkspaceReader(WorkspaceReader workspaceReader)
Sets the workspace reader used during this session. If set, the workspace reader will usually be consulted first to resolve artifacts.

Parameters:
workspaceReader - The workspace reader for this session, may be null if none.
Returns:
This session for chaining, never null.

getRepositoryListener

public RepositoryListener getRepositoryListener()
Specified by:
getRepositoryListener in interface RepositorySystemSession

setRepositoryListener

public DefaultRepositorySystemSession setRepositoryListener(RepositoryListener repositoryListener)
Sets the listener being notified of actions in the repository system.

Parameters:
repositoryListener - The repository listener, may be null if none.
Returns:
This session for chaining, never null.

getTransferListener

public TransferListener getTransferListener()
Specified by:
getTransferListener in interface RepositorySystemSession

setTransferListener

public DefaultRepositorySystemSession setTransferListener(TransferListener transferListener)
Sets the listener being notified of uploads/downloads by the repository system.

Parameters:
transferListener - The transfer listener, may be null if none.
Returns:
This session for chaining, never null.

getSystemProperties

public Map<String,String> getSystemProperties()
Specified by:
getSystemProperties in interface RepositorySystemSession

setSystemProperties

public DefaultRepositorySystemSession setSystemProperties(Map<String,String> systemProperties)
Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually collected from the runtime environment like System.getProperties() and environment variables.

Parameters:
systemProperties - The system properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setSystemProps

public DefaultRepositorySystemSession setSystemProps(Hashtable<?,?> systemProperties)
Sets the system properties to use, e.g. for processing of artifact descriptors. System properties are usually collected from the runtime environment like System.getProperties() and environment variables.

Parameters:
systemProperties - The system properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setSystemProperty

public DefaultRepositorySystemSession setSystemProperty(String key,
                                                        String value)
Sets the specified system property.

Parameters:
key - The property key, must not be null.
value - The property value, may be null to remove/unset the property.
Returns:
This session for chaining, never null.

getUserProperties

public Map<String,String> getUserProperties()
Specified by:
getUserProperties in interface RepositorySystemSession

setUserProperties

public DefaultRepositorySystemSession setUserProperties(Map<String,String> userProperties)
Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to system properties but are set on the discretion of the user and hence are considered of higher priority than system properties.

Parameters:
userProperties - The user properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setUserProps

public DefaultRepositorySystemSession setUserProps(Map<?,?> userProperties)
Sets the user properties to use, e.g. for processing of artifact descriptors. User properties are similar to system properties but are set on the discretion of the user and hence are considered of higher priority than system properties.

Parameters:
userProperties - The user properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setUserProperty

public DefaultRepositorySystemSession setUserProperty(String key,
                                                      String value)
Sets the specified user property.

Parameters:
key - The property key, must not be null.
value - The property value, may be null to remove/unset the property.
Returns:
This session for chaining, never null.

getConfigProperties

public Map<String,Object> getConfigProperties()
Specified by:
getConfigProperties in interface RepositorySystemSession

setConfigProperties

public DefaultRepositorySystemSession setConfigProperties(Map<String,Object> configProperties)
Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling, connector-specific behavior, etc.)

Parameters:
configProperties - The configuration properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setConfigProps

public DefaultRepositorySystemSession setConfigProps(Map<?,?> configProperties)
Sets the configuration properties used to tweak internal aspects of the repository system (e.g. thread pooling, connector-specific behavior, etc.)

Parameters:
configProperties - The configuration properties, may be null or empty if none.
Returns:
This session for chaining, never null.

setConfigProperty

public DefaultRepositorySystemSession setConfigProperty(String key,
                                                        Object value)
Sets the specified configuration property.

Parameters:
key - The property key, must not be null.
value - The property value, may be null to remove/unset the property.
Returns:
This session for chaining, never null.

getMirrorSelector

public MirrorSelector getMirrorSelector()
Specified by:
getMirrorSelector in interface RepositorySystemSession

setMirrorSelector

public DefaultRepositorySystemSession setMirrorSelector(MirrorSelector mirrorSelector)
Sets the mirror selector to use for repositories discovered in artifact descriptors. Note that this selector is not used for remote repositories which are passed as request parameters to the repository system, those repositories are supposed to denote the effective repositories.

Parameters:
mirrorSelector - The mirror selector to use, may be null.
Returns:
This session for chaining, never null.

getProxySelector

public ProxySelector getProxySelector()
Specified by:
getProxySelector in interface RepositorySystemSession

setProxySelector

public DefaultRepositorySystemSession setProxySelector(ProxySelector proxySelector)
Sets the proxy selector to use for repositories discovered in artifact descriptors. Note that this selector is not used for remote repositories which are passed as request parameters to the repository system, those repositories are supposed to have their proxy (if any) already set.

Parameters:
proxySelector - The proxy selector to use, may be null.
Returns:
This session for chaining, never null.
See Also:
RemoteRepository.getProxy()

getAuthenticationSelector

public AuthenticationSelector getAuthenticationSelector()
Specified by:
getAuthenticationSelector in interface RepositorySystemSession

setAuthenticationSelector

public DefaultRepositorySystemSession setAuthenticationSelector(AuthenticationSelector authenticationSelector)
Sets the authentication selector to use for repositories discovered in artifact descriptors. Note that this selector is not used for remote repositories which are passed as request parameters to the repository system, those repositories are supposed to have their authentication (if any) already set.

Parameters:
authenticationSelector - The authentication selector to use, may be null.
Returns:
This session for chaining, never null.
See Also:
RemoteRepository.getAuthentication()

getArtifactTypeRegistry

public ArtifactTypeRegistry getArtifactTypeRegistry()
Specified by:
getArtifactTypeRegistry in interface RepositorySystemSession

setArtifactTypeRegistry

public DefaultRepositorySystemSession setArtifactTypeRegistry(ArtifactTypeRegistry artifactTypeRegistry)
Sets the registry of artifact types recognized by this session.

Parameters:
artifactTypeRegistry - The artifact type registry, may be null.
Returns:
This session for chaining, never null.

getDependencyTraverser

public DependencyTraverser getDependencyTraverser()
Specified by:
getDependencyTraverser in interface RepositorySystemSession

setDependencyTraverser

public DefaultRepositorySystemSession setDependencyTraverser(DependencyTraverser dependencyTraverser)
Sets the dependency traverser to use for building dependency graphs.

Parameters:
dependencyTraverser - The dependency traverser to use for building dependency graphs, may be null.
Returns:
This session for chaining, never null.

getDependencyManager

public DependencyManager getDependencyManager()
Specified by:
getDependencyManager in interface RepositorySystemSession

setDependencyManager

public DefaultRepositorySystemSession setDependencyManager(DependencyManager dependencyManager)
Sets the dependency manager to use for building dependency graphs.

Parameters:
dependencyManager - The dependency manager to use for building dependency graphs, may be null.
Returns:
This session for chaining, never null.

getDependencySelector

public DependencySelector getDependencySelector()
Specified by:
getDependencySelector in interface RepositorySystemSession

setDependencySelector

public DefaultRepositorySystemSession setDependencySelector(DependencySelector dependencySelector)
Sets the dependency selector to use for building dependency graphs.

Parameters:
dependencySelector - The dependency selector to use for building dependency graphs, may be null.
Returns:
This session for chaining, never null.

getDependencyGraphTransformer

public DependencyGraphTransformer getDependencyGraphTransformer()
Specified by:
getDependencyGraphTransformer in interface RepositorySystemSession

setDependencyGraphTransformer

public DefaultRepositorySystemSession setDependencyGraphTransformer(DependencyGraphTransformer dependencyGraphTransformer)
Sets the dependency graph transformer to use for building dependency graphs.

Parameters:
dependencyGraphTransformer - The dependency graph transformer to use for building dependency graphs, may be null.
Returns:
This session for chaining, never null.

getData

public SessionData getData()
Specified by:
getData in interface RepositorySystemSession

setData

public DefaultRepositorySystemSession setData(SessionData data)
Sets the custom data associated with this session.

Parameters:
data - The session data, may be null.
Returns:
This session for chaining, never null.

getCache

public RepositoryCache getCache()
Specified by:
getCache in interface RepositorySystemSession

setCache

public DefaultRepositorySystemSession setCache(RepositoryCache cache)
Sets the cache the repository system may use to save data for future reuse during the session.

Parameters:
cache - The repository cache, may be null if none.
Returns:
This session for chaining, never null.


Copyright © 2010-2011 Sonatype, Inc.. All Rights Reserved.