org.jmonit.web
Class JMonitFilter

java.lang.Object
  extended by org.jmonit.web.JMonitFilter
All Implemented Interfaces:
javax.servlet.Filter
Direct Known Subclasses:
JMonitFilterWithWebUI

public class JMonitFilter
extends java.lang.Object
implements javax.servlet.Filter

A servlet Filter to be configured in your WEB-INF/web.xml to intercept all incoming request.

         <filter>
         <filter-name>jMonit</filter-name>
         <filter-class>org.jmonit.web.JMonitFilter</filter-class>
         </filter>
         <filter-mapping>
         <filter-name>jMonit</filter-name>
         <url-pattern>/*</url-pattern>
         </filter-mapping>
 

A monitor will be created for each application URI. By default, the requested resource extension is used to group monitors in sub-categories.

Author:
Nicolas De Loof

Constructor Summary
JMonitFilter()
           
 
Method Summary
protected  java.lang.String buildMonitorNameFromUri(java.lang.String uri)
          Build the monitor name from request URI.
 void destroy()
          
 void doFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, javax.servlet.FilterChain chain)
          Http specific doFilter implementation
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Delegates to Http based doFilter.
protected  java.lang.String getRequestedUri(javax.servlet.http.HttpServletRequest request)
           
protected  java.lang.String getTagForUri(java.lang.String uri)
          Build the monitor name from request URI.
 void init(javax.servlet.FilterConfig filterConfig)
          
protected  void initDefaultTags(javax.servlet.FilterConfig filterConfig)
           
protected  void initMapping(javax.servlet.FilterConfig filterConfig)
           
protected  void initRepository(javax.servlet.FilterConfig filterConfig)
           
 void setRepository(Repository repository)
           
 void setTags(java.util.Map<java.lang.String,java.lang.String> tags)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMonitFilter

public JMonitFilter()
Method Detail

destroy

public void destroy()

Specified by:
destroy in interface javax.servlet.Filter
See Also:
Filter.destroy()

doFilter

public void doFilter(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Http specific doFilter implementation

Parameters:
request - Http request
response - Http response
chain - request chain
Throws:
java.io.IOException - IO exception occurs
javax.servlet.ServletException - servlet Exception occurs

getRequestedUri

protected java.lang.String getRequestedUri(javax.servlet.http.HttpServletRequest request)

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Delegates to Http based doFilter.

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException
See Also:
Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)

init

public void init(javax.servlet.FilterConfig filterConfig)
          throws javax.servlet.ServletException

Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException
See Also:
Filter.init(javax.servlet.FilterConfig)

setTags

public void setTags(java.util.Map<java.lang.String,java.lang.String> tags)
Parameters:
tags - The tags to set

setRepository

public void setRepository(Repository repository)
Parameters:
repository - the repository to set

buildMonitorNameFromUri

protected java.lang.String buildMonitorNameFromUri(java.lang.String uri)
Build the monitor name from request URI.

Override this method in a custom filter to define application specific monitors based on URIs.

Parameters:
uri - requested URI
Returns:
monitor name

getTagForUri

protected java.lang.String getTagForUri(java.lang.String uri)
Build the monitor name from request URI.

Override this method in a custom filter to define application specific monitors based on URIs.

Parameters:
uri - requested URI
Returns:
domain Domain for requested URI

initDefaultTags

protected void initDefaultTags(javax.servlet.FilterConfig filterConfig)
Parameters:
filterConfig - configuration

initMapping

protected void initMapping(javax.servlet.FilterConfig filterConfig)
Parameters:
filterConfig - configuration

initRepository

protected void initRepository(javax.servlet.FilterConfig filterConfig)
Parameters:
filterConfig - configuration


Copyright © 2007 Nicolas De Loof. All Rights Reserved.