annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java @ 406:10aa92f2eca0

Add a account column to the users table artifacts/trunk@5242 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Thu, 23 Aug 2012 13:33:27 +0000
parents 694d818e99b2
children
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
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 package de.intevation.artifactdatabase;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
207
b2115f484edb Move Config and XMLUtils totally to commons package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
11 import de.intevation.artifacts.common.utils.Config;
b2115f484edb Move Config and XMLUtils totally to commons package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 100
diff changeset
12
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 import de.intevation.artifacts.Artifact;
75
d4c4c23847f5 Extended the Artifact-Interface-Method setup to be able to put the XML-Document which can contain further Data
Tim Englich <tim.englich@intevation.de>
parents: 41
diff changeset
14 import de.intevation.artifacts.ArtifactFactory;
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 24
diff changeset
15 import de.intevation.artifacts.ArtifactSerializer;
297
694d818e99b2 Adapted the signature of Artifact.setup() - a parameter of type CallMeta has been added.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 293
diff changeset
16 import de.intevation.artifacts.CallMeta;
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
17 import de.intevation.artifacts.GlobalContext;
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18
93
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 91
diff changeset
19 import org.apache.log4j.Logger;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 91
diff changeset
20
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 91
diff changeset
21 import org.w3c.dom.Document;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 91
diff changeset
22 import org.w3c.dom.Node;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 91
diff changeset
23
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
24 /**
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
25 * Trivial implementation of the ArtifactFactory interface.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
26 * Time to live (ttl), name and description are configured
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
27 * via the Node given to #setup(Document, Node) with attributes
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
28 * of same name. The class name of the artifacts to be build by this
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
29 * factory is configures with the attribute 'artifact'.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
30 *
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: 75
diff changeset
31 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
32 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 public class DefaultArtifactFactory
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 implements ArtifactFactory
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
36 private static Logger logger =
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
37 Logger.getLogger(DefaultArtifactFactory.class);
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
38
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
39 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
40 * XPath to access the TTL of this artifact.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
41 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 public static final String XPATH_TTL = "@ttl";
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
43 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
44 * XPath to access the name of this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
45 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 public static final String XPATH_NAME = "@name";
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
47 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
48 * XPath to access the description of this artifact factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
49 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 public static final String XPATH_DESCRIPTION = "@description";
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
51 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
52 * XPath to access the class name of the artifacts to be build
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
53 * by this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
54 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 public static final String XPATH_ARTIFACT = "@artifact";
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
57 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
58 * Default description of this factory if none is given by the
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
59 * configuration.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
60 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 public static final String DEFAULT_DESCRIPTION =
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 "No description available";
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
64 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
65 * Class to load if no artifact class is given in the configuration.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
66 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 public static final String DEFAULT_ARTIFACT =
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 "de.intevation.artifactdatabase.DefaultArtifact";
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
70 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
71 * The Time to live of the artifacts build by this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
72 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 protected Long ttl;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
75 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
76 * The name of this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
77 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 protected String name;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
80 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
81 * The description of this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
82 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 protected String description;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
85 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
86 * The class of the artifacts to be build by this factory.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
87 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 protected Class artifactClass;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
90 /**
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
91 * Default constructor.
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
92 */
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 public DefaultArtifactFactory() {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 public String getName() {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 return name;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 public String getDescription() {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 return description;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
104 public Artifact createArtifact(
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
105 String identifier,
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
106 GlobalContext context,
297
694d818e99b2 Adapted the signature of Artifact.setup() - a parameter of type CallMeta has been added.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 293
diff changeset
107 CallMeta callMeta,
293
a367a0d011af Set an interface for the global context; added a method to the artifact database to return an instance of an Artifact.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 207
diff changeset
108 Document data
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
109 ) {
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 try {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 Artifact artifact =
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 (Artifact)artifactClass.newInstance();
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113
297
694d818e99b2 Adapted the signature of Artifact.setup() - a parameter of type CallMeta has been added.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 293
diff changeset
114 artifact.setup(identifier, this, context, callMeta, data);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 return artifact;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 catch (InstantiationException ie) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
119 logger.error(ie.getLocalizedMessage(), ie);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 catch (IllegalAccessException iae) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
122 logger.error(iae.getLocalizedMessage(), iae);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 catch (ClassCastException cce) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
125 logger.error(cce.getLocalizedMessage(), cce);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 return null;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 public void setup(Document document, Node factoryNode) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 String ttlString = Config.getStringXPath(factoryNode, XPATH_TTL);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134 if (ttlString != null) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 try {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 ttl = Long.valueOf(ttlString);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 catch (NumberFormatException nfe) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
139 logger.warn("'" + ttlString + "' is not an integer.");
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 description = Config.getStringXPath(
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 factoryNode, XPATH_DESCRIPTION, DEFAULT_DESCRIPTION);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
145
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
146 name = Config.getStringXPath(
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
147 factoryNode, XPATH_NAME, toString());
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
148
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
149 String artifact = Config.getStringXPath(
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
150 factoryNode, XPATH_ARTIFACT, DEFAULT_ARTIFACT);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
151
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
152 try {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
153 artifactClass = Class.forName(artifact);
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
154 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
155 catch (ClassNotFoundException cnfe) {
17
5a6b6a3debc7 Integrated logging into artifact database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 10
diff changeset
156 logger.error(cnfe.getLocalizedMessage(), cnfe);
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
157 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
158
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
159 if (artifactClass == null) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 artifactClass = DefaultArtifact.class;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
161 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
162 }
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
163
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
164 public Long timeToLiveUntouched(Artifact artifact, Object context) {
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
165 return ttl;
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
166 }
41
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 24
diff changeset
167
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 24
diff changeset
168 public ArtifactSerializer getSerializer() {
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 24
diff changeset
169 return DefaultArtifactSerializer.INSTANCE;
5e4bc24ea438 Made serilization more flexible. DB update required!!!
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 24
diff changeset
170 }
10
e8626caac353 * Made Artifact life cycle symmetric: setup/endOfLife.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
171 }
91
730ff077a58c More javadoc, some code formatting.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 90
diff changeset
172 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org