Example usage for org.apache.http.nio.reactor IOSession ATTACHMENT_KEY

List of usage examples for org.apache.http.nio.reactor IOSession ATTACHMENT_KEY

Introduction

In this page you can find the example usage for org.apache.http.nio.reactor IOSession ATTACHMENT_KEY.

Prototype

String ATTACHMENT_KEY

To view the source code for org.apache.http.nio.reactor IOSession ATTACHMENT_KEY.

Click Source Link

Document

Name of the context attribute key, which can be used to obtain the session attachment object.

Usage

From source file:org.apache.synapse.transport.nhttp.ClientIODispatch.java

@Override
protected DefaultNHttpClientConnection createConnection(final IOSession session) {
    Axis2HttpRequest axis2Req = (Axis2HttpRequest) session.getAttribute(IOSession.ATTACHMENT_KEY);
    HttpRoute route = axis2Req.getRoute();
    return this.connFactory.createConnection(session, route);
}

From source file:org.apache.synapse.transport.passthru.ClientIODispatch.java

@Override
protected DefaultNHttpClientConnection createConnection(final IOSession session) {
    HostConnections hostConnections = (HostConnections) session.getAttribute(IOSession.ATTACHMENT_KEY);
    HttpRoute route = hostConnections.getRoute();
    return this.connFactory.createConnection(session, route);
}

From source file:org.apache.axis2.transport.nhttp.PlainClientIOEventDispatch.java

public void connected(final IOSession session) {
    // Decorate I/O session with logging capabilities
    LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(session),
            new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params);
    session.setAttribute(NHTTP_CONN, conn);

    Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
    this.handler.connected(conn, attachment);
}

From source file:org.apache.synapse.transport.nhttp.ClientIODispatch.java

@Override
protected void onConnected(final DefaultNHttpClientConnection conn) {
    Axis2HttpRequest axis2Req = (Axis2HttpRequest) conn.getContext().getAttribute(IOSession.ATTACHMENT_KEY);
    try {/*from   ww  w  .j a v a  2 s . co  m*/
        this.handler.connected(conn, axis2Req);
    } catch (final Exception ex) {
        this.handler.exception(conn, ex);
    }
}

From source file:org.apache.synapse.transport.passthru.ClientIODispatch.java

@Override
protected void onConnected(final DefaultNHttpClientConnection conn) {
    HostConnections hostConnections = (HostConnections) conn.getContext()
            .getAttribute(IOSession.ATTACHMENT_KEY);
    try {// www  .  j  a v a 2 s. c o m
        this.handler.connected(conn, hostConnections);
    } catch (final Exception ex) {
        this.handler.exception(conn, ex);
    }
}

From source file:org.apache.axis2.transport.nhttp.SSLClientIOEventDispatch.java

public void connected(final IOSession session) {

    SSLIOSession sslSession = new SSLIOSession(session, this.sslcontext, this.sslHandler);

    LoggingNHttpClientConnection conn = new LoggingNHttpClientConnection(new LoggingIOSession(sslSession),
            new DefaultHttpResponseFactory(), new HeapByteBufferAllocator(), this.params);

    session.setAttribute(NHTTP_CONN, conn);
    session.setAttribute(SSL_SESSION, sslSession);

    Object attachment = session.getAttribute(IOSession.ATTACHMENT_KEY);
    this.handler.connected(conn, attachment);

    try {/*from  w w  w. jav a 2 s  . c  o  m*/
        sslSession.bind(SSLMode.CLIENT, this.params);
    } catch (SSLException ex) {
        this.handler.exception(conn, ex);
        sslSession.shutdown();
    }
}

From source file:org.apache.http.impl.nio.client.InternalIODispatch.java

@Override
protected void onConnected(final DefaultNHttpClientConnection conn) {
    final Object attachment = conn.getContext().getAttribute(IOSession.ATTACHMENT_KEY);
    try {/*  w w  w .  j a v a2s.  com*/
        this.handler.connected(conn, attachment);
    } catch (final Exception ex) {
        this.handler.exception(conn, ex);
    }
}