Annotation Type BeanParam


@Target({PARAMETER,METHOD,FIELD}) @Retention(RUNTIME) @Documented public @interface BeanParam
The annotation that may be used to inject a custom "parameter aggregator" value object into a resource class field, property or resource method parameter.

The runtime will instantiate the object and inject all it's fields and properties annotated with either one of the @XxxParam annotation (@PathParam, @FormParam ...) or the @Context annotation. For the POJO classes same instantiation and injection rules apply as in case of instantiation and injection of request-scoped root resource classes.

For example:

public class MyBean {
  @FormParam("myData")
  private String data;

  @HeaderParam("myHeader")
  private String header;

  @PathParam("id")
  public void setResourceId(String id) {...}

  ...
}

@Path("myresources")
public class MyResources {
  @POST
  @Path("{id}")
  public void post(@BeanParam MyBean myBean) {...}

  ...
}

Because injection occurs at object creation time, use of this annotation on resource class fields and bean properties is only supported for the default per-request resource class lifecycle. Resource classes using other lifecycles should only use this annotation on resource method parameters.

Since:
2.0