![JAR search and dependency download from the Maven repository](/logo.png)
org.efaps.ui.servlet.InitServlet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of efaps-webapp Show documentation
Show all versions of efaps-webapp Show documentation
eFaps WebApp provides a web interface as the User Interface for eFaps
which can be easily expanded and altered.
/*
* Copyright 2003 - 2012 The eFaps Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Revision: $Rev: 8999 $
* Last Changed: $Date: 2013-03-05 18:56:38 -0500 (Tue, 05 Mar 2013) $
* Last Changed By: $Author: [email protected] $
*/
package org.efaps.ui.servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.efaps.admin.runlevel.RunLevel;
import org.efaps.db.Context;
import org.efaps.util.EFapsException;
import org.efaps.util.RequestHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Init the webapp.
* @author The eFaps Team
* @version $Id: InitServlet.java 8999 2013-03-05 23:56:38Z [email protected] $
*/
public class InitServlet
extends HttpServlet
{
/**
* Needed foer serialization.
*/
private static final long serialVersionUID = 7212518317632161066L;
/**
* Logging instance used in this class.
*/
private static final Logger LOG = LoggerFactory.getLogger(InitServlet.class);
/**
* @param _config ServletConfig
* @throws ServletException on error
*/
@Override
public void init(final ServletConfig _config)
throws ServletException
{
super.init(_config);
RequestHandler.initReplacableMacros("/"
+ _config.getServletContext().getServletContextName()
+ "/");
// the runlevel should only be loaded once from a filter during the init phase, as long as is is the same one
if (!"webapp".equals(RunLevel.getName4Current())) {
try {
Context.begin();
RunLevel.init("webapp");
RunLevel.execute();
} catch (final EFapsException e) {
InitServlet.LOG.error("Error during execution of runlevel", e);
throw new ServletException(e);
} finally {
try {
Context.rollback();
} catch (final EFapsException e) {
InitServlet.LOG.error("Error during rollback of context after load of runlevel", e);
throw new ServletException(e);
}
}
}
}
/* (non-Javadoc)
* @see javax.servlet.GenericServlet#destroy()
*/
@Override
public void destroy()
{
RunLevel.stop();
super.destroy();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy