Package org.jboss.as.process.protocol
Interface Connection
-
- All Superinterfaces:
AutoCloseable,Closeable
public interface Connection extends Closeable
A peer-to-peer connection with another participant in the management protocol.- Author:
- David M. Lloyd
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceConnection.ClosedCallbackA callback that will be triggered once the connection is closed
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidattach(Object attachment)voidbackupMessageHandler()Records the current message handler, which can be reset usingrestoreMessageHandler()voidclose()Close the connection.ObjectgetAttachment()InetAddressgetPeerAddress()Get the remote peer address.voidrestoreMessageHandler()Resets the message handler to any that was backed up usingbackupMessageHandler().voidsetMessageHandler(MessageHandler messageHandler)Change the current message handler.voidshutdownWrites()Shut down writes once all messages are sent.OutputStreamwriteMessage()Write a protocol message.
-
-
-
Method Detail
-
writeMessage
OutputStream writeMessage() throws IOException
Write a protocol message. Returns a stream which can be written to, to transmit the data. When the stream is closed, the message is concluded.- Returns:
- the stream to which the message should be written
- Throws:
IOException- if an I/O error occurs
-
shutdownWrites
void shutdownWrites() throws IOExceptionShut down writes once all messages are sent. This will cause the reading side'sMessageHandler.handleShutdown(Connection)method to be called.- Throws:
IOException- if an I/O error occurs
-
close
void close() throws IOExceptionClose the connection. This will interrupt both reads and writes and so should only be done in the event of an unrecoverable failure of the connection.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if the close fails
-
setMessageHandler
void setMessageHandler(MessageHandler messageHandler)
Change the current message handler.- Parameters:
messageHandler- the new message handler to use
-
getPeerAddress
InetAddress getPeerAddress()
Get the remote peer address.- Returns:
- the peer address
-
attach
void attach(Object attachment)
-
getAttachment
Object getAttachment()
-
backupMessageHandler
void backupMessageHandler()
Records the current message handler, which can be reset usingrestoreMessageHandler()
-
restoreMessageHandler
void restoreMessageHandler()
Resets the message handler to any that was backed up usingbackupMessageHandler(). If no backup was done,MessageHandler.NULLis used
-
-