Class BootHttpRequestHandler
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
org.summerboot.jexpress.nio.server.NioServerHttpRequestHandler
org.summerboot.jexpress.nio.server.BootHttpRequestHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,ErrorAuditor
- Direct Known Subclasses:
DefaultHttpRequestHandler
- Version:
- 2.0
- Author:
- Changski Tie Zheng Zhang 张铁铮, 魏泽北, 杜旺财, 杜富贵
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected static SMTPClientConfigprotected HealthInspectorprotected PostOfficeFields inherited from class org.summerboot.jexpress.nio.server.NioServerHttpRequestHandler
log, nioCfg -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterLogging(io.netty.handler.codec.http.HttpHeaders httpHeaders, io.netty.handler.codec.http.HttpMethod httpMethod, String httpRequestUri, String httpPostRequestBody, ServiceContext context, long queuingTime, long processTime, long responseTime, long responseContentLength, String logContent, Throwable ioEx) protected voidafterService(RequestProcessor processor, io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) protected abstract booleanauthenticationCheck(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) create User object based on token in the header, then set User object to contextprotected StringbeforeLogging(String log) beforeSendingError(String errorContent) protected HealthInspectorprotected voidnak(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage) protected voidnakError(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage, Throwable ex) Build negative acknowledgement context with exception at ERROR level when ex is not nullprotected voidnakFatal(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage, Throwable ex, Collection<String> emailTo, String content) Build negative acknowledgement context with exception at FATAL level, no matter ex is null or notprotected voidonActionNotFound(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) protected voidonHttpConnectTimeoutException(HttpConnectTimeoutException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) Happens when a connection, over which an HttpRequest is intended to be sent, is not successfully established within a specified time period.protected voidonHttpTimeoutException(HttpTimeoutException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) Happens when a context is not received within a specified time period.protected voidonInterruptedException(InterruptedException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) protected voidonIOException(Throwable ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) protected voidonNamingException(NamingException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) protected voidonPersistenceException(jakarta.persistence.PersistenceException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) protected voidonRejectedExecutionException(Throwable ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) protected voidonUnexpectedException(Throwable ex, RequestProcessor processor, io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) protected abstract booleanpreProcess(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) do any validation checks before processingprotected voidprotectAuthToken(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders) protected voidservice(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) Methods inherited from class org.summerboot.jexpress.nio.server.NioServerHttpRequestHandler
channelActive, channelInactive, channelRead0, channelReadComplete, exceptionCaught, getRequestProcessor, userEventTriggeredMethods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRegistered, channelUnregistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
BINDING_NAME
- See Also:
-
po
-
healthInspector
-
cmtpCfg
-
-
Constructor Details
-
BootHttpRequestHandler
public BootHttpRequestHandler()
-
-
Method Details
-
service
protected void service(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) - Specified by:
servicein classNioServerHttpRequestHandler
-
authenticationCheck
protected abstract boolean authenticationCheck(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) throws Exception create User object based on token in the header, then set User object to context- Parameters:
processor-httpRequestHeaders-httpRequestPath-context-- Returns:
- true if good to preProcess (caller is verified), otherwise false
- Throws:
Exception
-
preProcess
protected abstract boolean preProcess(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) throws Exception do any validation checks before processing- Parameters:
processor-httpRequestHeaders-httpRequestPath-context-- Returns:
- true if good to process request, otherwise false
- Throws:
Exception
-
onActionNotFound
protected void onActionNotFound(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) -
onNamingException
protected void onNamingException(NamingException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) -
onPersistenceException
protected void onPersistenceException(jakarta.persistence.PersistenceException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) -
onHttpConnectTimeoutException
protected void onHttpConnectTimeoutException(HttpConnectTimeoutException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) Happens when a connection, over which an HttpRequest is intended to be sent, is not successfully established within a specified time period.- Parameters:
ex-httptMethod-httpRequestPath-context-
-
onHttpTimeoutException
protected void onHttpTimeoutException(HttpTimeoutException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) Happens when a context is not received within a specified time period.- Parameters:
ex-httptMethod-httpRequestPath-context-
-
onRejectedExecutionException
protected void onRejectedExecutionException(Throwable ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) -
onIOException
protected void onIOException(Throwable ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) -
getHealthInspector
-
onInterruptedException
protected void onInterruptedException(InterruptedException ex, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, ServiceContext context) -
onUnexpectedException
protected void onUnexpectedException(Throwable ex, RequestProcessor processor, io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) -
afterService
protected void afterService(RequestProcessor processor, io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders, io.netty.handler.codec.http.HttpMethod httptMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) -
protectAuthToken
protected void protectAuthToken(RequestProcessor processor, io.netty.handler.codec.http.HttpHeaders httpRequestHeaders) -
beforeLogging
- Specified by:
beforeLoggingin classNioServerHttpRequestHandler
-
afterLogging
protected void afterLogging(io.netty.handler.codec.http.HttpHeaders httpHeaders, io.netty.handler.codec.http.HttpMethod httpMethod, String httpRequestUri, String httpPostRequestBody, ServiceContext context, long queuingTime, long processTime, long responseTime, long responseContentLength, String logContent, Throwable ioEx) throws Exception - Specified by:
afterLoggingin classNioServerHttpRequestHandler- Throws:
Exception
-
nak
protected void nak(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage) -
nakError
protected void nakError(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage, Throwable ex) Build negative acknowledgement context with exception at ERROR level when ex is not null- Parameters:
context-httpResponseStatus-appErrorCode-errorMessage-ex-
-
nakFatal
protected void nakFatal(ServiceContext context, io.netty.handler.codec.http.HttpResponseStatus httpResponseStatus, int appErrorCode, String errorMessage, Throwable ex, Collection<String> emailTo, String content) Build negative acknowledgement context with exception at FATAL level, no matter ex is null or not- Parameters:
context-httpResponseStatus-appErrorCode-errorMessage-ex-emailTo-content-
-
beforeSendingError
-