@Test public void testThreadLocalConnectionRegistry() throws IOException, ServletException { ConnectionsRegistry.INSTANCE.setThreadLocal(false); try { SniffyFilter filter = new SniffyFilter(); filter.init(getFilterConfig(true)); assertTrue(ConnectionsRegistry.INSTANCE.isThreadLocal()); } finally { ConnectionsRegistry.INSTANCE.setThreadLocal(false); } }
public void init(FilterConfig filterConfig) throws ServletException { try { String monitorSocket = filterConfig.getInitParameter("monitor-socket"); if (null == this.monitorSocket && (null == monitorSocket || Boolean.parseBoolean(monitorSocket))) { setMonitorSocket(true); } String filterEnabled = filterConfig.getInitParameter("enabled"); if (null != filterEnabled) { if ("system".equals(filterEnabled)) { this.filterEnabled = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getFilterEnabled()); } else { this.filterEnabled = Boolean.parseBoolean(filterEnabled); } } String excludePattern = filterConfig.getInitParameter("exclude-pattern"); if (null != excludePattern) { this.excludePattern = Pattern.compile(excludePattern); } String injectHtmlEnabled = filterConfig.getInitParameter("inject-html"); if (null != injectHtmlEnabled) { if ("system".equals(injectHtmlEnabled)) { this.injectHtml = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getInjectHtmlEnabled()); } else { this.injectHtml = Boolean.parseBoolean(injectHtmlEnabled); } } String injectHtmlExcludePattern = filterConfig.getInitParameter("inject-html-exclude-pattern"); if (null != injectHtmlExcludePattern) { this.injectHtmlExcludePattern = Pattern.compile(injectHtmlExcludePattern); } String faultToleranceCurrentRequest = filterConfig.getInitParameter("fault-tolerance-current-request"); if (null != faultToleranceCurrentRequest) { ConnectionsRegistry.INSTANCE.setThreadLocal(Boolean.parseBoolean(faultToleranceCurrentRequest)); } sniffyServlet.init(new FilterServletConfigAdapter(filterConfig, "sniffy")); servletContext = filterConfig.getServletContext(); } catch (Exception e) { e.printStackTrace(); filterEnabled = false; } }
SniffyFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { try { String monitorSocket = filterConfig.getInitParameter("monitor-socket"); if (null == this.monitorSocket && (null == monitorSocket || Boolean.parseBoolean(monitorSocket))) { setMonitorSocket(true); } String filterEnabled = filterConfig.getInitParameter("enabled"); if (null != filterEnabled) { if ("system".equals(filterEnabled)) { this.filterEnabled = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getFilterEnabled()); } else { this.filterEnabled = Boolean.parseBoolean(filterEnabled); } } String excludePattern = filterConfig.getInitParameter("exclude-pattern"); if (null != excludePattern) { this.excludePattern = Pattern.compile(excludePattern); } String injectHtmlEnabled = filterConfig.getInitParameter("inject-html"); if (null != injectHtmlEnabled) { if ("system".equals(injectHtmlEnabled)) { this.injectHtml = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getInjectHtmlEnabled()); } else { this.injectHtml = Boolean.parseBoolean(injectHtmlEnabled); } } String injectHtmlExcludePattern = filterConfig.getInitParameter("inject-html-exclude-pattern"); if (null != injectHtmlExcludePattern) { this.injectHtmlExcludePattern = Pattern.compile(injectHtmlExcludePattern); } String faultToleranceCurrentRequest = filterConfig.getInitParameter("fault-tolerance-current-request"); if (null != faultToleranceCurrentRequest) { ConnectionsRegistry.INSTANCE.setThreadLocal(Boolean.parseBoolean(faultToleranceCurrentRequest)); } sniffyServlet.init(new FilterServletConfigAdapter(filterConfig, "sniffy")); servletContext = filterConfig.getServletContext(); } catch (Exception e) { e.printStackTrace(); filterEnabled = false; } } }
SniffyFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { try { String monitorSocket = filterConfig.getInitParameter("monitor-socket"); if (null == this.monitorSocket && (null == monitorSocket || Boolean.parseBoolean(monitorSocket))) { setMonitorSocket(true); } String filterEnabled = filterConfig.getInitParameter("enabled"); if (null != filterEnabled) { if ("system".equals(filterEnabled)) { this.filterEnabled = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getFilterEnabled()); } else { this.filterEnabled = Boolean.parseBoolean(filterEnabled); } } String excludePattern = filterConfig.getInitParameter("exclude-pattern"); if (null != excludePattern) { this.excludePattern = Pattern.compile(excludePattern); } String injectHtmlEnabled = filterConfig.getInitParameter("inject-html"); if (null != injectHtmlEnabled) { if ("system".equals(injectHtmlEnabled)) { this.injectHtml = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getInjectHtmlEnabled()); } else { this.injectHtml = Boolean.parseBoolean(injectHtmlEnabled); } } String injectHtmlExcludePattern = filterConfig.getInitParameter("inject-html-exclude-pattern"); if (null != injectHtmlExcludePattern) { this.injectHtmlExcludePattern = Pattern.compile(injectHtmlExcludePattern); } String faultToleranceCurrentRequest = filterConfig.getInitParameter("fault-tolerance-current-request"); if (null != faultToleranceCurrentRequest) { ConnectionsRegistry.INSTANCE.setThreadLocal(Boolean.parseBoolean(faultToleranceCurrentRequest)); } sniffyServlet.init(new FilterServletConfigAdapter(filterConfig, "sniffy")); servletContext = filterConfig.getServletContext(); } catch (Exception e) { e.printStackTrace(); filterEnabled = false; } } SniffyFilter(); }
SniffyFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { try { String monitorSocket = filterConfig.getInitParameter("monitor-socket"); if (null == this.monitorSocket && (null == monitorSocket || Boolean.parseBoolean(monitorSocket))) { setMonitorSocket(true); } String filterEnabled = filterConfig.getInitParameter("enabled"); if (null != filterEnabled) { if ("system".equals(filterEnabled)) { this.filterEnabled = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getFilterEnabled()); } else { this.filterEnabled = Boolean.parseBoolean(filterEnabled); } } String excludePattern = filterConfig.getInitParameter("exclude-pattern"); if (null != excludePattern) { this.excludePattern = Pattern.compile(excludePattern); } String injectHtmlEnabled = filterConfig.getInitParameter("inject-html"); if (null != injectHtmlEnabled) { if ("system".equals(injectHtmlEnabled)) { this.injectHtml = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getInjectHtmlEnabled()); } else { this.injectHtml = Boolean.parseBoolean(injectHtmlEnabled); } } String injectHtmlExcludePattern = filterConfig.getInitParameter("inject-html-exclude-pattern"); if (null != injectHtmlExcludePattern) { this.injectHtmlExcludePattern = Pattern.compile(injectHtmlExcludePattern); } String faultToleranceCurrentRequest = filterConfig.getInitParameter("fault-tolerance-current-request"); if (null != faultToleranceCurrentRequest) { ConnectionsRegistry.INSTANCE.setThreadLocal(Boolean.parseBoolean(faultToleranceCurrentRequest)); } sniffyServlet.init(new FilterServletConfigAdapter(filterConfig, "sniffy")); servletContext = filterConfig.getServletContext(); } catch (Exception e) { e.printStackTrace(); filterEnabled = false; } } SniffyFilter(); void init(FilterConfig filterConfig); void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain); void destroy(); boolean isInjectHtml(); void setInjectHtml(boolean injectHtml); Pattern getInjectHtmlExcludePattern(); void setInjectHtmlExcludePattern(Pattern injectHtmlExcludePattern); @Deprecated boolean isEnabled(); @Deprecated void setEnabled(boolean enabled); boolean isFilterEnabled(); void setFilterEnabled(boolean filterEnabled); boolean isMonitorSocket(); void setMonitorSocket(boolean monitorSocket); Pattern getExcludePattern(); void setExcludePattern(Pattern excludePattern); }
SniffyFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { try { String monitorSocket = filterConfig.getInitParameter("monitor-socket"); if (null == this.monitorSocket && (null == monitorSocket || Boolean.parseBoolean(monitorSocket))) { setMonitorSocket(true); } String filterEnabled = filterConfig.getInitParameter("enabled"); if (null != filterEnabled) { if ("system".equals(filterEnabled)) { this.filterEnabled = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getFilterEnabled()); } else { this.filterEnabled = Boolean.parseBoolean(filterEnabled); } } String excludePattern = filterConfig.getInitParameter("exclude-pattern"); if (null != excludePattern) { this.excludePattern = Pattern.compile(excludePattern); } String injectHtmlEnabled = filterConfig.getInitParameter("inject-html"); if (null != injectHtmlEnabled) { if ("system".equals(injectHtmlEnabled)) { this.injectHtml = Boolean.TRUE.equals(SniffyConfiguration.INSTANCE.getInjectHtmlEnabled()); } else { this.injectHtml = Boolean.parseBoolean(injectHtmlEnabled); } } String injectHtmlExcludePattern = filterConfig.getInitParameter("inject-html-exclude-pattern"); if (null != injectHtmlExcludePattern) { this.injectHtmlExcludePattern = Pattern.compile(injectHtmlExcludePattern); } String faultToleranceCurrentRequest = filterConfig.getInitParameter("fault-tolerance-current-request"); if (null != faultToleranceCurrentRequest) { ConnectionsRegistry.INSTANCE.setThreadLocal(Boolean.parseBoolean(faultToleranceCurrentRequest)); } sniffyServlet.init(new FilterServletConfigAdapter(filterConfig, "sniffy")); servletContext = filterConfig.getServletContext(); } catch (Exception e) { e.printStackTrace(); filterEnabled = false; } } SniffyFilter(); void init(FilterConfig filterConfig); void doFilter(final ServletRequest request, ServletResponse response, final FilterChain chain); void destroy(); boolean isInjectHtml(); void setInjectHtml(boolean injectHtml); Pattern getInjectHtmlExcludePattern(); void setInjectHtmlExcludePattern(Pattern injectHtmlExcludePattern); @Deprecated boolean isEnabled(); @Deprecated void setEnabled(boolean enabled); boolean isFilterEnabled(); void setFilterEnabled(boolean filterEnabled); boolean isMonitorSocket(); void setMonitorSocket(boolean monitorSocket); Pattern getExcludePattern(); void setExcludePattern(Pattern excludePattern); static final String HEADER_CORS_HEADERS; static final String HEADER_NUMBER_OF_QUERIES; static final String HEADER_TIME_TO_FIRST_BYTE; static final String HEADER_REQUEST_DETAILS; static final String SNIFFY_URI_PREFIX; static final String JAVASCRIPT_URI; static final String JAVASCRIPT_SOURCE_URI; static final String JAVASCRIPT_MAP_URI; static final String REQUEST_URI_PREFIX; static final String SNIFFY; static final String SNIFFY_ENABLED_PARAMETER; static final String INJECT_HTML_ENABLED_PARAMETER; }