KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > net > server > ClientObjectHandler


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.net.server;
16
17 import java.io.*;
18 import java.net.SocketTimeoutException JavaDoc;
19 /**
20  * This interface defines the methods
21  * that should be implemented by any class that
22  * wants to handle java Objects from a client.
23  *
24  * <p>
25  * Recommendations to be followed when implementing ClientObjectHandler
26  * <ul>
27  * <li>Should have a default constructor.
28  * <li>Should be thread safe.
29  * <li>It should not store any client data that may be needed in the
30  * implementation.
31  * <li>If any client data is need to be saved from the client session,
32  * it should be saved to a {@link ClientData} class, which can be retrieved
33  * using handler.getClientData() method.
34  * </ul>
35  * </p>
36  * <p>
37  * Ex:
38  * <code><BLOCKQUOTE><pre>
39 package dateserver;
40
41 import java.net.*;
42 import java.io.*;
43 import java.util.Date;
44 import org.quickserver.net.server.*;
45
46 public class ObjectHandler implements ClientObjectHandler {
47
48     public void handleObject(ClientHandler handler, Object command)
49             throws SocketTimeoutException, IOException {
50         handler.sendSystemMsg("Got Object : " + command.toString());
51         handler.setDataMode(DataMode.STRING);
52     }
53 }
54 </pre></BLOCKQUOTE></code></p>
55  * @author Akshathkumar Shetty
56  */

57 public interface ClientObjectHandler {
58
59     /**
60      * Method called every time client sends an Object.
61      * Should be used to handle the Object sent.
62      * @exception java.net.SocketTimeoutException if socket times out
63      * @exception java.io.IOException if io error in socket
64      * @since v1.2
65      */

66     public void handleObject(ClientHandler handler, Object JavaDoc command)
67         throws SocketTimeoutException JavaDoc, IOException;
68
69 }
70
Popular Tags