1 | // |
---|
2 | // $Id: FileUploadThread.java 1026 2010-02-24 10:12:19Z etienne_sf $ |
---|
3 | // |
---|
4 | // jupload - A file upload applet. |
---|
5 | // Copyright 2007 The JUpload Team |
---|
6 | // |
---|
7 | // Created: ? |
---|
8 | // Creator: William JinHua Kwong |
---|
9 | // Last modified: $Date: 2010-02-24 07:12:19 -0300 (Qua, 24 Fev 2010) $ |
---|
10 | // |
---|
11 | // This program is free software; you can redistribute it and/or modify it under |
---|
12 | // the terms of the GNU General Public License as published by the Free Software |
---|
13 | // Foundation; either version 2 of the License, or (at your option) any later |
---|
14 | // version. This program is distributed in the hope that it will be useful, but |
---|
15 | // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
16 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
17 | // details. You should have received a copy of the GNU General Public License |
---|
18 | // along with this program; if not, write to the Free Software Foundation, Inc., |
---|
19 | // 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
20 | |
---|
21 | package wjhk.jupload2.upload; |
---|
22 | |
---|
23 | import java.util.concurrent.BlockingQueue; |
---|
24 | |
---|
25 | import wjhk.jupload2.exception.JUploadException; |
---|
26 | import wjhk.jupload2.policies.UploadPolicy; |
---|
27 | |
---|
28 | /** |
---|
29 | * This interface defines the methods of the various FileUploadThread classes. |
---|
30 | * The default implementation is in the {@link DefaultFileUploadThread}. It |
---|
31 | * allows retries, for network errors. See |
---|
32 | * {@link UploadPolicy#PROP_RETRY_MAX_NUMBER_OF} and |
---|
33 | * {@link UploadPolicy#PROP_RETRY_NB_SECONDS_BETWEEN} for details. |
---|
34 | */ |
---|
35 | public interface FileUploadThread { |
---|
36 | /** |
---|
37 | * @return the packetQueue |
---|
38 | */ |
---|
39 | public BlockingQueue<UploadFilePacket> getPacketQueue(); |
---|
40 | |
---|
41 | /** |
---|
42 | * Get the server response message. In HTTP mode, it's the body part, |
---|
43 | * without the HTTP headers.<BR> |
---|
44 | * Note: was getResponseMsg until release 3.4.1. |
---|
45 | * |
---|
46 | * @return The String that contains the HTTP response message (e.g. |
---|
47 | * "SUCCESS") |
---|
48 | */ |
---|
49 | public String getResponseMsg(); |
---|
50 | |
---|
51 | /** |
---|
52 | * Closes the connection to the server and releases resources. |
---|
53 | */ |
---|
54 | public void close(); |
---|
55 | |
---|
56 | /** |
---|
57 | * @return The Thread state |
---|
58 | * @see Thread#getState() |
---|
59 | */ |
---|
60 | public Thread.State getState(); |
---|
61 | |
---|
62 | /** |
---|
63 | * This method is created in this interface, and is implemented by |
---|
64 | * {@link DefaultFileUploadThread}, as this class is a subclass of |
---|
65 | * {@link Thread}. |
---|
66 | * |
---|
67 | * @return true if the thread is currently working. |
---|
68 | * @see java.lang.Thread#isAlive() |
---|
69 | */ |
---|
70 | public boolean isAlive(); |
---|
71 | |
---|
72 | /** |
---|
73 | * This method is created in this interface, and is implemented by |
---|
74 | * {@link DefaultFileUploadThread}, as this class is a subclass of |
---|
75 | * {@link Thread}. |
---|
76 | * |
---|
77 | * @throws InterruptedException |
---|
78 | * @see java.lang.Thread#join() |
---|
79 | */ |
---|
80 | public void join() throws InterruptedException; |
---|
81 | |
---|
82 | /** |
---|
83 | * This method is created in this interface, and is implemented by |
---|
84 | * {@link DefaultFileUploadThread}, as this class is a subclass of |
---|
85 | * {@link Thread}. |
---|
86 | * |
---|
87 | * @param millisec |
---|
88 | * @throws InterruptedException |
---|
89 | * @see java.lang.Thread#join(long) |
---|
90 | */ |
---|
91 | public void join(long millisec) throws InterruptedException; |
---|
92 | |
---|
93 | /** |
---|
94 | * This method is created in this interface, and is implemented by |
---|
95 | * {@link DefaultFileUploadThread}, as this class is a subclass of |
---|
96 | * {@link Thread}. |
---|
97 | * |
---|
98 | * @see java.lang.Thread#start() |
---|
99 | */ |
---|
100 | public void start(); |
---|
101 | |
---|
102 | /** |
---|
103 | * This method is created in this interface, and is implemented by |
---|
104 | * {@link DefaultFileUploadThread}, as this class is a subclass of |
---|
105 | * {@link Thread}. |
---|
106 | * |
---|
107 | * @see java.lang.Thread#interrupt() |
---|
108 | */ |
---|
109 | public void interrupt(); |
---|
110 | |
---|
111 | /** |
---|
112 | * Changes the FileUploadManagerThread. The standard way is to give the |
---|
113 | * FileUploadManagerThread to the constructor. This method is used by JUnit |
---|
114 | * tests, to be able to control which FileUploadThread is created. |
---|
115 | * |
---|
116 | * @param fileUploadManagerThread |
---|
117 | * @throws JUploadException |
---|
118 | * @see FileUploadManagerThread |
---|
119 | */ |
---|
120 | void setFileUploadThreadManager( |
---|
121 | FileUploadManagerThread fileUploadManagerThread) |
---|
122 | throws JUploadException; |
---|
123 | |
---|
124 | } |
---|