ingo@1631: package de.intevation.flys.artifacts.services; ingo@1631: ingo@1631: import org.w3c.dom.Document; ingo@1631: ingo@1631: import org.apache.log4j.Logger; ingo@1631: ingo@1631: import org.hibernate.Session; ingo@1631: ingo@1631: import de.intevation.artifacts.CallMeta; ingo@1631: import de.intevation.artifacts.GlobalContext; ingo@1631: sascha@2607: import de.intevation.artifactdatabase.XMLService; ingo@1631: ingo@1631: import de.intevation.flys.backend.SessionHolder; ingo@1631: ingo@1631: sascha@2607: public abstract class FLYSService extends XMLService { ingo@1631: ingo@1631: private static final Logger logger = Logger.getLogger(FLYSService.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: 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() { ingo@1631: logger.debug("init"); ingo@1631: SessionHolder.acquire(); ingo@1631: } ingo@1631: ingo@1631: ingo@1631: protected void shutdown() { ingo@1631: logger.debug("shutdown"); ingo@1631: Session session = SessionHolder.HOLDER.get(); ingo@1631: session.close(); ingo@1631: ingo@1631: SessionHolder.release(); ingo@1631: } ingo@1631: } ingo@1631: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :