Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FLYSService.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 247f3e98a14b |
children |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.services; | |
2 | |
3 import org.w3c.dom.Document; | |
4 | |
5 import org.apache.log4j.Logger; | |
6 | |
7 import org.hibernate.Session; | |
8 | |
9 import de.intevation.artifacts.CallMeta; | |
10 import de.intevation.artifacts.GlobalContext; | |
11 | |
12 import de.intevation.artifactdatabase.XMLService; | |
13 | |
14 import de.intevation.flys.backend.SessionHolder; | |
15 | |
16 | |
17 public abstract class FLYSService extends XMLService { | |
18 | |
19 private static final Logger logger = Logger.getLogger(FLYSService.class); | |
20 | |
21 | |
22 @Override | |
23 public Document processXML( | |
24 Document data, | |
25 GlobalContext globalContext, | |
26 CallMeta callMeta | |
27 ) { | |
28 init(); | |
29 | |
30 try { | |
31 return doProcess(data, globalContext, callMeta); | |
32 } | |
33 finally { | |
34 shutdown(); | |
35 } | |
36 } | |
37 | |
38 | |
39 protected abstract Document doProcess( | |
40 Document data, | |
41 GlobalContext globalContext, | |
42 CallMeta callMeta); | |
43 | |
44 | |
45 protected void init() { | |
46 logger.debug("init"); | |
47 SessionHolder.acquire(); | |
48 } | |
49 | |
50 | |
51 protected void shutdown() { | |
52 logger.debug("shutdown"); | |
53 Session session = SessionHolder.HOLDER.get(); | |
54 session.close(); | |
55 | |
56 SessionHolder.release(); | |
57 } | |
58 } | |
59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |