001    /*
002     * The contents of this file are subject to the terms
003     * of the Common Development and Distribution License
004     * (the "License").  You may not use this file except
005     * in compliance with the License.
006     * 
007     * You can obtain a copy of the license at
008     * http://www.opensource.org/licenses/cddl1.php
009     * See the License for the specific language governing
010     * permissions and limitations under the License.
011     */
012    
013    /*
014     * HeaderParam.java
015     *
016     * Created on January 24, 2007, 2:33 PM
017     *
018     */
019    
020    package javax.ws.rs;
021    
022    import java.lang.annotation.Documented;
023    import java.lang.annotation.ElementType;
024    import java.lang.annotation.Retention;
025    import java.lang.annotation.RetentionPolicy;
026    import java.lang.annotation.Target;
027    
028    /**
029     * Binds the value(s) of a HTTP header to a resource method parameter, 
030     * resource class field, or resource class bean property. A default value 
031     * can be specified using the {@link DefaultValue} annotation.
032     * 
033     * The type <code>T</code> of the annotated parameter, field or property 
034     * must either:
035     * <ol>
036     * <li>Be a primitive type</li>
037     * <li>Have a constructor that accepts a single <code>String</code> argument</li>
038     * <li>Have a static method named <code>valueOf</code> or <code>fromString</code>
039     * that accepts a single 
040     * <code>String</code> argument (see, for example, {@link Integer#valueOf(String)})</li>
041     * <li>Be <code>List&lt;T&gt;</code>, <code>Set&lt;T&gt;</code> or 
042     * <code>SortedSet&lt;T&gt;</code>, where <code>T</code> satisfies 2 or 3 above.
043     * The resulting collection is read-only.</li>
044     * </ol>
045     * 
046     * <p>If the type is not one of those listed in 4 above then the first value 
047     * (lexically) of the header is used.</p>
048     *
049     * <p>Because injection occurs at object creation time, use of this annotation 
050     * on resource class fields and bean properties is only supported for the 
051     * default per-request resource class lifecycle. Resource classes using 
052     * other lifecycles should only use this annotation on resource method
053     * parameters.</p>
054     *
055     * @see DefaultValue
056     * @see javax.ws.rs.core.HttpHeaders
057     */
058    @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
059    @Retention(RetentionPolicy.RUNTIME)
060    @Documented
061    public @interface HeaderParam {
062        /**
063         * Defines the name of the HTTP header whose value will be used
064         * to initialize the value of the annotated method argument, class field or
065         * bean property. Case insensitive.
066         */
067        String value();
068    }