Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/FLYSService.java @ 3814:8083f6384023
merged flys-artifacts/pre2.6-2012-01-04
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:56 +0200 |
parents | 26e19cdaed5e |
children | a5f327849b85 |
comparison
equal
deleted
inserted
replaced
1491:2a00f4849738 | 3814:8083f6384023 |
---|---|
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.DefaultService; | |
13 | |
14 import de.intevation.flys.backend.SessionHolder; | |
15 | |
16 | |
17 public abstract class FLYSService extends DefaultService { | |
18 | |
19 private static final Logger logger = Logger.getLogger(FLYSService.class); | |
20 | |
21 | |
22 public Document process( | |
23 Document data, | |
24 GlobalContext globalContext, | |
25 CallMeta callMeta | |
26 ) { | |
27 init(); | |
28 | |
29 try { | |
30 return doProcess(data, globalContext, callMeta); | |
31 } | |
32 finally { | |
33 shutdown(); | |
34 } | |
35 } | |
36 | |
37 | |
38 protected abstract Document doProcess( | |
39 Document data, | |
40 GlobalContext globalContext, | |
41 CallMeta callMeta); | |
42 | |
43 | |
44 protected void init() { | |
45 logger.debug("init"); | |
46 SessionHolder.acquire(); | |
47 } | |
48 | |
49 | |
50 protected void shutdown() { | |
51 logger.debug("shutdown"); | |
52 Session session = SessionHolder.HOLDER.get(); | |
53 session.close(); | |
54 | |
55 SessionHolder.release(); | |
56 } | |
57 } | |
58 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |