javax.websocket
Annotation Type WebSocketPathParam
@Retention(value=RUNTIME)
@Target(value=PARAMETER)
public @interface WebSocketPathParam
This annotation may be used to annotate method parameters on server side web socket POJOs
where a URI-template has been used in the path-mapping of the WebSocketEndpoint
annotation. The method parameter may be of type String or any Java primitive
type or any boxed version thereof. If a client URI matches the URI-template,
but the requested path parameter cannot be decoded, then the websocket's error
handler will be called.
For example:-
 @WebSocketEndpoint("/bookings/{guest-id}");
public class BookingServer {
  @WebSocketMessage
 public void processBookingRequest(@WebSocketPathParam("guest-id") String guestID, String message, Session session) {
   // process booking from the given guest here
 }
}
For example:-
 @WebSocketEndpoint("/rewards/{vip-level}");
public class RewardServer {
  @WebSocketMessage
 public void processReward(@WebSocketPathParam("vip-level") Integer vipLevel, String message, Session session) {
   // process reward here
 }
}
- Author:
- dannycoward
|
Required Element Summary |
String |
value
The name of the variable used in the URI-template. |
value
public abstract String value
- The name of the variable used in the URI-template. If the name does
not match a path variable in the URI-template, the value of the method parameter
this annotation annotates is null.
- Returns:
- the name of the variable used in the URI-template.
Copyright © 2012 Oracle and/or its affiliates. All rights reserved.