Class MirroringArtifactProvider
- java.lang.Object
-
- org.eclipse.tycho.repository.local.MirroringArtifactProvider
-
- All Implemented Interfaces:
org.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>,IArtifactFileProvider,IArtifactProvider,IRawArtifactFileProvider,IRawArtifactProvider
- Direct Known Subclasses:
PackedFormatMirroringArtifactProvider
public class MirroringArtifactProvider extends java.lang.Object implements IRawArtifactFileProvider
IRawArtifactFileProviderwhich caches all accessed artifacts in the local Maven repository.Note that a MirroringArtifactProvider is not a transparent cache of the remote providers. The content provided by this instance differs from the remote providers' content in the following ways:
- This instance provides all content in the local Maven repository (previously cached or installed) in addition to the remote content. This allows lazy access to the remote repositories (bug 347477).
- This instance only provides the remote artifacts in certain formats, i.e. only the canonical format, or the canonical format and the packed format.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMirroringArtifactProvider.MirroringFailedException
-
Field Summary
Fields Modifier and Type Field Description protected LocalArtifactRepositorylocalArtifactRepositoryprotected MavenLoggerloggerprotected org.eclipse.core.runtime.IProgressMonitormonitorprotected IRawArtifactProviderremoteProvidersprotected MavenLoggersplittingLogger
-
Constructor Summary
Constructors Constructor Description MirroringArtifactProvider(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, MavenLogger logger)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static org.eclipse.core.runtime.IStatusartifactNotFoundStatus(org.eclipse.equinox.p2.metadata.IArtifactKey key)booleancontains(org.eclipse.equinox.p2.metadata.IArtifactKey key)Returnstrueif this is a provider for the given artifact.booleancontains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returnstrueif this a provider for an artifact in the given formatprivate voidcreateCanonicalArtifactFromLocalPackedArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)static MirroringArtifactProvidercreateInstance(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, boolean mirrorPacked, MavenLogger logger)Creates a newMirroringArtifactProviderinstance.protected voiddownloadArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)protected org.eclipse.core.runtime.IStatusdownloadCanonicalArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)protected org.eclipse.core.runtime.IStatusdownloadMostSpecificNeededFormatOfArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key)private voidensureArtifactIsPresentInCanonicalFormat(org.eclipse.equinox.p2.metadata.IArtifactKey key)(package private) static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptorfindCanonicalDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)(package private) static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptorfindPackedDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)org.eclipse.core.runtime.IStatusgetArtifact(IArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor)Writes the requested artifact to the givenIArtifactSink.org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[]getArtifactDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key)Return the raw artifact formats in which the given artifact can be provided.java.io.FilegetArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key)Returns the file system location of the given artifact.java.io.FilegetArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor)Returns the file system location of the given artifact in the given format.org.eclipse.core.runtime.IStatusgetRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor)Writes the requested artifact in the specified raw format to the givenIRawArtifactSink.private booleanmakeLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key)Downloads the artifact from remote if it isn't available locally yet.protected booleanmakeOneFormatLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key)(package private) org.eclipse.core.runtime.IProgressMonitormonitorForDownload()Returns anIProgressMonitorwhich translates p2's status updates into a reasonable log output.private static org.eclipse.core.runtime.IProgressMonitornonNull(org.eclipse.core.runtime.IProgressMonitor monitor)org.eclipse.equinox.p2.query.IQueryResult<org.eclipse.equinox.p2.metadata.IArtifactKey>query(org.eclipse.equinox.p2.query.IQuery<org.eclipse.equinox.p2.metadata.IArtifactKey> query, org.eclipse.core.runtime.IProgressMonitor monitor)
-
-
-
Field Detail
-
logger
protected final MavenLogger logger
-
splittingLogger
protected final MavenLogger splittingLogger
-
remoteProviders
protected final IRawArtifactProvider remoteProviders
-
localArtifactRepository
protected final LocalArtifactRepository localArtifactRepository
-
monitor
protected final org.eclipse.core.runtime.IProgressMonitor monitor
-
-
Constructor Detail
-
MirroringArtifactProvider
MirroringArtifactProvider(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, MavenLogger logger)
-
-
Method Detail
-
createInstance
public static MirroringArtifactProvider createInstance(LocalArtifactRepository localArtifactRepository, IRawArtifactProvider remoteProviders, boolean mirrorPacked, MavenLogger logger)
Creates a newMirroringArtifactProviderinstance.- Parameters:
localArtifactRepository- The local Maven repositoryremoteProviders- The provider that will be queried by this instance when it is asked for an artifact which is not (yet) available in the local Maven repository. Typically this provider is backed by remote p2 repositories.mirrorPacked- Iftrue, the returned instance will also mirror the packed format of all artifacts it is asked for.logger- a logger for progress output
-
contains
public final boolean contains(org.eclipse.equinox.p2.metadata.IArtifactKey key)
Description copied from interface:IArtifactProviderReturnstrueif this is a provider for the given artifact.- Specified by:
containsin interfaceIArtifactProvider- Parameters:
key- An artifact key- Returns:
trueif this instance can provide the artifact for the given key
-
query
public final org.eclipse.equinox.p2.query.IQueryResult<org.eclipse.equinox.p2.metadata.IArtifactKey> query(org.eclipse.equinox.p2.query.IQuery<org.eclipse.equinox.p2.metadata.IArtifactKey> query, org.eclipse.core.runtime.IProgressMonitor monitor)- Specified by:
queryin interfaceorg.eclipse.equinox.p2.query.IQueryable<org.eclipse.equinox.p2.metadata.IArtifactKey>
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedExceptionDescription copied from interface:IArtifactFileProviderReturns the file system location of the given artifact.- Specified by:
getArtifactFilein interfaceIArtifactFileProvider- Parameters:
key- An artifact key- Returns:
- The location of the specified artifact, or
nullthe given artifact does not exist. - Throws:
MirroringArtifactProvider.MirroringFailedException
-
getArtifactFile
public final java.io.File getArtifactFile(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws MirroringArtifactProvider.MirroringFailedExceptionDescription copied from interface:IRawArtifactFileProviderReturns the file system location of the given artifact in the given format.- Specified by:
getArtifactFilein interfaceIRawArtifactFileProvider- Parameters:
descriptor- The key and format of an artifact- Returns:
- The location of the specified raw artifact, or
nullthe that artifact does not exist in the given format. - Throws:
MirroringArtifactProvider.MirroringFailedException
-
getArtifact
public final org.eclipse.core.runtime.IStatus getArtifact(IArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException, MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IArtifactProviderWrites the requested artifact to the givenIArtifactSink.The implementation is free to pick the most suitable internal storage format to serve the request, e.g. it may extract the artifact from a pack200-compressed format. If an error is detected while streaming the artifact (e.g. an MD5 checksum error), the implementation may re-attempt the read from all other available sources. In case there were multiple read attempts, a multi-status with the results of all attempts is returned.
- Specified by:
getArtifactin interfaceIArtifactProvider- Parameters:
sink- A sink for a specific artifact. When this method returns, the sink will either be closed (withIArtifactSink.commitWrite()orIArtifactSink.abortWrite(), depending on the status), or not have received any content.monitor- A progress monitor, ornull- Returns:
- A non-fatal status (warning or better) if the read operation was successful.
- Throws:
ArtifactSinkException- if that exception is thrown by the givenIArtifactSinkMirroringArtifactProvider.MirroringFailedException- See Also:
IArtifactSink.getArtifactToBeWritten()
-
getRawArtifact
public final org.eclipse.core.runtime.IStatus getRawArtifact(IRawArtifactSink sink, org.eclipse.core.runtime.IProgressMonitor monitor) throws ArtifactSinkException, MirroringArtifactProvider.MirroringFailedException
Description copied from interface:IRawArtifactProviderWrites the requested artifact in the specified raw format to the givenIRawArtifactSink.If an error is detected while streaming the artifact (e.g. an MD5 checksum error) and there are other sources available (e.g. in a composite provider), the implementation may re-attempt the read from these other sources. In case there were multiple read attempts, a multi-status with the results of all attempts is returned.
- Specified by:
getRawArtifactin interfaceIRawArtifactProvider- Parameters:
sink- A sink for a specific artifact in a specific format. When this method returns, the sink will either be closed (withIArtifactSink.commitWrite()orIArtifactSink.abortWrite(), depending on the status), or not have received any content.monitor- A progress monitor, ornull- Returns:
- A non-fatal status (warning or better) if the read operation was successful.
- Throws:
ArtifactSinkException- if that exception is thrown by the givenIArtifactSinkMirroringArtifactProvider.MirroringFailedException- See Also:
IArtifactSink.getArtifactToBeWritten(),IRawArtifactSink.getArtifactFormatToBeWritten()
-
getArtifactDescriptors
public final org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] getArtifactDescriptors(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedExceptionDescription copied from interface:IRawArtifactProviderReturn the raw artifact formats in which the given artifact can be provided.- Specified by:
getArtifactDescriptorsin interfaceIRawArtifactProvider- Parameters:
key- An artifact key- Returns:
- The descriptors associated with the given key
- Throws:
MirroringArtifactProvider.MirroringFailedException
-
contains
public final boolean contains(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor descriptor) throws MirroringArtifactProvider.MirroringFailedExceptionDescription copied from interface:IRawArtifactProviderReturnstrueif this a provider for an artifact in the given format- Specified by:
containsin interfaceIRawArtifactProvider- Parameters:
descriptor- An artifact descriptor- Returns:
trueif this instance can provide the artifact as raw artifact in the described format- Throws:
MirroringArtifactProvider.MirroringFailedException
-
makeLocallyAvailable
private boolean makeLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedExceptionDownloads the artifact from remote if it isn't available locally yet.- Returns:
falseif the artifact is neither already cached locally nor available remotely.- Throws:
MirroringArtifactProvider.MirroringFailedException- if a fatal error occurred while downloading the artifact.
-
makeOneFormatLocallyAvailable
protected boolean makeOneFormatLocallyAvailable(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException, org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
MirroringArtifactProvider.MirroringFailedExceptionorg.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
downloadArtifact
protected final void downloadArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws MirroringArtifactProvider.MirroringFailedException, org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
MirroringArtifactProvider.MirroringFailedExceptionorg.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
downloadMostSpecificNeededFormatOfArtifact
protected org.eclipse.core.runtime.IStatus downloadMostSpecificNeededFormatOfArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
org.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
downloadCanonicalArtifact
protected final org.eclipse.core.runtime.IStatus downloadCanonicalArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
org.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
ensureArtifactIsPresentInCanonicalFormat
private void ensureArtifactIsPresentInCanonicalFormat(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
org.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
createCanonicalArtifactFromLocalPackedArtifact
private void createCanonicalArtifactFromLocalPackedArtifact(org.eclipse.equinox.p2.metadata.IArtifactKey key) throws org.eclipse.equinox.p2.core.ProvisionException, ArtifactSinkException- Throws:
org.eclipse.equinox.p2.core.ProvisionExceptionArtifactSinkException
-
findPackedDescriptor
static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor findPackedDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
-
findCanonicalDescriptor
static org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor findCanonicalDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor[] descriptors)
-
artifactNotFoundStatus
private static org.eclipse.core.runtime.IStatus artifactNotFoundStatus(org.eclipse.equinox.p2.metadata.IArtifactKey key)
-
monitorForDownload
final org.eclipse.core.runtime.IProgressMonitor monitorForDownload()
Returns anIProgressMonitorwhich translates p2's status updates into a reasonable log output.
-
nonNull
private static org.eclipse.core.runtime.IProgressMonitor nonNull(org.eclipse.core.runtime.IProgressMonitor monitor)
-
-