javax.servlet.http.*;
import com.jamonapi.*;
/*
To put the object into an HTTPSession call: session.setAttribute("user", new User("steve"));
*/
public class User extends java.lang.Object implements HttpSessionBindingListener {
private Monitor userMon;
private Monitor sessionMon;
// Assumes you have a way of populating the userName
private String userName;
public User(String userName) {
this.userName=userName;
}
public void valueBound(HttpSessionBindingEvent event) {
sessionMon = MonitorFactory.start("MyAppName.allSessions");
userMon = MonitorFactory.start("MyAppName.session."+userName);
}
/* Called when a sessin ends with an explicit invalidate() or its timeout period has been reached. */
public void valueUnbound(HttpSessionBindingEvent event) {
userMon.stop();
sessionMon.stop();
}
}