in proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java [268:376]
protected void configure(ServletConfig config, ServletContext context)
throws Exception
{
// Set the application root. This defaults to the webapp
// context if not otherwise set.
applicationRoot = findInitParameter(context, config,
TurbineConstants.APPLICATION_ROOT_KEY,
TurbineConstants.APPLICATION_ROOT_DEFAULT);
webappRoot = context.getRealPath("/");
// log.info("Web Application root is " + webappRoot);
// log.info("Application root is " + applicationRoot);
if (applicationRoot == null || applicationRoot.equals(TurbineConstants.WEB_CONTEXT))
{
applicationRoot = webappRoot;
// log.info("got empty or 'webContext' Application root. Application root now: " + applicationRoot);
}
// Set the applicationRoot for this webapp.
setApplicationRoot(applicationRoot);
//
// Now we run the Turbine configuration code. There are two ways
// to configure Turbine:
//
// a) By supplying an web.xml init parameter called "configuration"
//
// <init-param>
// <param-name>configuration</param-name>
// <param-value>/WEB-INF/conf/turbine.xml</param-value>
// </init-param>
//
// This loads an XML based configuration file.
//
// b) By supplying an web.xml init parameter called "properties"
//
// <init-param>
// <param-name>properties</param-name>
// <param-value>/WEB-INF/conf/TurbineResources.properties</param-value>
// </init-param>
//
// This loads a Properties based configuration file. Actually, these are
// extended properties as provided by commons-configuration
//
// If neither a) nor b) is supplied, Turbine will fall back to the
// known behaviour of loading a properties file called
// /WEB-INF/conf/TurbineResources.properties relative to the
// web application root.
Path confPath = configureApplication( config, context );
configureLogging(confPath);
//
// Logging with log4j2 is done via convention, finding in path
setTurbineServletConfig(config);
setTurbineServletContext(context);
getServiceManager().setApplicationRoot(applicationRoot);
// We want to set a few values in the configuration so
// that ${variable} interpolation will work for
//
// ${applicationRoot}
// ${webappRoot}
configuration.setProperty(TurbineConstants.APPLICATION_ROOT_KEY, applicationRoot);
configuration.setProperty(TurbineConstants.WEBAPP_ROOT_KEY, webappRoot);
getServiceManager().setConfiguration(configuration);
// Initialize the service manager. Services
// that have its 'earlyInit' property set to
// a value of 'true' will be started when
// the service manager is initialized.
getServiceManager().init();
// Retrieve the pipeline class and then initialize it. The pipeline
// handles the processing of a webrequest/response cycle.
String descriptorPath =
configuration.getString(
"pipeline.default.descriptor",
TurbinePipeline.CLASSIC_PIPELINE);
if (log.isDebugEnabled())
{
log.debug("Using descriptor path: " + descriptorPath);
}
// context resource path has to begin with slash, cft. context.getResource
if (!descriptorPath.startsWith( "/" ))
{
descriptorPath = "/" + descriptorPath;
}
try (InputStream reader = context.getResourceAsStream(descriptorPath))
{
JAXBContext jaxb = JAXBContext.newInstance(TurbinePipeline.class);
Unmarshaller unmarshaller = jaxb.createUnmarshaller();
pipeline = (Pipeline) unmarshaller.unmarshal(reader);
}
log.debug("Initializing pipeline");
pipeline.initialize();
}