Author: gk
Date: Mon Nov 5 15:18:22 2018
New Revision: 1845811
URL: http://svn.apache.org/viewvc?rev=1845811&view=rev
Log:
- log4j.xml: applicationRoot in memory substitution, respect backslashes in
windows systems
- proposal log4j2
Added:
turbine/core/trunk/proposals/gk/
turbine/core/trunk/proposals/gk/log4j2/
turbine/core/trunk/proposals/gk/log4j2/conf/
turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml (with props)
turbine/core/trunk/proposals/gk/log4j2/conf/test/
turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml (with
props)
turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml (with props)
turbine/core/trunk/proposals/gk/log4j2/pom.xml (with props)
turbine/core/trunk/proposals/gk/log4j2/src/
turbine/core/trunk/proposals/gk/log4j2/src/java/
turbine/core/trunk/proposals/gk/log4j2/src/java/org/
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java
(with props)
Modified:
turbine/core/trunk/src/java/org/apache/turbine/Turbine.java
Added: turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml?rev=1845811&view=auto
==============================================================================
--- turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml (added)
+++ turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml Mon Nov 5 15:18:22
2018
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<Configuration >
+ <Appenders>
+ <Console name="console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </Console>
+ <File name="avalon" fileName="${web:rootDir}/logs/avalon.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ <File name="torque" fileName="${web:rootDir}/logs/torque.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ <File name="turbine" fileName="${web:rootDir}/logs/turbine.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ <File name="velocity" fileName="${web:rootDir}/logs/velocity.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ </Appenders>
+ <Loggers>
+ <Logger name="avalon" level="info" additivity="false">
+ <AppenderRef ref="avalon"/>
+ </Logger>
+ <Logger name="org.apache.torque" level="info" additivity="false">
+ <AppenderRef ref="torque"/>
+ </Logger>
+ <Logger name="scheduler" level="info" additivity="false">
+ <AppenderRef ref="scheduler"/>
+ </Logger>
+ <Logger name="org.apache.turbine" level="info" additivity="false">
+ <AppenderRef ref="turbine"/>
+ <AppenderRef ref="console"/>
+ </Logger>
+ <Root level="info">
+ <AppenderRef ref="turbine"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
Propchange: turbine/core/trunk/proposals/gk/log4j2/conf/log4j2.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml?rev=1845811&view=auto
==============================================================================
--- turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml (added)
+++ turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml Mon Nov 5
15:18:22 2018
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<Configuration >
+ <Appenders>
+ <Console name="console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </Console>
+ <File name="logfile" fileName="target/turbine.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.turbine" level="debug" additivity="false">
+ <AppenderRef ref="logfile"/>
+ </Logger>
+ <Root level="error">
+ <AppenderRef ref="logfile"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
Propchange: turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2-test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml?rev=1845811&view=auto
==============================================================================
--- turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml (added)
+++ turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml Mon Nov 5
15:18:22 2018
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<Configuration >
+ <Appenders>
+ <Console name="console" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </Console>
+ <File name="logfile"
fileName="${applicationRoot}target/turbine.log">
+ <PatternLayout pattern="%d [%t] %-5p %c - %m%n"/>
+ </File>
+ </Appenders>
+ <Loggers>
+ <Logger name="org.apache.turbine" level="debug" additivity="false">
+ <AppenderRef ref="logfile"/>
+ </Logger>
+ <Root level="error">
+ <AppenderRef ref="logfile"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
Propchange: turbine/core/trunk/proposals/gk/log4j2/conf/test/log4j2.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: turbine/core/trunk/proposals/gk/log4j2/pom.xml
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/proposals/gk/log4j2/pom.xml?rev=1845811&view=auto
==============================================================================
--- turbine/core/trunk/proposals/gk/log4j2/pom.xml (added)
+++ turbine/core/trunk/proposals/gk/log4j2/pom.xml Mon Nov 5 15:18:22 2018
@@ -0,0 +1,1186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.turbine</groupId>
+ <artifactId>turbine-parent</artifactId>
+ <version>5</version>
+ </parent>
+ <groupId>org.apache.turbine</groupId>
+ <artifactId>turbine</artifactId>
+ <name>Apache Turbine</name>
+ <version>5.0-SNAPSHOT</version>
+ <description>Turbine is a servlet based framework that allows experienced
Java
+ developers to quickly build secure web applications. Parts of Turbine
+ can also be used independently of the web portion of Turbine as
+ well. In other words, we strive to make portions of Turbine easily
+ available for use in other applications.</description>
+
+ <url>http://turbine.apache.org/${turbine.site.path}</url>
+
+ <inceptionYear>2000</inceptionYear>
+
+ <developers>
+ <developer>
+ <id>brekke</id>
+ <name>Jeff Brekke</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>hoffmann</id>
+ <name>Jürgen Hoffmann</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>daveb</id>
+ <name>Dave Bryson</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>burton</id>
+ <name>Kevin A. Burton</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>dobbs</id>
+ <name>Eric Dobbs</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>seade</id>
+ <name>Scott Eade</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>Backstage Technologies Pty. Ltd.</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <id>fedor</id>
+ <name>Fedor Karpelevitch</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>legassick</id>
+ <name>Sean Legassick</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>jmcnally</id>
+ <name>John McNally</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>CollabNet, Inc.</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <id>quintonm</id>
+ <name>Quinton McCombs</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>NEqualsOne</organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone />
+ </developer>
+ <developer>
+ <id>painter</id>
+ <name>Jeffery Painter</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>mpoeschl</id>
+ <name>Martin Poeschl</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>tucana.at</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <id>epugh</id>
+ <name>Eric Pugh</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </developer>
+ <developer>
+ <id>dlr</id>
+ <name>Daniel Rall</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>CollabNet, Inc.</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <id>henning</id>
+ <name>Henning P. Schmiedehausen</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>INTERMETA - Gesellschaft fuer Mehrwertdienste
mbH</organization>
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone>1</timezone>
+ </developer>
+ <developer>
+ <id>kschrader</id>
+ <name>Kurt Schrader</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>University of Michigan</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <id>jon</id>
+ <name>Jon Scott Stevens</name>
+ <email>[email protected]</email>
+ <url />
+ <organization>CollabNet, Inc.</organization>
+ <timezone />
+ </developer>
+ <developer>
+ <name>Thomas Vandahl</name>
+ <id>tv</id>
+ <email>[email protected]</email>
+ <organization />
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone>1</timezone>
+ </developer>
+ <developer>
+ <name>Ludwig Magnusson</name>
+ <id>ludwig</id>
+ <email>[email protected]</email>
+ <organization />
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone>1</timezone>
+ </developer>
+ <developer>
+ <name>Georg Kallidis</name>
+ <id>gk</id>
+ <email>[email protected]</email>
+ <organization />
+ <roles>
+ <role>Java Developer</role>
+ </roles>
+ <timezone>1</timezone>
+ </developer>
+ </developers>
+ <contributors>
+ <contributor>
+ <name>Gary Bartlett</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Youngho Cho</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Frank Conradie</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Gonzalo A. Diethelm</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>David Duddleston</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Christopher Elkins</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>M. Sean Gilligan</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Jian He</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Humberto Hernandez</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Nissim Karpenstein</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Rafal Krzewski</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Chris Kimpton</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Brian Lawler</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Josh Lucas</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Carl Ludwig</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Jonas Mauras</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Brett McLaughlin</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Leon Messerschmidt</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Chris Meyer</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Steven Nagy</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Kasper Nielsen</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Paul O'Leary</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Giacomo Pati</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Mark Porter</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Jeff Prickett</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Ilkka Priha</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Cameron Riley</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Greg Ritter</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Ingo Schuster</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Costas Stergiou</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>George Stewart</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Ralf Stranzenbach</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Hakan Tandogan</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Scott C. Tavares</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>John Thorhauer</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Magnús Ãór Torfason</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Scott Weaver</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ <contributor>
+ <name>Siegfried Goeschl</name>
+ <email>[email protected]</email>
+ <url />
+ <organization />
+ <timezone />
+ </contributor>
+ </contributors>
+
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/turbine/core/trunk</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/turbine/core/trunk</developerConnection>
+ <url>http://svn.apache.org/viewcvs/turbine/core/trunk/</url>
+ </scm>
+
+ <build>
+ <sourceDirectory>src/java</sourceDirectory>
+ <testSourceDirectory>src/test</testSourceDirectory>
+
+ <resources>
+ <resource>
+ <directory>src/macros</directory>
+ <targetPath>macros</targetPath>
+ <includes>
+ <include>TurbineMacros.vm</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${basedir}/src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <testResources>
+ <testResource>
+ <targetPath />
+ <directory>conf/test</directory>
+ <includes>
+ <include>commons-logging.properties</include>
+ <include>log4j2-test.xml</include><!-- cft. loading path
https://logging.apache.org/log4j/2.x/manual/configuration.html -->
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- run optionally, use not as reporting plugin, as it exposes file
paths to artifacts and
+ check each possible vulnerability carefully, find more info about how
to read, false positives et al. here:
+
https://jeremylong.github.io/DependencyCheck/dependency-check-maven/plugin-info.html
or
+ https://github.com/jeremylong/DependencyCheck
+ CLI mvn phase
+ $>mvn verify -Ddependency.check.skip=false
+ or to invoke goal only:
+ $>mvn org.owasp:dependency-check-maven:check
-Ddependency.check.skip=false
+ -->
+ <plugin>
+ <groupId>org.owasp</groupId>
+ <artifactId>dependency-check-maven</artifactId>
+ <version>3.1.2</version><!-- requires mvn version > 3.3! For older
version try to check v 3.2.1 or 3.1.2 -->
+ <executions>
+ <execution>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>${dependency.check.skip}</skip>
+ <!-- suppress false positive -->
+ <suppressionFiles>
+
<suppressionFile>${project.basedir}/suppression-owasp-fp.xml</suppressionFile>
+ </suppressionFiles>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!--default setting is forkCount=1/reuseForks=true -->
+ <reuseForks>false</reuseForks>
+ <forkCount>1</forkCount>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.torque</groupId>
+ <artifactId>torque-maven-plugin</artifactId>
+ <version>4.0</version>
+ <configuration>
+ <targetDatabase>mysql</targetDatabase>
+ <schemaDir>src/torque/schema</schemaDir>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-om-scheduler-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.om</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+ <sourceIncludes>
+ <include>scheduler-schema.xml</include>
+ </sourceIncludes>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>mysql</torque.database>
+
<torque.om.addGetByNameMethods>false</torque.om.addGetByNameMethods>
+
<torque.om.save.saveException>TorqueException</torque.om.save.saveException>
+
<torque.om.package>org.apache.turbine.services.schedule</torque.om.package>
+
<torque.om.useIsForBooleanGetters>true</torque.om.useIsForBooleanGetters>
+
<torque.runOnlyOnSourceChange>true</torque.runOnlyOnSourceChange>
+ </options>
+ <outputDirMap>
+
<modifiable>${project.build.directory}/generated-sources</modifiable>
+ </outputDirMap>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-mysql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/mysql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>mysql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-hsqldb</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/hsqldb</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>hsqldb</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-derby</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/derby</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>derby</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-oracle</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/oracle</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>oracle</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-postgresql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/postgresql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>postgresql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-sql-mssql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+ <configPackage>org.apache.torque.templates.sql</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/mssql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>mssql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>torque-idtable-mysql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/mysql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>mysql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-idtable-hsqldb</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/hsqldb</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>hsqldb</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-idtable-derby</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/derby</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>derby</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-idtable-oracle</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/oracle</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>oracle</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-idtable-postgresql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/postgresql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>postgresql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ <execution>
+ <id>torque-idtable-mssql</id>
+ <phase>package</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <packaging>classpath</packaging>
+
<configPackage>org.apache.torque.templates.idtable</configPackage>
+ <sourceDir>src/torque/schema</sourceDir>
+
<defaultOutputDir>${project.build.directory}/generated-sql/torque/mssql</defaultOutputDir>
+ <defaultOutputDirUsage>none</defaultOutputDirUsage>
+ <loglevel>error</loglevel>
+ <options>
+ <torque.database>mssql</torque.database>
+ </options>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.torque</groupId>
+ <artifactId>torque-templates</artifactId>
+ <version>4.0</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <configuration>
+ <aggregate>false</aggregate>
+ </configuration>
+ </plugin>
+ <plugin><!-- since 2.7 running the old report requires to register it
explicitely, otherwise the build may fail -->
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>cobertura</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.avalon.framework</groupId>
+ <artifactId>avalon-framework-api</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-configuration2</artifactId>
+ <version>2.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ <version>1.6</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ <dependency>
+ <groupId>ecs</groupId>
+ <artifactId>ecs</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>net.sf.uadetector</groupId>
+ <artifactId>uadetector-resources</artifactId>
+ <version>2014.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-cache</artifactId>
+ <version>1.1.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-factory</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-pool</artifactId>
+ <version>1.0.5-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-localization</artifactId>
+ <version>1.0.7-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-parser</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-intake</artifactId>
+ <version>${fulcrum.intake}</version>
+ </dependency>
+ <!-- yaafi 1.0.7 is in group turbine, 1.0.8 will be in group fulcrum again
(package ) -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-yaafi</artifactId>
+ <version>1.0.8-SNAPSHOT</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-crypto</artifactId>
+ <version>1.0.8-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-xslt</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-mimetype</artifactId>
+ <version>1.0.6-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.torque</groupId>
+ <artifactId>torque-runtime</artifactId>
+ <version>4.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-logkit</groupId>
+ <artifactId>avalon-logkit</artifactId>
+ </exclusion>
+ <exclusion> <!-- exclude this to exclude beanutils v1.8.0 ->
CVE-2014-0114 -->
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency> <!-- include more modern version just for torque-runtime v4.0
-->
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.10</version>
+ </dependency>
+ <!-- using snapshot, until released -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-api</artifactId>
+ <version>${fulcrum.security}</version>
+ </dependency>
+ <!-- using snapshot, until released -->
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-memory</artifactId>
+ <version>${fulcrum.security}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-security-api</artifactId>
+ <version>${fulcrum.security}</version>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-quartz</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <!-- TODO update to stable 2.7.1, because of CVE-2016-5699 -->
+ <groupId>org.python</groupId>
+ <artifactId>jython</artifactId>
+ <version>2.7.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.jabsorb</groupId>
+ <artifactId>jabsorb</artifactId>
+ <version>1.3.2</version>
+ <optional>true</optional>
+ <!-- reqires maven version >= 3, exclude old versions:
org.slf4j:slf4j-jdk14,slf4j-api,(renamed)cl104-over-slf4j,org.mortbay.jetty:jsp-2.1,
commons-httpclient:commons-httpclient,
+ mvn eclipse:eclipse still no wildcard exclude (mvn version 3.3.9)
+ -->
+ <exclusions>
+ <exclusion>
+ <artifactId>jsp-2.1</artifactId>
+ <groupId>org.mortbay.jetty</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jcl104-over-slf4j</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>slf4j-jdk14</artifactId>
+ <groupId>org.slf4j</groupId>
+ </exclusion>
+ <exclusion>
+ <artifactId>*</artifactId>
+ <groupId>*</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <!-- delegate slf4j to log4j -->
+ <!--dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency-->
+ <dependency> <!-- redirect JCL to slf4j -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency><!-- delegate slf4j to log4j2 -->
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-web</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <!-- log3j1 bridge instead of log4j -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-1.2-api</artifactId>
+ <version>2.11.1</version>
+ </dependency>
+ <!--dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency-->
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-core</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>2.2.9</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-testcontainer</artifactId>
+ <version>1.0.8-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>apache-release</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.owasp</groupId>
+ <artifactId>dependency-check-maven</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>turbine-release-site</id>
+ <phase>prepare-package</phase>
+ <goals>
+ <goal>site</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <!-- build the source and binary distribution packages -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>turbine-default-assembly</id>
+ <configuration>
+ <skipAssembly>true</skipAssembly>
+ </configuration>
+ </execution>
+ <execution>
+ <id>turbine-core-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <runOnlyAtExecutionRoot>true</runOnlyAtExecutionRoot>
+ <descriptors>
+ <descriptor>./src/assembly/binaries.xml</descriptor>
+ <descriptor>./src/assembly/source.xml</descriptor>
+ </descriptors>
+ <tarLongFileFormat>gnu</tarLongFileFormat>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <properties>
+ <dependency.check.skip>false</dependency.check.skip>
+ <doclint>none</doclint><!-- since javadoc v.3 this is the reuqired
instead of -Xdoclint:none, remove if turbine parent is correct again using
profile java8 -->
+ </properties>
+ </profile>
+ </profiles>
+
+ <properties>
+ <!-- maven.compiler setting in turbine parent -->
+ <!-- TODO: Change for release -->
+ <turbine.site.path>turbine/turbine-5.0</turbine.site.path>
+ <fulcrum.intake>2.0.0-SNAPSHOT</fulcrum.intake>
+ <fulcrum.security>1.1.3-SNAPSHOT</fulcrum.security>
+ <slf4j.version>1.7.25</slf4j.version>
+ <dependency.check.skip>true</dependency.check.skip>
+ </properties>
+
+</project>
Propchange: turbine/core/trunk/proposals/gk/log4j2/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java
URL:
http://svn.apache.org/viewvc/turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java?rev=1845811&view=auto
==============================================================================
---
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java
(added)
+++
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java
Mon Nov 5 15:18:22 2018
@@ -0,0 +1,1111 @@
+package org.apache.turbine;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.FactoryConfigurationError;
+
+import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
+import
org.apache.commons.configuration2.builder.combined.CombinedConfigurationBuilder;
+import org.apache.commons.configuration2.builder.fluent.Parameters;
+import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.commons.configuration2.io.HomeDirectoryLocationStrategy;
+import org.apache.commons.lang3.NotImplementedException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.text.StringSubstitutor;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.xml.DOMConfigurator;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configurator;
+import org.apache.turbine.modules.PageLoader;
+import org.apache.turbine.pipeline.Pipeline;
+import org.apache.turbine.pipeline.PipelineData;
+import org.apache.turbine.pipeline.TurbinePipeline;
+import org.apache.turbine.services.Initable;
+import org.apache.turbine.services.InitializationException;
+import org.apache.turbine.services.ServiceManager;
+import org.apache.turbine.services.TurbineServices;
+import org.apache.turbine.services.rundata.RunDataService;
+import org.apache.turbine.services.template.TemplateService;
+import org.apache.turbine.util.LocaleUtils;
+import org.apache.turbine.util.RunData;
+import org.apache.turbine.util.ServerData;
+import org.apache.turbine.util.TurbineConfig;
+import org.apache.turbine.util.TurbineException;
+import org.apache.turbine.util.uri.URIConstants;
+//import org.apache.log4j.LogManager;
+//import org.apache.log4j.PropertyConfigurator;
+//import org.apache.log4j.xml.DOMConfigurator;
+
+/**
+ * Turbine is the main servlet for the entire system. If you
+ * need to perform initialization of a service, then you should implement the
+ * Services API and let your code be initialized by it.
+ * <p>
+ * Turbine servlet recognizes the following initialization parameters.
+ * <ul>
+ * <li><code>properties</code> the path to TurbineResources.properties file
+ * used to configure Turbine, relative to the application root.</li>
+ * <li><code>configuration</code> the path to TurbineConfiguration.xml file
+ * used to configure Turbine from various sources, relative
+ * to the application root.</li>
+ * <li><code>applicationRoot</code> this parameter defaults to the web context
+ * of the servlet container. You can use this parameter to specify the
directory
+ * within the server's filesystem, that is the base of your web
application.</li>
+ * </ul>
+ *
+ * @author <a href="mailto:[email protected]">Jon S. Stevens</a>
+ * @author <a href="mailto:[email protected]">Brett McLaughlin</a>
+ * @author <a href="mailto:[email protected]">Greg Ritter</a>
+ * @author <a href="mailto:[email protected]">John D. McNally</a>
+ * @author <a href="mailto:[email protected]">Frank Y. Kim</a>
+ * @author <a href="mailto:[email protected]">Rafal Krzewski</a>
+ * @author <a href="mailto:[email protected]">Jason van Zyl</a>
+ * @author <a href="mailto:[email protected]">Sean Legassick</a>
+ * @author <a href="mailto:[email protected]">Martin Poeschl</a>
+ * @author <a href="mailto:[email protected]">Henning P. Schmiedehausen</a>
+ * @author <a href="mailto:[email protected]">Quinton McCombs</a>
+ * @author <a href="mailto:[email protected]">Eric Pugh</a>
+ * @author <a href="mailto:[email protected]">Peter Courcoux</a>
+ * @author <a href="mailto:[email protected]">Thomas Vandahl</a>
+ * @version $Id: Turbine.java 1845484 2018-11-01 15:15:03Z gk $
+ */
+@WebServlet(
+ name = "Turbine",
+ urlPatterns = {"/app"},
+ loadOnStartup = 1,
+ initParams={ @WebInitParam(name = TurbineConstants.APPLICATION_ROOT_KEY,
+ value = TurbineConstants.APPLICATION_ROOT_DEFAULT),
+ @WebInitParam(name = TurbineConfig.PROPERTIES_PATH_KEY,
+ value = TurbineConfig.PROPERTIES_PATH_DEFAULT) } )
+@MultipartConfig
+public class TurbineLog4J2 extends HttpServlet
+{
+ /** Serial version */
+ private static final long serialVersionUID = -6317118078613623990L;
+
+ /**
+ * Name of path info parameter used to indicate the redirected stage of
+ * a given user's initial Turbine request
+ * @deprecated
+ */
+ @Deprecated // not used
+ public static final String REDIRECTED_PATHINFO_NAME = "redirected";
+
+ /** The base directory key @deprecated
+ * */
+ @Deprecated // not used
+ public static final String BASEDIR_KEY = "basedir";
+
+ /**
+ * In certain situations the init() method is called more than once,
+ * sometimes even concurrently. This causes bad things to happen,
+ * so we use this flag to prevent it.
+ */
+ private static boolean firstInit = true;
+
+ /**
+ * The pipeline to use when processing requests.
+ */
+ private static Pipeline pipeline = null;
+
+ /** Whether init succeeded or not. */
+ private static Throwable initFailure = null;
+
+ /**
+ * Should initialization activities be performed during doGet() execution?
+ */
+ private static boolean firstDoGet = true;
+
+ /**
+ * Keep all the properties of the web server in a convenient data
+ * structure
+ */
+ private static volatile ServerData serverData = null;
+
+ /** The base from which the Turbine application will operate. */
+ private static String applicationRoot;
+
+ /** Servlet config for this Turbine webapp. */
+ private static ServletConfig servletConfig;
+
+ /** Servlet context for this Turbine webapp. */
+ private static ServletContext servletContext;
+
+ /**
+ * The webapp root where the Turbine application
+ * is running in the servlet container.
+ * This might differ from the application root.
+ */
+ private static String webappRoot;
+
+ /** Our internal configuration object */
+ private static Configuration configuration = null;
+
+ /** Which configuration method is being used */
+ private enum ConfigurationStyle
+ {
+ XML,
+ PROPERTIES,
+ JSON,
+ YAML,
+ UNSET
+ }
+
+ /** Logging class from commons.logging */
+ private static Log log = LogFactory.getLog(TurbineLog4J2.class);
+
+ /**
+ *
+ */
+ public static Logger log4j2Logger = LogManager.getLogger();
+
+ /**
+ * This init method will load the default resources from a
+ * properties file.
+ *
+ * This method is called by init(ServletConfig config)
+ *
+ * @throws ServletException a servlet exception.
+ */
+ @Override
+ public void init() throws ServletException
+ {
+ synchronized (TurbineLog4J2.class)
+ {
+ super.init();
+
+ if (!firstInit)
+ {
+ log.info("Double initialization of Turbine was attempted!");
+ return;
+ }
+ // executing init will trigger some static initializers, so we have
+ // only one chance.
+ firstInit = false;
+ ServletConfig config = getServletConfig();
+
+ try
+ {
+ ServletContext context = config.getServletContext();
+
+ configure(config, context);
+
+ TemplateService templateService =
+
(TemplateService)getServiceManager().getService(TemplateService.SERVICE_NAME);
+ if (templateService == null)
+ {
+ throw new TurbineException("No Template Service
configured!");
+ }
+
+ if (getRunDataService() == null)
+ {
+ throw new TurbineException("No RunData Service
configured!");
+ }
+ }
+ catch (Throwable e)
+ {
+ // save the exception to complain loudly later :-)
+ initFailure = e;
+ log.fatal("Turbine: init() failed: ", e);
+ throw new ServletException("Turbine: init() failed", e);
+ }
+
+ log.info("Turbine: init() Ready to Rumble!");
+ }
+ }
+
+ /**
+ * Read the master configuration file in, configure logging
+ * and start up any early services.
+ *
+ * @param config The Servlet Configuration supplied by the container
+ * @param context The Servlet Context supplied by the container
+ *
+ * @throws Exception A problem occurred while reading the configuration or
performing early startup
+ */
+
+ 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 targetPath = configureFromConfiguration( config, context );
+
+ //
+ // Set up logging as soon as possible
+ //
+ configureLogging(targetPath);
+
+ // Now report our successful configuration to the world
+ log.info("Loaded configuration: " + configuration.toString());
+
+ 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();
+ }
+
+ private Path configureFromConfiguration( ServletConfig config,
ServletContext context )
+ throws IOException, ConfigurationException
+ {
+ ConfigurationStyle confStyle = ConfigurationStyle.UNSET;
+ // first test
+ String confFile= findInitParameter(context, config,
+ TurbineConfig.CONFIGURATION_PATH_KEY,
+ null);
+ if (StringUtils.isNotEmpty(confFile))
+ {
+ confStyle = ConfigurationStyle.XML;
+ }
+ else // second test
+ {
+ confFile = findInitParameter(context, config,
+ TurbineConfig.PROPERTIES_PATH_KEY,
+ null);
+ if (StringUtils.isNotEmpty((confFile)) )
+ {
+ confStyle = ConfigurationStyle.PROPERTIES;
+ }
+ }
+ // more tests ..
+ // last test
+ if (confStyle == ConfigurationStyle.UNSET)
+ { // last resort
+ confFile = findInitParameter(context, config,
+ TurbineConfig.PROPERTIES_PATH_KEY,
+ TurbineConfig.PROPERTIES_PATH_DEFAULT);
+ confStyle = ConfigurationStyle.PROPERTIES;
+ }
+
+ // now begin loading
+ Parameters params = new Parameters();
+ File confPath = getApplicationRootAsFile(); //.getCanonicalPath();
+
+ if (confFile.startsWith( "/" ))
+ {
+ confFile = confFile.substring( 1 ); // cft. RFC2396 should not
start with a slash, if not absolute path
+ }
+
+ Path confFileRelativePath = Paths.get( confFile );// relative to
later join
+ Path targetPath = Paths.get( confPath.toURI() );
+ targetPath = targetPath.resolve( confFileRelativePath );
+
+ // Get the target path directory
+ Path targetPathDirectory = targetPath.getParent();
+ if ( targetPathDirectory != null )
+ {
+ // set the configuration path
+ confPath = targetPathDirectory.normalize().toFile();
+
+ Path targetFilePath = targetPath.getFileName();
+ if ( targetFilePath != null )
+ {
+ // set the configuration file name
+ confFile = targetFilePath.toString();
+ }
+
+ }
+
+ switch (confStyle)
+ {
+ case XML:
+ // relative base path used for this and child configuration
files
+ CombinedConfigurationBuilder combinedBuilder = new
CombinedConfigurationBuilder()
+ .configure(params.fileBased()
+ .setFileName(confFile)
+ .setListDelimiterHandler(new
DefaultListDelimiterHandler(','))
+ .setLocationStrategy(new
HomeDirectoryLocationStrategy(confPath.getCanonicalPath(), false)));
+ configuration = combinedBuilder.getConfiguration();
+ break;
+
+ case PROPERTIES:
+ FileBasedConfigurationBuilder<PropertiesConfiguration>
propertiesBuilder =
+ new FileBasedConfigurationBuilder<>(
+ PropertiesConfiguration.class)
+ .configure(params.properties()
+ .setFileName(confFile)
+ .setListDelimiterHandler(new
DefaultListDelimiterHandler(','))
+ .setLocationStrategy(new
HomeDirectoryLocationStrategy(confPath.getCanonicalPath(), false)));
+ configuration = propertiesBuilder.getConfiguration();
+ break;
+ case JSON: case YAML:
+ throw new NotImplementedException("JSON or XAML configuration
style not yet implemented!");
+
+ default:
+ break;
+ }
+ if (log4j2Logger != null) {
+ // Now report our successful configuration to the world
+ log4j2Logger.info("Loaded configuration (" + confStyle + ") from "
+ confFile + " style: " + configuration.toString());
+ }
+ return targetPath;
+ }
+
+ /**
+ * Configure the logging facilities of Turbine
+ * @param targetPath
+ *
+ * @throws IOException if the configuration file handling fails.
+ */
+ protected void configureLogging(Path targetPath) throws IOException
+ {
+
+ Boolean useLog4j2 = configuration.getBoolean( "use.log4j2", false);
+
+ if (useLog4j2) {
+ // Log4j" has a default configuration, as a result log4j2Logger
will always be set
+ log4j2Logger.info("Configured log4j2");
+ } else {
+ configureLog4j1x( targetPath );
+ }
+ }
+
+ private void configureLog4j1x( Path targetPath )
+ throws IOException
+ {
+ boolean success = false;
+
+
+ String log4jFile =
configuration.getString(TurbineConstants.LOG4J_CONFIG_FILE,
+
TurbineConstants.LOG4J_CONFIG_FILE_DEFAULT);
+
+ if (log4jFile.startsWith( "/" ))
+ {
+ log4jFile = log4jFile.substring( 1 );
+ }
+ // log4j must either share path with configuration path or resolved
relatively
+ Path log4jTarget = null;
+ Path logConfPath = targetPath.getParent();
+ if ( logConfPath != null )
+ {
+ Path logFilePath = logConfPath.resolve( log4jFile );
+ if ( logFilePath != null )
+ {
+ log4jTarget = logFilePath.normalize();
+ }
+ }
+
+ if (StringUtils.isNotEmpty(log4jFile) &&
+ !log4jFile.equalsIgnoreCase("none") && log4jTarget != null &&
log4jTarget.toFile().exists() )
+ {
+ log4jFile = log4jTarget.toFile().getAbsolutePath();
+ Configurator.initialize("log4j1x_config", null,
log4jTarget.toFile().toURI());
+
+ LoggerContext context = (LoggerContext)
LogManager.getContext(false);
+ org.apache.logging.log4j.core.config.Configuration log4jconf =
context.getConfiguration();
+ String appRoot =
log4jconf.getStrSubstitutor().getVariableResolver().lookup("applicationRoot");
+ log4jconf.getStrSubstitutor().replace( appRoot );
+
+
+ if (log4jFile.endsWith(".xml"))
+ {
+ // load XML type configuration
+ // NOTE: Only system property expansion available
+ try
+ {
+ // NOTE: expand application root explicitely
+ Map<String,String> valMap = new HashMap<>();
+ valMap.put(TurbineConstants.APPLICATION_ROOT_KEY,
getApplicationRoot().replace( '\\', '/' ));
+ StringSubstitutor sub = new StringSubstitutor(valMap);
+ String log4jTemplate = new
String(Files.readAllBytes(Paths.get(log4jFile)));
+ String resolvedString = sub.replace(log4jTemplate);
+
+ // just always use slashes
+ String winFS = "\\";
+ if (FileSystems.getDefault().getSeparator().equals( winFS )
+ && resolvedString.contains( winFS )) {
+ System.out.println(
FileSystems.getDefault().getClass().getName() + " with fsep ('"+
FileSystems.getDefault().getSeparator() + "') found in " + log4jFile + ",
changing to forward slash ('/')." );
+ resolvedString = resolvedString.replace( '\\', '/' );
+ }
+ Reader memoryConfiguration = new
StringReader(resolvedString);
+ DOMConfigurator log4jDOMConf = new DOMConfigurator();
+ log4jDOMConf.doConfigure(memoryConfiguration,
org.apache.log4j.LogManager.getLoggerRepository());
+
+ success = true;
+ }
+ catch (FactoryConfigurationError e)
+ {
+ System.err.println("Could not configure Log4J from
configuration file "
+ + log4jFile + ": ");
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ //
+ // Load the config file above into a Properties object and
+ // fix up the Application root
+ //
+ Properties p = new Properties();
+
+ try (FileInputStream fis = new FileInputStream(log4jFile))
+ {
+ p.load(fis);
+ p.setProperty(TurbineConstants.APPLICATION_ROOT_KEY,
getApplicationRoot());
+ PropertyConfigurator.configure(p);
+ success = true;
+ }
+ catch (FileNotFoundException fnf)
+ {
+ System.err.println("Could not open Log4J configuration
file "
+ + log4jFile + ": ");
+ fnf.printStackTrace();
+ }
+ }
+ }
+ if (success)
+ {
+ // Rebuild our log object with a configured commons-logging
+ log = LogFactory.getLog(this.getClass());
+ log.info("Configured log4j from " + log4jFile);
+ }
+ }
+
+ /**
+ * Finds the specified servlet configuration/initialization
+ * parameter, looking first for a servlet-specific parameter, then
+ * for a global parameter, and using the provided default if not
+ * found.
+ */
+ protected String findInitParameter(ServletContext context,
+ ServletConfig config, String name, String defaultValue)
+ {
+ String path = null;
+
+ // Try the name as provided first.
+ boolean usingNamespace =
name.startsWith(TurbineConstants.CONFIG_NAMESPACE);
+ while (true)
+ {
+ path = config.getInitParameter(name);
+ if (StringUtils.isEmpty(path))
+ {
+ path = context.getInitParameter(name);
+ if (StringUtils.isEmpty(path))
+ {
+ // The named parameter didn't yield a value.
+ if (usingNamespace)
+ {
+ path = defaultValue;
+ }
+ else
+ {
+ // Try again using Turbine's namespace.
+ name = TurbineConstants.CONFIG_NAMESPACE + '.' + name;
+ usingNamespace = true;
+ continue;
+ }
+ }
+ }
+ break;
+ }
+
+ return path;
+ }
+
+ /**
+ * Initializes the services which need <code>PipelineData</code> to
+ * initialize themselves (post startup).
+ *
+ * @param data The first <code>GET</code> request.
+ */
+ public void init(PipelineData data)
+ {
+ synchronized (TurbineLog4J2.class)
+ {
+ if (firstDoGet)
+ {
+ // All we want to do here is save some servlet
+ // information so that services and processes
+ // that don't have direct access to a RunData
+ // object can still know something about
+ // the servlet environment.
+ saveServletInfo(data);
+
+ // Initialize services with the PipelineData instance
+ TurbineServices services =
(TurbineServices)getServiceManager();
+
+ for (Iterator<String> i = services.getServiceNames();
i.hasNext();)
+ {
+ String serviceName = i.next();
+ Object service = services.getService(serviceName);
+
+ if (service instanceof Initable)
+ {
+ try
+ {
+
((Initable)service).init(data);
+ }
+ catch (InitializationException e)
+ {
+ log.warn("Could not initialize Initable
" + serviceName + " with PipelineData", e);
+ }
+ }
+ }
+
+ // Mark that we're done.
+ firstDoGet = false;
+ log.info("Turbine: first Request successful");
+ }
+ }
+ }
+
+ /**
+ * Return the current configuration with all keys included
+ *
+ * @return a Configuration Object
+ */
+ public static Configuration getConfiguration()
+ {
+ return configuration;
+ }
+
+ /**
+ * Return the server name.
+ *
+ * @return String server name
+ */
+ public static String getServerName()
+ {
+ return getDefaultServerData().getServerName();
+ }
+
+ /**
+ * Return the server scheme.
+ *
+ * @return String server scheme
+ */
+ public static String getServerScheme()
+ {
+ return getDefaultServerData().getServerScheme();
+ }
+
+ /**
+ * Return the server port.
+ *
+ * @return String server port
+ */
+ public static String getServerPort()
+ {
+ return Integer.toString(getDefaultServerData().getServerPort());
+ }
+
+ /**
+ * Get the script name. This is the initial script name.
+ * Actually this is probably not needed any more. I'll
+ * check. jvz.
+ *
+ * @return String initial script name.
+ */
+ public static String getScriptName()
+ {
+ return getDefaultServerData().getScriptName();
+ }
+
+ /**
+ * Return the context path.
+ *
+ * @return String context path
+ */
+ public static String getContextPath()
+ {
+ return getDefaultServerData().getContextPath();
+ }
+
+ /**
+ * Return all the Turbine Servlet information (Server Name, Port,
+ * Scheme in a ServerData structure. This is generated from the
+ * values set when initializing the Turbine and may not be correct
+ * if you're running in a clustered structure. You can provide default
+ * values in your configuration for cases where access is requied before
+ * your application is first accessed by a user. This might be used
+ * if you need a DataURI and have no RunData object handy.
+ *
+ * @return An initialized ServerData object
+ */
+ public static ServerData getDefaultServerData()
+ {
+ if (serverData == null)
+ {
+ String serverName
+ =
configuration.getString(TurbineConstants.DEFAULT_SERVER_NAME_KEY);
+ if (serverName == null)
+ {
+ log.error("ServerData Information requested from Turbine
before first request!");
+ }
+ else
+ {
+ log.info("ServerData Information retrieved from
configuration.");
+ }
+ // Will be overwritten once the first request is run;
+ serverData = new ServerData(serverName,
+
configuration.getInt(TurbineConstants.DEFAULT_SERVER_PORT_KEY,
+ URIConstants.HTTP_PORT),
+
configuration.getString(TurbineConstants.DEFAULT_SERVER_SCHEME_KEY,
+ URIConstants.HTTP),
+
configuration.getString(TurbineConstants.DEFAULT_SCRIPT_NAME_KEY),
+
configuration.getString(TurbineConstants.DEFAULT_CONTEXT_PATH_KEY));
+ }
+ return serverData;
+ }
+
+ /**
+ * Set the servlet config for this turbine webapp.
+ *
+ * @param config New servlet config
+ */
+ public static void setTurbineServletConfig(ServletConfig config)
+ {
+ servletConfig = config;
+ }
+
+ /**
+ * Get the servlet config for this turbine webapp.
+ *
+ * @return ServletConfig
+ */
+ public static ServletConfig getTurbineServletConfig()
+ {
+ return servletConfig;
+ }
+
+ /**
+ * Set the servlet context for this turbine webapp.
+ *
+ * @param context New servlet context.
+ */
+ public static void setTurbineServletContext(ServletContext context)
+ {
+ servletContext = context;
+ }
+
+ /**
+ * Get the servlet context for this turbine webapp.
+ *
+ * @return ServletContext
+ */
+ public static ServletContext getTurbineServletContext()
+ {
+ return servletContext;
+ }
+
+ /**
+ * The <code>Servlet</code> destroy method. Invokes
+ * <code>ServiceBroker</code> tear down method.
+ */
+ @Override
+ public void destroy()
+ {
+ // Shut down all Turbine Services.
+ getServiceManager().shutdownServices();
+
+ firstInit = true;
+ firstDoGet = true;
+ log.info("Turbine: Done shutting down!");
+ }
+
+ /**
+ * The primary method invoked when the Turbine servlet is executed.
+ *
+ * @param req Servlet request.
+ * @param res Servlet response.
+ * @throws IOException a servlet exception.
+ * @throws ServletException a servlet exception.
+ */
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException
+ {
+ // Check to make sure that we started up properly.
+ if (initFailure != null)
+ {
+ handleHorribleException(res, initFailure);
+ return;
+ }
+
+ // Get general PipelineData here...
+ try (PipelineData pipelineData = getRunDataService().getRunData(req,
res, getServletConfig()))
+ {
+ try
+ {
+ // Perform turbine specific initialization below.
+ Map<Class<?>, Object> runDataMap = new HashMap<Class<?>,
Object>();
+ runDataMap.put(RunData.class, pipelineData);
+ // put the data into the pipeline
+ pipelineData.put(RunData.class, runDataMap);
+
+ // If this is the first invocation, perform some
+ // initialization. Certain services need RunData to initialize
+ // themselves.
+ if (firstDoGet)
+ {
+ init(pipelineData);
+ }
+
+ // Stages of Pipeline implementation execution
+ // configurable via attached Valve implementations in a
+ // XML properties file.
+ pipeline.invoke(pipelineData);
+ }
+ catch (Throwable t)
+ {
+ handleException(pipelineData, res, t);
+ }
+ }
+ catch (Throwable t)
+ {
+ handleHorribleException(res, t);
+ }
+ }
+
+ /**
+ * In this application doGet and doPost are the same thing.
+ *
+ * @param req Servlet request.
+ * @param res Servlet response.
+ * @throws IOException a servlet exception.
+ * @throws ServletException a servlet exception.
+ */
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse res)
+ throws IOException, ServletException
+ {
+ doGet(req, res);
+ }
+
+ /**
+ * Return the servlet info.
+ *
+ * @return a string with the servlet information.
+ */
+ @Override
+ public String getServletInfo()
+ {
+ return "Turbine Servlet";
+ }
+
+ /**
+ * This method is about making sure that we catch and display
+ * errors to the screen in one fashion or another. What happens is
+ * that it will attempt to show the error using your user defined
+ * Error Screen. If that fails, then it will resort to just
+ * displaying the error and logging it all over the place
+ * including the servlet engine log file, the Turbine log file and
+ * on the screen.
+ *
+ * @param pipelineData A Turbine PipelineData object.
+ * @param res Servlet response.
+ * @param t The exception to report.
+ */
+ protected void handleException(PipelineData pipelineData,
HttpServletResponse res,
+ Throwable t)
+ {
+ RunData data = (RunData) pipelineData;
+ // make sure that the stack trace makes it the log
+ log.error("Turbine.handleException: ", t);
+
+ try
+ {
+ // This is where we capture all exceptions and show the
+ // Error Screen.
+ data.setStackTrace(ExceptionUtils.getStackTrace(t), t);
+
+ // setup the screen
+ data.setScreen(configuration.getString(
+ TurbineConstants.SCREEN_ERROR_KEY,
+ TurbineConstants.SCREEN_ERROR_DEFAULT));
+
+ // do more screen setup for template execution if needed
+ if (data.getTemplateInfo() != null)
+ {
+ data.getTemplateInfo()
+ .setScreenTemplate(configuration.getString(
+ TurbineConstants.TEMPLATE_ERROR_KEY,
+ TurbineConstants.TEMPLATE_ERROR_VM));
+ }
+
+ // Make sure to not execute an action.
+ data.setAction("");
+
+ PageLoader.getInstance().exec(pipelineData,
+ configuration.getString(TurbineConstants.PAGE_DEFAULT_KEY,
+ TurbineConstants.PAGE_DEFAULT_DEFAULT));
+
+ data.getResponse().setContentType(data.getContentType());
+ data.getResponse().setStatus(data.getStatusCode());
+ }
+ // Attempt to do *something* at this point...
+ catch (Throwable reallyScrewedNow)
+ {
+ handleHorribleException(res, reallyScrewedNow);
+ }
+ }
+
+ /**
+ * This method handles exception cases where no PipelineData object exists
+ *
+ * @param res Servlet response.
+ * @param t The exception to report.
+ */
+ protected void handleHorribleException(HttpServletResponse res, Throwable
t)
+ {
+ try
+ {
+ res.setContentType( TurbineConstants.DEFAULT_TEXT_CONTENT_TYPE );
+ res.setStatus(200);
+ PrintWriter writer = res.getWriter();
+ writer.println("Horrible Exception: ");
+ t.printStackTrace(writer);
+ }
+ catch (Exception ignored)
+ {
+ // ignore
+ }
+
+ log.error(t.getMessage(), t);
+ }
+
+ /**
+ * Save some information about this servlet so that
+ * it can be utilized by object instances that do not
+ * have direct access to PipelineData.
+ *
+ * @param data Turbine request data
+ */
+ public static synchronized void saveServletInfo(PipelineData data)
+ {
+ // Store the context path for tools like ContentURI and
+ // the UIManager that use webapp context path information
+ // for constructing URLs.
+
+ //
+ // Bundle all the information above up into a convenient structure
+ //
+ ServerData requestServerData = data.get(TurbineLog4J2.class,
ServerData.class);
+ serverData = (ServerData) requestServerData.clone();
+ }
+
+ /**
+ * Set the application root for the webapp.
+ *
+ * @param val New app root.
+ */
+ public static void setApplicationRoot(String val)
+ {
+ applicationRoot = val;
+ }
+
+ /**
+ * Get the application root for this Turbine webapp.
+ *
+ * @return String applicationRoot
+ */
+ public static String getApplicationRoot()
+ {
+ return applicationRoot;
+ }
+
+ /**
+ * Get the application root for this Turbine webapp as a
+ * file object.
+ *
+ * @return File applicationRootFile
+ */
+ public static File getApplicationRootAsFile()
+ {
+ return new File(applicationRoot);
+ }
+
+ /**
+ * Used to get the real path of configuration and resource
+ * information. This can be used by an app being
+ * developed in a standard CVS layout.
+ *
+ * @param path path translated to the application root
+ * @return the real path
+ */
+ public static String getRealPath(String path)
+ {
+ if (path.startsWith("/"))
+ {
+ return new File(getApplicationRootAsFile(),
path.substring(1)).getAbsolutePath();
+ }
+
+ return new File(getApplicationRootAsFile(), path).getAbsolutePath();
+ }
+
+ /**
+ * Return an instance of the currently configured Service Manager
+ *
+ * @return A service Manager instance
+ */
+ private ServiceManager getServiceManager()
+ {
+ return TurbineServices.getInstance();
+ }
+
+ /**
+ * Returns the default input encoding for the servlet.
+ *
+ * @return the default input encoding.
+ *
+ * @deprecated Use {@link
org.apache.turbine.pipeline.DefaultSetEncodingValve} to set default encoding
+ */
+ @Deprecated
+ public static String getDefaultInputEncoding()
+ {
+ return LocaleUtils.getDefaultInputEncoding();
+ }
+
+ /**
+ * Static Helper method for looking up the RunDataService
+ * @return A RunDataService
+ */
+ private RunDataService getRunDataService()
+ {
+ return (RunDataService)
getServiceManager().getService(RunDataService.SERVICE_NAME);
+ }
+}
Propchange:
turbine/core/trunk/proposals/gk/log4j2/src/java/org/apache/turbine/Turbine.java
------------------------------------------------------------------------------
svn:eol-style = native