Class Context
- All Implemented Interfaces:
Closeable,AutoCloseable
RepositorySystem, RepositorySystemSession and list of
RemoteRepository. Context is Closeable, ideally used in try-with-resource constructs.
The very first context instance application creates using Runtime.create(ContextOverrides) is called "root
context", and creation of it can be considered "heavy" operation (runtime dependent). Root context should be kept
open as long as application is expected to make use of Resolver.
Context instances may be customized with customize(ContextOverrides) method, in that case the returned
context is "derived" from this context. In those cases the context instances should be handled "as nested", so
closed in opposite order as they were obtained. Creating customized contexts can be considered "light" operation,
as they merely alter the RepositorySystemSession instance and repositories, while the
RepositorySystem is just inherited from this instance (is not reconstructed).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionContext(RuntimeSupport runtime, ContextOverrides contextOverrides, Path basedir, MavenUserHome mavenUserHome, MavenSystemHome mavenSystemHome, org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, HTTPProxy httpProxy, Lookup lookup, Runnable managedCloser) -
Method Summary
Modifier and TypeMethodDescriptionbasedir()The basedir ("cwd"), nevernull.voidclose()Closes the context.Returns the effectiveContextOverrides, nevernull.customize(ContextOverrides overrides) Returns a newContextinstance, that is customized using passed inContextOverrides, using this instance as "base".ExposesRuntimeinstance used to create this context instance.Returns HTTP Proxy that Resolver will use, ornull.lookup()ReturnsLookupinstance usable to look up resolver components, nevernull.Returns effectiveMavenSystemHome, may benull, if no Maven Home discovered.Returns effectiveMavenUserHome, nevernull.List<org.eclipse.aether.repository.RemoteRepository> Returns the list ofRemoteRepository, nevernull.org.eclipse.aether.RepositorySystemReturns theRepositorySystem, nevernull.org.eclipse.aether.RepositorySystemSessionReturns theRepositorySystemSession, nevernull.
-
Constructor Details
-
Context
public Context(RuntimeSupport runtime, ContextOverrides contextOverrides, Path basedir, MavenUserHome mavenUserHome, MavenSystemHome mavenSystemHome, org.eclipse.aether.RepositorySystem repositorySystem, org.eclipse.aether.RepositorySystemSession repositorySystemSession, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories, HTTPProxy httpProxy, Lookup lookup, Runnable managedCloser)
-
-
Method Details
-
contextOverrides
Returns the effectiveContextOverrides, nevernull. This instance MAY be different from the user supplied one toRuntime.create(ContextOverrides), as it will contain discovered configuration as well.- Since:
- 2.1.0
-
basedir
The basedir ("cwd"), nevernull.- Since:
- 2.3.0
-
mavenUserHome
Returns effectiveMavenUserHome, nevernull.- Since:
- 2.1.0
-
mavenSystemHome
Returns effectiveMavenSystemHome, may benull, if no Maven Home discovered.- Since:
- 2.1.0
-
repositorySystemSession
public org.eclipse.aether.RepositorySystemSession repositorySystemSession()Returns theRepositorySystemSession, nevernull. -
repositorySystem
public org.eclipse.aether.RepositorySystem repositorySystem()Returns theRepositorySystem, nevernull. -
remoteRepositories
Returns the list ofRemoteRepository, nevernull. -
httpProxy
Returns HTTP Proxy that Resolver will use, ornull. This configuration may come from usersettings.xml.- Since:
- 2.4.0
-
lookup
ReturnsLookupinstance usable to look up resolver components, nevernull.- Since:
- 2.4.10
-
customize
Returns a newContextinstance, that is customized using passed inContextOverrides, using this instance as "base". -
getRuntime
ExposesRuntimeinstance used to create this context instance. -
close
public void close()Closes the context. Once closed context instance should not be used anymore.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-