|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread wjhk.jupload2.upload.FileUploadManagerThread
public class FileUploadManagerThread
This class is responsible for managing the upload. At the end of the upload,
the JUploadPanel.updateButtonState()
is called, to refresh the button
state. Its job is to:
FileData.beforeUpload()
for each file in the file list. JUploadPanel.updateButtonState()
and the call to
UploadPolicy.afterUpload(Exception, String)
. JUploadPanel
, when
the user clicks on the upload button.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
Thread.State, Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
(package private) long |
currentRequestStartTime
Contains the date/time (as a long) of the start of the current upload. |
(package private) wjhk.jupload2.gui.filepanel.FilePanel |
filePanel
The current file list. |
(package private) FileUploadThread |
fileUploadThread
The upload thread, that will wait for the next file packet to be ready, then send it. |
(package private) long |
globalStartTime
Contains the system time of the start of the global upload. |
(package private) long |
maxChunkSize
|
(package private) long |
nbBytesReadyForUpload
Contains the sum of the files, ready for upload, and not uploaded yet |
(package private) long |
nbBytesUploadedForCurrentFile
Indicated the number of bytes that have currently been sent for the current file. |
(package private) int |
nbFilesBeingUploaded
Number of files that has been read by the FileUploadThread
thread. |
(package private) int |
nbFilesPerRequest
|
(package private) int |
nbPreparedFiles
Number of files that are prepared for upload. |
(package private) int |
nbSentFiles
Number of files that have already been sent. |
(package private) int |
nbSuccessfullyUploadedFiles
Number of files that have been successfully uploaded. already been sent. |
(package private) long |
nbTotalNumberOfPreparedBytes
Sum of the length for all prepared files. |
(package private) long |
nbUploadedBytes
Current number of bytes that have been uploaded. |
(package private) UploadFileData[] |
nextPacket
Contains the next packet to upload. |
(package private) int |
numOfFileInCurrentRequest
During the upload, when uploading several files in one packet, this attribute indicates which file is currently being uploaded. |
(package private) JProgressBar |
preparationProgressBar
The JUploadPanel progress bar, to follow the file preparation
progress. |
(package private) boolean |
stop
If set to 'true', the thread will stop the current upload. |
(package private) Timer |
timerProgressBar
Used to update the progress: 50ms is nice, as it is fast enough, and doesn't make CPU rise to 100%. |
(package private) Timer |
timerStatusBar
Used to update the status bar (upload speed, ETA...): 300ms make it accurate, and avoid an always changing value. |
static int |
UPLOAD_STATUS_CHUNK_UPLOADED_WAITING_FOR_RESPONSE
A chunk (a part) of the file identified by numOfFileInCurrentRequest has been sent. |
static int |
UPLOAD_STATUS_FILE_UPLOADED_WAITING_FOR_RESPONSE
All data for the file identified by numOfFileInCurrentRequest has been sent. |
static int |
UPLOAD_STATUS_NOT_STARTED
Indicates that nothings has begun |
static int |
UPLOAD_STATUS_UPLOADED
The upload for the file identified by numOfFileInCurrentRequest is finished |
static int |
UPLOAD_STATUS_UPLOADING
We're sending data to the server, for the file identified by numOfFileInCurrentRequest. |
(package private) long |
uploadDuration
Contains the sum of the upload duration for all requests. |
(package private) JUploadException |
uploadException
Thread Exception, if any occurred during upload. |
(package private) UploadFileData[] |
uploadFileDataArray
The list of files to upload |
(package private) boolean |
uploadFinished
Indicates whether the upload is finished or not. |
(package private) JUploadPanel |
uploadPanel
A shortcut to the upload panel |
(package private) UploadPolicy |
uploadPolicy
The current upload policy. |
(package private) JProgressBar |
uploadProgressBar
The JUploadPanel progress bar, to follow the upload of the
prepared files to the server. |
(package private) long |
uploadStartTime
Contains the time of the actual start of upload. |
(package private) int |
uploadStatus
Indicates what is the current file being uploaded, and its upload status. |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
FileUploadManagerThread(UploadPolicy uploadPolicy)
Standard constructor of the class. |
|
FileUploadManagerThread(UploadPolicy uploadPolicy,
FileUploadThread fileUploadThreadParam)
Internal constructor. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
|
void |
anotherFileHasBeenSent(FileData newlyUploadedFileData)
This method is called each time a new file is sent to the server. |
void |
currentRequestIsFinished(UploadFileData[] currentPacket)
This method is called when the server response for the upload indicates a success. |
int |
getNbUploadedFiles()
Get the total number of files which have been successfully uploaded. |
UploadFileData[] |
getNextPacket()
Returns the next packet of files, for upload, according to the current upload policy. |
JUploadException |
getUploadException()
Get the last upload exception that occurs. |
long |
getUploadStartTime()
Retrieve the start time of the upload. |
boolean |
isUploadFinished()
Indicates whether the upload is finished or not. |
void |
nbBytesUploaded(long nbBytes)
Used by the UploadFileData#uploadFile(java.io.OutputStream, long) for each uploaded buffer |
void |
run()
The heart of the program. |
void |
setUploadException(JUploadException uploadException)
Stores the last upload exception that occurs. |
void |
setUploadStatus(int numOfFileInCurrentRequest,
int uploadStatus)
Indicate the current state of the upload, to allow a correct display of the upload progress bar. |
void |
stopUpload()
Reaction to the user click on the 'Stop' button, or any action from the user asking to stop the upload. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int UPLOAD_STATUS_NOT_STARTED
public static final int UPLOAD_STATUS_UPLOADING
public static final int UPLOAD_STATUS_CHUNK_UPLOADED_WAITING_FOR_RESPONSE
public static final int UPLOAD_STATUS_FILE_UPLOADED_WAITING_FOR_RESPONSE
public static final int UPLOAD_STATUS_UPLOADED
long currentRequestStartTime
wjhk.jupload2.gui.filepanel.FilePanel filePanel
FileUploadThread fileUploadThread
long globalStartTime
long maxChunkSize
UploadPolicy.getMaxChunkSize()
long nbBytesReadyForUpload
int nbFilesBeingUploaded
FileUploadThread
thread. These files have been read by the getNextPacket()
method.
int nbFilesPerRequest
UploadPolicy.getNbFilesPerRequest()
int nbPreparedFiles
FileData.beforeUpload()
has been called.
int nbSentFiles
int nbSuccessfullyUploadedFiles
long nbBytesUploadedForCurrentFile
long nbTotalNumberOfPreparedBytes
anotherFileHasBeenSent(FileData)
int numOfFileInCurrentRequest
int uploadStatus
UploadFileData[] nextPacket
getNextPacket()
JProgressBar preparationProgressBar
JUploadPanel
progress bar, to follow the file preparation
progress.
JProgressBar uploadProgressBar
JUploadPanel
progress bar, to follow the upload of the
prepared files to the server.
boolean uploadFinished
currentRequestIsFinished(UploadFileData[])
method) setUploadException(JUploadException)
method) stopUpload()
method)
long uploadStartTime
boolean stop
UploadFileData.uploadFile(java.io.OutputStream, long)
JUploadException uploadException
long uploadDuration
long nbUploadedBytes
JUploadPanel uploadPanel
UploadPolicy uploadPolicy
UploadFileData[] uploadFileDataArray
Timer timerStatusBar
Timer timerProgressBar
Constructor Detail |
---|
public FileUploadManagerThread(UploadPolicy uploadPolicy) throws JUploadException
uploadPolicy
-
JUploadException
public FileUploadManagerThread(UploadPolicy uploadPolicy, FileUploadThread fileUploadThreadParam) throws JUploadException
FileUploadThread
.
uploadPolicy
- The current uploadPolicyfileUploadThreadParam
- The instance of FileUploadThread
that should be used. Allows execution of unit tests, based on
a specific FileUploadThread, that does ... nothing.
JUploadException
Method Detail |
---|
public final void run()
run
in interface Runnable
run
in class Thread
Thread.run()
public int getNbUploadedFiles()
public final long getUploadStartTime()
public void setUploadException(JUploadException uploadException)
uploadException
- public JUploadException getUploadException()
public boolean isUploadFinished()
run()
method.
public void nbBytesUploaded(long nbBytes) throws JUploadException
nbBytes
- Number of additional bytes that where uploaded.
JUploadException
public void setUploadStatus(int numOfFileInCurrentRequest, int uploadStatus) throws JUploadException
numOfFileInCurrentRequest
- uploadStatus
-
JUploadException
public void stopUpload()
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
e
- public void anotherFileHasBeenSent(FileData newlyUploadedFileData) throws JUploadException
newlyUploadedFileData
-
JUploadException
public void currentRequestIsFinished(UploadFileData[] currentPacket) throws JUploadException
currentPacket
- The packet of files that was successfully uploaded.
JUploadException
public UploadFileData[] getNextPacket() throws JUploadException
JUploadException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |