Top Description Fields Constructors Methods
org.apache.derby.impl.store.replication.net

public Class SocketConnection

extends Object
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, java.net.Socket

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

Modifier and TypeField and Description
private final ObjectInputStream
objInputStream

used to read message objects sent in the socket connection.

private final ObjectOutputStream
objOutputStream

used to write message objects into the socket connection.

private final Socket
socket

Contains the Socket connection between the Replication master and the slave.

Constructor Summary

AccessConstructor and Description
public
SocketConnection(Socket
the Socket object that this class encapsulates.
socket
)

Constructor creates the streams from the socket object passed as parameter.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the data read from the connection.
readMessage
()

Used to read the object messages that are sent.

public void
tearDown()

Closes the Socket and the object streams obtained from it.

public void
writeMessage(Object
the data to be written into the connection.
message
)

Used to send the object messages across the socket conection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

objInputStreamback to summary
private final ObjectInputStream objInputStream

used to read message objects sent in the socket connection.

objOutputStreamback to summary
private final ObjectOutputStream objOutputStream

used to write message objects into the socket connection.

socketback to summary
private final Socket socket

Contains the Socket connection between the Replication master and the slave.

Constructor Detail

SocketConnectionback to summary
public SocketConnection(Socket socket) throws IOException

Constructor creates the streams from the socket object passed as parameter.

Parameters
socket:Socket

the Socket object that this class encapsulates.

Exceptions
IOException:
If an exception occurs while creating the streams from the socket object.

Method Detail

readMessageback to summary
public Object readMessage() throws ClassNotFoundException, IOException

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:Object

the data read from the connection.

Exceptions
ClassNotFoundException:
Class of a serialized object cannot be found.
IOException:
if an exception occurs while reading from the stream.
tearDownback to summary
public void tearDown() throws IOException

Closes the Socket and the object streams obtained from it.

Exceptions
IOException:
if an exception occurs while trying to close the socket or the streams.
writeMessageback to summary
public void writeMessage(Object message) throws IOException

Used to send the object messages across the socket conection.

Parameters
message:Object

the data to be written into the connection.

Exceptions
IOException:
if an exception occurs while writing into the stream.