1 package be
.nikiroo
.utils
.serial
.server
;
3 import java
.io
.IOException
;
4 import java
.net
.Socket
;
7 * Class used for the server basic handling.
9 * It represents a single action: a server is expected to execute one action for
14 public class ConnectActionServerObject
extends ConnectActionServer
{
16 * Create a new {@link ConnectActionServerObject} as the server version.
19 * the socket to bind to
21 * an optional key to encrypt all the communications (if NULL,
22 * everything will be sent in clear text)
24 public ConnectActionServerObject(Socket s
, String key
) {
29 * Serialise and send the given object to the client.
35 * in case of I/O error
36 * @throws NoSuchFieldException
37 * if the serialised data contains information about a field
38 * which does actually not exist in the class we know of
39 * @throws NoSuchMethodException
40 * if a class described in the serialised data cannot be created
41 * because it is not compatible with this code
42 * @throws ClassNotFoundException
43 * if a class described in the serialised data cannot be found
45 public void send(Object data
) throws IOException
, NoSuchFieldException
,
46 NoSuchMethodException
, ClassNotFoundException
{
47 action
.sendObject(data
);
51 * (Flush the data to the client if needed and) retrieve its answer.
53 * @return the deserialised answer (which can actually be NULL)
56 * in case of I/O error
57 * @throws NoSuchFieldException
58 * if the serialised data contains information about a field
59 * which does actually not exist in the class we know of
60 * @throws NoSuchMethodException
61 * if a class described in the serialised data cannot be created
62 * because it is not compatible with this code
63 * @throws ClassNotFoundException
64 * if a class described in the serialised data cannot be found
65 * @throws java.lang.NullPointerException
66 * if the counter part has no data to send
68 public Object
rec() throws NoSuchFieldException
, NoSuchMethodException
,
69 ClassNotFoundException
, IOException
, java
.lang
.NullPointerException
{
70 return action
.recObject();