Package org.spincast.plugins.undertow
Class SpincastUndertowServer
java.lang.Object
org.spincast.plugins.undertow.SpincastUndertowServer
- All Implemented Interfaces:
org.spincast.core.server.Server
Server implementation using
Undertow.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpincastUndertowServer(SpincastUndertowUtils spincastUndertowUtils, org.spincast.core.config.SpincastConfig config, SpincastUndertowConfig spincastUndertowConfig, org.spincast.core.controllers.FrontController frontController, org.spincast.core.utils.SpincastUtils spincastUtils, org.spincast.core.cookies.CookieFactory cookieFactory, CorsHandlerFactory corsHandlerFactory, GzipCheckerHandlerFactory gzipCheckerHandlerFactory, SkipResourceOnQueryStringHandlerFactory skipResourceOnQueryStringHandlerFactory, SpincastResourceHandlerFactory spincastResourceHandlerFactory, CacheBusterRemovalHandlerFactory cacheBusterRemovalHandlerFactory, SpincastClassPathResourceManagerFactory fileClassPathResourceManagerFactory, SpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory, WebsocketEndpointFactory spincastWebsocketEndpointFactory, org.spincast.core.utils.ssl.SSLContextFactory sslContextFactory) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected io.undertow.Undertow.BuilderaddBuilderOptions(io.undertow.Undertow.Builder builder) voidaddCookies(Object exchange, Map<String, org.spincast.core.cookies.Cookie> cookies) voidaddHttpAuthentication(String realmName, String username, String password) protected voidaddHttpListener(io.undertow.Undertow.Builder builder, String serverHost, int httpServerPort) protected voidaddHttpsListener(io.undertow.Undertow.Builder builder, String serverHost, int httpsServerPort) protected voidaddMaxEntitySize(io.undertow.Undertow.Builder builder) voidaddStaticResourceToServe(org.spincast.core.routing.StaticResource<?> staticResource) protected io.undertow.server.HttpServerExchangecastExchange(Object exchange) io.undertow.util.HeaderMapconvertHeadersToUndertowHeaderMap(Map<String, List<String>> headers) io.undertow.util.HttpStringconvertHttpMethodToUndertowHttpString(org.spincast.core.routing.HttpMethod httpMethod) voidcreateHttpAuthenticationRealm(String pathPrefix, String realmName) protected io.undertow.server.handlers.LearningPushHandlerprotected Pathprotected org.spincast.core.websocket.WebsocketEndpointHandlercreateUndertowWebsocketEndpointHandler(String endpointId, org.spincast.core.websocket.WebsocketEndpointHandler appHandler) protected voidenableHttp2(io.undertow.Undertow.Builder builder) voidvoidflushBytes(Object exchange, byte[] bytes, boolean end) booleanforceRequestSizeValidation(Object exchangeObj) protected CacheBusterRemovalHandlerHandler to remove cache busters from the request's URL.protected CacheBusterRemovalHandlerFactoryprotected io.undertow.io.IoCallbackprotected org.spincast.core.config.SpincastConfigorg.spincast.core.utils.ContentTypeDefaultsgetContentTypeBestMatch(Object exchangeObj) protected Stringprotected org.spincast.core.cookies.CookieFactorygetCookies(Object exchange) protected CorsHandlerFactoryprotected io.undertow.io.IoCallbackprotected SpincastClassPathResourceManagerFactoryprotected io.undertow.server.HttpHandlerThe very first handler considered by Undertow.protected io.undertow.server.handlers.form.FormDatagetFormData(io.undertow.server.HttpServerExchange exchange) May return NULL.getFormData(Object exchangeObj) protected io.undertow.server.handlers.form.FormParserFactoryprotected org.spincast.core.controllers.FrontControllergetFullUrlOriginal(Object exchangeObj) getFullUrlOriginal(Object exchangeObj, boolean keepCacheBusters) getFullUrlProxied(Object exchangeObj) getFullUrlProxied(Object exchangeObj, boolean keepCacheBusters) protected GzipCheckerHandlerFactoryprotected io.undertow.server.handlers.PathHandlerHandler to check for HTTP authentication requirement.protected io.undertow.server.HttpHandlerprotected Map<String,SpincastHttpAuthIdentityManager> org.spincast.core.routing.HttpMethodgetHttpMethod(Object exchange) protected io.undertow.server.HttpHandlerprotected intprotected SpincastHttpAuthIdentityManagergetQueryStringParams(Object exchange) getRawInputStream(Object exchangeObj) protected StringgetRealmNameToDisplay(String pathPrefix, String realmName) The realm name to display.getRequestHeaders(Object exchangeObj) The names of the headers are case insensitive.getRequestScheme(Object exchange) getResponseHeaders(Object exchangeObj) protected intprotected io.undertow.Undertow.Builderprotected intprotected SkipResourceOnQueryStringHandlerFactoryprotected io.undertow.server.HttpHandlerprotected SpincastHttpAuthIdentityManagerFactoryprotected SpincastResourceHandlerFactoryprotected SpincastUndertowConfigprotected SpincastUndertowUtilsprotected org.spincast.core.utils.SpincastUtilsprotected WebsocketEndpointFactoryprotected org.spincast.core.utils.ssl.SSLContextFactoryprotected longorg.spincast.core.routing.StaticResource<?>getStaticResourceServed(String urlPath) protected io.undertow.server.handlers.PathHandlerSet<org.spincast.core.routing.StaticResource<?>>getUploadedFiles(Object exchangeObj) protected ObjectgetWebsocketEndpointCreationLock(String endpointId) Gets the creation/close lock for a specific Websocket endpoint.org.spincast.core.websocket.WebsocketEndpointManagergetWebsocketEndpointManager(String endpointId) List<org.spincast.core.websocket.WebsocketEndpointManager>protected Map<String,WebsocketEndpoint> protected booleanisPushSupported(io.undertow.server.ServerConnection connection) booleanisResponseClosed(Object exchange) booleanisResponseHeadersSent(Object exchange) booleanvoidprotected voidpushResource(io.undertow.server.ServerConnection connection, String path, io.undertow.util.HttpString httpMethod, io.undertow.util.HeaderMap headerMap) voidvoidremoveHttpAuthentication(String username) voidremoveHttpAuthentication(String username, String realmName) voidremoveResponseHeader(Object exchange, String name) protected voidremoveStaticResource(org.spincast.core.routing.StaticResourceType staticResourceType, String urlPath) voidremoveStaticResourcesServed(org.spincast.core.routing.StaticResourceType staticResourceType, String urlPath) protected voidsendPushHeaders(io.undertow.server.HttpServerExchange exchange, org.spincast.core.routing.ResourceToPush resourceToPush) In case the server is behind a reverse-proxy such as Nginx: it is this proxy that will do the actual push of the resource.protected voidvoidsetResponseHeader(Object exchangeObj, String name, List<String> values) voidvoidsetResponseStatusCode(Object exchange, int statusCode) voidstart()voidstop()voidstop(boolean sendClosingMessageToPeers) voidwebsocketCloseEndpoint(String endpointId) voidwebsocketCloseEndpoint(String endpointId, int closingCode, String closingReason) voidwebsocketConnection(Object exchangeObj, String endpointId, String peerId) org.spincast.core.websocket.WebsocketEndpointManagerwebsocketCreateEndpoint(String endpointId, org.spincast.core.websocket.WebsocketEndpointHandler appEndpointHandler)
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE
- See Also:
-
EXCHANGE_VARIABLE_EXCHANGE_COMPLETED
-
-
Constructor Details
-
SpincastUndertowServer
@Inject public SpincastUndertowServer(SpincastUndertowUtils spincastUndertowUtils, org.spincast.core.config.SpincastConfig config, SpincastUndertowConfig spincastUndertowConfig, org.spincast.core.controllers.FrontController frontController, org.spincast.core.utils.SpincastUtils spincastUtils, org.spincast.core.cookies.CookieFactory cookieFactory, CorsHandlerFactory corsHandlerFactory, GzipCheckerHandlerFactory gzipCheckerHandlerFactory, SkipResourceOnQueryStringHandlerFactory skipResourceOnQueryStringHandlerFactory, SpincastResourceHandlerFactory spincastResourceHandlerFactory, CacheBusterRemovalHandlerFactory cacheBusterRemovalHandlerFactory, SpincastClassPathResourceManagerFactory fileClassPathResourceManagerFactory, SpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory, WebsocketEndpointFactory spincastWebsocketEndpointFactory, org.spincast.core.utils.ssl.SSLContextFactory sslContextFactory) Constructor
-
-
Method Details
-
getSpincastUndertowUtils
-
getConfig
protected org.spincast.core.config.SpincastConfig getConfig() -
getSpincastUndertowConfig
-
getFrontController
protected org.spincast.core.controllers.FrontController getFrontController() -
getSpincastUtils
protected org.spincast.core.utils.SpincastUtils getSpincastUtils() -
getCookieFactory
protected org.spincast.core.cookies.CookieFactory getCookieFactory() -
getCorsHandlerFactory
-
getGzipCheckerHandlerFactory
-
getSkipResourceOnQueryStringHandlerFactory
-
getSpincastResourceHandlerFactory
-
getCacheBusterRemovalHandlerFactory
-
getFileClassPathResourceManagerFactory
-
getSpincastHttpAuthIdentityManagerFactory
-
getSpincastWebsocketEndpointFactory
-
getStaticResourcesServedByUrlPath
-
getHttpAuthIdentityManagersByRealmName
-
getWebsocketEndpointsMap
-
getHttpAuthActiveRealms
-
getSslContextFactory
protected org.spincast.core.utils.ssl.SSLContextFactory getSslContextFactory() -
getHttpAuthenticationRealms
- Specified by:
getHttpAuthenticationRealmsin interfaceorg.spincast.core.server.Server
-
getFormParserFactory
protected io.undertow.server.handlers.form.FormParserFactory getFormParserFactory() -
createUndertowTempDir
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.spincast.core.server.Server
-
start
public void start()- Specified by:
startin interfaceorg.spincast.core.server.Server
-
getServerStartTryNbr
protected int getServerStartTryNbr() -
getStartServerSleepMilliseconds
protected long getStartServerSleepMilliseconds() -
getServerBuilder
protected io.undertow.Undertow.Builder getServerBuilder() -
addHttpListener
protected void addHttpListener(io.undertow.Undertow.Builder builder, String serverHost, int httpServerPort) -
addHttpsListener
protected void addHttpsListener(io.undertow.Undertow.Builder builder, String serverHost, int httpsServerPort) -
addBuilderOptions
protected io.undertow.Undertow.Builder addBuilderOptions(io.undertow.Undertow.Builder builder) -
addMaxEntitySize
protected void addMaxEntitySize(io.undertow.Undertow.Builder builder) -
enableHttp2
protected void enableHttp2(io.undertow.Undertow.Builder builder) -
getFinalHandler
protected io.undertow.server.HttpHandler getFinalHandler()The very first handler considered by Undertow. -
getCacheBusterRemovalHandler
Handler to remove cache busters from the request's URL. -
getHttpAuthenticationHandler
protected io.undertow.server.handlers.PathHandler getHttpAuthenticationHandler()Handler to check for HTTP authentication requirement. -
getHttpAuthHandlerNextHandler
protected io.undertow.server.HttpHandler getHttpAuthHandlerNextHandler() -
getLearningPushHandler
protected io.undertow.server.HttpHandler getLearningPushHandler() -
createLearningPushHandler
protected io.undertow.server.handlers.LearningPushHandler createLearningPushHandler() -
createHttpAuthenticationRealm
- Specified by:
createHttpAuthenticationRealmin interfaceorg.spincast.core.server.Server
-
getRealmNameToDisplay
The realm name to display. -
getOrCreateHttpAuthIdentityManagersByRealmName
protected SpincastHttpAuthIdentityManager getOrCreateHttpAuthIdentityManagersByRealmName(String realmName) -
addHttpAuthentication
- Specified by:
addHttpAuthenticationin interfaceorg.spincast.core.server.Server
-
removeHttpAuthentication
- Specified by:
removeHttpAuthenticationin interfaceorg.spincast.core.server.Server
-
removeHttpAuthentication
- Specified by:
removeHttpAuthenticationin interfaceorg.spincast.core.server.Server
-
getSpincastFrontControllerHandler
protected io.undertow.server.HttpHandler getSpincastFrontControllerHandler() -
stop
public void stop()- Specified by:
stopin interfaceorg.spincast.core.server.Server
-
stop
public void stop(boolean sendClosingMessageToPeers) - Specified by:
stopin interfaceorg.spincast.core.server.Server
-
getSecondsToWaitForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer
protected int getSecondsToWaitForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer() -
getMilliSecondsIncrementWhenWaitingForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer
protected int getMilliSecondsIncrementWhenWaitingForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer() -
sendWebsocketEnpointsClosedWhenServerStops
protected void sendWebsocketEnpointsClosedWhenServerStops() -
getStaticResourcesPathHandler
protected io.undertow.server.handlers.PathHandler getStaticResourcesPathHandler() -
addStaticResourceToServe
public void addStaticResourceToServe(org.spincast.core.routing.StaticResource<?> staticResource) - Specified by:
addStaticResourceToServein interfaceorg.spincast.core.server.Server
-
removeStaticResourcesServed
public void removeStaticResourcesServed(org.spincast.core.routing.StaticResourceType staticResourceType, String urlPath) - Specified by:
removeStaticResourcesServedin interfaceorg.spincast.core.server.Server
-
removeAllStaticResourcesServed
public void removeAllStaticResourcesServed()- Specified by:
removeAllStaticResourcesServedin interfaceorg.spincast.core.server.Server
-
removeStaticResource
protected void removeStaticResource(org.spincast.core.routing.StaticResourceType staticResourceType, String urlPath) -
getStaticResourceServed
- Specified by:
getStaticResourceServedin interfaceorg.spincast.core.server.Server
-
getStaticResourcesServed
- Specified by:
getStaticResourcesServedin interfaceorg.spincast.core.server.Server
-
getHttpMethod
- Specified by:
getHttpMethodin interfaceorg.spincast.core.server.Server
-
castExchange
-
getContentTypeBestMatch
- Specified by:
getContentTypeBestMatchin interfaceorg.spincast.core.server.Server
-
getFullUrlProxied
- Specified by:
getFullUrlProxiedin interfaceorg.spincast.core.server.Server
-
getFullUrlProxied
- Specified by:
getFullUrlProxiedin interfaceorg.spincast.core.server.Server
-
getFullUrlOriginal
- Specified by:
getFullUrlOriginalin interfaceorg.spincast.core.server.Server
-
getFullUrlOriginal
- Specified by:
getFullUrlOriginalin interfaceorg.spincast.core.server.Server
-
setResponseHeader
- Specified by:
setResponseHeaderin interfaceorg.spincast.core.server.Server
-
setResponseHeaders
- Specified by:
setResponseHeadersin interfaceorg.spincast.core.server.Server
-
getResponseHeaders
- Specified by:
getResponseHeadersin interfaceorg.spincast.core.server.Server
-
removeResponseHeader
- Specified by:
removeResponseHeaderin interfaceorg.spincast.core.server.Server
-
setResponseStatusCode
- Specified by:
setResponseStatusCodein interfaceorg.spincast.core.server.Server
-
getDoNothingCallback
protected io.undertow.io.IoCallback getDoNothingCallback() -
getCloseExchangeCallback
protected io.undertow.io.IoCallback getCloseExchangeCallback() -
flushBytes
- Specified by:
flushBytesin interfaceorg.spincast.core.server.Server
-
end
- Specified by:
endin interfaceorg.spincast.core.server.Server
-
isResponseClosed
- Specified by:
isResponseClosedin interfaceorg.spincast.core.server.Server
-
isResponseHeadersSent
- Specified by:
isResponseHeadersSentin interfaceorg.spincast.core.server.Server
-
getRequestScheme
- Specified by:
getRequestSchemein interfaceorg.spincast.core.server.Server
-
addCookies
- Specified by:
addCookiesin interfaceorg.spincast.core.server.Server
-
getCookies
- Specified by:
getCookiesin interfaceorg.spincast.core.server.Server
-
getCookieEncoding
-
getQueryStringParams
- Specified by:
getQueryStringParamsin interfaceorg.spincast.core.server.Server
-
getRawInputStream
- Specified by:
getRawInputStreamin interfaceorg.spincast.core.server.Server
-
getFormData
protected io.undertow.server.handlers.form.FormData getFormData(io.undertow.server.HttpServerExchange exchange) May return NULL. -
getFormData
- Specified by:
getFormDatain interfaceorg.spincast.core.server.Server
-
getUploadedFiles
- Specified by:
getUploadedFilesin interfaceorg.spincast.core.server.Server
-
forceRequestSizeValidation
- Specified by:
forceRequestSizeValidationin interfaceorg.spincast.core.server.Server
-
getRequestHeaders
The names of the headers are case insensitive.- Specified by:
getRequestHeadersin interfaceorg.spincast.core.server.Server
-
getWebsocketEndpointCreationLock
Gets the creation/close lock for a specific Websocket endpoint. -
websocketCreateEndpoint
public org.spincast.core.websocket.WebsocketEndpointManager websocketCreateEndpoint(String endpointId, org.spincast.core.websocket.WebsocketEndpointHandler appEndpointHandler) - Specified by:
websocketCreateEndpointin interfaceorg.spincast.core.server.Server
-
createUndertowWebsocketEndpointHandler
protected org.spincast.core.websocket.WebsocketEndpointHandler createUndertowWebsocketEndpointHandler(String endpointId, org.spincast.core.websocket.WebsocketEndpointHandler appHandler) -
websocketCloseEndpoint
- Specified by:
websocketCloseEndpointin interfaceorg.spincast.core.server.Server
-
websocketCloseEndpoint
- Specified by:
websocketCloseEndpointin interfaceorg.spincast.core.server.Server
-
websocketConnection
- Specified by:
websocketConnectionin interfaceorg.spincast.core.server.Server
-
getWebsocketEndpointManagers
- Specified by:
getWebsocketEndpointManagersin interfaceorg.spincast.core.server.Server
-
getWebsocketEndpointManager
public org.spincast.core.websocket.WebsocketEndpointManager getWebsocketEndpointManager(String endpointId) - Specified by:
getWebsocketEndpointManagerin interfaceorg.spincast.core.server.Server
-
getIp
- Specified by:
getIpin interfaceorg.spincast.core.server.Server
-
convertHttpMethodToUndertowHttpString
public io.undertow.util.HttpString convertHttpMethodToUndertowHttpString(org.spincast.core.routing.HttpMethod httpMethod) -
convertHeadersToUndertowHeaderMap
-
push
- Specified by:
pushin interfaceorg.spincast.core.server.Server
-
isPushSupported
protected boolean isPushSupported(io.undertow.server.ServerConnection connection) -
pushResource
protected void pushResource(io.undertow.server.ServerConnection connection, String path, io.undertow.util.HttpString httpMethod, io.undertow.util.HeaderMap headerMap) -
sendPushHeaders
protected void sendPushHeaders(io.undertow.server.HttpServerExchange exchange, org.spincast.core.routing.ResourceToPush resourceToPush) In case the server is behind a reverse-proxy such as Nginx: it is this proxy that will do the actual push of the resource. We tell it to do so using special response headers.
-