(httpHost.getHostName(), httpHost.getPort());
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected org.apache.http.HttpRequest getHttpRequest(final Object[] args) {
+ if (args[1] instanceof org.apache.http.HttpRequest) {
+ return (org.apache.http.HttpRequest) args[1];
+ } else {
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/AsyncInternalClientExecuteInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/AsyncInternalClientExecuteInterceptor.java
new file mode 100644
index 000000000..b52e151f4
--- /dev/null
+++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/AsyncInternalClientExecuteInterceptor.java
@@ -0,0 +1,100 @@
+package com.nhn.pinpoint.profiler.modifier.connector.httpclient4.interceptor;
+
+import org.apache.http.HttpHost;
+
+import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
+import com.nhn.pinpoint.bootstrap.pair.NameIntValuePair;
+
+/**
+ *
+ * suitable target method
+ *
+ *
+ * org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(HttpAsyncRequestProducer, HttpAsyncResponseConsumer, HttpContext, FutureCallback)
+ * org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute(HttpAsyncRequestProducer, HttpAsyncResponseConsumer, FutureCallback)
+ *
+ *
+ * original code of method.
+ *
+ *
+ *
+ * // org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute
+ * public Future execute(
+ * final org.apache.http.nio.protocol.HttpAsyncRequestProducer requestProducer,
+ * final org.apache.http.nio.protocol.HttpAsyncResponseConsumer responseConsumer,
+ * final org.apache.http.protocol.HttpContext context,
+ * final org.apache.http.concurrent.FutureCallback callback) {
+ *
+ * final Status status = getStatus();
+ * Asserts.check(status == Status.ACTIVE, "Request cannot be executed; I/O reactor status: %s", status);
+ *
+ * final BasicFuture future = new BasicFuture(callback);
+ * final HttpClientContext localcontext = HttpClientContext.adapt(context != null ? context : new BasicHttpContext());
+ * setupContext(localcontext);
+ *
+ * @SuppressWarnings("resource")
+ * final DefaultClientExchangeHandlerImpl handler = new DefaultClientExchangeHandlerImpl(
+ * this.log,
+ * requestProducer,
+ * responseConsumer,
+ * localcontext,
+ * future,
+ * this.connmgr,
+ * this.exec);
+ *
+ * try {
+ * handler.start();
+ * } catch (final Exception ex) {
+ * handler.failed(ex);
+ * }
+ * return future;
+ * }
+ *
+ * OR
+ *
+ * // org.apache.http.impl.nio.client.CloseableHttpAsyncClient.execute
+ * public Future execute(
+ * final HttpAsyncRequestProducer requestProducer,
+ * final HttpAsyncResponseConsumer responseConsumer,
+ * final FutureCallback callback) {
+ *
+ * return execute(requestProducer, responseConsumer, new BasicHttpContext(), callback);
+ * }
+ *
+ *
+ *
+ *
+ * @author netspider
+ *
+ */
+public class AsyncInternalClientExecuteInterceptor extends AbstractHttpRequestExecute implements TargetClassLoader {
+
+ @Override
+ protected NameIntValuePair getHost(Object[] args) {
+ if (!(args[0] instanceof org.apache.http.nio.protocol.HttpAsyncRequestProducer)) {
+ return null;
+ }
+
+ final org.apache.http.nio.protocol.HttpAsyncRequestProducer producer = (org.apache.http.nio.protocol.HttpAsyncRequestProducer) args[0];
+ final HttpHost httpHost = producer.getTarget();
+
+ return new NameIntValuePair(httpHost.getHostName(), httpHost.getPort());
+ }
+
+ @Override
+ protected org.apache.http.HttpRequest getHttpRequest(final Object[] args) {
+ if (!(args[0] instanceof org.apache.http.nio.protocol.HttpAsyncRequestProducer)) {
+ return null;
+ }
+ final org.apache.http.nio.protocol.HttpAsyncRequestProducer producer = (org.apache.http.nio.protocol.HttpAsyncRequestProducer) args[0];
+ try {
+ /**
+ * FIXME org.apache.http.nio.protocol.BasicAsyncRequestProducer.
+ * generateRequest() 는 문제가 되지 않지만 다른 구현체는 문제가 될 수 있다.
+ */
+ return producer.generateRequest();
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureCompletedInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureCompletedInterceptor.java
new file mode 100644
index 000000000..5c45eaadc
--- /dev/null
+++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureCompletedInterceptor.java
@@ -0,0 +1,97 @@
+package com.nhn.pinpoint.profiler.modifier.connector.httpclient4.interceptor;
+
+import com.nhn.pinpoint.bootstrap.context.Trace;
+import com.nhn.pinpoint.bootstrap.context.TraceContext;
+import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
+import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
+import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
+import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
+import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
+import com.nhn.pinpoint.bootstrap.logging.PLogger;
+import com.nhn.pinpoint.common.ServiceType;
+
+/**
+ *
+ * suitable method
+ *
+ * org.apache.http.concurrent.BasicFuture.completed(T)
+ *
+ *
+ * original code of method
+ *
+ *
+ * public boolean completed(final T result) {
+ * synchronized (this) {
+ * if (this.completed) {
+ * return false;
+ * }
+ * this.completed = true;
+ * this.result = result;
+ * notifyAll();
+ * }
+ * if (this.callback != null) {
+ * this.callback.completed(result);
+ * }
+ * return true;
+ * }
+ *
+ *
+ *
+ * @author netspider
+ *
+ */
+public class BasicFutureCompletedInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
+
+ protected PLogger logger;
+ protected boolean isDebug;
+
+ protected TraceContext traceContext;
+ protected MethodDescriptor descriptor;
+
+ @Override
+ public void before(Object target, Object[] args) {
+ if (isDebug) {
+ logger.beforeInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ trace.traceBlockBegin();
+ trace.markBeforeTime();
+ trace.recordServiceType(ServiceType.HTTP_CLIENT_INTERNAL);
+ }
+
+ @Override
+ public void after(Object target, Object[] args, Object result) {
+ if (isDebug) {
+ logger.afterInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ try {
+ trace.recordApi(descriptor);
+ trace.recordException(result);
+ trace.markAfterTime();
+ } finally {
+ trace.traceBlockEnd();
+ }
+ }
+
+ @Override
+ public void setTraceContext(TraceContext traceContext) {
+ this.traceContext = traceContext;
+ }
+
+ @Override
+ public void setMethodDescriptor(MethodDescriptor descriptor) {
+ this.descriptor = descriptor;
+ traceContext.cacheApi(descriptor);
+ }
+}
diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureFailedInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureFailedInterceptor.java
new file mode 100644
index 000000000..b2a082f22
--- /dev/null
+++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureFailedInterceptor.java
@@ -0,0 +1,97 @@
+package com.nhn.pinpoint.profiler.modifier.connector.httpclient4.interceptor;
+
+import com.nhn.pinpoint.bootstrap.context.Trace;
+import com.nhn.pinpoint.bootstrap.context.TraceContext;
+import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
+import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
+import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
+import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
+import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
+import com.nhn.pinpoint.bootstrap.logging.PLogger;
+import com.nhn.pinpoint.common.ServiceType;
+
+/**
+ *
+ * suitable method
+ *
+ * org.apache.http.concurrent.BasicFuture.failed(Exception)
+ *
+ *
+ * original code of method
+ *
+ *
+ * public boolean failed(final Exception exception) {
+ * synchronized (this) {
+ * if (this.completed) {
+ * return false;
+ * }
+ * this.completed = true;
+ * this.ex = exception;
+ * notifyAll();
+ * }
+ * if (this.callback != null) {
+ * this.callback.failed(exception);
+ * }
+ * return true;
+ * }
+ *
+ *
+ *
+ * @author netspider
+ *
+ */
+public class BasicFutureFailedInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
+
+ protected PLogger logger;
+ protected boolean isDebug;
+
+ protected TraceContext traceContext;
+ protected MethodDescriptor descriptor;
+
+ @Override
+ public void before(Object target, Object[] args) {
+ if (isDebug) {
+ logger.beforeInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ trace.traceBlockBegin();
+ trace.markBeforeTime();
+ trace.recordServiceType(ServiceType.HTTP_CLIENT_INTERNAL);
+ }
+
+ @Override
+ public void after(Object target, Object[] args, Object result) {
+ if (isDebug) {
+ logger.afterInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ try {
+ trace.recordApi(descriptor);
+ trace.recordException(result);
+ trace.markAfterTime();
+ } finally {
+ trace.traceBlockEnd();
+ }
+ }
+
+ @Override
+ public void setTraceContext(TraceContext traceContext) {
+ this.traceContext = traceContext;
+ }
+
+ @Override
+ public void setMethodDescriptor(MethodDescriptor descriptor) {
+ this.descriptor = descriptor;
+ traceContext.cacheApi(descriptor);
+ }
+}
diff --git a/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureGetInterceptor.java b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureGetInterceptor.java
new file mode 100644
index 000000000..15a2ee48d
--- /dev/null
+++ b/src/main/java/com/nhn/pinpoint/profiler/modifier/connector/httpclient4/interceptor/BasicFutureGetInterceptor.java
@@ -0,0 +1,113 @@
+package com.nhn.pinpoint.profiler.modifier.connector.httpclient4.interceptor;
+
+import com.nhn.pinpoint.bootstrap.context.Trace;
+import com.nhn.pinpoint.bootstrap.context.TraceContext;
+import com.nhn.pinpoint.bootstrap.interceptor.ByteCodeMethodDescriptorSupport;
+import com.nhn.pinpoint.bootstrap.interceptor.MethodDescriptor;
+import com.nhn.pinpoint.bootstrap.interceptor.SimpleAroundInterceptor;
+import com.nhn.pinpoint.bootstrap.interceptor.TargetClassLoader;
+import com.nhn.pinpoint.bootstrap.interceptor.TraceContextSupport;
+import com.nhn.pinpoint.bootstrap.logging.PLogger;
+import com.nhn.pinpoint.common.ServiceType;
+
+/**
+ * suitable method
+ *
+ *
+ * org.apache.http.concurrent.BasicFuture.get()
+ * org.apache.http.concurrent.BasicFuture.get(long, TimeUnit)
+ *
+ *
+ *
+ *
+ * public synchronized T get() throws InterruptedException, ExecutionException {
+ * while (!this.completed) {
+ * wait();
+ * }
+ * return getResult();
+ * }
+ *
+ * public synchronized T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+ * Args.notNull(unit, "Time unit");
+ * final long msecs = unit.toMillis(timeout);
+ * final long startTime = (msecs <= 0) ? 0 : System.currentTimeMillis();
+ * long waitTime = msecs;
+ * if (this.completed) {
+ * return getResult();
+ * } else if (waitTime <= 0) {
+ * throw new TimeoutException();
+ * } else {
+ * for (;;) {
+ * wait(waitTime);
+ * if (this.completed) {
+ * return getResult();
+ * } else {
+ * waitTime = msecs - (System.currentTimeMillis() - startTime);
+ * if (waitTime <= 0) {
+ * throw new TimeoutException();
+ * }
+ * }
+ * }
+ * }
+ * }
+ *
+ *
+ *
+ * @author netspider
+ *
+ */
+public class BasicFutureGetInterceptor implements SimpleAroundInterceptor, ByteCodeMethodDescriptorSupport, TraceContextSupport, TargetClassLoader {
+
+ protected PLogger logger;
+ protected boolean isDebug;
+
+ protected TraceContext traceContext;
+ protected MethodDescriptor descriptor;
+
+ @Override
+ public void before(Object target, Object[] args) {
+ if (isDebug) {
+ logger.beforeInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ trace.traceBlockBegin();
+ trace.markBeforeTime();
+ trace.recordServiceType(ServiceType.HTTP_CLIENT_INTERNAL);
+ }
+
+ @Override
+ public void after(Object target, Object[] args, Object result) {
+ if (isDebug) {
+ logger.afterInterceptor(target, args);
+ }
+
+ Trace trace = traceContext.currentTraceObject();
+ if (trace == null) {
+ return;
+ }
+
+ try {
+ trace.recordApi(descriptor);
+ trace.recordException(result);
+ trace.markAfterTime();
+ } finally {
+ trace.traceBlockEnd();
+ }
+ }
+
+ @Override
+ public void setTraceContext(TraceContext traceContext) {
+ this.traceContext = traceContext;
+ }
+
+ @Override
+ public void setMethodDescriptor(MethodDescriptor descriptor) {
+ this.descriptor = descriptor;
+ traceContext.cacheApi(descriptor);
+ }
+}