Interface Transport

    • 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 point TransportListener.transportError(Throwable). If the users wishes to perform a block on connect outcome the awaitConnect() method will wait for and or throw an error based on the connect outcome.
        Parameters:
        host - The remote host that this Transport should attempt to connect to.
        port - The port on the remote host that this Transport should attempt to bind to.
        listener - The TransportListener that will handle Transport 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 the Transport to connect to the remote that was indicated in the connect(String, int, TransportListener) call.
        Throws:
        java.lang.InterruptedException - If the wait mechanism was interrupted while waiting for a successful connect.
        java.io.IOException - If the Transport 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 produce ProtonBuffer 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 - A Runnable 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 - A Runnable 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.
      • 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 the connect(String, int, TransportListener) method this method returns null.
        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.