TracciamentoOpenSPCoopAppenderDB.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.tracciamento.ITracciaProducer;
  27. import org.openspcoop2.protocol.sdk.tracciamento.Traccia;
  28. import org.openspcoop2.protocol.sdk.tracciamento.TracciamentoException;

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

  37. public class TracciamentoOpenSPCoopAppenderDB implements ITracciaProducer{

  38.     /** Driver di base: valido per tutti i protocolli */
  39.     org.openspcoop2.protocol.basic.tracciamento.TracciaProducer tracciamentoBase = 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 tracciamento emesso da una porta di dominio.
  48.      *
  49.      * @param appenderProperties Proprieta' dell'appender
  50.      * @throws TracciamentoException
  51.      */
  52.     @Override
  53.     public void initializeAppender(OpenspcoopAppender appenderProperties) throws TracciamentoException{
  54.         try{
  55.             this.basicProtocolFactory = new BasicProtocolFactory(OpenSPCoop2Logger.getLoggerOpenSPCoopCore());
  56.             this.tracciamentoBase = (org.openspcoop2.protocol.basic.tracciamento.TracciaProducer) this.basicProtocolFactory.createTracciaProducer();
  57.             this.tracciamentoBase.initializeAppender(appenderProperties);
  58.         }catch(Exception e){
  59.             throw new TracciamentoException(e.getMessage(),e);
  60.         }
  61.     }

  62.    
  63.    
  64.     /**
  65.      * Registra una traccia prodotta da una porta di dominio, utilizzando le informazioni definite dalla specifica SPC.
  66.      *
  67.      * @param conOpenSPCoopPdD Connessione verso il database
  68.      * @param traccia Traccia
  69.      * @throws TracciamentoException
  70.      */
  71.     @Override
  72.     public void log(Connection conOpenSPCoopPdD, Traccia traccia) throws TracciamentoException{
  73.         this.tracciamentoBase.log(conOpenSPCoopPdD, traccia);  
  74.     }



  75.     @Override
  76.     public void isAlive() throws CoreException {
  77.         this.tracciamentoBase.isAlive();
  78.     }



  79.     @Override
  80.     public IProtocolFactory<?> getProtocolFactory() {
  81.         return this.basicProtocolFactory;
  82.     }


  83. }