KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.coldcore.coloradoftp.connection;
2
3 import java.nio.channels.SocketChannel JavaDoc;
4
5 /**
6  * Data or control connection.
7  * Connections read and write data from and to users.
8  *
9  * Life cycle of a connection is very simple. When it is accepted and configured it is then
10  * added to a connection pool which calls on it service method. When connection dies, the
11  * connection pool removes it from its internal list and the connection will be garbage
12  * collected.
13  *
14  * When poisoned, connection must die as soon as it has nothing to read/write to/from user.
15  * This is mainly for control connections as data connections do not use it. But since
16  * connection pool's specification requires it to poison all connections as soon as server's
17  * core becomes poisoned (before shutdown to let everyone finish and leave), the methods are
18  * located in this class.
19  *
20  *
21  * ColoradoFTP - The Open Source FTP Server (http://cftp.coldcore.com)
22  */

23 public interface Connection {
24
25   /** Kill connection (free resources) */
26   public void destroy();
27
28
29   /** Get connection's channel
30    * @return Channel
31    */

32   public SocketChannel JavaDoc getSocketChannel();
33
34
35   /** Initialize connection (acquire resources)
36    * @param channel Channel
37    */

38   public void initialize(SocketChannel JavaDoc channel);
39
40
41   /** Test if connection is destroyed
42    * @return TRUE if destroyed, FALSE otherwise
43    */

44   public boolean isDestroyed();
45
46
47   /** Poison connection (when there is nothing more to read/write it must die,
48    * data connections output/input data and die, control connections are not allowed to
49    * read user input and die when all output is done)
50    */

51   public void poison();
52
53
54   /** Test if connection is poisoned (will be destroyed shortly)
55    * @return TRUE if poisoned, FALSE otherwise
56    */

57   public boolean isPoisoned();
58
59
60   /** Get bytes user sent so far
61    * @return Bytes count
62    */

63   public long getBytesRead();
64
65
66   /** Get bytes server sent so far
67    * @return Bytes count
68    */

69   public long getBytesWrote();
70
71
72   /** Self-service routine */
73   public void service() throws Exception JavaDoc;
74 }
75
Popular Tags