teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.services; ingo@1631: ingo@1631: import org.w3c.dom.Document; ingo@1631: ingo@1631: import org.apache.log4j.Logger; ingo@1631: teichmann@5831: import org.dive4elements.artifacts.CallMeta; teichmann@5831: import org.dive4elements.artifacts.GlobalContext; ingo@1631: teichmann@5831: import org.dive4elements.artifactdatabase.XMLService; ingo@1631: teichmann@5831: import org.dive4elements.river.backend.SessionHolder; ingo@1631: ingo@1631: teichmann@5868: public abstract class D4EService extends XMLService { ingo@1631: teichmann@8202: private static final Logger log = Logger.getLogger(D4EService.class); ingo@1631: ingo@1631: sascha@2084: @Override sascha@2607: public Document processXML( ingo@1631: Document data, ingo@1631: GlobalContext globalContext, ingo@1631: CallMeta callMeta ingo@1631: ) { ingo@1631: init(); ingo@1631: ingo@1631: try { ingo@1631: return doProcess(data, globalContext, callMeta); ingo@1631: } ingo@1631: finally { ingo@1631: shutdown(); ingo@1631: } ingo@1631: } ingo@1631: ingo@1631: felix@6920: /** Override to do the meat work (called in processXML). */ ingo@1631: protected abstract Document doProcess( ingo@1631: Document data, ingo@1631: GlobalContext globalContext, ingo@1631: CallMeta callMeta); ingo@1631: ingo@1631: ingo@1631: protected void init() { teichmann@8202: log.debug("init"); ingo@1631: SessionHolder.acquire(); ingo@1631: } ingo@1631: ingo@1631: felix@6920: /** Called when processing done, close session. */ ingo@1631: protected void shutdown() { teichmann@8202: log.debug("shutdown"); ingo@1631: SessionHolder.release(); ingo@1631: } ingo@1631: } ingo@1631: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :