Annotation Type Request


Request bean annotation.

Identifies an interface to use to interact with HTTP parts of an HTTP request through a bean.

Can be used in the following locations:

  • Arguments and argument-types of server-side @RestOp-annotated methods.
  • Arguments and argument-types of client-side @RemoteResource-annotated interfaces.
Arguments and argument-types of server-side @RestOp-annotated methods

Annotation that can be applied to a parameter of a @RestOp-annotated method to identify it as an interface for retrieving HTTP parts through a bean interface.

Example:

@RestGet("/mypath/{p1}/{p2}/*") public void myMethod(@Request MyRequest requestBean) {...} public interface MyRequest { @Path // Path variable name inferred from getter. String getP1(); @Path("p2") String getX(); @Path("/*") String getRemainder(); @Query String getQ1(); // Schema-based query parameter: Pipe-delimited lists of comma-delimited lists of integers. @Query( collectionFormat="pipes" items=@Items( items=@SubItems( collectionFormat="csv" type="integer" ) ) ) int[][] getQ3(); @Header("*") Map<String,Object> getHeaders();

// Same as above but annotation defined on interface. @RestGet(path="/mypath/{p1}/{p2}/*") public void myMethod(MyRequest requestBean) {...} @Request public interface MyRequest {...}

The return types of the getters must be the supported parameter types for the HTTP-part annotation used.
Schema-based serialization and parsing is allowed just as if used as individual parameter types.

See Also:
Arguments and argument-types of client-side @RemoteResource-annotated interfaces

Annotation applied to Java method arguments of interface proxies to denote a bean with remote resource annotations.

Example:

@RemoteResource(path="/myproxy") public interface MyProxy { @RemoteGet("/mymethod/{p1}/{p2}") String myProxyMethod(@Request MyRequest requestBean); } public class MyRequest { @Path // Path variable name inferred from getter. public String getP1() {...} @Path("p2") public String getX() {...} @Path("/*") public String getRemainder() {...} @Query public String getQ1() {...} // Schema-based query parameter: Pipe-delimited lists of comma-delimited lists of integers. @Query( schema=@Query( collectionFormat="pipes" items=@Items( items=@SubItems( collectionFormat="csv" type="integer" ) ) ) ) public int[][] getQ3() {...} @Header("*") public Map<String,Object> getHeaders() {...} }

See Also:

See Also:
  • Element Details

    • on

      Dynamically apply this annotation to the specified classes.
      See Also:
      Returns:
      The annotation value.
      Default:
      {}
    • onClass

      Dynamically apply this annotation to the specified classes.

      Identical to on() except allows you to specify class objects instead of a strings.

      See Also:
      Returns:
      The annotation value.
      Default:
      {}
    • parser

      Specifies the HttpPartParser class used for parsing strings to values.

      Overrides for this part the part parser defined on the REST resource which by default is OpenApiParser.

      Returns:
      The annotation value.
      Default:
      org.apache.juneau.httppart.HttpPartParser.Void.class
    • serializer

      Specifies the HttpPartSerializer class used for serializing values to strings.

      Overrides for this part the part serializer defined on the REST client which by default is OpenApiSerializer.

      Returns:
      The annotation value.
      Default:
      org.apache.juneau.httppart.HttpPartSerializer.Void.class