diff options
author | gjoranv <gv@verizonmedia.com> | 2021-12-14 16:39:15 +0100 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2021-12-14 16:41:08 +0100 |
commit | cf12240836eb451ae3d0b6f3ed84620f25e5eb77 (patch) | |
tree | 8b1f1576f6f05e819193c8039d246b1ecb16e156 /container-core/src/main/java/com/yahoo | |
parent | d2161e04cf9d5addc50d1e39ed8a9febb9ee72b8 (diff) |
Move the Context class to ThreadedHttpRequestHandler
- Add new ctor that takes a Context
Diffstat (limited to 'container-core/src/main/java/com/yahoo')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java | 38 | ||||
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/jdisc/ThreadedHttpRequestHandler.java | 44 |
2 files changed, 44 insertions, 38 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java b/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java index 717bde1eb5e..ed884d104ed 100644 --- a/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java +++ b/container-core/src/main/java/com/yahoo/container/jdisc/LoggingRequestHandler.java @@ -29,44 +29,6 @@ import java.util.logging.Level; // TODO Vespa 8: Remove deprecated constructors public abstract class LoggingRequestHandler extends ThreadedHttpRequestHandler { - public static class Context { - - final Executor executor; - final Metric metric; - - /** @deprecated Use {@link #Context(Executor, Metric)} instead */ - @Deprecated(forRemoval = true, since = "7") - public Context(Executor executor, AccessLog ignored, Metric metric) { - this(executor, metric); - } - - @Inject - public Context(Executor executor, Metric metric) { - this.executor = executor; - this.metric = metric; - } - - public Context(Context other) { - this.executor = other.executor; - this.metric = other.metric; - } - - public Executor getExecutor() { return executor; } - @Deprecated(forRemoval = true, since = "7") public AccessLog getAccessLog() { return null; } - public Metric getMetric() { return metric; } - - } - - public static Context testOnlyContext() { - return new Context(new Executor() { - @Override - public void execute(Runnable command) { - command.run(); - } - }, - null); - } - @Inject public LoggingRequestHandler(Context ctx) { this(ctx.executor, ctx.metric); diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/ThreadedHttpRequestHandler.java b/container-core/src/main/java/com/yahoo/container/jdisc/ThreadedHttpRequestHandler.java index 0c3c1e2120b..3cd20f64ca1 100644 --- a/container-core/src/main/java/com/yahoo/container/jdisc/ThreadedHttpRequestHandler.java +++ b/container-core/src/main/java/com/yahoo/container/jdisc/ThreadedHttpRequestHandler.java @@ -2,6 +2,7 @@ package com.yahoo.container.jdisc; import com.google.inject.Inject; +import com.yahoo.container.logging.AccessLog; import com.yahoo.jdisc.Metric; import com.yahoo.jdisc.Request; import com.yahoo.jdisc.handler.BufferedContentChannel; @@ -47,6 +48,11 @@ public abstract class ThreadedHttpRequestHandler extends ThreadedRequestHandler this(executor, metric, false); } + // TODO: move Inject annotation here! + public ThreadedHttpRequestHandler(Context context) { + this(context.executor, context.metric); + } + public ThreadedHttpRequestHandler(Executor executor, Metric metric, boolean allowAsyncResponse) { super(executor, metric, allowAsyncResponse); log = Logger.getLogger(this.getClass().getName()); @@ -250,4 +256,42 @@ public abstract class ThreadedHttpRequestHandler extends ThreadedRequestHandler } + public static Context testOnlyContext() { + return new Context(new Executor() { + @Override + public void execute(Runnable command) { + command.run(); + } + }, + null); + } + + public static class Context { + + final Executor executor; + final Metric metric; + + /** @deprecated Use {@link #Context(Executor, Metric)} instead */ + @Deprecated(forRemoval = true, since = "7") + public Context(Executor executor, AccessLog ignored, Metric metric) { + this(executor, metric); + } + + @Inject + public Context(Executor executor, Metric metric) { + this.executor = executor; + this.metric = metric; + } + + public Context(Context other) { + this.executor = other.executor; + this.metric = other.metric; + } + + public Executor getExecutor() { return executor; } + @Deprecated(forRemoval = true, since = "7") public AccessLog getAccessLog() { return null; } + public Metric getMetric() { return metric; } + + } + } |