Class SocketConnection
java.lang.Object
org.apache.derby.impl.store.replication.net.SocketConnection
This class encapsulates a
Socket
connection and has
methods that allow to read and write into the Object streams
created from this connection.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ObjectInputStream
used to read message objects sent in the socket connection.private final ObjectOutputStream
used to write message objects into the socket connection.private final Socket
Contains the Socket connection between the Replication master and the slave. -
Constructor Summary
ConstructorsConstructorDescriptionSocketConnection
(Socket socket) Constructor creates the streams from the socket object passed as parameter. -
Method Summary
Modifier and TypeMethodDescriptionUsed to read the object messages that are sent.void
tearDown()
Closes theSocket
and the object streams obtained from it.void
writeMessage
(Object message) Used to send the object messages across the socket conection.
-
Field Details
-
socket
Contains the Socket connection between the Replication master and the slave. -
objOutputStream
used to write message objects into the socket connection. -
objInputStream
used to read message objects sent in the socket connection.
-
-
Constructor Details
-
SocketConnection
Constructor creates the streams from the socket object passed as parameter.- Parameters:
socket
- theSocket
object that this class encapsulates.- Throws:
IOException
- If an exception occurs while creating the streams from the socket object.
-
-
Method Details
-
readMessage
Used to read the object messages that are sent. waits on the input stream until a data is present that can be read and returns this data.- Returns:
- the data read from the connection.
- Throws:
ClassNotFoundException
- Class of a serialized object cannot be found.IOException
- if an exception occurs while reading from the stream.
-
writeMessage
Used to send the object messages across the socket conection.- Parameters:
message
- the data to be written into the connection.- Throws:
IOException
- if an exception occurs while writing into the stream.
-
tearDown
Closes theSocket
and the object streams obtained from it.- Throws:
IOException
- if an exception occurs while trying to close the socket or the streams.
-