Class StreamArtifactSink
- java.lang.Object
-
- org.eclipse.tycho.repository.p2base.artifact.provider.streaming.StreamArtifactSink
-
- All Implemented Interfaces:
IArtifactSink
- Direct Known Subclasses:
StreamRawArtifactSink
class StreamArtifactSink extends java.lang.Object implements IArtifactSink
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.OutputStream
destination
private org.eclipse.equinox.p2.metadata.IArtifactKey
requestedKey
private boolean
writeStarted
-
Constructor Summary
Constructors Constructor Description StreamArtifactSink(org.eclipse.equinox.p2.metadata.IArtifactKey requestedKey, java.io.OutputStream destination)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abortWrite()
Method for aborting the write operation.java.io.OutputStream
beginWrite()
Method for starting the write operation.boolean
canBeginWrite()
Check ifIArtifactSink.beginWrite()
can be called on this instance.void
commitWrite()
Method to committing the write operation.org.eclipse.equinox.p2.metadata.IArtifactKey
getArtifactToBeWritten()
Returns the key of the artifact expected by this instance.
-
-
-
Method Detail
-
getArtifactToBeWritten
public org.eclipse.equinox.p2.metadata.IArtifactKey getArtifactToBeWritten()
Description copied from interface:IArtifactSink
Returns the key of the artifact expected by this instance.- Specified by:
getArtifactToBeWritten
in interfaceIArtifactSink
-
canBeginWrite
public boolean canBeginWrite()
Description copied from interface:IArtifactSink
Check ifIArtifactSink.beginWrite()
can be called on this instance. This method will typically returnfalse
ifIArtifactSink.commitWrite()
has already been called on this instance, or ifIArtifactSink.beginWrite()
has been called before and the instance doesn't support re-starting the write operation.- Specified by:
canBeginWrite
in interfaceIArtifactSink
- Returns:
true
ifIArtifactSink.beginWrite()
can be called on this instance.
-
beginWrite
public java.io.OutputStream beginWrite() throws ArtifactSinkException
Description copied from interface:IArtifactSink
Method for starting the write operation. If this method has been called before, any content written so far will be discarded.- Specified by:
beginWrite
in interfaceIArtifactSink
- Returns:
- the
OutputStream
to write the artifact content to. The ownership of the stream is not transferred to the caller, i.e.OutputStream.close()
must not be called on the returned instance. Instead, callIArtifactSink.commitWrite()
orIArtifactSink.abortWrite()
to free any allocated resources. - Throws:
ArtifactSinkException
- if an error occurs while starting the write operation.
-
commitWrite
public void commitWrite() throws ArtifactSinkException
Description copied from interface:IArtifactSink
Method to committing the write operation. Will be called after the entire artifact content has been successfully streamed to theOutputStream
returned byIArtifactSink.beginWrite()
.- Specified by:
commitWrite
in interfaceIArtifactSink
- Throws:
ArtifactSinkException
- if an error occurs while committing the write operation.
-
abortWrite
public void abortWrite() throws ArtifactSinkException
Description copied from interface:IArtifactSink
Method for aborting the write operation. Should be called if an error is detected while streaming the artifact content.- Specified by:
abortWrite
in interfaceIArtifactSink
- Throws:
ArtifactSinkException
- if an error occurs while aborting the write operation.
-
-