/** Initializes Metrics. */ private void initMetrics(ServletContext servletContext, EnumSet<DispatcherType> disps) { log.debug("Initializing Metrics registries"); servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry); servletContext.setAttribute(MetricsServlet.METRICS_REGISTRY, metricRegistry); log.debug("Registering Metrics Filter"); FilterRegistration.Dynamic metricsFilter = servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter()); metricsFilter.addMappingForUrlPatterns(disps, true, "/*"); metricsFilter.setAsyncSupported(true); log.debug("Registering Metrics Servlet"); ServletRegistration.Dynamic metricsAdminServlet = servletContext.addServlet("metricsServlet", new MetricsServlet()); metricsAdminServlet.addMapping("/management/jhipster/metrics/*"); metricsAdminServlet.setAsyncSupported(true); metricsAdminServlet.setLoadOnStartup(2); }
public void contextInitialized(ServletContextEvent sce) { final ServletContext app = sce.getServletContext(); final Configuration conf = NutchConfiguration.get(app); LOG.info("creating new bean"); NutchBean bean = null; try { bean = new NutchBean(conf); app.setAttribute(KEY, bean); } catch (final IOException ex) { LOG.error(StringUtils.stringifyException(ex)); } }
/** Check to see if the configuration file has been updated so that it may be reloaded. */ private boolean configUpdated() { try { URL url = ctx.getResource(resourcesDir + XHP_CONFIG); URLConnection con; if (url == null) return false; con = url.openConnection(); long lastModified = con.getLastModified(); long XHP_LAST_MODIFIEDModified = 0; if (ctx.getAttribute(XHP_LAST_MODIFIED) != null) { XHP_LAST_MODIFIEDModified = ((Long) ctx.getAttribute(XHP_LAST_MODIFIED)).longValue(); } else { ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified)); return false; } if (XHP_LAST_MODIFIEDModified < lastModified) { ctx.setAttribute(XHP_LAST_MODIFIED, new Long(lastModified)); return true; } } catch (Exception ex) { getLogger().severe("XmlHttpProxyServlet error checking configuration: " + ex); } return false; }
@Override public void setAttribute(String s, Object o) { proxy.setAttribute(s, o); }