PostOutResponseHandler.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.core.handlers.transazioni;

  21. import org.openspcoop2.monitor.sdk.transaction.FaseTracciamento;
  22. import org.openspcoop2.pdd.core.handlers.HandlerException;
  23. import org.openspcoop2.pdd.core.handlers.PostOutResponseContext;
  24. import org.openspcoop2.pdd.logger.transazioni.InformazioniTransazione;
  25. import org.openspcoop2.pdd.logger.transazioni.TracciamentoManager;

  26. /**    
  27.  * PostOutResponseHandler
  28.  *
  29.  * @author Poli Andrea (poli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class PostOutResponseHandler extends LastPositionHandler implements  org.openspcoop2.pdd.core.handlers.PostOutResponseHandler{

  34.     /**
  35.      * Indicazione sull'inizializzazione dell'handler
  36.      */
  37.     private Boolean initialized = false;
  38.    
  39.     /**
  40.      * TracciamentoManager
  41.      */
  42.     private TracciamentoManager tracciamentoManager = null;

  43.     private synchronized void init() throws HandlerException {

  44.         if(this.initialized==null || !this.initialized.booleanValue()){

  45.             try{
  46.                 this.tracciamentoManager = new TracciamentoManager(FaseTracciamento.POST_OUT_RESPONSE);            
  47.             }catch(Exception e){
  48.                 throw new HandlerException("Errore durante l'inizializzazione del gestore del tracciamento: "+e.getMessage(),e);
  49.             }

  50.             this.initialized = true;
  51.         }

  52.     }



  53.     @Override
  54.     public void invoke(PostOutResponseContext context) throws HandlerException {
  55.        
  56.         if(this.initialized==null || !this.initialized.booleanValue()){
  57.             init();
  58.         }
  59.         if(!this.tracciamentoManager.isTransazioniEnabled()) {
  60.             return;
  61.         }
  62.        
  63.         InformazioniTransazione info = new InformazioniTransazione(context);
  64.        
  65.         this.tracciamentoManager.invoke(info, context.getEsito());
  66.        
  67.     }
  68.    
  69. }