Top Description Inners Fields Constructors Methods
org.glassfish.tyrus.servlet

public Class TyrusServletContainerInitializer

extends Object
implements ServletContainerInitializer
Class Inheritance
All Implemented Interfaces
jakarta.servlet.ServletContainerInitializer
Annotations
@HandlesTypes:ServerEndpoint, ServerApplicationConfig, Endpoint
Imports
java.io.IOException, java.util.HashSet, .List, .Locale, .Map, .Set, java.util.logging.Level, .Logger, jakarta.servlet.http.HttpServletRequest, .HttpServletRequestWrapper, .HttpServletResponse, jakarta.websocket.DeploymentException, .Endpoint, jakarta.websocket.server.ServerApplicationConfig, .ServerContainer, .ServerEndpoint, .ServerEndpointConfig, jakarta.servlet.FilterRegistration, .ServletContainerInitializer, .ServletContext, .ServletException, jakarta.servlet.annotation.HandlesTypes, org.glassfish.tyrus.core.DebugContext, .TyrusWebSocketEngine, org.glassfish.tyrus.core.monitoring.ApplicationEventListener, org.glassfish.tyrus.core.uri.internal.PathSegment, .UriComponent, org.glassfish.tyrus.server.TyrusServerContainer, org.glassfish.tyrus.spi.WebSocketEngine

Registers a filter for upgrade handshake.

All requests will be handled by registered filter if not specified otherwise.

Authors
Jitendra Kotamraju, Pavel Bucek

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final Set<Class<?>>
FILTERED_CLASSES

Tyrus classes scanned by container will be filtered.

private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private ApplicationEventListener
private Boolean

Returns:

parsed java.lang.Boolean value or null when the value is not boolean or when the init parameter is not present.
getBooleanContextParam
(ServletContext
used to retrieve init parameter.
ctx
,
String
parameter name.
paramName
)

Get java.lang.Boolean parameter from jakarta.servlet.ServletContext.

private <T extends Enum<T>> T
getEnumContextParam(ServletContext ctx, String paramName, Class<T> type, T defaultValue)

private Integer

Returns:

parsed Integer value or null when the value is not integer or when the init parameter is not present.
getIntContextParam
(ServletContext
used to retrieve init parameter.
ctx
,
String
parameter name.
paramName
)

Get Integer parameter from jakarta.servlet.ServletContext.

public void
onStartup(Set<Class<?>>
the Set of application classes that extend, implement, or have been annotated with the class types specified by the HandlesTypes annotation, or null if there are no matches, or this ServletContainerInitializer has not been annotated with HandlesTypes
classes
,
final ServletContext
the ServletContext of the web application that is being started and in which the classes contained in c were found
ctx
)

Implements jakarta.servlet.ServletContainerInitializer.onStartup.

Notifies this ServletContainerInitializer of the startup of the application represented by the given ServletContext.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FILTERED_CLASSESback to summary
private static final Set<Class<?>> FILTERED_CLASSES

Tyrus classes scanned by container will be filtered.

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

TyrusServletContainerInitializerback to summary
public TyrusServletContainerInitializer()

Method Detail

createApplicationEventListenerback to summary
private ApplicationEventListener createApplicationEventListener(final ServletContext ctx)
getBooleanContextParamback to summary
private Boolean getBooleanContextParam(ServletContext ctx, String paramName)

Get java.lang.Boolean parameter from jakarta.servlet.ServletContext.

Parameters
ctx:ServletContext

used to retrieve init parameter.

paramName:String

parameter name.

Returns:Boolean

parsed java.lang.Boolean value or null when the value is not boolean or when the init parameter is not present.

getEnumContextParamback to summary
private <T extends Enum<T>> T getEnumContextParam(ServletContext ctx, String paramName, Class<T> type, T defaultValue)
getIntContextParamback to summary
private Integer getIntContextParam(ServletContext ctx, String paramName)

Get Integer parameter from jakarta.servlet.ServletContext.

Parameters
ctx:ServletContext

