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     * CookieParam.java
015     *
016     * Created on November 16, 2006, 2:04 PM
017     *
018     */
019    
020    package javax.ws.rs;
021    
022    import java.lang.annotation.ElementType;
023    import java.lang.annotation.Retention;
024    import java.lang.annotation.RetentionPolicy;
025    import java.lang.annotation.Target;
026    
027    /**
028     * Binds the value of a HTTP cookie to a resource method parameter, 
029     * resource class field, or resource class bean property.
030     * A default value can be specified using the {@link DefaultValue}
031     * annotation.
032     * 
033     * The type <code>T</code> of the annotated parameter, field or property must 
034     * either:
035     * <ol>
036     * <li>Be a primitive type</li>
037     * <li>Be {@link javax.ws.rs.core.Cookie}</li>
038     * <li>Have a constructor that accepts a single String argument</li>
039     * <li>Have a static method named <code>valueOf</code> or <code>fromString</code>
040     * that accepts a single 
041     * String argument (see, for example, {@link Integer#valueOf(String)})
042     * <li>Be <code>List&lt;T&gt;</code>, <code>Set&lt;T&gt;</code> or 
043     * <code>SortedSet&lt;T&gt;</code>, where <code>T</code> satisfies 2, 3 or 4 above.
044     * The resulting collection is read-only.</li>
045     * </ol>
046     *
047     * <p>Because injection occurs at object creation time, use of this annotation 
048     * on resource class fields and bean properties is only supported for the 
049     * default per-request resource class lifecycle. Resource classes using 
050     * other lifecycles should only use this annotation on resource method
051     * parameters.</p>
052     *
053     * @see DefaultValue
054     * @see javax.ws.rs.core.Cookie
055     * @see javax.ws.rs.core.HttpHeaders#getCookies
056     */
057    @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD})
058    @Retention(RetentionPolicy.RUNTIME)
059    public @interface CookieParam {
060        /**
061         * Defines the name of the HTTP cookie whose value will be used
062         * to initialize the value of the annotated method argument, class field or
063         * bean property.
064         */
065        String value();
066    }