@Test public void enable_access_logs_by_Default() throws Exception { Tomcat tomcat = mock(Tomcat.class, Mockito.RETURNS_DEEP_STUBS); Props props = new Props(new Properties()); props.set(PATH_LOGS.getKey(), temp.newFolder().getAbsolutePath()); underTest.configure(tomcat, props); verify(tomcat.getHost().getPipeline()).addValve(any(ProgrammaticLogbackValve.class)); }
private static void configureLogbackAccess(Tomcat tomcat, Props props) { if (props.valueAsBoolean(PROPERTY_ENABLE, true)) { ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve(); LogbackHelper helper = new LogbackHelper(); LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access"); FileAppender appender = policy.createAppender("ACCESS_LOG"); PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder(); fileEncoder.setContext(valve); fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN)); fileEncoder.start(); appender.setEncoder(fileEncoder); appender.start(); valve.addAppender(appender); tomcat.getHost().getPipeline().addValve(valve); } }
@Override public void setWrapper(Wrapper wrapper) { Valve valve = createValve(); if (wrapper != null) { host = (Host) wrapper.getParent().getParent(); Engine engine = (Engine) host.getParent(); Service service = engine.getService(); connectors = service.findConnectors(); try { deployerOName = new ObjectName(host.getParent().getName() + ":type=Deployer,host=" + host.getName()); } catch (MalformedObjectNameException e) { logger.trace("", e); } host.getPipeline().addValve(valve); mbeanServer = ManagementFactory.getPlatformMBeanServer(); } else if (host != null) { host.getPipeline().removeValve(valve); } }
/** * Tomcat style invocation. */ @Override public void invoke(org.apache.catalina.connector.Request request, org.apache.catalina.connector.Response response) throws IOException, ServletException { Host host = preInvoke(request, response); if (host == null) { return; } if (host.getPipeline().hasNonBasicValves() || host.hasCustomPipeline()) { // Invoke pipeline host.getPipeline().invoke(request, response); } else { // Invoke basic valve only host.getPipeline().getBasic().invoke(request, response); } }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param valveContext Valve context used to forward to the next Valve * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ public final void event(Request request, Response response, HttpEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param valveContext Valve context used to forward to the next Valve * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ public final void event(Request request, Response response, HttpEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
/** * Process Comet event. * * @param request Request to be processed * @param response Response to be produced * @param event the event * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void event(Request request, Response response, CometEvent event) throws IOException, ServletException { // Ask this Host to process this request request.getHost().getPipeline().getFirst().event(request, response, event); }
@Override public void accept(final Tomcat tomcat) { final ProtocolHandler protocolHandler = tomcat.getConnector().getProtocolHandler(); if (!AbstractHttp11Protocol.class.isInstance(protocolHandler)) { return; } final LetsEncryptReloadLifecycle.LetsEncryptConfig config = instance.getConfiguration() .getExtension(LetsEncryptReloadLifecycle.LetsEncryptConfig.class); if (config.getDomains() == null || config.getDomains().trim().isEmpty()) { return; } new LogFacade(getClass().getName()).info("Let's Encrypt extension activated"); tomcat.getHost().getPipeline().addValve(new LetsEncryptValve(AbstractHttp11Protocol.class.cast(protocolHandler), config)); }
/** * Select the appropriate child Host to process this request, * based on the requested server name. If no matching Host can * be found, return an appropriate HTTP error. * * @param request Request to be processed * @param response Response to be produced * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void invoke(Request request, Response response) throws IOException, ServletException { // Select the Host to be used for this Request Host host = request.getHost(); if (host == null) { // HTTP 0.9 or HTTP 1.0 request without a host when no default host // is defined. This is handled by the CoyoteAdapter. return; } if (request.isAsyncSupported()) { request.setAsyncSupported(host.getPipeline().isAsyncSupported()); } // Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response); } }
/** * Select the appropriate child Host to process this request, * based on the requested server name. If no matching Host can * be found, return an appropriate HTTP error. * * @param request Request to be processed * @param response Response to be produced * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ @Override public final void invoke(Request request, Response response) throws IOException, ServletException { // Select the Host to be used for this Request Host host = request.getHost(); if (host == null) { // HTTP 0.9 or HTTP 1.0 request without a host when no default host // is defined. This is handled by the CoyoteAdapter. return; } if (request.isAsyncSupported()) { request.setAsyncSupported(host.getPipeline().isAsyncSupported()); } // Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response); } }
/** * Select the appropriate child Host to process this request, * based on the requested server name. If no matching Host can * be found, return an appropriate HTTP error. * * @param request Request to be processed * @param response Response to be produced * @param valveContext Valve context used to forward to the next Valve * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ public final void invoke(Request request, Response response) throws IOException, ServletException { // Select the Host to be used for this Request Host host = request.getHost(); if (host == null) { response.sendError (HttpServletResponse.SC_BAD_REQUEST, sm.getString("standardEngine.noHost", request.getServerName())); return; } // Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response); }
/** * Select the appropriate child Host to process this request, * based on the requested server name. If no matching Host can * be found, return an appropriate HTTP error. * * @param request Request to be processed * @param response Response to be produced * @param valveContext Valve context used to forward to the next Valve * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ public final void invoke(Request request, Response response) throws IOException, ServletException { // Select the Host to be used for this Request Host host = request.getHost(); if (host == null) { response.sendError (HttpServletResponse.SC_BAD_REQUEST, MESSAGES.noHost(request.getServerName())); return; } // Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response); }
/** * Select the appropriate child Host to process this request, * based on the requested server name. If no matching Host can * be found, return an appropriate HTTP error. * * @param request Request to be processed * @param response Response to be produced * @param valveContext Valve context used to forward to the next Valve * * @exception IOException if an input/output error occurred * @exception ServletException if a servlet error occurred */ public final void invoke(Request request, Response response) throws IOException, ServletException { // Select the Host to be used for this Request Host host = request.getHost(); if (host == null) { response.sendError (HttpServletResponse.SC_BAD_REQUEST, sm.getString("standardEngine.noHost", request.getServerName())); return; } // Ask this Host to process this request host.getPipeline().getFirst().invoke(request, response); }
@Override public void afterPropertiesSet() throws Exception { tomcat.setBaseDir(baseDirectory); tomcat.getHost().setAppBase(baseDirectory); configureNetwork(); extractWarFile(); tomcat.start(); if (!showServerInfoOnError) { for (Valve valve : tomcat.getHost().getPipeline().getValves()) { if (valve instanceof ErrorReportValve) { ((ErrorReportValve) valve).setShowServerInfo(false); } } } }
private static void configureLogbackAccess(Tomcat tomcat, Props props) { if (props.valueAsBoolean(PROPERTY_ENABLE, true)) { ProgrammaticLogbackValve valve = new ProgrammaticLogbackValve(); LogbackHelper helper = new LogbackHelper(); LogbackHelper.RollingPolicy policy = helper.createRollingPolicy(valve, props, "access"); FileAppender appender = policy.createAppender("ACCESS_LOG"); PatternLayoutEncoder fileEncoder = new PatternLayoutEncoder(); fileEncoder.setContext(valve); fileEncoder.setPattern(props.value(PROPERTY_PATTERN, DEFAULT_SQ_ACCESS_LOG_PATTERN)); fileEncoder.start(); appender.setEncoder(fileEncoder); appender.start(); valve.addAppender(appender); tomcat.getHost().getPipeline().addValve(valve); } }