used to retrieve init parameter.

paramName:String

parameter name.

Returns:Integer

parsed Integer value or null when the value is not integer or when the init parameter is not present.

onStartupback to summary
public void onStartup(Set<Class<?>> classes, final ServletContext ctx) throws ServletException

Implements jakarta.servlet.ServletContainerInitializer.onStartup.

Doc from jakarta.servlet.ServletContainerInitializer.onStartup.

Notifies this ServletContainerInitializer of the startup of the application represented by the given ServletContext.

If this ServletContainerInitializer is bundled in a JAR file inside the WEB-INF/lib directory of an application, its onStartup method will be invoked only once during the startup of the bundling application. If this ServletContainerInitializer is bundled inside a JAR file outside of any WEB-INF/lib directory, but still discoverable as described above, its onStartup method will be invoked every time an application is started.

Parameters
classes:Set<Class<?>>

the Set of application classes that extend, implement, or have been annotated with the class types specified by the HandlesTypes annotation, or null if there are no matches, or this ServletContainerInitializer has not been annotated with HandlesTypes

ctx:ServletContext

the ServletContext of the web application that is being started and in which the classes contained in c were found

Annotations
@Override
Exceptions
ServletException:
if an error has occurred
org.glassfish.tyrus.servlet back to summary

private Class TyrusServletContainerInitializer.TyrusServerContainerImpl

extends TyrusServerContainer
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ApplicationEventListener
private final String
private final WebSocketEngine
private final Integer
private final Integer
private final Integer
private final Boolean
private final DebugContext.TracingThreshold
private final DebugContext.TracingType
private final TyrusServletUpgrade

Constructor Summary

AccessConstructor and Description
private
TyrusServerContainerImpl(Set<Class<?>> set, ApplicationEventListener applicationEventListener, Integer incomingBufferSize, Integer maxSessionsPerApp, Integer maxSessionsPerRemoteAddr, Boolean parallelBroadcastEnabled, DebugContext.TracingType tracingType, DebugContext.TracingThreshold tracingThreshold, String contextPath, boolean wsadlEnabled)

Method Summary

Modifier and TypeMethod and Description
private static String
private TyrusServletUpgrade
private static String
public WebSocketEngine
getWebSocketEngine()

Implements org.glassfish.tyrus.spi.ServerContainer.getWebSocketEngine.

Return WebSocketEngine to upgrade requests and setting up the connection.

private static boolean
isVariable(String segment)

public void
public void
public void
upgradeHttpToWebSocket(Object
The HttpServletRequest to be processed as a WebSocket handshake as per section 4.0 of RFC 6455.
servletRequest
,
Object
The HttpServletResponse to be used when processing the httpServletRequest as a WebSocket handshake as per section 4.0 of RFC 6455.
servletResponse
,
ServerEndpointConfig
The server endpoint configuration to use to configure the WebSocket endpoint
sec
,
Map<String, String>
Provides a mapping of path parameter names and values, if any, to be used for the WebSocket connection established by the call to this method. If no such mapping is defined, an empty Map must be passed.
pathParameters
)

Overrides org.glassfish.tyrus.server.TyrusServerContainer.upgradeHttpToWebSocket.

Implements jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

Upgrade the HTTP connection represented by the HttpServletRequest and HttpServletResponse to the WebSocket protocol and establish a WebSocket connection as per the provided ServerEndpointConfig.

Inherited from org.glassfish.tyrus.server.TyrusServerContainer:
addEndpointaddEndpointasyncConnectToServerasyncConnectToServerasyncConnectToServerasyncConnectToServerconnectToServerconnectToServerconnectToServerconnectToServerdoneDeploymentgetClientManagergetDefaultAsyncSendTimeoutgetDefaultMaxBinaryMessageBufferSizegetDefaultMaxSessionIdleTimeoutgetDefaultMaxTextMessageBufferSizegetInstalledExtensionsgetPortsetAsyncSendTimeoutsetDefaultMaxBinaryMessageBufferSizesetDefaultMaxSessionIdleTimeoutsetDefaultMaxTextMessageBufferSizestartstop

