Log4JLoggerWithBatchContext.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.utils.logger.log4j;

  21. import java.util.List;

  22. import org.openspcoop2.utils.UtilsException;
  23. import org.openspcoop2.utils.logger.beans.context.batch.BatchContext;
  24. import org.openspcoop2.utils.logger.beans.context.batch.BatchTransaction;
  25. import org.openspcoop2.utils.logger.beans.context.core.AbstractContext;
  26. import org.openspcoop2.utils.logger.beans.context.core.BaseClient;
  27. import org.openspcoop2.utils.logger.beans.context.core.BaseServer;
  28. import org.openspcoop2.utils.logger.config.DiagnosticConfig;
  29. import org.openspcoop2.utils.logger.config.Log4jConfig;
  30. import org.openspcoop2.utils.logger.config.MultiLoggerConfig;

  31. /**
  32.  * Log4JLogger
  33.  *
  34.  * @author Poli Andrea (apoli@link.it)
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  */
  38. public class Log4JLoggerWithBatchContext extends AbstractLog4JLoggerWithContext  {

  39.     public Log4JLoggerWithBatchContext(MultiLoggerConfig config) throws UtilsException {
  40.         super(config);
  41.     }

  42.     public Log4JLoggerWithBatchContext(DiagnosticConfig diagnosticConfig, Log4jConfig logConfig) throws UtilsException {
  43.         super(diagnosticConfig, logConfig);
  44.     }
  45.    
  46.     @Override
  47.     protected AbstractContext newContext() {
  48.         return new BatchContext();
  49.     }

  50.     @Override
  51.     protected BaseClient getClient() {
  52.         return null;
  53.     }

  54.     @Override
  55.     protected List<BaseServer> getServers() {
  56.         if(this.context==null) {
  57.             return null;
  58.         }
  59.         if(this.context instanceof BatchContext) {
  60.             BatchContext batchContext = (BatchContext) this.context;
  61.             if(batchContext.getTransaction()!=null) {
  62.                 return ((BatchTransaction)batchContext.getTransaction()).getServers();
  63.             }
  64.         }
  65.         return null;
  66.     }
  67.    
  68. }