org.atmosphere.annotation.http
Annotation Type Path


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

Identifies the URI path that a resource class or class method will serve requests for. Embedded template variables are allowed and are of the form {name} where name is the template variable name. Values of template variables may be extracted using PathParam.

Paths are relative. For an annotated class the base URI is the application context. For an annotated method the base URI is the effective URI of the containing class. For the purposes of absolutizing a path against the base URI , a leading '/' in a path is ignored and base URIs are treated as if they ended in '/'. E.g.:

@Path("widgets")
public class WidgetsResource {
  @GET
  String getList() {...}
 
  @GET @Path("{id}")
  String getWidget(@PathParam("id") String id) {...}
}

In the above, if the application context is http://example.com/catalogue, then GET reguests for http://example.com/catalogue/widgets will be handled by the getList method while reguests for http://example.com/catalogue/widgets/nnn (where nnn is some value) will be handled by the getWidget method. The same would apply if the value of either @Path annotation started with '/'.

Classes may also be annotated with ConsumeMime and ProduceMime to filter the requests they will receive.

See Also:
ConsumeMime, ProduceMime, PathParam

Required Element Summary
 String value
          Defines a URI template for the resource class or method, must not include matrix parameters.
 
Optional Element Summary
 boolean encode
          Controls whether the literal part of the supplied value (those characters that are not part of a template variable) are URL encoded.
 boolean limited
          Controls whether a trailing template variable is limited to a single path segment (true) or not (false).
 

Element Detail

value

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

encode

public abstract boolean encode
Controls whether the literal part of the supplied value (those characters that are not part of a template variable) are URL encoded. If true, any characters in the URI template that are not valid URI character will be automatically encoded. If false then all characters must be valid URI characters.

Default:
true

limited

public abstract boolean limited
Controls whether a trailing template variable is limited to a single path segment (true) or not (false). E.g. @Path("widgets/{id}") would match widgets/foo but not widgets/foo/bar whereas @Path(value="widgets/{id}", limit=false) would match both.

Default:
true


Copyright © 2009 SUN Microsystems. All Rights Reserved.