]> www.dolda2000.com Git - jsvc.git/commitdiff
Added a way to get the time of start of the server context.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 21:18:03 +0000 (23:18 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 21:18:03 +0000 (23:18 +0200)
src/dolda/jsvc/ServerContext.java
src/dolda/jsvc/j2ee/J2eeContext.java
src/dolda/jsvc/j2ee/Servlet.java
src/dolda/jsvc/test/TestResponder.java

index b9809f9038370274ebb38415cb92c0910682a7bb..c2d539b9533bd3a012985788ac656c78895d81f4 100644 (file)
@@ -2,4 +2,5 @@ package dolda.jsvc;
 
 public interface ServerContext {
     public String rootpath();
+    public long starttime();
 }
index f2531280ff7da64c8030e57f230269a73e05eaba..e8f65a6ee64c86f46e1a6e76bbd659da0344fb82 100644 (file)
@@ -18,4 +18,8 @@ public class J2eeContext implements ServerContext {
     public String rootpath() {
        return(req.getContextPath());
     }
+    
+    public long starttime() {
+       return((Long)cfg.getServletContext().getAttribute("jsvc.starttime"));
+    }
 }
index 4d0d3bdfb268df7060c8b4df773d7d47ec8fcf5c..165b0f2e2cfe489515da86777d8430b85e4749c0 100644 (file)
@@ -48,6 +48,8 @@ public class Servlet extends HttpServlet {
        } catch(InvocationTargetException e) {
            throw(new ServletException("JSvc bootstrapper failed", e));
        }
+       ServletContext ctx = getServletContext();
+       ctx.setAttribute("jsvc.starttime", System.currentTimeMillis());
     }
     
     public void destroy() {
index fbe22049c607f23fcadec95ed80b0863bff77797..d466156e3853d81522601ea7d04cc6e53df26958 100644 (file)
@@ -19,6 +19,7 @@ public class TestResponder implements Responder {
        out.println("<h1>Barda</h1>");
        out.println("Bardslen.");
        out.println(req.inheaders());
+       out.println(req.ctx().starttime());
        out.println("</body>");
        out.println("</html>");
        out.flush();