KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.coldcore.coloradoftp.connection;
2
3 /**
4  * Initiates a data connection with user.
5  *
6  * This class establishes a new connection to user's machine as a result of a PORT command.
7  * This class is a part of a control connection and is created on a per user basis.
8  *
9  * When a user wants a server to establish a data connection with his/her machine, this class
10  * is executed by a control connection untill a data connection is established or failed.
11  * In the latter case it is a responsibility of this class to send a failed reply to the user
12  * (this will also clear the INTERRUPT state of the control connection).
13  * Otherwise, if data connection is established, this class must add it to a connection pool
14  * and set control connection's reference to the new data connection.
15  *
16  * This class can establish connection with user only after user gets "150" reply from the
17  * control connection and not before. Data port listener and data connection do not have to
18  * check for "150" reply, but this class has to.
19  *
20  * The easiest way to test this condition is:
21  * 1. Before producing "150" relpy, a command saves into a user session amount of bytes
22  * the control connection has sent to the user so far (byte marker)
23  * 2. This class must wait until byte marker apperas in the session and the control
24  * connection writes beyond it
25  * 3. When control connection clears its outgoing buffer the "150" reply is sent to the user
26  * NB! This class may or may not remove byte marker from the session later, so it is the
27  * responsibility of a file command to clear the byte marker before initiating a new
28  * data connection to make sure that this class will wait for a proper "150" reply.
29  *
30  *
31  * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
32  */

33 public interface DataConnectionInitiator {
34
35   /** Set IP address to connect to
36    * @param ip User's IP address
37    */

38   public void setIp(String JavaDoc ip);
39
40
41   /** Get IP address to connect to
42    * @return User's IP address
43    */

44   public String JavaDoc getIp();
45
46
47   /** Set port number to connect to
48    * @param port User's port number
49    */

50   public void setPort(int port);
51
52
53   /** Get port number to connect to
54    * @return User's port number
55    */

56   public int getPort();
57
58
59   /** Test if data connection initiator is active and should be executed by a control connection.
60    * @return TRUE if it is active, FALSE otherwise
61    */

62   public boolean isActive();
63
64
65   /** Activate (start connecting) */
66   public void activate();
67
68
69   /** Abort data connection initializer (if active then stop connection attempts and send failed reply).
70    * This method has nothong to do with ABOR command and reply must not be to ABOR command.
71    */

72   public void abort();
73
74
75   /** Get control connection of this data connection initiator
76    * @return Control connection
77    */

78   public ControlConnection getControlConnection();
79
80
81   /** Set control connection of this control connection initiator
82    * @param controlConnection Control connection
83    */

84   public void setControlConnection(ControlConnection controlConnection);
85 }
86
Popular Tags