org.androidannotations.annotations.rest
Annotation Type RequiresCookie


@Retention(value=CLASS)
@Target(value={METHOD,TYPE})
public @interface RequiresCookie

Use on Get, Post, … annotated methods to inject a cookie in the request.

The annotation value() is mandatory and define the cookie's name you want to inject.

To set a cookie's value you MUST either let your RestClient interface extends of RestClientHeaders or add the following method to your interface : void setCookie(String name, String value).

You can also add the getter version to read a cookie value : void getCookie(String name).

Example :
 @Rest(rootUrl = "http://myserver", converters = MappingJacksonHttpMessageConverter.class)
 public interface MyRestClient {
 
        @Get("/events/{id}")
        @RequiresCookie("session")
        Event getEvent(long id);
   
        void setCookie(String name, String value);
        String getCookie(String name);
 }
 
 @EBean
 public class MyBean {
 
        @RestService MyRestClient;
 
        @AfterInject
        public void init() {
                myRestClient.setCookie("session", "my session uid");
        }
 }
 

See Also:
Rest, Get, Post, Put, Delete, Head, Options, SetsCookie

Required Element Summary
 String[] value
           
 

Element Detail

value

public abstract String[] value


Copyright © 2010-2014. All Rights Reserved.