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 b9809f9..c2d539b 100644 (file)
@@ -2,4 +2,5 @@ package dolda.jsvc;
 
 public interface ServerContext {
     public String rootpath();
+    public long starttime();
 }
index f253128..e8f65a6 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 4d0d3bd..165b0f2 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 fbe2204..d466156 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();