Class ProxyFilter

  • All Implemented Interfaces:
    IoFilter

    public class ProxyFilter
    extends IoFilterAdapter
    ProxyFilter.java - Proxy IoFilter. Automatically inserted into the IoFilter chain by ProxyConnector. Sends the initial handshake message to the proxy and handles any response to the handshake. Once the handshake has completed and the proxied connection has been established this filter becomes transparent to data flowing through the connection.

    Based upon SSLFilter from mina-filter-ssl.

    Since:
    MINA 2.0.0-M3
    Author:
    Apache MINA Project
    • Constructor Detail

      • ProxyFilter

        public ProxyFilter()
        Create a new ProxyFilter.
    • Method Detail

      • filterWrite

        public void filterWrite​(IoFilter.NextFilter nextFilter,
                                IoSession session,
                                WriteRequest writeRequest)
        Filters outgoing writes, queueing them up if necessary while a handshake is ongoing.
        Specified by:
        filterWrite in interface IoFilter
        Overrides:
        filterWrite in class IoFilterAdapter
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        writeRequest - the data to write
      • writeData

        public void writeData​(IoFilter.NextFilter nextFilter,
                              IoSession session,
                              WriteRequest writeRequest,
                              boolean isHandshakeData)
        Actually write data. Queues the data up unless it relates to the handshake or the handshake is done.
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        writeRequest - the data to write
        isHandshakeData - true if writeRequest is written by the proxy classes.
      • messageSent

        public void messageSent​(IoFilter.NextFilter nextFilter,
                                IoSession session,
                                WriteRequest writeRequest)
                         throws Exception
        Filter handshake related messages from reaching the messageSent callbacks of downstream filters.
        Specified by:
        messageSent in interface IoFilter
        Overrides:
        messageSent in class IoFilterAdapter
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        writeRequest - the data written
        Throws:
        Exception - If an error occurred while processing the event
      • sessionCreated

        public void sessionCreated​(IoFilter.NextFilter nextFilter,
                                   IoSession session)
                            throws Exception
        Called when the session is created. Will create the handler able to handle the ProxyIoSession.getRequest() request stored in the session. Event is stored in an IoSessionEventQueue for later delivery to the next filter in the chain when the handshake would have succeed. This will prevent the rest of the filter chain from being affected by this filter internals. Please note that this event can occur multiple times because of some http proxies not handling keep-alive connections thus needing multiple sessions during the handshake.
        Specified by:
        sessionCreated in interface IoFilter
        Overrides:
        sessionCreated in class IoFilterAdapter
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        Throws:
        Exception - If an error occurred while processing the event
      • sessionOpened

        public void sessionOpened​(IoFilter.NextFilter nextFilter,
                                  IoSession session)
                           throws Exception
        Event is stored in an IoSessionEventQueue for later delivery to the next filter in the chain when the handshake would have succeed. This will prevent the rest of the filter chain from being affected by this filter internals.
        Specified by:
        sessionOpened in interface IoFilter
        Overrides:
        sessionOpened in class IoFilterAdapter
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        Throws:
        Exception - If an error occurred while processing the event
      • sessionClosed

        public void sessionClosed​(IoFilter.NextFilter nextFilter,
                                  IoSession session)
                           throws Exception
        Event is stored in an IoSessionEventQueue for later delivery to the next filter in the chain when the handshake would have succeed. This will prevent the rest of the filter chain from being affected by this filter internals.
        Specified by:
        sessionClosed in interface IoFilter
        Overrides:
        sessionClosed in class IoFilterAdapter
        Parameters:
        nextFilter - the next filter in filter chain
        session - the session object
        Throws:
        Exception - If an error occurred while processing the event