annotate artifact-database/src/main/java/de/intevation/artifactdatabase/DefaultService.java @ 386:fd32dc33a24c

Added a method State.getHelpText(). artifacts/trunk@4338 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 03 May 2012 07:55:23 +0000
parents 9798e4d83681
children
rev   line source
100
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 90
diff changeset
1 /*
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 90
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 90
diff changeset
3 *
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 90
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: 90
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: 90
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: 90
diff changeset
7 */
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 90
diff changeset
8
69
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 package de.intevation.artifactdatabase;
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.CallMeta;
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.Service;
299
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
13 import de.intevation.artifacts.GlobalContext;
69
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.ServiceFactory;
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import org.apache.log4j.Logger;
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import org.w3c.dom.Document;
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
89
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
20 /**
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
21 * Trivial implementation of an artifact database service. Useful to
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
22 * be subclassed.
90
68285f7bc476 More javadoc.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 89
diff changeset
23 *
89
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
24 * @author <a href="mailto:sascha.teichmann@intevation.de">Sascha L. Teichmann</a>
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
25 */
69
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 public class DefaultService
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 implements Service
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 {
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 private static Logger logger = Logger.getLogger(DefaultService.class);
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
380
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
31 public static class Output implements Service.Output {
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
32
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
33 protected Object data;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
34 protected String mimeType;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
35
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
36 public Output() {
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
37 }
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
38
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
39 public Output(Object data, String mimeType) {
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
40 this.data = data;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
41 this.mimeType = mimeType;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
42 }
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
43
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
44 @Override
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
45 public Object getData() {
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
46 return data;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
47 }
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
48
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
49 @Override
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
50 public String getMIMEType() {
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
51 return mimeType;
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
52 }
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
53 } // class Output
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
54
299
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
55 @Override
380
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
56 public Service.Output process(
299
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
57 Document data,
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
58 GlobalContext globalContext,
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
59 CallMeta callMeta
89
d348fe1fd822 More javadoc (fixes small glitches, too).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 69
diff changeset
60 ) {
299
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
61 logger.debug("Service.process");
380
9798e4d83681 Services are now able to return more than just XML documents.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 299
diff changeset
62 return new Output(new byte[0], "application/octet-stream");
69
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 }
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64
299
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
65 @Override
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
66 public void setup(ServiceFactory factory, GlobalContext globalContext) {
a8d62eb93cd4 Services now take GlobalContext on setup and process.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 207
diff changeset
67 logger.debug("Service.setup");
69
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 }
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 }
498bb84334d0 Added base class for services and service factories.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org