Show ThinkcapSessionListener.java syntax highlighted
package org.integratedmodelling.thinkcap;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.apache.velocity.VelocityContext;
import org.integratedmodelling.thinklab.exception.ThinklabException;
public class ThinkcapSessionListener implements HttpSessionListener {
public void sessionCreated(HttpSessionEvent arg0) {
HttpSession session = arg0.getSession();
/* create new IMT session and link it to HTTP session */
ThinkcapSession sess = null;
ThinkCap thinkcap = ThinkcapManager.getThinkcapManager().getThinkcap();
try {
sess = (ThinkcapSession) thinkcap.createNewSession();
} catch (ThinklabException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
session.setAttribute("thinkcap.session.IMTSession", sess);
/*
* TODO authentication, logging, bookkeeping
* lookup cookies
*
* */
/* retrieve common context */
VelocityContext cct = (VelocityContext)
session.getServletContext().getAttribute("thinkcap.VelocityContext");
/*
* prepare context for request handling, merging in common context
*/
VelocityContext ctx = new VelocityContext(cct);
/* initialize as needed */
ctx.put("pageSpecs", new PageSpecs(ctx));
ctx.put("thinkcapSession", sess);
/* put stuff into session */
sess.initialize(session, ctx);
/* set context into http session */
session.setAttribute("thinkcap.session.VelocityContext", ctx);
}
public void sessionDestroyed(HttpSessionEvent arg0) {
// TODO cleanup, save
}
}
See more files for this project here