|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.magnolia.cms.servlets.MgnlServletContextListener
public class MgnlServletContextListener
Magnolia main listener: reads initialization parameter from a properties file. The name of the file can be defined as a context parameter in web.xml. Multiple path, comma separated, are supported (the first existing file in the list will be used), and the following variables will be used:
${servername}
: name of the server where the webapp is running, lowercase${webapp}
: the latest token in the webapp path (e.g. magnoliaPublic
for a webapp
deployed ad tomcat/webapps/magnoliaPublic
)
If no magnolia.initialization.file
context parameter is set, the following default is assumed:
<context-param> <param-name>magnolia.initialization.file</param-name> <param-value> WEB-INF/config/${servername}/${webapp}/magnolia.properties, WEB-INF/config/${servername}/magnolia.properties, WEB-INF/config/${webapp}/magnolia.properties, WEB-INF/config/default/magnolia.properties, WEB-INF/config/magnolia.properties </param-value> </context-param>
The ${servername} variable will be resolved to the full name obtained by using InetAddress.getLocalHost().getHostName(), which may also contain the server domain, depending on your server configuration/operating system. You can set the optional context parameter "magnolia.unqualified.server.name" to true if you prefer using the unqualified name (the server "server.domain.com" will be simply resolved as "server")
<context-param> <param-name>magnolia.unqualified.server.name</param-name> <param-value>true</param-value> </context-param>The following parameters are needed in the properties file:
${magnolia.root}logs/magnolia-debug.log
.
Important: if you drop multiple magnolia wars in a container which doesn't isolate system properties
(e.g. tomcat) you will need to change the name of the magnolia.root.sysproperty
variable in web.xml and
in log4j configuration files.
Using the ${servername}
and ${webapp}
properties you can easily bundle in the same webapp
different set of configurations which are automatically applied dependending on the server name (useful for switching
between development, test and production instances where the repository configuration need to be different) or the
webapp name (useful to bundle both the public and admin log4j/jndi/bootstrap configuration in the same war). By
default the initializer will try to search for the file in different location with different combination of
servername
and webapp
: the default
fallback directory will be used if no other
environment-specific directory has been added.
Field Summary | |
---|---|
static String |
MAGNOLIA_INITIALIZATION_FILE
Context parameter name. |
static String |
MAGNOLIA_UNQUALIFIED_SERVER_NAME
Context parameter name. |
Constructor Summary | |
---|---|
MgnlServletContextListener()
|
Method Summary | |
---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
|
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
|
protected String |
getPropertiesFilesString(javax.servlet.ServletContext context,
String servername,
String webapp)
|
protected String |
initRootPath(javax.servlet.ServletContext context)
Initializes the application real root path. |
protected String |
initServername(boolean unqualified)
|
protected String |
initWebappName(String rootPath)
|
protected void |
startServer(javax.servlet.ServletContext context)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String MAGNOLIA_INITIALIZATION_FILE
public static final String MAGNOLIA_UNQUALIFIED_SERVER_NAME
Constructor Detail |
---|
public MgnlServletContextListener()
Method Detail |
---|
public void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed
in interface javax.servlet.ServletContextListener
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
ServletContextListener.contextInitialized(javax.servlet.ServletContextEvent)
protected void startServer(javax.servlet.ServletContext context)
protected String getPropertiesFilesString(javax.servlet.ServletContext context, String servername, String webapp)
protected String initWebappName(String rootPath)
protected String initRootPath(javax.servlet.ServletContext context)
context
- Servlet context.
protected String initServername(boolean unqualified)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |