Skip to content

Creating Stateful Endpoints

Lahiru Sahan Jayasinghe edited this page Jan 5, 2014 · 2 revisions

By default, the execution of a request does not consult an HTTP context and does not maintain a stateful conversation with the server. This can be changed by placing the @Stateful annotation on the endpoint. @Stateful directs request execution to use an BasicHttpContext with a BasicCookieStore which provides session management via cookies.

@Stateful
@Endpoint("http://example.com")
public interface ExampleEndpoint {

    @GET("/rememberme")
    void rememberMe();
}

...

endpoint.rememberMe(); //1. Creates a new session.
endpoint.rememberMe(); //2. Identifies an existing session.

1. response-header: "Set-Cookie: JSESSIONID=123456789"
2. request-header: "Cookie: JSESSIONID=123456789"