javax.net.websocket.annotations
Annotation Type WebSocketEndpoint


@Retention(value=RUNTIME)
@Target(value=TYPE)
public @interface WebSocketEndpoint

This class level annotation declares that the class it decorates is a web socket endpoint. The annotation allows the developer to define the URL (or URI template) which this endpoint must 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:

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

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

Since:
Draft 002
Author:
dannycoward

Required Element Summary
 String value
          The URI or URI-template (level-1) where the endpoint will be deployed.
 
Optional Element Summary
 Class[] decoders
          The ordered array of decoder classes this endpoint will use.
 Class[] 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) where the endpoint will be deployed. The URI us relative to the root of the web socket container. Examples:
 @WebSocketEndpoint("/chat")
 @WebSocketEndpoint("/chat/{user}")
 @WebSocketEndpoint("/booking/{privilege-level}")

subprotocols

public abstract String[] subprotocols
The ordered array of web socket protocols this endpoint supports. For example, {'superchat', 'chat'}.

Default:
{}

decoders

public abstract Class[] 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.

Default:
{}

encoders

public abstract Class[] 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.

Default:
{}


Copyright © 2012. All Rights Reserved.