- java.lang.Object
-
- org.redkale.net.Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
- org.redkale.net.http.HttpServer
-
public class HttpServer extends Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
Http服务器详情见: https://redkale.org
- 作者:
- zhangjx
-
-
字段概要
字段 修饰符和类型 字段 说明 protected ExecutorService
workExecutor
-
从类继承的字段 org.redkale.net.Server
address, aliveTimeoutSeconds, application, backlog, bufferCapacity, bufferPoolSize, charset, config, context, dispatcher, logger, maxBody, maxConns, maxHeader, name, netprotocol, readTimeoutSeconds, RESNAME_SERVER_ROOT, resourceFactory, responsePoolSize, serverChannel, serverClassLoader, serverStartTime, sslBuilder, sslContext, writeTimeoutSeconds
-
-
构造器概要
构造器 构造器 说明 HttpServer()
HttpServer(Application application)
HttpServer(Application application, long serverStartTime, ResourceFactory resourceFactory)
HttpServer(ResourceFactory resourceFactory)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
addForbidURIRegex(String urlreg)
屏蔽请求URL的正则表达式HttpServer
addHttpFilter(HttpFilter filter, AnyValue conf)
添加HttpFilterHttpServer
addHttpServlet(String mapping, BiConsumer<HttpRequest,HttpResponse> consumer)
添加HttpServletHttpServer
addHttpServlet(String mapping, HttpServlet servlet)
添加HttpServletHttpServer
addHttpServlet(String prefix, HttpServlet servlet, String... mappings)
添加HttpServletHttpServer
addHttpServlet(HttpServlet servlet, String... mappings)
添加HttpServletHttpServer
addHttpServlet(HttpServlet servlet, String prefix, AnyValue conf, String... mappings)
添加HttpServlet<S extends Service,T extends HttpServlet>
TaddRestServlet(ClassLoader classLoader, String name, S service, Class userType, Class<T> baseServletType, String prefix)
添加RestServlet<S extends Service,T extends HttpServlet>
TaddRestServlet(ClassLoader classLoader, S service, Class userType, Class<T> baseServletType, String prefix)
添加RestServlet<S extends WebSocket,T extends WebSocketServlet>
TaddRestWebSocketServlet(ClassLoader classLoader, Class<S> webSocketType, MessageAgent messageAgent, String prefix, AnyValue conf)
添加WebSocketServletprotected HttpContext
createContext()
protected ByteBufferPool
createSafeBufferPool(LongAdder createCounter, LongAdder cycleCounter, int bufferPoolSize)
protected ObjectPool<HttpResponse>
createSafeResponsePool(LongAdder createCounter, LongAdder cycleCounter, int responsePoolSize)
void
destroy(AnyValue config)
List<HttpFilter>
getHttpFilters()
List<HttpServlet>
getHttpServlets()
HttpResourceServlet
getResourceServlet()
获取静态资源HttpServletHttpResponse.HttpResponseConfig
getResponseConfig()
void
init(AnyValue config)
protected void
postPrepareInit()
protected void
postStart()
boolean
removeForbidURIRegex(String urlreg)
删除屏蔽请求URL的正则表达式<T extends HttpFilter>
TremoveHttpFilter(Class<T> filterClass)
删除HttpFilter<T extends WebSocket>
HttpServletremoveHttpServlet(Class<T> websocketOrServletType)
删除HttpServletHttpServlet
removeHttpServlet(Service service)
删除HttpServletprotected String
startExtLog()
-
从类继承的方法 org.redkale.net.Server
addServlet, changeAddress, changeAliveTimeoutSeconds, changeCharset, changeMaxBody, changeMaxconns, changeMaxHeader, changeReadTimeoutSeconds, changeWriteTimeoutSeconds, containsFilter, containsFilter, containsServlet, containsServlet, destroyFilter, destroyServlet, formatLenth, getAliveTimeoutSeconds, getAsyncGroup, getBacklog, getBufferCapacity, getBufferPoolSize, getCharset, getClosedConnectionCount, getConfBufferCapacity, getConfBufferPoolSize, getConfNetprotocol, getContext, getCreateConnectionCount, getDispatcherServlet, getLivingConnectionCount, getLogger, getMaxBody, getMaxConns, getMaxHeader, getName, getNetprotocol, getReadTimeoutSeconds, getResourceFactory, getResponsePoolSize, getServerClassLoader, getServerStartTime, getSocketAddress, getWriteTimeoutSeconds, initContextConfig, loadLib, parseLenth, parseLenth, setServerClassLoader, shutdown, start
-
-
-
-
字段详细资料
-
workExecutor
protected ExecutorService workExecutor
-
-
构造器详细资料
-
HttpServer
public HttpServer()
-
HttpServer
public HttpServer(ResourceFactory resourceFactory)
-
HttpServer
public HttpServer(Application application)
-
HttpServer
public HttpServer(Application application, long serverStartTime, ResourceFactory resourceFactory)
-
-
方法详细资料
-
init
public void init(AnyValue config) throws Exception
- 覆盖:
init
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
- 抛出:
Exception
-
postStart
protected void postStart()
- 覆盖:
postStart
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
destroy
public void destroy(AnyValue config) throws Exception
- 覆盖:
destroy
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
- 抛出:
Exception
-
startExtLog
protected String startExtLog()
- 覆盖:
startExtLog
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
getHttpServlets
public List<HttpServlet> getHttpServlets()
-
getHttpFilters
public List<HttpFilter> getHttpFilters()
-
getResponseConfig
public HttpResponse.HttpResponseConfig getResponseConfig()
-
getResourceServlet
public HttpResourceServlet getResourceServlet()
获取静态资源HttpServlet- 返回:
- HttpServlet
-
removeHttpServlet
public HttpServlet removeHttpServlet(Service service)
删除HttpServlet- 参数:
service
- Service- 返回:
- HttpServlet
-
removeHttpServlet
public <T extends WebSocket> HttpServlet removeHttpServlet(Class<T> websocketOrServletType)
删除HttpServlet- 类型参数:
T
- 泛型- 参数:
websocketOrServletType
- Class- 返回:
- HttpServlet
-
addForbidURIRegex
public boolean addForbidURIRegex(String urlreg)
屏蔽请求URL的正则表达式- 参数:
urlreg
- 正则表达式- 返回:
- 是否成功
-
removeForbidURIRegex
public boolean removeForbidURIRegex(String urlreg)
删除屏蔽请求URL的正则表达式- 参数:
urlreg
- 正则表达式- 返回:
- 是否成功
-
removeHttpFilter
public <T extends HttpFilter> T removeHttpFilter(Class<T> filterClass)
删除HttpFilter- 类型参数:
T
- 泛型- 参数:
filterClass
- HttpFilter类- 返回:
- HttpFilter
-
addHttpFilter
public HttpServer addHttpFilter(HttpFilter filter, AnyValue conf)
添加HttpFilter- 参数:
filter
- HttpFilterconf
- AnyValue- 返回:
- HttpServer
-
addHttpServlet
public HttpServer addHttpServlet(String mapping, HttpServlet servlet)
添加HttpServlet- 参数:
mapping
- 匹配规则servlet
- HttpServlet- 返回:
- HttpServer
-
addHttpServlet
public HttpServer addHttpServlet(String mapping, BiConsumer<HttpRequest,HttpResponse> consumer)
添加HttpServlet- 参数:
mapping
- 匹配规则consumer
- HttpServlet- 返回:
- HttpServer
-
addHttpServlet
public HttpServer addHttpServlet(String prefix, HttpServlet servlet, String... mappings)
添加HttpServlet- 参数:
prefix
- url前缀servlet
- HttpServletmappings
- 匹配规则- 返回:
- HttpServer
-
addHttpServlet
public HttpServer addHttpServlet(HttpServlet servlet, String... mappings)
添加HttpServlet- 参数:
servlet
- HttpServletmappings
- 匹配规则- 返回:
- HttpServer
-
addHttpServlet
public HttpServer addHttpServlet(HttpServlet servlet, String prefix, AnyValue conf, String... mappings)
添加HttpServlet- 参数:
prefix
- url前缀servlet
- HttpServletconf
- 配置信息mappings
- 匹配规则- 返回:
- HttpServer
-
addRestWebSocketServlet
public <S extends WebSocket,T extends WebSocketServlet> T addRestWebSocketServlet(ClassLoader classLoader, Class<S> webSocketType, MessageAgent messageAgent, String prefix, AnyValue conf)
添加WebSocketServlet- 类型参数:
S
- WebSocketT
- HttpServlet- 参数:
classLoader
- ClassLoaderwebSocketType
- WebSocket的类型messageAgent
- MessageAgentprefix
- url前缀conf
- 配置信息- 返回:
- RestServlet
-
addRestServlet
public <S extends Service,T extends HttpServlet> T addRestServlet(ClassLoader classLoader, S service, Class userType, Class<T> baseServletType, String prefix)
添加RestServlet- 类型参数:
S
- ServiceT
- HttpServlet- 参数:
classLoader
- ClassLoaderservice
- Service对象userType
- 用户数据类型baseServletType
- RestServlet基类prefix
- url前缀- 返回:
- RestServlet
-
addRestServlet
public <S extends Service,T extends HttpServlet> T addRestServlet(ClassLoader classLoader, String name, S service, Class userType, Class<T> baseServletType, String prefix)
添加RestServlet- 类型参数:
S
- ServiceT
- HttpServlet- 参数:
classLoader
- ClassLoadername
- 资源名service
- Service对象userType
- 用户数据类型baseServletType
- RestServlet基类prefix
- url前缀- 返回:
- RestServlet
-
createContext
protected HttpContext createContext()
- 指定者:
createContext
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
postPrepareInit
protected void postPrepareInit()
- 覆盖:
postPrepareInit
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
createSafeBufferPool
protected ByteBufferPool createSafeBufferPool(LongAdder createCounter, LongAdder cycleCounter, int bufferPoolSize)
- 指定者:
createSafeBufferPool
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
createSafeResponsePool
protected ObjectPool<HttpResponse> createSafeResponsePool(LongAdder createCounter, LongAdder cycleCounter, int responsePoolSize)
- 指定者:
createSafeResponsePool
在类中Server<String,HttpContext,HttpRequest,HttpResponse,HttpServlet>
-
-