Search in sources :

Example 11 with PropertyFile

use of com.peterphi.std.io.PropertyFile in project stdlib by petergeneric.

the class TomcatService method getTomcatsAndPorts.

public Map<File, Integer> getTomcatsAndPorts() {
    final Map<File, Integer> map = new HashMap<>();
    for (File domain : tomcatRoot.listFiles(new TomcatDomainFilenameFilter())) {
        try {
            PropertyFile props = new PropertyFile(new File(domain, "tomcat.properties"));
            final int port = props.get("tomcat.port", -1);
            final String path = props.get("tomcat.webapp.folder");
            final File webappFolder = new File(path);
            if (port <= 0)
                throw new IllegalArgumentException("No port specified!");
            else if (!webappFolder.exists())
                throw new IllegalArgumentException("No valid webapp folder specified: does not exist: " + webappFolder);
            map.put(webappFolder, port);
        } catch (Exception e) {
            throw new RuntimeException("Error reading tomcat.properties for " + domain, e);
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) PropertyFile(com.peterphi.std.io.PropertyFile) PropertyFile(com.peterphi.std.io.PropertyFile) File(java.io.File)

Aggregations

PropertyFile (com.peterphi.std.io.PropertyFile)11 File (java.io.File)3 GuiceProperties (com.peterphi.std.guice.apploader.GuiceProperties)2 GuiceRole (com.peterphi.std.guice.apploader.GuiceRole)2 ClassScannerFactory (com.peterphi.std.guice.common.ClassScannerFactory)2 GuiceConfig (com.peterphi.std.guice.common.serviceprops.composite.GuiceConfig)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 Matchers (com.google.inject.matcher.Matchers)1 Named (com.google.inject.name.Named)1 BasicSetup (com.peterphi.std.guice.apploader.BasicSetup)1 GuiceSetup (com.peterphi.std.guice.apploader.GuiceSetup)1 GuiceBuilder (com.peterphi.std.guice.apploader.impl.GuiceBuilder)1