CorePluginLoader.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.monitor.engine.dynamic;

  21. import org.openspcoop2.utils.resources.Loader;
  22. import org.slf4j.Logger;

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

  31.     private static IPluginLoader staticInstance;
  32.     public static synchronized void initialize(Loader loader, Logger log, Class<?> c) throws Exception {
  33.         staticInstance = (IPluginLoader) loader.newInstance(c);
  34.         staticInstance.init(loader, log);
  35.     }
  36.     public static synchronized void initialize(Loader loader, Logger log, Class<?> c, IRegistroPluginsReader registroPluginsReader, int expireSeconds) throws Exception {
  37.         staticInstance = (IPluginLoader) loader.newInstance(c);
  38.         staticInstance.init(loader, log, registroPluginsReader, expireSeconds);
  39.     }
  40.     public static IPluginLoader getInstance() {
  41.         return staticInstance;
  42.     }
  43.     public static synchronized void close(Logger log) {
  44.         if(staticInstance!=null) {
  45.             staticInstance.close(log);
  46.         }
  47.     }
  48. }