|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object info.magnolia.init.MagnoliaServletContextListener
@Singleton public class MagnoliaServletContextListener
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 |
DEFAULT_PLATFORM_COMPONENTS_CONFIG_LOCATION
|
static String |
PLATFORM_COMPONENTS_CONFIG_LOCATION_NAME
|
Constructor Summary | |
---|---|
MagnoliaServletContextListener()
|
Method Summary | |
---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
|
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
|
protected ComponentProviderConfiguration |
getPlatformComponents()
|
protected List<String> |
getPlatformComponentsResources()
Returns a list of resources that contain platform components. |
protected ComponentProviderConfiguration |
getSystemComponents()
|
protected String |
initRootPath(javax.servlet.ServletContext context)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths . |
protected String |
initServername(boolean unqualified)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths . |
protected String |
initWebappName(String rootPath)
Deprecated. since 4.5, use or subclass MagnoliaInitPaths . |
protected void |
startServer()
|
protected void |
stopServer()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PLATFORM_COMPONENTS_CONFIG_LOCATION_NAME
public static final String DEFAULT_PLATFORM_COMPONENTS_CONFIG_LOCATION
Constructor Detail |
---|
public MagnoliaServletContextListener()
Method Detail |
---|
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
public void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed
in interface javax.servlet.ServletContextListener
protected ComponentProviderConfiguration getPlatformComponents()
protected List<String> getPlatformComponentsResources()
protected ComponentProviderConfiguration getSystemComponents()
protected void startServer()
protected void stopServer()
protected String initWebappName(String rootPath)
MagnoliaInitPaths
.
protected String initRootPath(javax.servlet.ServletContext context)
MagnoliaInitPaths
.
protected String initServername(boolean unqualified)
MagnoliaInitPaths
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |