org.cruxframework.crux.core.shared.rest.annotation
Annotation Type Path


@Target(value={TYPE,METHOD})
@Retention(value=RUNTIME)
public @interface Path

Used to define the path that will be associated to a REST operation, or a class with operations.

See the following example:

 @Path("rest")
 public class MyRestService{
    @GET
    @Path("test/{param1}")
    public String testOperation(@PathParam("param1") String value) {
       return null;
    }
 }
 

The method testOperation will answer for requests done to the URI http://<yourdomain>/<context>/rest/test/<anythingYouPassHere>

Author:
Thiago da Rosa de Bustamante

Required Element Summary
 String value
          Defines a URI template for the resource class or method, must not include matrix parameters.
 

Element Detail

value

public abstract String value
Defines a URI template for the resource class or method, must not include matrix parameters.

Embedded template parameters are allowed and are of the form:

 param = "{" *WSP name *WSP [ ":" *WSP regex *WSP ] "}"
 name = (ALPHA / DIGIT / "_")*(ALPHA / DIGIT / "." / "_" / "-" ) ; \w[\w\.-]*
 regex = *( nonbrace / "{" *nonbrace "}" ) ; where nonbrace is any char other than "{" and "}"

See RFC 5234 for a description of the syntax used above and the expansions of WSP, ALPHA and DIGIT. In the above name is the template parameter name and the optional regex specifies the contents of the capturing group for the parameter. If regex is not supplied then a default value of [^/]+ which terminates at a path segment boundary, is used. Matching of request URIs to URI templates is performed against encoded path values and implementations will not escape literal characters in regex automatically, therefore any literals in regex should be escaped by the author according to the rules of RFC 3986 section 3.3. Caution is recommended in the use of regex, incorrect use can lead to a template parameter matching unexpected URI paths. See Pattern for further information on the syntax of regular expressions. Values of template parameters may be extracted using PathParam.

The literal part of the supplied value (those characters that are not part of a template parameter) is automatically percent encoded to conform to the path production of RFC 3986 section 3.3. Note that percent encoded values are allowed in the literal part of the value, an implementation will recognize such values and will not double encode the '%' character.



Copyright © 2015. All rights reserved.