KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > connection > DataConnection


1 package com.coldcore.coloradoftp.connection;
2
3 /**
4  * Data connection.
5  *
6  * Data connections perform data transfers between users and the server. For example when a user
7  * requires to upload a file, a new data connection is created. When all data is transferred, the
8  * data connection dies. Server provides channels for data connections to read from or to
9  * write data into. Channels are usually mounted to files, and it is the responsibility of
10  * data connections to close channels in the end.
11  *
12  * User may have only one data connection which he/she can abort with the ABOR command.
13  *
14  * Data connection must send a reply to the user after:
15  * 1. User aborts it (ABOR command)
16  * 2. Data transfer finished
17  * 3. Data transfer failed
18  * The reply must comply with the command user submitted to trigger a data transfer. Data
19  * connections are not allowed to die without producing a reply.
20  *
21  * For a data transfer to begin a data connection must know where to read file data from
22  * or where to save it to (that is a channel). Also it requires a filename (but not for a
23  * directory listing, which is also served by data connections) and a command name to
24  * produce the correct reply in the end. The best approach wuld be to keep that information in
25  * a user session and let a data connection to decide itself when, how and what to transfer.
26  *
27  * Data connections may be established in two ways: user connects to the server (PASV) or the
28  * server connects to a user (PORT).
29  *
30  * When a user downloads a file, server can test if the complete file has beed downloaded (because
31  * it has a stream from the file). But when a user uploads a file, server has no way to test if
32  * the data transfer completed sucessully or if the user disconnected earlier before all the data
33  * has been uploaded. As a result, all uploads may be considered as sucessful.
34  *
35  * Because control connection has a reference to a data connection, the data connection must
36  * clear that reference when it is ready to be destroyed.
37  *
38  *
39  * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
40  */

41 public interface DataConnection extends Connection {
42
43   /** Get control connection of this data connection
44    * @return Control connection
45    */

46   public ControlConnection getControlConnection();
47
48
49   /** Set control connection of this control connection
50    * @param controlConnection Control connection
51    */

52   public void setControlConnection(ControlConnection controlConnection);
53
54
55   /** User submitted ABOR command.
56    * FTP spec: first comes "426" reply to tell that the data transfer has been
57    * terminated, and then "226" reply to ABOR.
58    */

59   public void abort();
60
61
62   /** Destory the connection silently (for urgent connection termination).
63    * In this method data connection must not use control connection to post
64    * a reply to a user.
65    */

66   public void destroyNoReply();
67
68
69   /** Set a callback object to receive notifications from this data connection.
70    * @param callback Callback
71    */

72   public void setDataConnectionCallback(DataConnectionCallback callback);
73 }
74
Popular Tags