, . .
, - @NameBinding:
@NameBinding
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface ResponseStatusCreated {}
, .
@ResponseStatusCreated
@Provider
class StatusCreatedFilter implements ContainerResponseFilter {
@Override
public void filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) throws IOException {
responseContext.setStatusInfo(Response.Status.CREATED)
String location = "...";
responseContext.getHeaders().putSingle("Location", location);
}
}
.
@POST
@Path("widget")
@ResponseStatusCreated
Object create(@RequestBody @Valid Widget wid) {
return ...
}
, , , .. @ResponseStatus(Status.CREATED) , responseContext.getAnnotations().