Top Description Methods
jakarta.websocket.server

public @Interface ServerEndpoint

extends Annotation
Annotations
@Retention:RUNTIME
@Target:TYPE
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, jakarta.websocket.Decoder, .Encoder

This class level annotation declares that the class it decorates is a web socket endpoint that will be deployed and made available in the URI-space of a web socket server. The annotation allows the developer to define the URL (or URI template) which this endpoint will be published, and other important properties of the endpoint to the websocket runtime, such as the encoders it uses to send messages.

The annotated class must have a public no-arg constructor.

For example:


@ServerEndpoint("/hello");
public class HelloServer {

    @OnMessage
    public void processGreeting(String message, Session session) {
        System.out.println("Greeting received:" + message);
    }

}

Author
dannycoward

Method Summary

Modifier and TypeMethod and Description
public Class<? extends ServerEndpointConfig.Configurator>

Returns:

the custom configuration class, or ServerEndpointConfig.Configurator.class if none was set in the annotation.
configurator
()

The optional custom configurator class that the developer would like to use to further configure new instances of this endpoint.

public Class<? extends Decoder>[]

Returns:

the decoders.
decoders
()

The ordered array of decoder classes this endpoint will use.

public Class<? extends Encoder>[]

Returns:

the encoders.
encoders
()

The ordered array of encoder classes this endpoint will use.

public String[]

Returns:

the subprotocols.
subprotocols
()

The ordered array of web socket protocols this endpoint supports.

public String

Returns:

the URI or URI-template
value
()

The URI or URI-template, level-1 (See RFC 6570) where the endpoint will be deployed.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

configuratorback to summary
public Class<? extends ServerEndpointConfig.Configurator> configurator()

The optional custom configurator class that the developer would like to use to further configure new instances of this endpoint. If no configurator class is provided, the implementation uses its own. The implementation creates a new instance of the configurator per logical endpoint.

Returns:Class<? extends ServerEndpointConfig.Configurator>

the custom configuration class, or ServerEndpointConfig.Configurator.class if none was set in the annotation.

decodersback to summary
public Class<? extends Decoder>[] decoders()

The ordered array of decoder classes this endpoint will use. For example, if the developer has provided a MysteryObject decoder, this endpoint will be able to receive MysteryObjects as web socket messages. The websocket runtime will use the first decoder in the list able to decode a message, ignoring the remaining decoders.

Returns:Class<? extends Decoder>[]

the decoders.

encodersback to summary
public Class<? extends Encoder>[] encoders()

The ordered array of encoder classes this endpoint will use. For example, if the developer has provided a MysteryObject encoder, this class will be able to send web socket messages in the form of MysteryObjects. The websocket runtime will use the first encoder in the list able to encode a message, ignoring the remaining encoders.

Returns:Class<? extends Encoder>[]

the encoders.

subprotocolsback to summary
public String[] subprotocols()

The ordered array of web socket protocols this endpoint supports. For example, {"superchat", "chat"}.

Returns:String[]

the subprotocols.

valueback to summary
public String value()

The URI or URI-template, level-1 (See RFC 6570) where the endpoint will be deployed. The URI us relative to the root of the web socket container and must begin with a leading "/". Trailing "/"'s are ignored. Examples:


@ServerEndpoint("/chat")
@ServerEndpoint("/chat/{user}")
@ServerEndpoint("/booking/{privilege-level}")

Returns:String

the URI or URI-template