ExtendedInfoManager.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.core.config.driver;

  21. import org.openspcoop2.core.commons.IExtendedInfo;
  22. import org.openspcoop2.utils.resources.Loader;

  23. /**
  24.  * ExtendedInfoManager
  25.  *  
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class ExtendedInfoManager {

  31.    
  32.     // STATIC
  33.    
  34.     private static ExtendedInfoManager staticInstance = null;
  35.     public static synchronized void initialize(
  36.             Loader openspcoop2Loader,
  37.             String classExtendedInfoConfigurazione,
  38.             String classExtendedInfoPortaDelegata, String classExtendedInfoPortaApplicativa){
  39.         initialize(false, openspcoop2Loader,
  40.                 classExtendedInfoConfigurazione, classExtendedInfoPortaDelegata, classExtendedInfoPortaApplicativa);
  41.     }
  42.     public static synchronized void initialize(
  43.             boolean forceOverride,
  44.             Loader openspcoop2Loader,
  45.             String classExtendedInfoConfigurazione,
  46.             String classExtendedInfoPortaDelegata, String classExtendedInfoPortaApplicativa){
  47.         if(staticInstance==null || forceOverride){
  48.             staticInstance = new ExtendedInfoManager(openspcoop2Loader,
  49.                     classExtendedInfoConfigurazione,
  50.                     classExtendedInfoPortaDelegata, classExtendedInfoPortaApplicativa);
  51.         }
  52.     }
  53.     public static ExtendedInfoManager getInstance() throws DriverConfigurazioneException{
  54.         if(staticInstance==null){
  55.             throw new DriverConfigurazioneException("ExtendedInfoManager not initialized");
  56.         }
  57.         return staticInstance;
  58.     }
  59.    
  60.    
  61.    
  62.     // INSTANCE
  63.    
  64.     private String classExtendedInfoConfigurazione;
  65.     private String classExtendedInfoPortaDelegata;
  66.     private String classExtendedInfoPortaApplicativa;
  67.     private Loader openspcoop2Loader;
  68.    
  69.     private ExtendedInfoManager(Loader openspcoop2Loader,
  70.             String classExtendedInfoConfigurazione,
  71.             String classExtendedInfoPortaDelegata, String classExtendedInfoPortaApplicativa){
  72.         this.openspcoop2Loader = openspcoop2Loader;
  73.         this.classExtendedInfoConfigurazione = classExtendedInfoConfigurazione;
  74.         this.classExtendedInfoPortaDelegata = classExtendedInfoPortaDelegata;
  75.         this.classExtendedInfoPortaApplicativa = classExtendedInfoPortaApplicativa;
  76.     }
  77.    
  78.    
  79.     public IExtendedInfo newInstanceExtendedInfoConfigurazione() throws DriverConfigurazioneException{
  80.         try{
  81.             if(this.classExtendedInfoConfigurazione==null){
  82.                 return null;
  83.             }
  84.             return (IExtendedInfo) this.openspcoop2Loader.newInstance(this.classExtendedInfoConfigurazione);
  85.         }catch(Throwable e){
  86.             throw new DriverConfigurazioneException("[ExtendedInfoConfigurazione] "+e.getMessage(),e);
  87.         }
  88.     }
  89.    
  90.     public IExtendedInfo newInstanceExtendedInfoPortaDelegata() throws DriverConfigurazioneException{
  91.         try{
  92.             if(this.classExtendedInfoPortaDelegata==null){
  93.                 return null;
  94.             }
  95.             return (IExtendedInfo) this.openspcoop2Loader.newInstance(this.classExtendedInfoPortaDelegata);
  96.         }catch(Throwable e){
  97.             throw new DriverConfigurazioneException("[ExtendedInfoPortaDelegata] "+e.getMessage(),e);
  98.         }
  99.     }
  100.    
  101.     public IExtendedInfo newInstanceExtendedInfoPortaApplicativa() throws DriverConfigurazioneException{
  102.         try{
  103.             if(this.classExtendedInfoPortaApplicativa==null){
  104.                 return null;
  105.             }
  106.             return (IExtendedInfo) this.openspcoop2Loader.newInstance(this.classExtendedInfoPortaApplicativa);
  107.         }catch(Throwable e){
  108.             throw new DriverConfigurazioneException("[ExtendedInfoPortaApplicativa] "+e.getMessage(),e);
  109.         }
  110.     }
  111.    
  112. }