Interface Transport
-
- All Known Implementing Classes:
TcpTransport
,WebSocketTransport
public interface Transport
Base class for all QpidJMS Transport instances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
awaitConnect()
Waits interruptibly for theTransport
to connect to the remote that was indicated in theconnect(String, int, TransportListener)
call.void
close()
Close the Transport, no additional send operations are accepted.Transport
connect(java.lang.String host, int port, TransportListener listener)
Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc.Transport
flush()
Request a flush of all pending writes to the underlying connection.ProtonBufferAllocator
getBufferAllocator()
Gets a buffer allocator that can produceProtonBuffer
instance that may be optimized for use with the underlying transport implementation.java.lang.String
getHost()
java.security.Principal
getLocalPrincipal()
int
getPort()
java.net.URI
getRemoteURI()
Returns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to.SslOptions
getSslOptions()
TransportListener
getTransportListener()
Gets the currently set TransportListener instanceTransportOptions
getTransportOptions()
boolean
isConnected()
boolean
isSecure()
Transport
write(ProtonBuffer output)
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.Transport
write(ProtonBuffer output, java.lang.Runnable ioComplete)
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.Transport
writeAndFlush(ProtonBuffer output)
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operationsTransport
writeAndFlush(ProtonBuffer output, java.lang.Runnable ioComplete)
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations
-
-
-
Method Detail
-
connect
Transport connect(java.lang.String host, int port, TransportListener listener) throws java.io.IOException
Performs the connect operation for the implemented Transport type such as a TCP socket connection, SSL/TLS handshake etc. The connection operation itself will be performed as an asynchronous operation with the success or failure being communicated to the event pointTransportListener.transportError(Throwable)
. If the users wishes to perform a block on connect outcome theawaitConnect()
method will wait for and or throw an error based on the connect outcome.- Parameters:
host
- The remote host that thisTransport
should attempt to connect to.port
- The port on the remote host that thisTransport
should attempt to bind to.listener
- TheTransportListener
that will handleTransport
events.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs while attempting the connect.
-
awaitConnect
void awaitConnect() throws java.lang.InterruptedException, java.io.IOException
Waits interruptibly for theTransport
to connect to the remote that was indicated in theconnect(String, int, TransportListener)
call.- Throws:
java.lang.InterruptedException
- If the wait mechanism was interrupted while waiting for a successful connect.java.io.IOException
- If theTransport
failed to connect or was closed before connected.
-
isConnected
boolean isConnected()
- Returns:
- true if transport is connected or false if the connection is down.
-
isSecure
boolean isSecure()
- Returns:
- true if transport is connected using a secured channel (SSL).
-
close
void close() throws java.io.IOException
Close the Transport, no additional send operations are accepted.- Throws:
java.io.IOException
- if an error occurs while closing the connection.
-
getBufferAllocator
ProtonBufferAllocator getBufferAllocator()
Gets a buffer allocator that can produceProtonBuffer
instance that may be optimized for use with the underlying transport implementation.- Returns:
- a
ProtonBufferAllocator
that creates transport friendly buffers.
-
write
Transport write(ProtonBuffer output) throws java.io.IOException
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport.- Parameters:
output
- The buffer of data that is to be transmitted.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs during the write operation.
-
write
Transport write(ProtonBuffer output, java.lang.Runnable ioComplete) throws java.io.IOException
Writes a chunk of data over the Transport connection without performing an explicit flush on the transport. This method allows for a completion callback that is signaled when the actual low level IO operation is completed which could be after this method has returned.- Parameters:
output
- The buffer of data that is to be transmitted.ioComplete
- ARunnable
that is invoked when the IO operation completes successfully.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs during the write operation.
-
writeAndFlush
Transport writeAndFlush(ProtonBuffer output) throws java.io.IOException
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Parameters:
output
- The buffer of data that is to be transmitted.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs during the write operation.
-
writeAndFlush
Transport writeAndFlush(ProtonBuffer output, java.lang.Runnable ioComplete) throws java.io.IOException
Writes a chunk of data over the Transport connection and requests a flush of all pending queued write operations- Parameters:
output
- The buffer of data that is to be transmitted.ioComplete
- ARunnable
that is invoked when the IO operation completes successfully.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs during the write operation.
-
flush
Transport flush() throws java.io.IOException
Request a flush of all pending writes to the underlying connection.- Returns:
- this
Transport
instance. - Throws:
java.io.IOException
- if an error occurs during the flush operation.
-
getTransportListener
TransportListener getTransportListener()
Gets the currently set TransportListener instance- Returns:
- the current TransportListener or null if none set.
-
getTransportOptions
TransportOptions getTransportOptions()
- Returns:
- a
TransportOptions
instance copied from the immutable options given at create time..
-
getSslOptions
SslOptions getSslOptions()
- Returns:
- a
SslOptions
instance copied from the immutable options given at create time..
-
getHost
java.lang.String getHost()
- Returns:
- the host name or IP address that the transport connects to.
-
getPort
int getPort()
- Returns:
- the port that the transport connects to.
-
getRemoteURI
java.net.URI getRemoteURI()
Returns a URI that contains some meaningful information about the remote connection such as a scheme that reflects the transport type and the remote host and port that the connection was instructed to connect to. If called before theconnect(String, int, TransportListener)
method this method returnsnull
.- Returns:
- a URI that reflects a meaningful view of the
Transport
remote connection details.
-
getLocalPrincipal
java.security.Principal getLocalPrincipal()
- Returns:
- the local principal for a Transport that is using a secure connection.
-
-