Author: maksimkaszynski
Date: 2007-06-13 13:18:32 -0400 (Wed, 13 Jun 2007)
New Revision: 1171
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/PhaseDemarcationNotifier.java
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/RequestBenchMarkFilter.java
Log:
benchmarking filters
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/PhaseDemarcationNotifier.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/PhaseDemarcationNotifier.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/PhaseDemarcationNotifier.java 2007-06-13
17:18:32 UTC (rev 1171)
@@ -0,0 +1,50 @@
+/**
+ *
+ */
+package org.richfaces.demo.benchmark;
+
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class PhaseDemarcationNotifier implements PhaseListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6533052212003582848L;
+ private final Log log = LogFactory.getLog(PhaseDemarcationNotifier.class);
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
+ */
+ public void afterPhase(PhaseEvent event) {
+ if (log.isTraceEnabled()) {
+ log.trace("Phase end " + event.getPhaseId());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#beforePhase(javax.faces.event.PhaseEvent)
+ */
+ public void beforePhase(PhaseEvent event) {
+ if (log.isTraceEnabled()) {
+ log.trace("Phase start " + event.getPhaseId());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.PhaseListener#getPhaseId()
+ */
+ public PhaseId getPhaseId() {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Added:
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/RequestBenchMarkFilter.java
===================================================================
---
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/RequestBenchMarkFilter.java
(rev 0)
+++
trunk/sandbox-samples/scrollable-grid-demo/src/main/java/org/richfaces/demo/benchmark/RequestBenchMarkFilter.java 2007-06-13
17:18:32 UTC (rev 1171)
@@ -0,0 +1,64 @@
+/**
+ *
+ */
+package org.richfaces.demo.benchmark;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class RequestBenchMarkFilter implements Filter {
+
+ private Log log = LogFactory.getLog(RequestBenchMarkFilter.class);
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+
+ long startTime = System.currentTimeMillis();
+
+ chain.doFilter(request, response);
+
+ long endTime = System.currentTimeMillis();
+
+
+ log.debug("Request " +
+ ((HttpServletRequest) request).getRequestURL() +
+ "took " +
+ (endTime - startTime) +
+ "ms");
+
+ }
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+ */
+ public void init(FilterConfig arg0) throws ServletException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Show replies by date