Kieker 1.9

kieker.monitoring.probe.servlet
Class SessionAndTraceRegistrationFilter

java.lang.Object
  extended by kieker.monitoring.probe.servlet.SessionAndTraceRegistrationFilter
All Implemented Interfaces:
javax.servlet.Filter, IMonitoringProbe

public class SessionAndTraceRegistrationFilter
extends Object
implements javax.servlet.Filter, IMonitoringProbe

For each incoming request via doFilter(ServletRequest, ServletResponse, FilterChain), this class (i) registers session and trace information into the thread-local data structures SessionRegistry and TraceRegistry accessible to other probes in the control-flow of this request, (ii) executes the given FilterChain and subsequently (iii) unregisters the thread-local data. If configured in the FilterConfig (see below), the execution of the doFilter(ServletRequest, ServletResponse, FilterChain) method is also part of the trace and logged to the IMonitoringController (note that this is the default behavior when no property is found). The filter can be integrated into the web.xml as follows:

 <filter>
   <filter-name>sessionAndTraceRegistrationFilter</filter-name>
   <filter-class>kieker.monitoring.probe.servlet.SessionAndTraceRegistrationFilter</filter-class>
 </filter>
 <filter-mapping>
   <filter-name>sessionAndTraceRegistrationFilter</filter-name>
   <url-pattern>/*</url-pattern>
 </filter-mapping>
 
 

Since:
1.5
Author:
Andre van Hoorn, Marco Luebcke, Jan Waller

Field Summary
static String CONFIG_PROPERTY_NAME_LOG_FILTER_EXECUTION
           
 
Constructor Summary
SessionAndTraceRegistrationFilter()
           
SessionAndTraceRegistrationFilter(boolean logFilterExecution)
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Register thread-local session and trace information, executes the given FilterChain and unregisters the session/trace information.
 void init(javax.servlet.FilterConfig config)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIG_PROPERTY_NAME_LOG_FILTER_EXECUTION

public static final String CONFIG_PROPERTY_NAME_LOG_FILTER_EXECUTION
See Also:
Constant Field Values
Constructor Detail

SessionAndTraceRegistrationFilter

public SessionAndTraceRegistrationFilter()

SessionAndTraceRegistrationFilter

public SessionAndTraceRegistrationFilter(boolean logFilterExecution)
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws IOException,
                     javax.servlet.ServletException
Register thread-local session and trace information, executes the given FilterChain and unregisters the session/trace information. If configured, the execution of this filter is also logged to the IMonitoringController. This method returns immediately if monitoring is not enabled.

Specified by:
doFilter in interface javax.servlet.Filter
Parameters:
request - The request.
response - The response.
chain - The filter chain to be used.
Throws:
IOException
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter

Kieker 1.9

Copyright 2014 Kieker Project, http://kieker-monitoring.net