Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultArtifactFactory.java @ 90:68285f7bc476
More javadoc.
artifacts/trunk@846 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 26 Mar 2010 17:59:50 +0000 |
parents | b2e0cb83631c |
children | 730ff077a58c |
comparison
equal
deleted
inserted
replaced
89:d348fe1fd822 | 90:68285f7bc476 |
---|---|
7 import de.intevation.artifacts.Artifact; | 7 import de.intevation.artifacts.Artifact; |
8 import de.intevation.artifacts.ArtifactFactory; | 8 import de.intevation.artifacts.ArtifactFactory; |
9 import de.intevation.artifacts.ArtifactSerializer; | 9 import de.intevation.artifacts.ArtifactSerializer; |
10 | 10 |
11 /** | 11 /** |
12 * Trivial implementation of the ArtifactFactory interface. | |
13 * Time to live (ttl), name and description are configured | |
14 * via the Node given to #setup(Document, Node) with attributes | |
15 * of same name. The class name of the artifacts to be build by this | |
16 * factory is configures with the attribute 'artifact'. | |
17 * | |
12 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> | 18 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a> |
13 */ | 19 */ |
14 public class DefaultArtifactFactory | 20 public class DefaultArtifactFactory |
15 implements ArtifactFactory | 21 implements ArtifactFactory |
16 { | 22 { |
17 private static Logger logger = | 23 private static Logger logger = |
18 Logger.getLogger(DefaultArtifactFactory.class); | 24 Logger.getLogger(DefaultArtifactFactory.class); |
19 | 25 |
26 /** | |
27 * XPath to access the TTL of this artifact. | |
28 */ | |
20 public static final String XPATH_TTL = "@ttl"; | 29 public static final String XPATH_TTL = "@ttl"; |
30 /** | |
31 * XPath to access the name of this factory. | |
32 */ | |
21 public static final String XPATH_NAME = "@name"; | 33 public static final String XPATH_NAME = "@name"; |
34 /** | |
35 * XPath to access the description of this artifact factory. | |
36 */ | |
22 public static final String XPATH_DESCRIPTION = "@description"; | 37 public static final String XPATH_DESCRIPTION = "@description"; |
38 /** | |
39 * XPath to access the class name of the artifacts to be build | |
40 * by this factory. | |
41 */ | |
23 public static final String XPATH_ARTIFACT = "@artifact"; | 42 public static final String XPATH_ARTIFACT = "@artifact"; |
24 | 43 |
44 /** | |
45 * Default description of this factory if none is given by the | |
46 * configuration. | |
47 */ | |
25 public static final String DEFAULT_DESCRIPTION = | 48 public static final String DEFAULT_DESCRIPTION = |
26 "No description available"; | 49 "No description available"; |
27 | 50 |
51 /** | |
52 * Class to load if no artifact class is given in the configuration. | |
53 */ | |
28 public static final String DEFAULT_ARTIFACT = | 54 public static final String DEFAULT_ARTIFACT = |
29 "de.intevation.artifactdatabase.DefaultArtifact"; | 55 "de.intevation.artifactdatabase.DefaultArtifact"; |
30 | 56 |
57 /** | |
58 * The Time to live of the artifacts build by this factory. | |
59 */ | |
31 protected Long ttl; | 60 protected Long ttl; |
32 | 61 |
62 /** | |
63 * The name of this factory. | |
64 */ | |
33 protected String name; | 65 protected String name; |
34 | 66 |
67 /** | |
68 * The description of this factory. | |
69 */ | |
35 protected String description; | 70 protected String description; |
36 | 71 |
72 /** | |
73 * The class of the artifacts to be build by this factory. | |
74 */ | |
37 protected Class artifactClass; | 75 protected Class artifactClass; |
38 | 76 |
77 /** | |
78 * Default constructor. | |
79 */ | |
39 public DefaultArtifactFactory() { | 80 public DefaultArtifactFactory() { |
40 } | 81 } |
41 | 82 |
42 public String getName() { | 83 public String getName() { |
43 return name; | 84 return name; |
45 | 86 |
46 public String getDescription() { | 87 public String getDescription() { |
47 return description; | 88 return description; |
48 } | 89 } |
49 | 90 |
50 public Artifact createArtifact(String identifier, | 91 public Artifact createArtifact( |
51 Object context, | 92 String identifier, |
52 Document data) { | 93 Object context, |
53 | 94 Document data |
95 ) { | |
54 try { | 96 try { |
55 Artifact artifact = | 97 Artifact artifact = |
56 (Artifact)artifactClass.newInstance(); | 98 (Artifact)artifactClass.newInstance(); |
57 | 99 |
58 artifact.setup(identifier, this, context, data); | 100 artifact.setup(identifier, this, context, data); |