| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
static String |
UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE |
| Constructor and Description |
|---|
SpincastUndertowServer(SpincastConfig config,
SpincastUndertowConfig spincastUndertowConfig,
FrontController frontController,
SpincastUtils spincastUtils,
CookieFactory cookieFactory,
CorsHandlerFactory corsHandlerFactory,
GzipCheckerHandlerFactory gzipCheckerHandlerFactory,
SkipResourceOnQueryStringHandlerFactory skipResourceOnQueryStringHandlerFactory,
SpincastResourceHandlerFactory spincastResourceHandlerFactory,
CacheBusterRemovalHandlerFactory cacheBusterRemovalHandlerFactory,
FileClassPathResourceManagerFactory fileClassPathResourceManagerFactory,
SpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory,
WebsocketEndpointFactory spincastWebsocketEndpointFactory,
SSLContextFactory sslContextFactory)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
protected io.undertow.Undertow.Builder |
addBuilderOptions(io.undertow.Undertow.Builder builder) |
void |
addCookies(Object exchange,
Map<String,Cookie> cookies)
Adds cookies.
|
void |
addHttpAuthentication(String realmName,
String username,
String password)
Adds a user to an HTTP protected realm.
|
protected void |
addHttpListener(io.undertow.Undertow.Builder builder,
String serverHost,
int httpServerPort) |
protected void |
addHttpsListener(io.undertow.Undertow.Builder builder,
String serverHost,
int httpsServerPort) |
void |
addStaticResourceToServe(StaticResource<?> staticResource)
Adds a static resource to serve directly by the server.
|
protected io.undertow.server.HttpServerExchange |
castExchange(Object exchange) |
void |
createHttpAuthenticationRealm(String pathPrefix,
String realmName)
Creates HTTP authentication protection (realm) for the
specified path prefix.
|
protected WebsocketEndpointHandler |
createUndertowWebsocketEndpointHandler(String endpointId,
WebsocketEndpointHandler appHandler) |
void |
end(Object exchange)
Ends the exchange.
|
void |
flushBytes(Object exchange,
byte[] bytes,
boolean end)
Flushes some bytes to the response.
|
boolean |
forceRequestSizeValidation(Object exchangeObj)
Is the request size valid?
|
protected CacheBusterRemovalHandler |
getCacheBusterRemovalHandler()
Handler to remove cache busters from the request's URL.
|
protected CacheBusterRemovalHandlerFactory |
getCacheBusterRemovalHandlerFactory() |
protected io.undertow.io.IoCallback |
getCloseExchangeCallback() |
protected SpincastConfig |
getConfig() |
ContentTypeDefaults |
getContentTypeBestMatch(Object exchangeObj)
Gets the best
Content-Type to use for the current request. |
protected String |
getCookieEncoding() |
protected CookieFactory |
getCookieFactory() |
Map<String,String> |
getCookies(Object exchange)
Gets the request cookies values.
|
protected CorsHandlerFactory |
getCorsHandlerFactory() |
protected io.undertow.io.IoCallback |
getDoNothingCallback() |
protected FileClassPathResourceManagerFactory |
getFileClassPathResourceManagerFactory() |
protected io.undertow.server.HttpHandler |
getFinalHandler()
The very first handler considered by Undertow.
|
protected io.undertow.server.handlers.form.FormData |
getFormData(io.undertow.server.HttpServerExchange exchange)
May return NULL.
|
Map<String,List<String>> |
getFormData(Object exchangeObj)
The form data, if any.
|
protected io.undertow.server.handlers.form.FormParserFactory |
getFormParserFactory() |
protected FrontController |
getFrontController() |
String |
getFullUrlOriginal(Object exchangeObj)
The full encoded URL of the original, non proxied, request, including the queryString.
|
String |
getFullUrlOriginal(Object exchangeObj,
boolean keepCacheBusters)
The full encoded URL of the original, non proxied, request, including the queryString.
|
String |
getFullUrlProxied(Object exchangeObj)
The full encoded URL of the potentially proxied request, including the queryString.
|
String |
getFullUrlProxied(Object exchangeObj,
boolean keepCacheBusters)
The full encoded URL of the potentially proxied request, including the queryString.
|
protected GzipCheckerHandlerFactory |
getGzipCheckerHandlerFactory() |
protected Map<String,String> |
getHttpAuthActiveRealms() |
protected io.undertow.server.handlers.PathHandler |
getHttpAuthenticationHandler()
Handler to check for HTTP authentication requirement.
|
Map<String,String> |
getHttpAuthenticationRealms()
Returns the existing HTTP authentication realms, the
key being the realm's name and the value being the
prefix path associated to this realm.
|
protected io.undertow.server.HttpHandler |
getHttpAuthHandlerNextHandler() |
protected Map<String,SpincastHttpAuthIdentityManager> |
getHttpAuthIdentityManagersByRealmName() |
HttpMethod |
getHttpMethod(Object exchange)
Gets the HTTP method associated with the request.
|
protected int |
getMilliSecondsIncrementWhenWaitingForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer() |
protected SpincastHttpAuthIdentityManager |
getOrCreateHttpAuthIdentityManagersByRealmName(String realmName) |
Map<String,List<String>> |
getQueryStringParams(Object exchange)
Gets the queryString parameters.
|
InputStream |
getRawInputStream(Object exchangeObj)
The raw InputStream of the current request.
|
protected String |
getRealmNameToDisplay(String pathPrefix,
String realmName)
The realm name to display.
|
Map<String,List<String>> |
getRequestHeaders(Object exchangeObj)
The headers from the request.
|
String |
getRequestScheme(Object exchange)
Gets the request scheme, "http" for example.
|
Map<String,List<String>> |
getResponseHeaders(Object exchangeObj)
Gets the response headers.
|
protected int |
getSecondsToWaitForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer() |
protected io.undertow.Undertow.Builder |
getServerBuilder() |
protected int |
getServerStartTryNbr() |
protected SkipResourceOnQueryStringHandlerFactory |
getSkipResourceOnQueryStringHandlerFactory() |
protected io.undertow.server.HttpHandler |
getSpincastFrontControllerHandler() |
protected SpincastHttpAuthIdentityManagerFactory |
getSpincastHttpAuthIdentityManagerFactory() |
protected SpincastResourceHandlerFactory |
getSpincastResourceHandlerFactory() |
protected SpincastUndertowConfig |
getSpincastUndertowConfig() |
protected SpincastUtils |
getSpincastUtils() |
protected WebsocketEndpointFactory |
getSpincastWebsocketEndpointFactory() |
protected SSLContextFactory |
getSslContextFactory() |
protected long |
getStartServerSleepMilliseconds() |
StaticResource<?> |
getStaticResourceServed(String urlPath)
Gets a static resource served directly by the server, using its path.
|
protected io.undertow.server.handlers.PathHandler |
getStaticResourcesPathHandler() |
Set<StaticResource<?>> |
getStaticResourcesServed()
Gets all static resource served directly by the server.
|
protected Map<String,StaticResource<?>> |
getStaticResourcesServedByUrlPath() |
Map<String,List<File>> |
getUploadedFiles(Object exchangeObj)
The uploaded files, if any.
|
protected Object |
getWebsocketEndpointCreationLock(String endpointId)
Gets the creation/close lock for a specific Websocket endpoint.
|
WebsocketEndpointManager |
getWebsocketEndpointManager(String endpointId)
Returns the manager for a Websockets endpoint.
|
List<WebsocketEndpointManager> |
getWebsocketEndpointManagers()
Returns the managers of the existing Websockets endpoints.
|
protected Map<String,WebsocketEndpoint> |
getWebsocketEndpointsMap() |
boolean |
isResponseClosed(Object exchange)
Is the response closed?
|
boolean |
isResponseHeadersSent(Object exchange)
Are the response headers sent?
|
boolean |
isRunning()
Is this server running (started)?
|
void |
removeAllStaticResourcesServed()
Removes all static resources served directly by the server.
|
void |
removeHttpAuthentication(String username)
Removes a user from all HTTP protected realms.
|
void |
removeHttpAuthentication(String username,
String realmName)
Removes a user to an HTTP protected realm.
|
void |
removeResponseHeader(Object exchange,
String name)
Removes a response header.
|
protected void |
removeStaticResource(StaticResourceType staticResourceType,
String urlPath) |
void |
removeStaticResourcesServed(StaticResourceType staticResourceType,
String urlPath)
Removes a static resource served directly by the server.
|
protected void |
sendWebsocketEnpointsClosedWhenServerStops() |
void |
setResponseHeader(Object exchangeObj,
String name,
List<String> values)
Sets a response header.
|
void |
setResponseHeaders(Object exchange,
Map<String,List<String>> headers)
Sets the response headers.
|
void |
setResponseStatusCode(Object exchange,
int statusCode)
Sets the response status code.
|
void |
start()
Starts the server.
|
void |
stop()
Stops the server
|
void |
stop(boolean sendClosingMessageToPeers)
Stops the server
|
void |
websocketCloseEndpoint(String endpointId)
Closes a Websocket endpoint.
|
void |
websocketCloseEndpoint(String endpointId,
int closingCode,
String closingReason)
Closes the entire Websocket endpoint.
|
void |
websocketConnection(Object exchangeObj,
String endpointId,
String peerId)
Transforms the request to a peer Websocket connection
on the endpoint 'endpointId'.
|
WebsocketEndpointManager |
websocketCreateEndpoint(String endpointId,
WebsocketEndpointHandler appEndpointHandler)
Creates a new Websocket endpoint.
|
protected final org.slf4j.Logger logger
public static final String UNDERTOW_EXCEPTION_CODE_REQUEST_TOO_LARGE
@Inject public SpincastUndertowServer(SpincastConfig config, SpincastUndertowConfig spincastUndertowConfig, FrontController frontController, SpincastUtils spincastUtils, CookieFactory cookieFactory, CorsHandlerFactory corsHandlerFactory, GzipCheckerHandlerFactory gzipCheckerHandlerFactory, SkipResourceOnQueryStringHandlerFactory skipResourceOnQueryStringHandlerFactory, SpincastResourceHandlerFactory spincastResourceHandlerFactory, CacheBusterRemovalHandlerFactory cacheBusterRemovalHandlerFactory, FileClassPathResourceManagerFactory fileClassPathResourceManagerFactory, SpincastHttpAuthIdentityManagerFactory spincastHttpAuthIdentityManagerFactory, WebsocketEndpointFactory spincastWebsocketEndpointFactory, SSLContextFactory sslContextFactory)
protected SpincastConfig getConfig()
protected SpincastUndertowConfig getSpincastUndertowConfig()
protected FrontController getFrontController()
protected SpincastUtils getSpincastUtils()
protected CookieFactory getCookieFactory()
protected CorsHandlerFactory getCorsHandlerFactory()
protected GzipCheckerHandlerFactory getGzipCheckerHandlerFactory()
protected SkipResourceOnQueryStringHandlerFactory getSkipResourceOnQueryStringHandlerFactory()
protected SpincastResourceHandlerFactory getSpincastResourceHandlerFactory()
protected CacheBusterRemovalHandlerFactory getCacheBusterRemovalHandlerFactory()
protected FileClassPathResourceManagerFactory getFileClassPathResourceManagerFactory()
protected SpincastHttpAuthIdentityManagerFactory getSpincastHttpAuthIdentityManagerFactory()
protected WebsocketEndpointFactory getSpincastWebsocketEndpointFactory()
protected Map<String,StaticResource<?>> getStaticResourcesServedByUrlPath()
protected Map<String,SpincastHttpAuthIdentityManager> getHttpAuthIdentityManagersByRealmName()
protected Map<String,WebsocketEndpoint> getWebsocketEndpointsMap()
protected SSLContextFactory getSslContextFactory()
public Map<String,String> getHttpAuthenticationRealms()
ServerThe map is immutable.
getHttpAuthenticationRealms in interface Serverprotected io.undertow.server.handlers.form.FormParserFactory getFormParserFactory()
public boolean isRunning()
Serverpublic void start()
Serverprotected int getServerStartTryNbr()
protected long getStartServerSleepMilliseconds()
protected io.undertow.Undertow.Builder getServerBuilder()
protected void addHttpListener(io.undertow.Undertow.Builder builder,
String serverHost,
int httpServerPort)
protected void addHttpsListener(io.undertow.Undertow.Builder builder,
String serverHost,
int httpsServerPort)
protected io.undertow.Undertow.Builder addBuilderOptions(io.undertow.Undertow.Builder builder)
protected io.undertow.server.HttpHandler getFinalHandler()
protected CacheBusterRemovalHandler getCacheBusterRemovalHandler()
protected io.undertow.server.handlers.PathHandler getHttpAuthenticationHandler()
protected io.undertow.server.HttpHandler getHttpAuthHandlerNextHandler()
public void createHttpAuthenticationRealm(String pathPrefix, String realmName)
ServercreateHttpAuthenticationRealm in interface ServerrealmName - The name of the realm. Must be unique on this server,
otherwise an exception is thrown. This allows the application to add
user to the realm using its name.protected String getRealmNameToDisplay(String pathPrefix, String realmName)
protected SpincastHttpAuthIdentityManager getOrCreateHttpAuthIdentityManagersByRealmName(String realmName)
public void addHttpAuthentication(String realmName, String username, String password)
ServeraddHttpAuthentication in interface Serverpublic void removeHttpAuthentication(String username, String realmName)
ServerremoveHttpAuthentication in interface Serverpublic void removeHttpAuthentication(String username)
ServerremoveHttpAuthentication in interface Serverprotected io.undertow.server.HttpHandler getSpincastFrontControllerHandler()
public void stop()
ServerWill try to send a "closing" message to any WebSocket peer before closing their connections.
public void stop(boolean sendClosingMessageToPeers)
Serverprotected int getSecondsToWaitForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer()
protected int getMilliSecondsIncrementWhenWaitingForWebSocketEndpointsToBeProperlyClosedBeforeKillingTheServer()
protected void sendWebsocketEnpointsClosedWhenServerStops()
protected io.undertow.server.handlers.PathHandler getStaticResourcesPathHandler()
public void addStaticResourceToServe(StaticResource<?> staticResource)
ServeraddStaticResourceToServe in interface Serverpublic void removeStaticResourcesServed(StaticResourceType staticResourceType, String urlPath)
ServerremoveStaticResourcesServed in interface Serverpublic void removeAllStaticResourcesServed()
ServerremoveAllStaticResourcesServed in interface Serverprotected void removeStaticResource(StaticResourceType staticResourceType, String urlPath)
public StaticResource<?> getStaticResourceServed(String urlPath)
ServergetStaticResourceServed in interface Serverpublic Set<StaticResource<?>> getStaticResourcesServed()
ServergetStaticResourcesServed in interface Serverpublic HttpMethod getHttpMethod(Object exchange)
ServergetHttpMethod in interface Serverprotected io.undertow.server.HttpServerExchange castExchange(Object exchange)
public ContentTypeDefaults getContentTypeBestMatch(Object exchangeObj)
ServerContent-Type to use for the current request.getContentTypeBestMatch in interface Serverpublic String getFullUrlProxied(Object exchangeObj)
ServerIs a reverse proxy is used (such as Nginx or Apache), this is going to be the proxied URL, as forwarded by the reverse proxy. If no reverse proxy is used, this is going to be the original URL, as seen by the user.
Even if the request is forwarded elsewhere in the framework, this URL won't change, it will still be the original one.
getFullUrlProxied in interface Serverpublic String getFullUrlProxied(Object exchangeObj, boolean keepCacheBusters)
ServerIs a reverse proxy is used (such as Nginx or Apache), this is going to be the proxied URL, as forwarded by the reverse proxy. If no reverse proxy is used, this is going to be the original URL, as seen by the user.
Even if the request is forwarded elsewhere in the framework, this URL won't change, it will still be the original one.
getFullUrlProxied in interface ServerkeepCacheBusters - if true, the returned URL will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.public String getFullUrlOriginal(Object exchangeObj)
ServerThis is going to be the *original* URL, as seen by the user, even if a reverse proxy is used (such as Nginx or Apache).
Even if the request is forwarded elsewhere in the framework, this URL won't change, it will still be the original one.
getFullUrlOriginal in interface Serverpublic String getFullUrlOriginal(Object exchangeObj, boolean keepCacheBusters)
ServerThis is going to be the *original* URL, as seen by the user, even if a reverse proxy is used (such as Nginx or Apache).
Even if the request is forwarded elsewhere in the framework, this URL won't change, it will still be the original one.
getFullUrlOriginal in interface ServerkeepCacheBusters - if true, the returned URL will contain
the cache buster codes, if there were any. The default behavior is to
automatically remove them.public void setResponseHeader(Object exchangeObj, String name, List<String> values)
ServersetResponseHeader in interface Serverpublic void setResponseHeaders(Object exchange, Map<String,List<String>> headers)
ServersetResponseHeaders in interface Serverpublic Map<String,List<String>> getResponseHeaders(Object exchangeObj)
ServergetResponseHeaders in interface Serverpublic void removeResponseHeader(Object exchange, String name)
ServerremoveResponseHeader in interface Serverpublic void setResponseStatusCode(Object exchange, int statusCode)
ServersetResponseStatusCode in interface Serverprotected io.undertow.io.IoCallback getDoNothingCallback()
protected io.undertow.io.IoCallback getCloseExchangeCallback()
public void flushBytes(Object exchange, byte[] bytes, boolean end)
ServerflushBytes in interface Serverend - if true, the exchange will be closed
and nothing more can be send.public void end(Object exchange)
Serverpublic boolean isResponseClosed(Object exchange)
ServerisResponseClosed in interface Serverpublic boolean isResponseHeadersSent(Object exchange)
ServerisResponseHeadersSent in interface Serverpublic String getRequestScheme(Object exchange)
ServergetRequestScheme in interface Serverpublic void addCookies(Object exchange, Map<String,Cookie> cookies)
ServeraddCookies in interface Serverpublic Map<String,String> getCookies(Object exchange)
ServergetCookies in interface Serverprotected String getCookieEncoding()
public Map<String,List<String>> getQueryStringParams(Object exchange)
ServergetQueryStringParams in interface Serverpublic InputStream getRawInputStream(Object exchangeObj)
ServergetRawInputStream in interface Serverprotected io.undertow.server.handlers.form.FormData getFormData(io.undertow.server.HttpServerExchange exchange)
public Map<String,List<String>> getFormData(Object exchangeObj)
ServergetFormData in interface Serverpublic Map<String,List<File>> getUploadedFiles(Object exchangeObj)
ServergetUploadedFiles in interface Serverpublic boolean forceRequestSizeValidation(Object exchangeObj)
ServerforceRequestSizeValidation in interface Serverpublic Map<String,List<String>> getRequestHeaders(Object exchangeObj)
ServergetRequestHeaders in interface Serverprotected Object getWebsocketEndpointCreationLock(String endpointId)
public WebsocketEndpointManager websocketCreateEndpoint(String endpointId, WebsocketEndpointHandler appEndpointHandler)
ServerwebsocketCreateEndpoint in interface Serverprotected WebsocketEndpointHandler createUndertowWebsocketEndpointHandler(String endpointId, WebsocketEndpointHandler appHandler)
public void websocketCloseEndpoint(String endpointId)
ServerwebsocketCloseEndpoint in interface Serverpublic void websocketCloseEndpoint(String endpointId, int closingCode, String closingReason)
ServerwebsocketCloseEndpoint in interface ServerclosingCode - The closing code.closingReason - The closing reason.public void websocketConnection(Object exchangeObj, String endpointId, String peerId)
ServerwebsocketConnection in interface Serverpublic List<WebsocketEndpointManager> getWebsocketEndpointManagers()
ServergetWebsocketEndpointManagers in interface Serverpublic WebsocketEndpointManager getWebsocketEndpointManager(String endpointId)
ServergetWebsocketEndpointManager in interface Servernull if not found.Copyright © 2017. All rights reserved.