annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FLYSService.java @ 3193:2f922be407ea

Moved common code of the *Artifacts into FLYSArtifact. flys-artifacts/trunk@4809 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 27 Jun 2012 13:45:55 +0000
parents 247f3e98a14b
children
rev   line source
1631
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.services;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import org.w3c.dom.Document;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import org.hibernate.Session;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import de.intevation.artifacts.CallMeta;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.GlobalContext;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2084
diff changeset
12 import de.intevation.artifactdatabase.XMLService;
1631
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.flys.backend.SessionHolder;
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
15
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
16
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2084
diff changeset
17 public abstract class FLYSService extends XMLService {
1631
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 private static final Logger logger = Logger.getLogger(FLYSService.class);
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21
2084
a5f327849b85 Added a service to invalidate caches by their names. Useful tp prevent cache inconsistencies caused by external ETL processes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1631
diff changeset
22 @Override
2607
247f3e98a14b Abjusted services to new hierachy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2084
diff changeset
23 public Document processXML(
1631
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 Document data,
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 GlobalContext globalContext,
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 CallMeta callMeta
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 ) {
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 init();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 try {
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 return doProcess(data, globalContext, callMeta);
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33 finally {
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 shutdown();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 protected abstract Document doProcess(
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40 Document data,
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 GlobalContext globalContext,
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 CallMeta callMeta);
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45 protected void init() {
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46 logger.debug("init");
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 SessionHolder.acquire();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
48 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
49
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
50
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 protected void shutdown() {
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 logger.debug("shutdown");
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 Session session = SessionHolder.HOLDER.get();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 session.close();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 SessionHolder.release();
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 }
26e19cdaed5e Improved database session handling in services and artifacts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org