/*
 * Copyright 2015-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */
package org.docksidestage;

import org.dbflute.tomcat.TomcatBoot;

/**
 * @author jflute
 */
public class FortressTomcatBoot { // #change_it_first

    public static final String CONTEXT = "/fortress";

    public static void main(String[] args) { // e.g. java -Dlasta.env=production -jar lastaflute-test-fortress.war
        TomcatBoot boot = new TomcatBoot(8152, CONTEXT);
        boot.asDevelopment(isDevelopment());
        boot.useMetaInfoResourceDetect().useWebFragmentsDetect(jarName -> { // both for swagger
            return jarName.contains("swagger-ui"); // meanwhile, restricted by [app]_env.properties
        });
        boot.configure("fortress_config.properties", "fortress_env.properties"); // e.g. URIEncoding
        boot.logging("tomcat_logging.properties", op -> {
            op.replace("tomcat.log.name", "catalina_out");
        }); // uses jdk14logger
        boot.bootAwait();
    }

    private static boolean isDevelopment() {
        return System.getProperty("lasta.env") == null;
    }
}

@@ -642,16 +642,147 @@
 stage;%0A%0A
+import org.apache.catalina.Host;%0Aimport org.apache.catalina.core.StandardHost;%0Aimport org.apache.catalina.valves.ErrorReportValve;%0A
 import o
@@ -1640,128 +1640,655 @@
 oot.
-bootAwait();%0A    %7D%0A%0A    private static boolean isDevelopment() %7B%0A        return System.getProperty(%22lasta.env%22) == null;
+asYouLikeIt(resource -%3E %7B%0A            Host host = resource.getHost();%0A            if (host instanceof StandardHost) %7B%0A                String fqcn = SilentErrorReportValve.class.getName();%0A                ((StandardHost) host).setErrorReportValveClass(fqcn); // suppress server info%0A            %7D%0A        %7D);%0A        boot.bootAwait();%0A    %7D%0A%0A    private static boolean isDevelopment() %7B%0A        return System.getProperty(%22lasta.env%22) == null;%0A    %7D%0A%0A    public static class SilentErrorReportValve extends ErrorReportValve %7B%0A%0A        public SilentErrorReportValve() %7B%0A            setShowReport(false);%0A            setShowServerInfo(false);%0A        %7D
 %0A   

test ((StandardHost) host).setErrorReportValveClass(fqcn)