DumpOpenSPCoopAppenderDB.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */



  20. package org.openspcoop2.pdd.logger;

  21. import java.sql.Connection;

  22. import org.openspcoop2.core.commons.CoreException;
  23. import org.openspcoop2.core.config.OpenspcoopAppender;
  24. import org.openspcoop2.protocol.engine.BasicProtocolFactory;
  25. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  26. import org.openspcoop2.protocol.sdk.dump.DumpException;
  27. import org.openspcoop2.protocol.sdk.dump.IDumpProducer;
  28. import org.openspcoop2.protocol.sdk.dump.Messaggio;

  29. /**
  30.  * Contiene l'implementazione di un appender personalizzato,
  31.  * per la registrazione dei messaggi su database.
  32.  *
  33.  * @author Poli Andrea (apoli@link.it)
  34.  * @author $Author$
  35.  * @version $Rev$, $Date$
  36.  */

  37. public class DumpOpenSPCoopAppenderDB implements IDumpProducer{

  38.     /** Driver di base: valido per tutti i protocolli */
  39.     org.openspcoop2.protocol.basic.dump.DumpProducer dumpBase = null;
  40.    
  41.     /** Factory di base */
  42.     private BasicProtocolFactory basicProtocolFactory;
  43.    
  44.        
  45.     /**
  46.      * Inizializza l'engine di un appender per la registrazione
  47.      * di un dump applicativo emesso da una porta di dominio.
  48.      *
  49.      * @param appenderProperties Proprieta' dell'appender
  50.      * @throws DumpException
  51.      */
  52.     @Override
  53.     public void initializeAppender(OpenspcoopAppender appenderProperties) throws DumpException{
  54.         try{
  55.             this.basicProtocolFactory = new BasicProtocolFactory(OpenSPCoop2Logger.getLoggerOpenSPCoopCore());
  56.             this.dumpBase = (org.openspcoop2.protocol.basic.dump.DumpProducer) this.basicProtocolFactory.createDumpProducer();
  57.             this.dumpBase.initializeAppender(appenderProperties);
  58.         }catch(Exception e){
  59.             throw new DumpException(e.getMessage(),e);
  60.         }
  61.     }

  62.    
  63.    
  64.     /**
  65.      * Dump di un messaggio
  66.      *
  67.      * @param conOpenSPCoopPdD Connessione verso il database
  68.      * @param messaggio
  69.      * @throws DumpException
  70.      */
  71.     @SuppressWarnings("deprecation")
  72.     @Deprecated
  73.     @Override
  74.     public void dump(Connection conOpenSPCoopPdD,Messaggio messaggio) throws DumpException{
  75.         this.dumpBase.dump(conOpenSPCoopPdD, messaggio);
  76.     }
  77.     @Override
  78.     public void dump(Connection conOpenSPCoopPdD,Messaggio messaggio,boolean headersCompact) throws DumpException{
  79.         this.dumpBase.dump(conOpenSPCoopPdD,messaggio,headersCompact);
  80.     }



  81.     @Override
  82.     public void isAlive() throws CoreException {
  83.         this.dumpBase.isAlive();
  84.     }



  85.     @Override
  86.     public IProtocolFactory<?> getProtocolFactory() {
  87.         return this.basicProtocolFactory;
  88.     }


  89. }