-
@Retention(value=RUNTIME) @Target(value=TYPE) public @interface ServerEndpoint
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
-
-
Required Element Summary
Required Elements Modifier and Type Required Element and Description String
value
The URI or URI-template, level-1 (See RFC 6570) where the endpoint will be deployed.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element and Description 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.Class<? extends Decoder>[]
decoders
The ordered array of decoder classes this endpoint will use.Class<? extends Encoder>[]
encoders
The ordered array of encoder classes this endpoint will use.String[]
subprotocols
The ordered array of web socket protocols this endpoint supports.
-
-
-
Element Detail
-
value
public abstract 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:
- the URI or URI-template
-
-
-
subprotocols
public abstract String[] subprotocols
The ordered array of web socket protocols this endpoint supports. For example, {"superchat", "chat"}.- Returns:
- the subprotocols.
- Default:
- {}
-
-
-
decoders
public abstract 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:
- the decoders.
- Default:
- {}
-
-
-
encoders
public abstract 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:
- the encoders.
- Default:
- {}
-
-
-
configurator
public abstract 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:
- the custom configuration class, or ServerEndpointConfig.Configurator.class if none was set in the annotation.
- Default:
- javax.websocket.server.ServerEndpointConfig.Configurator.class
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/websocket/server/ServerEndpoint.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.