Class AbstractTransporter
java.lang.Object
org.eclipse.aether.spi.connector.transport.AbstractTransporter
- All Implemented Interfaces:
Closeable,AutoCloseable,Transporter
A skeleton implementation for custom transporters.
-
Field Summary
Fields inherited from interface org.eclipse.aether.spi.connector.transport.Transporter
ERROR_NOT_FOUND, ERROR_OTHER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this transporter and frees any network resources associated with it.voidDownloads a resource from the repository.protected abstract voidImplementsclose(), gets only called if the transporter has not already been closed.protected abstract voidImplementsget(GetTask), gets only called if the transporter has not been closed.protected abstract voidImplementspeek(PeekTask), gets only called if the transporter has not been closed.protected abstract voidImplementsput(PutTask), gets only called if the transporter has not been closed.voidChecks the existence of a resource in the repository.voidUploads a resource to the repository.protected voidutilGet(GetTask task, InputStream is, boolean close, long length, boolean resume) Performs stream-based I/O for the specified download task and notifies the configured transport listener.protected voidutilPut(PutTask task, OutputStream os, boolean close) Performs stream-based I/O for the specified upload task and notifies the configured transport listener.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.aether.spi.connector.transport.Transporter
classify
-
Constructor Details
-
AbstractTransporter
protected AbstractTransporter()Enables subclassing.
-
-
Method Details
-
peek
Description copied from interface:TransporterChecks the existence of a resource in the repository. If the remote repository can be contacted successfully but indicates the resource specified in the request does not exist, an exception is thrown such that invokingTransporter.classify(Throwable)with that exception yieldsTransporter.ERROR_NOT_FOUND.- Specified by:
peekin interfaceTransporter- Parameters:
task- The existence check to perform, must not benull.- Throws:
Exception- If the existence of the specified resource could not be confirmed.
-
implPeek
Implementspeek(PeekTask), gets only called if the transporter has not been closed.- Parameters:
task- The existence check to perform, must not benull.- Throws:
Exception- If the existence of the specified resource could not be confirmed.
-
get
Description copied from interface:TransporterDownloads a resource from the repository. If the resource is downloaded to a file as given byGetTask.getDataFile()and the operation fails midway, the transporter should not delete the partial file but leave its management to the caller.- Specified by:
getin interfaceTransporter- Parameters:
task- The download to perform, must not benull.- Throws:
Exception- If the transfer failed.
-
implGet
Implementsget(GetTask), gets only called if the transporter has not been closed.- Parameters:
task- The download to perform, must not benull.- Throws:
Exception- If the transfer failed.
-
utilGet
protected void utilGet(GetTask task, InputStream is, boolean close, long length, boolean resume) throws IOException, org.eclipse.aether.transfer.TransferCancelledException Performs stream-based I/O for the specified download task and notifies the configured transport listener. Subclasses might want to invoke this utility method from within theirimplGet(GetTask)to avoid boilerplate I/O code.- Parameters:
task- The download to perform, must not benull.is- The input stream to download the data from, must not benull.close-trueif the supplied input stream should be automatically closed,falseto leave the stream open.length- The size in bytes of the downloaded resource or-1if unknown, not to be confused with the length of the supplied input stream which might be smaller if the download is resumed.resume-trueif the download resumes fromGetTask.getResumeOffset(),falseif the download starts at the first byte of the resource.- Throws:
IOException- If the transfer encountered an I/O error.org.eclipse.aether.transfer.TransferCancelledException- If the transfer was cancelled.
-
put
Description copied from interface:TransporterUploads a resource to the repository.- Specified by:
putin interfaceTransporter- Parameters:
task- The upload to perform, must not benull.- Throws:
Exception- If the transfer failed.
-
implPut
Implementsput(PutTask), gets only called if the transporter has not been closed.- Parameters:
task- The upload to perform, must not benull.- Throws:
Exception- If the transfer failed.
-
utilPut
protected void utilPut(PutTask task, OutputStream os, boolean close) throws IOException, org.eclipse.aether.transfer.TransferCancelledException Performs stream-based I/O for the specified upload task and notifies the configured transport listener. Subclasses might want to invoke this utility method from within theirimplPut(PutTask)to avoid boilerplate I/O code.- Parameters:
task- The upload to perform, must not benull.os- The output stream to upload the data to, must not benull.close-trueif the supplied output stream should be automatically closed,falseto leave the stream open.- Throws:
IOException- If the transfer encountered an I/O error.org.eclipse.aether.transfer.TransferCancelledException- If the transfer was cancelled.
-
close
Description copied from interface:TransporterCloses this transporter and frees any network resources associated with it. Once closed, a transporter must not be used for further transfers, any attempt to do so would yield aIllegalStateExceptionor similar. Closing an already closed transporter is harmless and has no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTransporter
-
implClose
Implementsclose(), gets only called if the transporter has not already been closed.
-