Field Detail

applicationEventListenerback to summary
private final ApplicationEventListener applicationEventListener
contextPathback to summary
private final String contextPath
engineback to summary
private final WebSocketEngine engine
incomingBufferSizeback to summary
private final Integer incomingBufferSize
maxSessionsPerAppback to summary
private final Integer maxSessionsPerApp
maxSessionsPerRemoteAddrback to summary
private final Integer maxSessionsPerRemoteAddr
parallelBroadcastEnabledback to summary
private final Boolean parallelBroadcastEnabled
tracingThresholdback to summary
private final DebugContext.TracingThreshold tracingThreshold
tracingTypeback to summary
private final DebugContext.TracingType tracingType
tyrusServletUpgradeback to summary
private final TyrusServletUpgrade tyrusServletUpgrade

Constructor Detail

TyrusServerContainerImplback to summary
private TyrusServerContainerImpl(Set<Class<?>> set, ApplicationEventListener applicationEventListener, Integer incomingBufferSize, Integer maxSessionsPerApp, Integer maxSessionsPerRemoteAddr, Boolean parallelBroadcastEnabled, DebugContext.TracingType tracingType, DebugContext.TracingThreshold tracingThreshold, String contextPath, boolean wsadlEnabled)

Method Detail

computeRequestPathback to summary
private static String computeRequestPath(String path, Map<String, String> pathParams)
getServletUpgradeback to summary
private TyrusServletUpgrade getServletUpgrade()
getVariableNameback to summary
private static String getVariableName(String segment)
getWebSocketEngineback to summary
public WebSocketEngine getWebSocketEngine()

Implements org.glassfish.tyrus.spi.ServerContainer.getWebSocketEngine.

Doc from org.glassfish.tyrus.spi.ServerContainer.getWebSocketEngine.

Return WebSocketEngine to upgrade requests and setting up the connection.

Returns:WebSocketEngine

websocket engine

Annotations
@Override
isVariableback to summary
private static boolean isVariable(String segment)
registerback to summary
public void register(Class<?> endpointClass) throws DeploymentException

Implements abstract org.glassfish.tyrus.server.TyrusServerContainer.register.

Annotations
@Override
registerback to summary
public void register(ServerEndpointConfig serverEndpointConfig) throws DeploymentException

Implements abstract org.glassfish.tyrus.server.TyrusServerContainer.register.

Annotations
@Override
upgradeHttpToWebSocketback to summary
public void upgradeHttpToWebSocket(Object servletRequest, Object servletResponse, ServerEndpointConfig sec, Map<String, String> pathParameters) throws IOException, DeploymentException

Overrides org.glassfish.tyrus.server.TyrusServerContainer.upgradeHttpToWebSocket.

Implements jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

Doc from jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

Upgrade the HTTP connection represented by the HttpServletRequest and HttpServletResponse to the WebSocket protocol and establish a WebSocket connection as per the provided ServerEndpointConfig.

This method is primarily intended to be used by frameworks that implement the front-controller pattern. It does not deploy the provided endpoint.

If the WebSocket implementation is not deployed as part of a Jakarta Servlet container, this method will throw an UnsupportedOperationException.

Parameters
servletRequest:Object

The HttpServletRequest to be processed as a WebSocket handshake as per section 4.0 of RFC 6455.

servletResponse:Object

The HttpServletResponse to be used when processing the httpServletRequest as a WebSocket handshake as per section 4.0 of RFC 6455.

sec:ServerEndpointConfig

The server endpoint configuration to use to configure the WebSocket endpoint

pathParameters:Map<String, String>

Provides a mapping of path parameter names and values, if any, to be used for the WebSocket connection established by the call to this method. If no such mapping is defined, an empty Map must be passed.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs during the establishment of a WebSocket connection
DeploymentException:
if a configuration error prevents the establishment of a WebSocket connection