KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > xsocket > stream > io > spi > IIoHandlerCallback


1 // $Id: IoHandlerBase.java 1315 2007-06-10 08:05:00Z grro $
2
/*
3  * Copyright (c) xsocket.org, 2006 - 2007. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Please refer to the LGPL license at: http://www.gnu.org/copyleft/lesser.txt
20  * The latest copy of this software may be found on http://www.xsocket.org/
21  */

22 package org.xsocket.stream.io.spi;
23
24 import java.io.IOException JavaDoc;
25
26 import org.xsocket.Synchronized;
27
28
29 /**
30  * Call back interface to notify io events of the {@link IIoHandler}. The IIoHandler
31  * is responsible to notify the events in the occured order. <br><br>
32  *
33  *
34  * <b>This class is experimental and is subject to change</b>
35  *
36  * @author grro@xsocket.org
37  */

38 public interface IIoHandlerCallback {
39         
40     
41     /**
42      * notifies that data has been read from the socket. <br><br>
43      *
44      * This method has to be called by a worker thread if
45      * the {@link IIoHandlerContext#getWorkerpool()} is not <code>null</code>.
46      * If the {@link IIoHandlerContext#getWorkerpool()} is <code>null</code>,
47      * no dedicate worker threads will be used (non-multithreading mode). <br>
48      * The callback method will only be called if the {@link IIoHandlerContext#isAppHandlerListenForDataEvent()}
49      * method returns true. If the handler requires synchronization ({@link IIoHandlerContext#getAppHandlerSynchronizationMode()} != {@link Synchronized.Mode#OFF}),
50      * the callback method has to be called in a synchronized context.<br><br>
51      *
52      */

53     public void onDataRead();
54         
55     
56     /**
57      * notifies that the underlying connection has been established. <br>
58      * The callback method will only be called if the {@link IIoHandlerContext#isAppHandlerListenForConnectEvent()}
59      * method returns true. If the handler is not thread-safe ({@link IIoHandlerContext#isAppHandlerThreadSafe()} is false),
60      * the callback method has to be called in a synchronized context.<br><br>
61      *
62      * The threading behaivour is equals to {@link IIoHandlerCallback#onDataRead()}
63      *
64      */

65     public void onConnect();
66         
67     
68     /**
69      * notifies that the underlying connection has been disconnected (closed).<br>
70      * The callback method will only be called if the {@link IIoHandlerContext#isAppHandlerListenforDisconnectEvent()}
71      * method returns true. If the handler is not thread-safe ({@link IIoHandlerContext#isAppHandlerThreadSafe()} is false),
72      * the callback method has to be called in a synchronized context.<br><br>
73      *
74      * The threading behaivour is equals to {@link IIoHandlerCallback#onDataRead()}
75      *
76      */

77     public void onDisconnect();
78         
79     
80     /**
81      * notifies the idle time out has been occured.<br>
82      * The callback method will only be called if the {@link IIoHandlerContext#isAppHandlerListenForTimeoutEvent()}
83      * method returns true. If the handler is not thread-safe ({@link IIoHandlerContext#isAppHandlerThreadSafe()} is false),
84      * the callback method has to be called in a synchronized context.<br><br>
85      *
86      * The threading behaivour is equals to {@link IIoHandlerCallback#onDataRead()}
87      *
88      */

89     public void onIdleTimeout();
90
91     
92     /**
93      * notifies the connection time out has been occured.<br>
94      * The callback method will only be called if the {@link IIoHandlerContext#isAppHandlerListenForTimeoutEvent()}
95      * method returns true. If the handler is not thread-safe ({@link IIoHandlerContext#isAppHandlerThreadSafe()} is false),
96      * the callback method has to be called in a synchronized context.<br><br>
97      *
98      * The threading behaivour is equals to {@link IIoHandlerCallback#onDataRead()}
99      *
100      */

101     public void onConnectionTimeout();
102         
103     
104     /**
105      * notifies that the connection has to be closed (connection is corrupt,
106      * selector has be closed, ...). This call back method will NOT be called in the case of
107      * idle or connection time out.<br><br>
108      *
109      * The threading behaivour is equals to {@link IIoHandlerCallback#onDataRead()}
110      *
111      */

112     public void onConnectionAbnormalTerminated();
113     
114     
115     /**
116      * notifies that data has been written on the socket.<br><br>
117      *
118      * For performance reasons this method shouldn't be performed by a worker thread.
119      *
120      */

121     public void onWritten();
122     
123     
124     /**
125      * notifies that an error has been occured by writing data on the socket.<br><br>
126      *
127      * For performance reasons this method shouldn't be performed by a worker thread.
128      *
129      * @param ioe ioException an io exception
130      */

131     public void onWriteException(IOException JavaDoc ioException);
132 }
133
Popular Tags