Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/org/dive4elements/artifactdatabase/App.java @ 473:d0ac790a6c89 dive4elements-move
Moved directories to org.dive4elements
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 10:57:18 +0200 |
parents | artifact-database/src/main/java/de/intevation/artifactdatabase/App.java@f33401ea2a6c |
children | 415df0fc4fa1 |
comparison
equal
deleted
inserted
replaced
472:783cc1b6b615 | 473:d0ac790a6c89 |
---|---|
1 /* | |
2 * Copyright (c) 2010 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 | |
9 package de.intevation.artifactdatabase; | |
10 | |
11 import de.intevation.artifacts.common.utils.Config; | |
12 | |
13 import de.intevation.artifactdatabase.rest.HTTPServer; | |
14 | |
15 import java.io.File; | |
16 | |
17 import java.net.MalformedURLException; | |
18 | |
19 import org.apache.log4j.PropertyConfigurator; | |
20 | |
21 import org.slf4j.bridge.SLF4JBridgeHandler; | |
22 | |
23 /** | |
24 * Starting point of the artifact database. | |
25 * | |
26 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | |
27 */ | |
28 public class App | |
29 { | |
30 /** | |
31 * The logging is done via Log4j. To configure the logging | |
32 * a file 'log4j.properties' is search in the configuration directory. | |
33 */ | |
34 public static final String LOG4J_PROPERTIES = | |
35 "log4j.properties"; | |
36 | |
37 /** | |
38 * Trys to load the Log4j configuration from ${config.dir}/log4j.properties. | |
39 */ | |
40 public static final void configureLogging() { | |
41 File configDir = Config.getConfigDirectory(); | |
42 File propFile = new File(configDir, LOG4J_PROPERTIES); | |
43 | |
44 if (propFile.isFile() && propFile.canRead()) { | |
45 try { | |
46 PropertyConfigurator.configure(propFile.toURI().toURL()); | |
47 SLF4JBridgeHandler.install(); | |
48 } | |
49 catch (MalformedURLException mue) { | |
50 mue.printStackTrace(System.err); | |
51 } | |
52 } | |
53 } | |
54 | |
55 /** | |
56 * Starts the artifact database. | |
57 * @param args The commandline arguments. Unused. | |
58 */ | |
59 public static void main(String[] args) { | |
60 | |
61 configureLogging(); | |
62 | |
63 FactoryBootstrap bootstrap = new FactoryBootstrap(); | |
64 | |
65 bootstrap.boot(); | |
66 | |
67 Backend backend = Backend.getInstance(); | |
68 | |
69 ArtifactDatabaseImpl db = new ArtifactDatabaseImpl( | |
70 bootstrap, backend); | |
71 | |
72 DatabaseCleaner cleaner = new DatabaseCleaner( | |
73 bootstrap.getContext(), backend, backend.getConfig()); | |
74 | |
75 HTTPServer httpServer = bootstrap.getHTTPServer(); | |
76 | |
77 bootstrap = null; | |
78 | |
79 backend.setCleaner(cleaner); | |
80 | |
81 cleaner.setLockedIdsProvider(db); | |
82 | |
83 cleaner.start(); | |
84 | |
85 db.start(); | |
86 | |
87 httpServer.startAsServer(db); | |
88 } | |
89 } | |
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |