How to use Sessions on DropWizard

Since 0.7.0 HttpSessions are supported.

dropwizard
So what to do? Two things.
On the Application class:

@Override
public void run(DemoConfiguration config, Environment environment)
throws ClassNotFoundException {

environment.servlets().setSessionHandler(new SessionHandler());
environment.jersey().register(HttpSessionProvider.class);
}

On the Resource class:

@GET
@Path(“/sessiontest”)
@Timed
@UnitOfWork
@ExceptionMetered
public DemoView getMain(@Context UriInfo info,
@Session HttpSession session,
@PathParam(“param1”) String param1){


}

Dropwizard with Sessions

Advertisements

Posted on January 31, 2015, in Uncategorized. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: