Oracle Fusion Middleware
Java API Reference for Oracle WebLogic Server
12c (12.1.2)

Part Number E27170-01

weblogic.websocket.annotation
Annotation Type WebSocket


@Target(value=java.lang.annotation.ElementType.TYPE)
@Retention(value=RUNTIME)
public @interface WebSocket

Annotation used to declare a WebSocket which communicates endpoints with the WebSocket Protocol (RFC6455).

The class annotated by the @WebSocket annotation must implement the WebSocketListener interface. The corresponding WebSocketListener instance is used to handle messages over the WebSocket to which the resource path is matched by the path pattern specified by the pathPatterns attribute of the @WebSocket annotation.

Example:


    @WebSocket (
       pathPatterns = {"/chat/*"},
       dispatchPolicy = "ChatWorkManager",
       timeout = 30,
       maxConnections = 1000
    )
    public class MyListener implements WebSocketListener {
      ...
    }
 

See Also:
http://tools.ietf.org/html/rfc6455, WebSocketListener

Optional Element Summary
 String dispatchPolicy
          The dispatch policy on which the events will be fired.
 int maxConnections
          Get the maximum open connections on this WebSocket.
 int maxMessageSize
          Get the maximum message size this WebSocket can handle.
 String[] pathPatterns
          Get the path pattern defined for this WebSocket.
 int timeout
          Get the timeout value for the WebSocket.
 

pathPatterns

public abstract String[] pathPatterns

Get the path pattern defined for this WebSocket. The default resource path is "/ws/*".

The following syntax is used to define path patterns:

  • The path pattern string must begin with a '/' character.
  • If the path pattern string ends with '/*' suffix, the path pattern matches any resource path that starts with the path pattern string trimming '*' suffix. For example, resource path '/ws/chat' is matched by path pattern '/ws/*'.
  • Otherwise, the resource path is matched only when it matches the path pattern exactly.

    Returns:
    the resource path.
    Default:
    "/ws/*"

  • dispatchPolicy

    public abstract String dispatchPolicy
    The dispatch policy on which the events will be fired. This uses the default dispatch policy for the Web application as the default.

    Returns:
    the dispatch policy.
    Default:
    ""

    timeout

    public abstract int timeout
    Get the timeout value for the WebSocket. A value of -1 indicates that the WebSocket will never time out. The default timeout value is 30 seconds.

    Returns:
    the timeout value in seconds.
    Default:
    30

    maxMessageSize

    public abstract int maxMessageSize
    Get the maximum message size this WebSocket can handle. Any message that exceeds this size will be rejected and the WebSocket will be closed with status code ClosingMessage.SC_MESSAGE_TOO_BIG. The default value is 4080 bytes.

    Returns:
    the maximum message size in bytes.
    Default:
    4080

    maxConnections

    public abstract int maxConnections
    Get the maximum open connections on this WebSocket. If open connections on this WebSocket exceed this value, any new HTTP request upgrading to this WebSocket will be rejected. A value of -1 indicates that there is no limitation on open connections. The default value is -1.

    Returns:
    the maximum open connections.
    Default:
    -1

    Copyright 1996, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

    Oracle Fusion Middleware
    Java API Reference for Oracle WebLogic Server
    12c (12.1.2)

    Part Number E27170-01