Top Description Methods
javax.websocket.server

public @Interface PathParam

extends Annotation
Annotations
@Retention:RUNTIME
@Target:PARAMETER
Imports
java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target

This annotation may be used to annotate method parameters on server endpoints where a URI-template has been used in the path-mapping of the ServerEndpoint annotation. The method parameter may be of type String, 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:-


@ServerEndpoint("/bookings/{guest-id}")
public class BookingServer {

    @OnMessage
    public void processBookingRequest(@PathParam("guest-id") String guestID, String message, Session session) {
        // process booking from the given guest here
    }
}

For example:-


@ServerEndpoint("/rewards/{vip-level}")
public class RewardServer {

    @OnMessage
    public void processReward(@PathParam("vip-level") Integer vipLevel, String message, Session session) {
        // process reward here
    }
}
Author
dannycoward

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the name of the variable used in the URI-template.
value
()

The name of the variable used in the URI-template.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public 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:String

the name of the variable used in the URI-template.