List of usage examples for org.apache.http.nio NHttpConnection getContext
HttpContext getContext();
From source file:org.apache.synapse.transport.passthru.TargetContext.java
public static void setRequest(NHttpConnection conn, TargetRequest request) { TargetContext info = (TargetContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (info != null) { info.setRequest(request);//from w w w.j a va2 s . c o m } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.TargetContext.java
public static void setResponse(NHttpConnection conn, TargetResponse response) { TargetContext info = (TargetContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (info != null) { info.setResponse(response);//www . j a v a 2s.c o m } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static boolean assertState(NHttpConnection conn, ProtocolState state) { SourceContext info = (SourceContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); return info != null && info.getState() == state; }
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static void setRequest(NHttpConnection conn, SourceRequest request) { SourceContext info = (SourceContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (info != null) { info.setRequest(request);//from w w w .ja va 2 s . co m } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static void setResponse(NHttpConnection conn, SourceResponse response) { SourceContext info = (SourceContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (info != null) { info.setResponse(response);/*www .jav a2 s .co m*/ } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static void updateState(NHttpConnection conn, ProtocolState state) { SourceContext sourceContext = (SourceContext) conn.getContext().getAttribute(CONNECTION_INFORMATION); if (sourceContext != null) { if (sourceContext.getSourceConfiguration().isCorrelationLoggingEnabled()) { long lastStateUpdateTime = sourceContext.getLastStateUpdatedTime(); String url = "", method = ""; if (sourceContext.getRequest() != null) { url = sourceContext.getRequest().getUri(); method = sourceContext.getRequest().getMethod(); } else { HttpRequest httpRequest = conn.getHttpRequest(); if (httpRequest != null) { url = httpRequest.getRequestLine().getUri(); method = httpRequest.getRequestLine().getMethod(); }//w w w.j a v a2 s. co m } if ((method.length() != 0) && (url.length() != 0)) { MDC.put(PassThroughConstants.CORRELATION_MDC_PROPERTY, conn.getContext().getAttribute(PassThroughConstants.CORRELATION_ID).toString()); correlationLog.info((sourceContext.updateLastStateUpdatedTime() - lastStateUpdateTime) + "|HTTP State Transition|" + conn.getContext().getAttribute("http.connection") + "|" + method + "|" + url + "|" + state.name()); MDC.remove(PassThroughConstants.CORRELATION_MDC_PROPERTY); } } sourceContext.setState(state); } else { throw new IllegalStateException("Connection information should be present"); } }
From source file:org.apache.synapse.transport.passthru.TargetContext.java
public static void create(NHttpConnection conn, ProtocolState state, TargetConfiguration configuration) { TargetContext targetContext = new TargetContext(configuration); conn.getContext().setAttribute(CONNECTION_INFORMATION, targetContext); targetContext.setState(state);//from w ww . j a v a 2 s . co m if (targetContext.getTargetConfiguration().isCorrelationLoggingEnabled()) { targetContext.updateLastStateUpdatedTime(); } }
From source file:org.apache.synapse.transport.passthru.SourceContext.java
public static void create(NHttpConnection conn, ProtocolState state, SourceConfiguration configuration) { SourceContext sourceContext = new SourceContext(configuration); conn.getContext().setAttribute(CONNECTION_INFORMATION, sourceContext); sourceContext.setState(state);// www. ja v a2s.c om if (sourceContext.getSourceConfiguration().isCorrelationLoggingEnabled()) { sourceContext.updateLastStateUpdatedTime(); } }
From source file:org.jclouds.http.httpnio.pool.NioHttpCommandConnectionPool.java
@Override protected void associateHandleWithConnection(HttpCommandConnectionHandle<NHttpConnection> handle, NHttpConnection connection) { connection.getContext().setAttribute("command-handle", handle); }
From source file:org.jclouds.http.httpnio.pool.NioHttpCommandConnectionPool.java
@Override protected NioHttpCommandConnectionHandle getHandleFromConnection(NHttpConnection connection) { return (NioHttpCommandConnectionHandle) connection.getContext().getAttribute("command-handle"); }