Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package pl.matisoft.soy.global.runtime.resolvers;
 
 
 import java.util.Date;
Created with IntelliJ IDEA. User: mati Date: 01/11/2013 Time: 18:21
public class HttpSessionDataResolver implements RuntimeDataResolver {
    private String prefix = "_http.session.";
    @Override
    public void resolveData(final HttpServletRequest requestfinal HttpServletResponse responsefinal Map<String, ? extends Objectmodelfinal SoyMapData root) {
        final HttpSession session = request.getSession(false);
        if (session == null) {
            return;
        }
        appendId(rootsession);
        appendCreationTime(rootsession);
        appendLastAccessedTime(rootsession);
        appendMaxInactiveInterval(rootsession);
    }
    private void appendMaxInactiveInterval(final SoyMapData rootfinal HttpSession session) {
        root.put( + "maxInactiveInterval"session.getMaxInactiveInterval());
    }
    private void appendLastAccessedTime(final SoyMapData rootfinal HttpSession session) {
        root.put( + "lastAccessedTime", DateFormat.getDateTimeInstance().format(new Date(session.getLastAccessedTime())));
    }
    private void appendCreationTime(final SoyMapData rootfinal HttpSession session) {
        root.put( + "creationTime", DateFormat.getDateTimeInstance().format(new Date(session.getCreationTime())));
    }
    private void appendId(final SoyMapData rootfinal HttpSession session) {
        if (session.getId() != null) {
            root.put( + "id"session.getId());
        }
    }
New to GrepCode? Check out our FAQ X