Annotation Type Path


  • @Retention(RUNTIME)
    @Target({METHOD,TYPE})
    public @interface Path
    Allocate a path to a component.

    This annotation can be applied to either a method or a type:

    • Method - the method should return a handleable type - i.e. either a RequestHandler, an annotated POJO, or an implementation of a resource handler interface. This will expose the returned object as a subpath beneath the handler that the method is a member of.
    • Type - declare the path of a handleable type, so that the path does not have to be declared in a separate interaction with a router. Note that if the @Path-annotated handleable type is returned from a method on another type also annotated with @Path, then the type annotation is ignored.

    Example:

    
         @RequestHandler(variant = COLLECTION_RESOURCE)
         @Path("things")
         public class ThingProducer {
             @Read
             public Promise<ResourceResponse, ResourceException> get(String id) {
                 // ...
             }
    
             @Path("{thing}/subthing")
             public SubthingProducer subthing() {
                 return new SubthingProducer();
             }
         }
    
         @RequestHandler(variant = SINGLETON_RESOURCE)
         public class SubthingProducer {
             @Read
             public Promise<ResourceResponse, ResourceException> get() {
                 // ...
             }
         }
     
    In this example, when an instance of ThingProducer would result in the following paths being created:
    • /things - collection binding to ThingProducer
    • /things/{id} - instance binding to ThingProducer
    • /things/{thing}/subthing - singleton binding to SubthingProducer
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String value
      The path value.
    • Element Detail

      • value

        String value
        The path value.