@DirectMethod
public WebContextInfo test_webContext() {
assert WebContextManager.isWebContextAttachedToCurrentThread();
WebContext context = WebContextManager.get();
HttpSession session = context.getSession();
ServletContext application = context.getServletContext();
// Keep a counter of how many times we have called this method in this session
Integer callsInSession = (Integer)session.getAttribute("callsInSession");
if( callsInSession == null ) {
callsInSession = Integer.valueOf(0);
}
callsInSession = Integer.valueOf(callsInSession.intValue() + 1);
session.setAttribute("callsInSession", callsInSession);
// Keep a counter of how many times we have called this method in this application
Integer callsInApplication = (Integer)application.getAttribute("callsInApplication");
if( callsInApplication == null ) {
callsInApplication = Integer.valueOf(0);
}
callsInApplication = Integer.valueOf(callsInApplication.intValue() + 1);
application.setAttribute("callsInApplication", callsInApplication);
// Return status information
WebContextInfo result = new WebContextInfo();
result.callsInApplication = callsInApplication.intValue();
result.callsInSession = callsInSession.intValue();
result.sessionId = context.getSession().getId();
return result;
}