001// *************************************************************************************************************************** 002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file * 003// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file * 004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance * 005// * with the License. You may obtain a copy of the License at * 006// * * 007// * http://www.apache.org/licenses/LICENSE-2.0 * 008// * * 009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an * 010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * 011// * specific language governing permissions and limitations under the License. * 012// *************************************************************************************************************************** 013package org.apache.juneau.rest.annotation; 014 015import static java.lang.annotation.ElementType.*; 016import static java.lang.annotation.RetentionPolicy.*; 017 018import java.io.*; 019import java.lang.annotation.*; 020 021/** 022 * Annotation that can be applied to a parameter of a {@link RestMethod @RestMethod} annotated method to identify it as the HTTP 023 * request body converted to a POJO. 024 * 025 * <h5 class='section'>Example:</h5> 026 * <p class='bcode'> 027 * <ja>@RestMethod</ja>(name=<jsf>POST</jsf>) 028 * <jk>public void</jk> doPostPerson(RestRequest req, RestResponse res, <ja>@Body</ja> Person person) { 029 * ... 030 * } 031 * </p> 032 * 033 * <p> 034 * This is functionally equivalent to the following code... 035 * <p class='bcode'> 036 * <ja>@RestMethod</ja>(name=<jsf>POST</jsf>) 037 * <jk>public void</jk> doPostPerson(RestRequest req, RestResponse res) { 038 * Person person = req.getBody().asType(Person.<jk>class</jk>); 039 * ... 040 * } 041 * </p> 042 * 043 * <p> 044 * {@link Reader Readers} and {@link InputStream InputStreams} can also be specified as content parameters. 045 * When specified, any registered parsers are bypassed. 046 * <p class='bcode'> 047 * <ja>@RestMethod</ja>(name=<jsf>POST</jsf>) 048 * <jk>public void</jk> doPostPerson(<ja>@Header</ja>(<js>"Content-Type"</js>) String mediaType, <ja>@Body</ja> InputStream input) { 049 * ... 050 * } 051 * </p> 052 * 053 * <h5 class='section'>See Also:</h5> 054 * <ul> 055 * <li class='link'><a class="doclink" href="../../../../../overview-summary.html#juneau-rest-server.Body">Overview > juneau-rest-server > @Body</a> 056 * </ul> 057 */ 058@Documented 059@Target(PARAMETER) 060@Retention(RUNTIME) 061@Inherited 062public @interface Body {}