csip.ServletContextHooks Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csip-core Show documentation
Show all versions of csip-core Show documentation
The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.
/*
* $Id: ServletContextHooks.java dcb5aa2353e5 2020-02-19 od $
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2019, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
/**
* Context Registration.
*
* @author Olaf David
*/
@WebListener
public class ServletContextHooks implements ServletContextListener {
static Logger l = Config.LOG;
@Override
public void contextInitialized(ServletContextEvent e) {
ServletContext ctx = e.getServletContext();
l.info("Starting " + ctx.getContextPath() + ", CSIP core "
+ Config.getString(Config.CSIP_PLATFORM_VERSION));
ContextConfig cc = new ContextConfig();
// Context internal settings.
cc.load(ctx, "/WEB-INF/csip-defaults.json");
cc.load(ctx, "/META-INF/csip-conf.json"); // deprecated
// Servlet init params.
cc.load(ctx);
// Tomcat/conf folder as .yaml
cc.load(new File(System.getProperty("catalina.home")
+ File.separatorChar + "conf" + ctx.getContextPath() + ".yaml"));
// webapp folder configuration files
cc.load(ctx, ".json");
cc.load(ctx, ".properties");
cc.load(ctx, ".yaml");
if (!cc.getConfig().isEmpty()) {
ControlService.updateConfig(cc.getConfig());
}
Config.startup();
l.info("CSIP Context Created: " + ctx.getContextPath());
}
@Override
public void contextDestroyed(ServletContextEvent e) {
Config.shutdown();
l.info("CSIP Context Destroyed: " + e.getServletContext().getContextPath());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy