javax.websocket.server

Annotation Type ServerEndpoint


  • @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
    • 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

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

21/08/2025 19:05:32 Cette version de la page est en cache (à la date du 21/08/2025 19:05:32) afin d'accélérer le traitement.
Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.

Document créé le 11/06/2005, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/websocket/server/ServerEndpoint.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, ServerEndpoint (Java(TM) EE 7 Specification APIs)

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.