Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/App.java @ 201:973f244ed568
Improved the TransitionEngine with a method that determines if a State B is reachable from a State A.
artifacts/trunk@1445 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 09 Mar 2011 15:48:06 +0000 |
parents | bfa65a812c7a |
children | b2115f484edb |
rev | line source |
---|---|
100
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
1 /* |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
3 * |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
7 */ |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
8 |
2
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.artifactdatabase; |
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
11 import de.intevation.artifactdatabase.rest.Standalone; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
12 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
13 import java.io.File; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
14 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
15 import java.net.MalformedURLException; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
16 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
17 import org.apache.log4j.PropertyConfigurator; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
18 |
83
8c4638abd518
Installed a SLF4J bridge to route incoming jul logs (used by restlet) to log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
19 import org.slf4j.bridge.SLF4JBridgeHandler; |
8c4638abd518
Installed a SLF4J bridge to route incoming jul logs (used by restlet) to log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
20 |
5
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
21 /** |
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
22 * Starting point of the artifact database. |
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
23 * |
77
48d1a9a082c2
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
41
diff
changeset
|
24 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
5
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
25 */ |
2
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public class App |
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 { |
87
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
28 /** |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
29 * The logging is done via Log4j. To configure the logging |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
30 * a file 'log4j.properties' is search in the configuration directory. |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
31 */ |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
32 public static final String LOG4J_PROPERTIES = |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
33 "log4j.properties"; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
34 |
87
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
35 /** |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
36 * Trys to load the Log4j configuration from ${config.dir}/log4j.properties. |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
37 */ |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
38 public static final void configureLogging() { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
39 File configDir = Config.getConfigDirectory(); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
40 File propFile = new File(configDir, LOG4J_PROPERTIES); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
41 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
42 if (propFile.isFile() && propFile.canRead()) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
43 try { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
44 PropertyConfigurator.configure(propFile.toURI().toURL()); |
83
8c4638abd518
Installed a SLF4J bridge to route incoming jul logs (used by restlet) to log4j.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
79
diff
changeset
|
45 SLF4JBridgeHandler.install(); |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
46 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
47 catch (MalformedURLException mue) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
48 mue.printStackTrace(System.err); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
49 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
50 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
51 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
52 |
87
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
53 /** |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
54 * Starts the artifact database. |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
55 * @param args The commandline arguments. Unused. |
0f48188a6e02
Added some javadoc to the artifactdatabase module. Not done yet.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
83
diff
changeset
|
56 */ |
2
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 public static void main(String[] args) { |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
58 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
59 configureLogging(); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
60 |
5
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
61 FactoryBootstrap bootstrap = new FactoryBootstrap(); |
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
62 |
8f2de197bce2
Added config to artifact database and modelled bootstap of artifact factories on top of this.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2
diff
changeset
|
63 bootstrap.boot(); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5
diff
changeset
|
64 |
128
bfa65a812c7a
Made the backend singleton.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
65 Backend backend = Backend.getInstance(); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
66 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
67 ArtifactDatabaseImpl db = new ArtifactDatabaseImpl( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
68 bootstrap, backend); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
69 |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
19
diff
changeset
|
70 DatabaseCleaner cleaner = new DatabaseCleaner( |
41
5e4bc24ea438
Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
32
diff
changeset
|
71 bootstrap.getContext(), backend); |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
19
diff
changeset
|
72 |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
73 bootstrap = null; |
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
74 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
75 backend.setCleaner(cleaner); |
30
88972c6daa4f
Added a cleanup thread which periodically removes
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
19
diff
changeset
|
76 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
77 cleaner.setFilter(db); |
13
0d6badf6af42
Added not yet working backend to artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
5
diff
changeset
|
78 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
30
diff
changeset
|
79 cleaner.start(); |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
80 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
13
diff
changeset
|
81 Standalone.startAsServer(db); |
2
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
141457e0d7b1
Created a new sub project for artifact database server.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 } |
79
f69e5b87f05f
Implementation to export artifacts as xml (applied patch from issue208 by SLT).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
77
diff
changeset
|
84 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |