Top Description Fields Constructors Methods
org.glassfish.tyrus.server

public Class Server

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.Arrays, .HashMap, .HashSet, .Map, .Set, .StringTokenizer, java.util.logging.Logger, jakarta.websocket.DeploymentException, org.glassfish.tyrus.spi.ServerContainer, .ServerContainerFactory

Implementation of the WebSocket Server.
Authors
Stepan Kopriva, Pavel Bucek

Field Summary

Modifier and TypeField and Description
private final Set<Class<?>>
private final String
private static final String
private static final String
private static final int
private final String
private static final Logger
private volatile int
private final Map<String, Object>
private ServerContainer
public static final String
STATIC_CONTENT_ROOT

Path to static content to be served by created Server instance.

Constructor Summary

AccessConstructor and Description
public
Server(Class<?>...
to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.
configuration
)

Create new server instance.

public
Server(Map<String, Object>
properties used as a parameter to (java.util.Map) call.
properties
,
Class<?>...
to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.
configuration
)

Create new server instance.

public
Server(String
hostName of the server.
hostName
,
int
port of the server. When provided value is 0, default port (8025) will be used, when -1, ephemeral port number will be used.
port
,
String
root path to the server App.
contextPath
,
Map<String, Object>
properties used as a parameter to (java.util.Map) call.
properties
,
Class<?>...
to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.
configuration
)

Construct new server.

public
Server(String
hostName of the server.
hostName
,
int
port of the server. When provided value is 0, default port (8025) will be used, when -1, ephemeral port number will be used.
port
,
String
root path to the server App.
contextPath
,
Map<String, Object>
properties used as a parameter to (java.util.Map) call.
properties
,
Set<Class<?>>
to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.
configuration
)

Construct new server.

Method Summary

Modifier and TypeMethod and Description
private static Set<Class<?>>
public int

Returns:

the port which was used to start the container.
getPort
()

Get the port which was used to start the container.

public static void
main(String[] args)

public void
start()

Start the server.

public void
stop()

Stop the server.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configurationback to summary
private final Set<Class<?>> configuration
contextPathback to summary
private final String contextPath
DEFAULT_CONTEXT_PATHback to summary
private static final String DEFAULT_CONTEXT_PATH
DEFAULT_HOST_NAMEback to summary
private static final String DEFAULT_HOST_NAME
DEFAULT_PORTback to summary
private static final int DEFAULT_PORT
hostNameback to summary
private final String hostName
LOGGERback to summary
private static final Logger LOGGER
portback to summary
private volatile int port
propertiesback to summary
private final Map<String, Object> properties
serverback to summary
private ServerContainer server
STATIC_CONTENT_ROOTback to summary
public static final String STATIC_CONTENT_ROOT

Path to static content to be served by created Server instance.

Value have to be non-empty String and should represent content root of static content (file system path).

See Also
Server#Server(java.util.Map, Class[]), Server#Server(String, int, String, java.util.Map, Class[]), Server#Server(String, int, String, java.util.Map, java.util.Set)

Constructor Detail

Serverback to summary
public Server(Class<?>... configuration)

Create new server instance.

Parameters
configuration:Class<?>[]

to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.

Serverback to summary
public Server(Map<String, Object> properties, Class<?>... configuration)

Create new server instance.

Parameters
properties:Map<String, Object>

properties used as a parameter to (java.util.Map) call.

configuration:Class<?>[]

to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.

Serverback to summary
public Server(String hostName, int port, String contextPath, Map<String, Object> properties, Class<?>... configuration)

Construct new server.

Parameters
hostName:String

hostName of the server.

port:int

port of the server. When provided value is 0, default port (8025) will be used, when -1, ephemeral port number will be used.

contextPath:String

root path to the server App.

properties:Map<String, Object>

properties used as a parameter to (java.util.Map) call.

configuration:Class<?>[]

to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.

See Also
getPort()
Serverback to summary
public Server(String hostName, int port, String contextPath, Map<String, Object> properties, Set<Class<?>> configuration)

Construct new server.

Parameters
hostName:String

hostName of the server.

port:int

port of the server. When provided value is 0, default port (8025) will be used, when -1, ephemeral port number will be used.

contextPath:String

root path to the server App.

properties:Map<String, Object>

properties used as a parameter to (java.util.Map) call.

configuration:Set<Class<?>>

to be registered with the server. Classes annotated with jakarta.websocket.server.ServerEndpoint, implementing jakarta.websocket.server.ServerApplicationConfig or extending jakarta.websocket.server.ServerEndpointConfig are supported.

See Also
getPort()

Method Detail

getClassesFromStringback to summary
private static Set<Class<?>> getClassesFromString(String rawString)
getPortback to summary
public int getPort()

Get the port which was used to start the container.

Returns:int

the port which was used to start the container.

mainback to summary
public static void main(String[] args)
startback to summary
public void start() throws DeploymentException

Start the server.

stopback to summary
public void stop()

Stop the server.