Saturday, March 12, 2011
Wednesday, March 2, 2011
CookieBaker: Dead Simple Java Library to Use HTTP Cookies as POJOs
CookieBaker is a dead simple Java library to read and write cookies in POJO form to avoid string splits and joins all over your codebase. Behind the scenes CookieBaker stores the cookie in JSON format using Jackson. CookieBaker also provides HMAC support, currently using SHA1 by default.
Usage
Define a simple Pojo with a default constructor
public class SampleObject implements Serializable { private String myString; public SampleObject() {} public String getMyString() { return myString; } public void setMyString(String myString) { this.myString = myString; } }Set Cookie
CookieBaker.saveCookie(response, cookieName, mySampleObjectInstance);
Get Cookie
SampleObject o = CookieBaker.getCookie(request, SampleObject.class, cookieName);
Install
git clone git@github.com:feliperazeek/CookieBaker.git
cd CookieBaker
mvn install
Import jar to your CLASSPATH or add Maven dependency to your project.
<dependency> <groupId>geeks.aretotally.in</groupId> <artifactId>cookiebaker</artifactId> <version>0.1</version> </dependency>
Roadmap
Integrate HTML5 Local Storage with browser auto-detection.
Subscribe to:
Comments (Atom)