1 package be
.nikiroo
.utils
.serial
.server
;
3 import java
.io
.IOException
;
4 import java
.net
.Socket
;
6 import be
.nikiroo
.utils
.Version
;
9 * Class used for the server basic handling.
11 * It represents a single action: a server is expected to execute one action for
16 public class ConnectActionServerObject
extends ConnectActionServer
{
18 * Create a new {@link ConnectActionServerObject} with the current
19 * application version (see {@link Version#getCurrentVersion()}) as the
23 * the socket to bind to
25 * an optional key to encrypt all the communications (if NULL,
26 * everything will be sent in clear text)
28 public ConnectActionServerObject(Socket s
, String key
) {
33 * Create a new {@link ConnectActionServerObject}.
36 * the socket to bind to
38 * an optional key to encrypt all the communications (if NULL,
39 * everything will be sent in clear text)
43 public ConnectActionServerObject(Socket s
, String key
, Version version
) {
44 super(s
, key
, version
);
48 * Serialise and send the given object to the client.
54 * in case of I/O error
55 * @throws NoSuchFieldException
56 * if the serialised data contains information about a field
57 * which does actually not exist in the class we know of
58 * @throws NoSuchMethodException
59 * if a class described in the serialised data cannot be created
60 * because it is not compatible with this code
61 * @throws ClassNotFoundException
62 * if a class described in the serialised data cannot be found
64 public void send(Object data
) throws IOException
, NoSuchFieldException
,
65 NoSuchMethodException
, ClassNotFoundException
{
66 action
.sendObject(data
);
70 * (Flush the data to the client if needed and) retrieve its answer.
72 * @return the deserialised answer (which can actually be NULL)
75 * in case of I/O error
76 * @throws NoSuchFieldException
77 * if the serialised data contains information about a field
78 * which does actually not exist in the class we know of
79 * @throws NoSuchMethodException
80 * if a class described in the serialised data cannot be created
81 * because it is not compatible with this code
82 * @throws ClassNotFoundException
83 * if a class described in the serialised data cannot be found
84 * @throws java.lang.NullPointerException
85 * if the counter part has no data to send
87 public Object
rec() throws NoSuchFieldException
, NoSuchMethodException
,
88 ClassNotFoundException
, IOException
, java
.lang
.NullPointerException
{
89 return action
.recObject();