ingo@100: /* ingo@100: * Copyright (c) 2010 by Intevation GmbH ingo@100: * ingo@100: * This program is free software under the LGPL (>=v2.1) ingo@100: * Read the file LGPL.txt coming with the software for details ingo@100: * or visit http://www.gnu.org/licenses/ if it does not exist. ingo@100: */ ingo@100: sascha@2: package de.intevation.artifactdatabase; sascha@2: sascha@207: import de.intevation.artifacts.common.utils.Config; sascha@207: sascha@19: import de.intevation.artifactdatabase.rest.Standalone; sascha@19: sascha@19: import java.io.File; sascha@19: sascha@19: import java.net.MalformedURLException; sascha@19: sascha@19: import org.apache.log4j.PropertyConfigurator; sascha@19: ingo@83: import org.slf4j.bridge.SLF4JBridgeHandler; ingo@83: sascha@5: /** sascha@5: * Starting point of the artifact database. sascha@5: * sascha@77: * @author Sascha L. Teichmann sascha@5: */ sascha@2: public class App sascha@2: { sascha@87: /** sascha@87: * The logging is done via Log4j. To configure the logging sascha@87: * a file 'log4j.properties' is search in the configuration directory. sascha@87: */ sascha@19: public static final String LOG4J_PROPERTIES = sascha@19: "log4j.properties"; sascha@19: sascha@87: /** sascha@87: * Trys to load the Log4j configuration from ${config.dir}/log4j.properties. sascha@87: */ sascha@19: public static final void configureLogging() { sascha@19: File configDir = Config.getConfigDirectory(); sascha@19: File propFile = new File(configDir, LOG4J_PROPERTIES); sascha@19: sascha@19: if (propFile.isFile() && propFile.canRead()) { sascha@19: try { sascha@19: PropertyConfigurator.configure(propFile.toURI().toURL()); ingo@83: SLF4JBridgeHandler.install(); sascha@19: } sascha@19: catch (MalformedURLException mue) { sascha@19: mue.printStackTrace(System.err); sascha@19: } sascha@19: } sascha@19: } sascha@19: sascha@87: /** sascha@87: * Starts the artifact database. sascha@87: * @param args The commandline arguments. Unused. sascha@87: */ sascha@2: public static void main(String[] args) { sascha@19: sascha@19: configureLogging(); sascha@19: sascha@5: FactoryBootstrap bootstrap = new FactoryBootstrap(); sascha@5: sascha@5: bootstrap.boot(); sascha@13: ingo@128: Backend backend = Backend.getInstance(); sascha@32: sascha@32: ArtifactDatabaseImpl db = new ArtifactDatabaseImpl( sascha@32: bootstrap, backend); sascha@32: sascha@30: DatabaseCleaner cleaner = new DatabaseCleaner( sascha@41: bootstrap.getContext(), backend); sascha@30: ingo@79: bootstrap = null; ingo@79: sascha@32: backend.setCleaner(cleaner); sascha@30: sascha@32: cleaner.setFilter(db); sascha@13: sascha@32: cleaner.start(); sascha@19: sascha@19: Standalone.startAsServer(db); sascha@2: } sascha@2: } ingo@79: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :