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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes this transporter and frees any network resources associated with it.void
Downloads a resource from the repository.protected abstract void
Implementsclose()
, gets only called if the transporter has not already been closed.protected abstract void
Implementsget(GetTask)
, gets only called if the transporter has not been closed.protected abstract void
Implementspeek(PeekTask)
, gets only called if the transporter has not been closed.protected abstract void
Implementsput(PutTask)
, gets only called if the transporter has not been closed.void
Checks the existence of a resource in the repository.void
Uploads a resource to the repository.protected void
utilGet
(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 void
utilPut
(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, wait
Methods 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:Transporter
Checks 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:
peek
in 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:Transporter
Downloads 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:
get
in 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, 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
-true
if the supplied input stream should be automatically closed,false
to leave the stream open.length
- The size in bytes of the downloaded resource or-1
if unknown, not to be confused with the length of the supplied input stream which might be smaller if the download is resumed.resume
-true
if the download resumes fromGetTask.getResumeOffset()
,false
if the download starts at the first byte of the resource.- Throws:
IOException
- If the transfer encountered an I/O error.TransferCancelledException
- If the transfer was cancelled.
-
put
Description copied from interface:Transporter
Uploads a resource to the repository.- Specified by:
put
in 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, 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
-true
if the supplied output stream should be automatically closed,false
to leave the stream open.- Throws:
IOException
- If the transfer encountered an I/O error.TransferCancelledException
- If the transfer was cancelled.
-
close
Description copied from interface:Transporter
Closes 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 aIllegalStateException
or similar. Closing an already closed transporter is harmless and has no effect.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceTransporter
-
implClose
Implementsclose()
, gets only called if the transporter has not already been closed.
-