T - the self typepublic abstract class RequestContextWrapper<T extends RequestContext> extends AbstractRequestContext
RequestContext.| Modifier | Constructor and Description |
|---|---|
protected |
RequestContextWrapper(T delegate)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
io.netty.buffer.ByteBufAllocator |
alloc()
Returns the
ByteBufAllocator for this RequestContext. |
<V> io.netty.util.Attribute<V> |
attr(io.netty.util.AttributeKey<V> key) |
Iterator<io.netty.util.Attribute<?>> |
attrs()
Returns all
Attributes set in this context. |
String |
decodedPath()
Returns the absolute path part of the current
Request URI, excluding the query part,
decoded in UTF-8. |
protected T |
delegate()
Returns the delegate context.
|
io.netty.channel.EventLoop |
eventLoop()
Returns the
EventLoop that is handling the current Request. |
<V> boolean |
hasAttr(io.netty.util.AttributeKey<V> key) |
RequestId |
id()
|
void |
invokeOnChildCallbacks(RequestContext newCtx)
Invokes all
RequestContext.onChild(BiConsumer) callbacks. |
void |
invokeOnEnterCallbacks()
Invokes all
RequestContext.onEnter(Consumer) callbacks. |
void |
invokeOnExitCallbacks()
Invokes all
RequestContext.onExit(Consumer) callbacks. |
<A extends SocketAddress> |
localAddress()
Returns the local address of this request, or
null if the connection is not established yet. |
RequestLog |
log()
Returns the
RequestLog that contains the information about the current Request. |
RequestLogBuilder |
logBuilder()
Returns the
RequestLogBuilder that collects the information about the current Request. |
MeterRegistry |
meterRegistry()
Returns the
MeterRegistry that collects various stats. |
HttpMethod |
method()
Returns the HTTP method of the current
Request. |
void |
onChild(BiConsumer<? super RequestContext,? super RequestContext> callback)
Registers
callback to be run when this context is replaced by a child context. |
void |
onEnter(Consumer<? super RequestContext> callback)
Registers
callback to be run when re-entering this RequestContext, usually when using
the RequestContext.makeContextAware(java.util.concurrent.Executor) family of methods. |
void |
onExit(Consumer<? super RequestContext> callback)
Registers
callback to be run when re-exiting this RequestContext, usually when using
the RequestContext.makeContextAware(java.util.concurrent.Executor) family of methods. |
String |
path()
|
String |
query()
Returns the query part of the current
Request URI, without the leading '?' |
<A extends SocketAddress> |
remoteAddress()
Returns the remote address of this request, or
null if the connection is not established yet. |
HttpRequest |
request()
Returns the
HttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet. |
RpcRequest |
rpcRequest()
Returns the
RpcRequest associated with this context, or null if there's no
RpcRequest associated with this context. |
SessionProtocol |
sessionProtocol()
Returns the
SessionProtocol of the current Request. |
SSLSession |
sslSession()
The
SSLSession for this request if the connection is made over TLS, or null if
the connection is not established yet or the connection is not a TLS connection. |
void |
updateRequest(HttpRequest req)
Replaces the
HttpRequest associated with this context with the specified one. |
void |
updateRpcRequest(RpcRequest rpcReq)
Replaces the
RpcRequest associated with this context with the specified one. |
contextAwareEventLoop, contextAwareExecutor, equals, executor, hashCode, isTimedOut, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, makeContextAware, onEnter, onExit, push, push, pushIfAbsent, rejectPromise, resolvePromise, setTimedOutclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitcurrent, currentOrNull, mapCurrent, newDerivedContext, push, pushprotected RequestContextWrapper(T delegate)
protected final T delegate()
public HttpRequest request()
RequestContextHttpRequest associated with this context, or null if there's no
HttpRequest associated with this context yet.@Nullable public RpcRequest rpcRequest()
RequestContextRpcRequest associated with this context, or null if there's no
RpcRequest associated with this context.public void updateRequest(HttpRequest req)
RequestContextHttpRequest associated with this context with the specified one.
This method is useful to a decorator that manipulates HTTP request headers.
Note that it is a bad idea to change the values of the pseudo headers (":method",
":path", ":scheme" and ":authority") when replacing an HttpRequest,
because the properties of this context, such as RequestContext.path(), are unaffected by such an attempt.
public void updateRpcRequest(RpcRequest rpcReq)
RequestContextRpcRequest associated with this context with the specified one.
This method is useful to a decorator that manipulates an RPC call.public SessionProtocol sessionProtocol()
RequestContextSessionProtocol of the current Request.@Nullable public <A extends SocketAddress> A remoteAddress()
RequestContextnull if the connection is not established yet.@Nullable public <A extends SocketAddress> A localAddress()
RequestContextnull if the connection is not established yet.@Nullable public SSLSession sslSession()
RequestContextSSLSession for this request if the connection is made over TLS, or null if
the connection is not established yet or the connection is not a TLS connection.public RequestId id()
RequestContextpublic HttpMethod method()
RequestContextRequest.public String path()
RequestContextpublic String decodedPath()
RequestContextRequest URI, excluding the query part,
decoded in UTF-8.public String query()
RequestContextpublic RequestLog log()
RequestContextRequestLog that contains the information about the current Request.public RequestLogBuilder logBuilder()
RequestContextRequestLogBuilder that collects the information about the current Request.public MeterRegistry meterRegistry()
RequestContextMeterRegistry that collects various stats.public Iterator<io.netty.util.Attribute<?>> attrs()
RequestContextAttributes set in this context.public io.netty.channel.EventLoop eventLoop()
RequestContextEventLoop that is handling the current Request.public void onEnter(Consumer<? super RequestContext> callback)
RequestContextcallback to be run when re-entering this RequestContext, usually when using
the RequestContext.makeContextAware(java.util.concurrent.Executor) family of methods. Any thread-local state associated with this context
should be restored by this callback.callback - a Consumer whose argument is this contextpublic void onExit(Consumer<? super RequestContext> callback)
RequestContextcallback to be run when re-exiting this RequestContext, usually when using
the RequestContext.makeContextAware(java.util.concurrent.Executor) family of methods. Any thread-local state associated with this context
should be reset by this callback.callback - a Consumer whose argument is this contextpublic void onChild(BiConsumer<? super RequestContext,? super RequestContext> callback)
RequestContextcallback to be run when this context is replaced by a child context.
You could use this method to inherit an attribute of this context to the child contexts or
register a callback to the child contexts that may be created later:
ctx.onChild((curCtx, newCtx) -> {
assert ctx == curCtx && curCtx != newCtx;
// Inherit the value of the 'MY_ATTR' attribute to the child context.
newCtx.attr(MY_ATTR).set(curCtx.attr(MY_ATTR).get());
// Add a callback to the child context.
newCtx.onExit(() -> { ... });
});
callback - a BiConsumer whose first argument is this context and
whose second argument is the new context that replaces this contextpublic void invokeOnEnterCallbacks()
RequestContextRequestContext.onEnter(Consumer) callbacks. It is discouraged to use this method directly.
Use RequestContext.makeContextAware(Runnable) or RequestContext.push(boolean) instead so that the callbacks are
invoked automatically.public void invokeOnExitCallbacks()
RequestContextRequestContext.onExit(Consumer) callbacks. It is discouraged to use this method directly.
Use RequestContext.makeContextAware(Runnable) or RequestContext.push(boolean) instead so that the callbacks are
invoked automatically.public void invokeOnChildCallbacks(RequestContext newCtx)
RequestContextRequestContext.onChild(BiConsumer) callbacks. It is discouraged to use this method directly.
Use RequestContext.makeContextAware(Runnable) or RequestContext.push(boolean) instead so that the callbacks are
invoked automatically.public <V> io.netty.util.Attribute<V> attr(io.netty.util.AttributeKey<V> key)
public <V> boolean hasAttr(io.netty.util.AttributeKey<V> key)
public io.netty.buffer.ByteBufAllocator alloc()
RequestContextByteBufAllocator for this RequestContext. Any buffers created by this
ByteBufAllocator must be
reference-counted. If you don't know
what this means, you should probably use byte[] or ByteBuffer directly instead
of calling this method.Copyright © 2020 LeanCloud. All rights reserved.