Package org.ametys.runtime.servlet
Class RuntimeServlet
- java.lang.Object
-
- javax.servlet.GenericServlet
-
- javax.servlet.http.HttpServlet
-
- org.ametys.runtime.servlet.RuntimeServlet
-
- All Implemented Interfaces:
Serializable
,Servlet
,ServletConfig
public class RuntimeServlet extends HttpServlet
Main entry point for applications.
Overrides the CocoonServlet to add some initialization.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RuntimeServlet.RunMode
The run modes
-
Field Summary
Fields Modifier and Type Field Description private Collection<Pattern>
_allowedURLPattern
private File
_ametysHome
private AmetysHomeLock
_ametysHomeLock
private DefaultContext
_avalonContext
private File
_cacheDir
private Cocoon
_cocoon
private HttpContext
_context
private Exception
_exception
private org.slf4j.Logger
_logger
private LoggerManager
_loggerManager
private int
_maxUploadSize
private static RuntimeServlet.RunMode
_mode
private RequestFactory
_requestFactory
private ServletContext
_servletContext
private String
_servletContextPath
private URL
_servletContextURL
private File
_uploadDir
private File
_workDir
static String
AMETYS_HOME_DEFAULT
The default ametys home path (relative to the servlet context)static String
AMETYS_HOME_PROPERTY
Name of the servlet initialization parameter for the ametys home propertystatic String
COCOON_CONF_URL
The cocoon.xconf URLstatic String
CONFIG_FILE_NAME
The config file namestatic String
CONTEXT_CONTEXT_ROOT
Constant for storing the servlet context URL in the Avalon contextstatic String
CONTEXT_SERVLET_CONFIG
Constant for storing theServletConfig
in the Avalon contextstatic int
DEFAULT_MAX_UPLOAD_SIZE
Default max upload size (10 Mb)static String
EXTERNAL_LOCATIONS
The optional location (relative to application context) of the file that configures the list of plugins/workspaces/kernel to get somewhere else
-
Constructor Summary
Constructors Constructor Description RuntimeServlet()
-
Method Summary
-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
-
-
-
Field Detail
-
CONTEXT_SERVLET_CONFIG
public static final String CONTEXT_SERVLET_CONFIG
Constant for storing theServletConfig
in the Avalon context- See Also:
- Constant Field Values
-
CONTEXT_CONTEXT_ROOT
public static final String CONTEXT_CONTEXT_ROOT
Constant for storing the servlet context URL in the Avalon context- See Also:
- Constant Field Values
-
COCOON_CONF_URL
public static final String COCOON_CONF_URL
The cocoon.xconf URL- See Also:
- Constant Field Values
-
DEFAULT_MAX_UPLOAD_SIZE
public static final int DEFAULT_MAX_UPLOAD_SIZE
Default max upload size (10 Mb)- See Also:
- Constant Field Values
-
CONFIG_FILE_NAME
public static final String CONFIG_FILE_NAME
The config file name- See Also:
- Constant Field Values
-
AMETYS_HOME_PROPERTY
public static final String AMETYS_HOME_PROPERTY
Name of the servlet initialization parameter for the ametys home property- See Also:
- Constant Field Values
-
AMETYS_HOME_DEFAULT
public static final String AMETYS_HOME_DEFAULT
The default ametys home path (relative to the servlet context)- See Also:
- Constant Field Values
-
EXTERNAL_LOCATIONS
public static final String EXTERNAL_LOCATIONS
The optional location (relative to application context) of the file that configures the list of plugins/workspaces/kernel to get somewhere else- See Also:
- Constant Field Values
-
_mode
private static RuntimeServlet.RunMode _mode
-
_servletContext
private ServletContext _servletContext
-
_servletContextPath
private String _servletContextPath
-
_servletContextURL
private URL _servletContextURL
-
_avalonContext
private DefaultContext _avalonContext
-
_context
private HttpContext _context
-
_requestFactory
private RequestFactory _requestFactory
-
_maxUploadSize
private int _maxUploadSize
-
_uploadDir
private File _uploadDir
-
_ametysHome
private File _ametysHome
-
_ametysHomeLock
private AmetysHomeLock _ametysHomeLock
-
_logger
private org.slf4j.Logger _logger
-
_loggerManager
private LoggerManager _loggerManager
-
_exception
private Exception _exception
-
_allowedURLPattern
private Collection<Pattern> _allowedURLPattern
-
-
Constructor Detail
-
RuntimeServlet
public RuntimeServlet()
-
-
Method Detail
-
init
public void init() throws ServletException
- Overrides:
init
in classGenericServlet
- Throws:
ServletException
-
_initAmetysHome
private void _initAmetysHome() throws AmetysHomeLockException
- Throws:
AmetysHomeLockException
-
_initAmetys
private void _initAmetys() throws Exception
- Throws:
Exception
-
_initLogger
private void _initLogger()
-
_createCocoon
private void _createCocoon() throws Exception
- Throws:
Exception
-
doMigrationAndInit
public static void doMigrationAndInit(PluginsComponentManager pluginCM) throws Exception
Init migration and plugins- Parameters:
pluginCM
- Plugins Component Manager- Throws:
Exception
- Something went wrong
-
_initPlugins
private static void _initPlugins(PluginsComponentManager pluginCM) throws Exception
- Throws:
Exception
-
_initMigration
private static void _initMigration(PluginsComponentManager pluginCM) throws Exception
- Throws:
Exception
-
_loadRuntimeConfig
private void _loadRuntimeConfig() throws ServletException
- Throws:
ServletException
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceServlet
- Overrides:
destroy
in classGenericServlet
-
_disposeCocoon
private final void _disposeCocoon()
-
service
public final void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
- Overrides:
service
in classHttpServlet
- Throws:
ServletException
IOException
-
restartCocoon
public void restartCocoon(HttpServletRequest req)
Restart cocoon- Parameters:
req
- The http servlet request, used to read safeMode and normalMode request attribute if possible. If null, safe mode will be forced only if it was alread forced.
-
_retrieveUri
private String _retrieveUri(HttpServletRequest req)
-
_fireRequestStarted
private void _fireRequestStarted(HttpServletRequest req)
-
_fireRequestEnded
private void _fireRequestEnded(HttpServletRequest req)
-
setRunMode
public static void setRunMode(RuntimeServlet.RunMode mode)
Set the run mode- Parameters:
mode
- the running mode
-
getRunMode
public static RuntimeServlet.RunMode getRunMode()
Get the run mode- Returns:
- the current run mode
-
_renderError
private void _renderError(HttpServletRequest req, HttpServletResponse res, Throwable throwable, String message) throws ServletException
- Throws:
ServletException
-
-