01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
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;
19:
20: /**
21: * This interface defines the methods
22: * that should be implemented by any class that
23: * wants to handle java Objects from a client.
24: *
25: * <p>
26: * Recommendations to be followed when implementing ClientObjectHandler
27: * <ul>
28: * <li>Should have a default constructor.
29: * <li>Should be thread safe.
30: * <li>It should not store any client data that may be needed in the
31: * implementation.
32: * <li>If any client data is need to be saved from the client session,
33: * it should be saved to a {@link ClientData} class, which can be retrieved
34: * using handler.getClientData() method.
35: * </ul>
36: * </p>
37: * <p>
38: * Ex:
39: * <code><BLOCKQUOTE><pre>
40: package dateserver;
41:
42: import java.net.*;
43: import java.io.*;
44: import java.util.Date;
45: import org.quickserver.net.server.*;
46:
47: public class ObjectHandler implements ClientObjectHandler {
48:
49: public void handleObject(ClientHandler handler, Object command)
50: throws SocketTimeoutException, IOException {
51: handler.sendSystemMsg("Got Object : " + command.toString());
52: handler.setDataMode(DataMode.STRING);
53: }
54: }
55: </pre></BLOCKQUOTE></code></p>
56: * @author Akshathkumar Shetty
57: */
58: public interface ClientObjectHandler {
59:
60: /**
61: * Method called every time client sends an Object.
62: * Should be used to handle the Object sent.
63: * @exception java.net.SocketTimeoutException if socket times out
64: * @exception java.io.IOException if io error in socket
65: * @since v1.2
66: */
67: public void handleObject(ClientHandler handler, Object command)
68: throws SocketTimeoutException, IOException;
69:
70: }
|