You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2005/05/23 12:46:08 UTC
svn commit: r177949 [1/2] - in
/jakarta/commons/proper/logging/branches/simon-1.1: ./ src/ src/conf/
src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/commons/
src/java/org/apache/commons/logging/
src/java/org/apache/commons/logging/impl/ src/media/ src/test/
src/test/org/ src/test/org/apache/ src/test/org/apache/commons/
src/test/org/apache/commons/logging/
src/test/org/apache/commons/logging/jdk14/
src/test/org/apache/commons/logging/log4j/
src/test/org/apache/commons/logging/simple/ target/
Author: skitching
Date: Mon May 23 03:46:05 2005
New Revision: 177949
URL: http://svn.apache.org/viewcvs?rev=177949&view=rev
Log:
Experimental static binding implementation of JCL
Added:
jakarta/commons/proper/logging/branches/simon-1.1/
jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt (with props)
jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt (with props)
jakarta/commons/proper/logging/branches/simon-1.1/build.xml
jakarta/commons/proper/logging/branches/simon-1.1/maven.xml
jakarta/commons/proper/logging/branches/simon-1.1/src/
jakarta/commons/proper/logging/branches/simon-1.1/src/conf/
jakarta/commons/proper/logging/branches/simon-1.1/src/conf/MANIFEST.MF
jakarta/commons/proper/logging/branches/simon-1.1/src/java/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/LogFactory.java.template
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpLogger.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleFactory.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/SimpleLogger.java (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/package.html
jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/package.html
jakarta/commons/proper/logging/branches/simon-1.1/src/java/overview.html
jakarta/commons/proper/logging/branches/simon-1.1/src/media/
jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.png (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/media/logo.xcf (with props)
jakarta/commons/proper/logging/branches/simon-1.1/src/test/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/commons/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/commons/logging/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/commons/logging/jdk14/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/commons/logging/log4j/
jakarta/commons/proper/logging/branches/simon-1.1/src/test/org/apache/commons/logging/simple/
jakarta/commons/proper/logging/branches/simon-1.1/target/
Added: jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt Mon May 23 03:46:05 2005
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt Mon May 23 03:46:05 2005
@@ -0,0 +1,3 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: jakarta/commons/proper/logging/branches/simon-1.1/build.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/build.xml?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/build.xml (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/build.xml Mon May 23 03:46:05 2005
@@ -0,0 +1,429 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed 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 name="Logging" default="compile-simple" basedir=".">
+
+
+<!--
+ "Logging" component of the Jakarta Commons Subproject
+ $Id: build.xml 155426 2005-02-26 13:10:49Z dirkv $
+-->
+
+
+<!-- ========== Initialize Properties ===================================== -->
+
+
+ <property file="build.properties"/> <!-- Component local -->
+ <property file="../build.properties"/> <!-- Commons local -->
+ <property file="${user.home}/build.properties"/> <!-- User local -->
+
+
+<!-- ========== External Dependencies ===================================== -->
+
+
+ <!-- The directories corresponding to your necessary dependencies -->
+ <property name="junit.home" value="/usr/local/junit3.5"/>
+ <property name="jakarta.home" value="../.."/>
+
+
+<!-- ========== Derived Values ============================================ -->
+
+
+ <!-- The locations of necessary jar files -->
+ <property name="junit.jar" value="${junit.home}/junit.jar"/>
+ <property name="log4j.jar" value="${jakarta.home}/jakarta-log4j/dist/lib/log4j.jar"/>
+
+
+<!-- ========== Component Declarations ==================================== -->
+
+
+ <!-- The name of this component -->
+ <property name="component.name" value="logging"/>
+
+ <!-- The primary package name of this component -->
+ <property name="component.package" value="org.apache.commons.logging"/>
+
+ <!-- The title of this component -->
+ <property name="component.title" value="Logging Wrapper Library"/>
+
+ <!-- The current version number of this component -->
+ <property name="component.version" value="1.2-dev"/>
+
+ <!-- The base directory for compilation targets -->
+ <property name="build.home" value="${basedir}/target"/>
+
+ <!-- The base directory for component configuration files -->
+ <property name="conf.home" value="src/conf"/>
+
+ <!-- The base directory for distribution targets -->
+ <property name="dist.home" value="dist"/>
+
+ <!-- The base directory for component sources -->
+ <property name="source.home" value="src/java"/>
+
+ <!-- The base directory for unit test sources -->
+ <property name="test.home" value="src/test"/>
+
+
+ <!-- Optional build -->
+ <property name="optional.home" value="optional"/>
+ <property name="optional.dist.home" value="${optional.home}/dist"/>
+
+
+<!-- ========== Compiler Defaults ========================================= -->
+
+
+ <!-- Should Java compilations set the 'debug' compiler option? -->
+ <property name="compile.debug" value="true"/>
+
+ <!-- Should Java compilations set the 'deprecation' compiler option? -->
+ <property name="compile.deprecation" value="false"/>
+
+ <!-- Should Java compilations set the 'optimize' compiler option? -->
+ <property name="compile.optimize" value="false"/>
+
+ <!-- Construct compile classpath -->
+ <path id="compile.classpath">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${junit.jar}"/>
+ <pathelement location="${log4j.jar}"/>
+ </path>
+
+
+<!-- ========== Test Execution Defaults =================================== -->
+
+
+ <!-- Construct unit test classpath (generic tests) -->
+ <path id="test.classpath">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${build.home}/tests"/>
+ <pathelement location="${junit.jar}"/>
+ <pathelement location="${log4j.jar}"/>
+ <pathelement location="${conf.home}"/>
+ </path>
+
+ <!-- Construct unit test classpath (JDK 1.4 tests) -->
+ <path id="test.classpath.jdk14">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${build.home}/tests"/>
+ <pathelement location="${junit.jar}"/>
+ </path>
+
+ <!-- Construct unit test classpath (Log4J tests) -->
+ <path id="test.classpath.log4j">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${build.home}/tests"/>
+ <pathelement location="${junit.jar}"/>
+ <pathelement location="${log4j.jar}"/>
+ </path>
+
+ <!-- Construct unit test classpath (Log4J tests) -->
+ <path id="test.classpath.log4j12">
+ <pathelement location="${build.home}/classes"/>
+ <pathelement location="${build.home}/tests"/>
+ <pathelement location="${junit.jar}"/>
+ <pathelement location="${log4j12.jar}"/>
+ </path>
+
+ <!-- Construct unit test classpath (Minimal Wrapper) -->
+ <path id="test.classpath.wrap">
+ <pathelement location="${build.home}/commons-logging-wrapper.jar"/>
+ </path>
+
+ <!-- Should all tests fail if one does? -->
+ <property name="test.failonerror" value="true"/>
+
+ <!-- The test runner to execute -->
+ <property name="test.runner" value="junit.textui.TestRunner"/>
+ <property name="test.entry" value="org.apache.commons.logging.TestAll"/>
+ <property name="test.wrapper" value="org.apache.commons.logging.Wrapper"/>
+
+<!-- ========== Executable Targets ======================================== -->
+
+
+ <target name="init"
+ description="Initialize and evaluate conditionals">
+ <echo message="-------- ${component.title} ${component.version} --------"/>
+ <filter token="name" value="${component.name}"/>
+ <filter token="package" value="${component.package}"/>
+ <filter token="version" value="${component.version}"/>
+ </target>
+
+ <target name="prepare" depends="init"
+ description="Prepare build directory">
+
+ <echo>
+ Log4j: ${log4j.jar}
+ </echo>
+
+ <mkdir dir="${build.home}"/>
+ <mkdir dir="${build.home}/classes"/>
+ <mkdir dir="${build.home}/conf"/>
+ <mkdir dir="${build.home}/docs"/>
+ <mkdir dir="${build.home}/docs/api"/>
+ <mkdir dir="${build.home}/tests"/>
+ </target>
+
+
+ <target name="static" depends="prepare"
+ description="Copy static files to build directory">
+ <tstamp/>
+ <copy todir="${build.home}/conf" filtering="on">
+ <fileset dir="${conf.home}" includes="*.MF"/>
+ <fileset dir="${conf.home}" includes="*.properties"/>
+ </copy>
+ </target>
+
+ <target name="compile" depends="static,compile-only"
+ description="Compile shareable components"/>
+
+ <target name='discovery' depends='init'>
+ <available property="jdk.1.4.present"
+ classname="java.util.logging.Logger"/>
+ <available classname="org.apache.log4j.Logger"
+ classpathref="compile.classpath"
+ property="log4j.present"/>
+ </target>
+
+ <target name="log4j-warning" unless='log4j.present' depends='init,discovery'>
+ <echo>
+ *** WARNING ***
+ Log4j not found: Cannot Build Log4jLogger
+ </echo>
+ </target>
+
+ <target name="jdk1.4-warning" unless='jdk.1.4.present' depends='init,discovery'>
+ <echo>
+ *** WARNING ***
+ JDK 1.4 not present: Cannot Build Jdk14Logger
+ </echo>
+ </target>
+
+ <target name="log4j12-warning" unless='log4j12.jar' depends='init,discovery'>
+ <echo>
+ *** WARNING ***
+ Log4J 1.2.x Jar not found: Cannot execute 1.2.x tests
+ </echo>
+ </target>
+
+ <target name='warning' depends='log4j-warning,jdk1.4-warning'/>
+
+
+ <target name="compile-only" depends="init,discovery,warning" >
+
+ <echo message="jdk.1.4.present=${jdk.1.4.present}"/>
+ <echo message="log4j.present=${log4j.present}"/>
+
+ <javac srcdir="${source.home}"
+ destdir="${build.home}/classes"
+ debug="${compile.debug}"
+ deprecation="${compile.deprecation}"
+ optimize="${compile.optimize}">
+ <classpath refid="compile.classpath"/>
+ <exclude name="org/apache/commons/logging/impl/Jdk13LumberjackLogger.java"
+ unless="jdk.1.4.present"/>
+ <exclude name="org/apache/commons/logging/impl/Jdk14Logger.java"
+ unless="jdk.1.4.present"/>
+ <exclude name="org/apache/commons/logging/impl/Log4J*.java"
+ unless="log4j.present"/>
+ <exclude name="org/apache/commons/logging/impl/Log4j*.java"
+ unless="log4j.present"/>
+ </javac>
+ <copy todir="${build.home}/classes" filtering="on">
+ <fileset dir="${source.home}" excludes="**/*.java"/>
+ </copy>
+ <mkdir dir="${build.home}/classes/META-INF"/>
+ <copy file="LICENSE.txt"
+ todir="${build.home}/classes/META-INF"/>
+ <copy file="NOTICE.txt"
+ todir="${build.home}/classes/META-INF"/>
+
+ <jar jarfile="${build.home}/commons-${component.name}.jar"
+ basedir="${build.home}/classes"
+ manifest="${build.home}/conf/MANIFEST.MF">
+ <include name="org/apache/commons/logging/**" />
+ <include name="META-INF/LICENSE.txt"/>
+ <include name="META-INF/NOTICE.txt"/>
+ </jar>
+
+ <jar jarfile="${build.home}/commons-${component.name}-api.jar"
+ basedir="${build.home}/classes"
+ manifest="${build.home}/conf/MANIFEST.MF">
+ <include name="org/apache/commons/logging/*.class" />
+ <include name="org/apache/commons/logging/impl/LogFactoryImpl*.class" />
+ <include name="org/apache/commons/logging/impl/Jdk14*.class" />
+ <include name="org/apache/commons/logging/impl/SimpleLog*.class" />
+ <include name="org/apache/commons/logging/impl/NoOpLog*.class" />
+ <include name="META-INF/LICENSE.txt"/>
+ <include name="META-INF/NOTICE.txt"/>
+ </jar>
+ </target>
+
+ <target name="clean"
+ description="Clean build and distribution directories">
+ <delete dir="${build.home}"/>
+ <delete dir="${dist.home}"/>
+ </target>
+
+
+ <target name="all" depends="clean,compile"
+ description="Clean and compile all components"/>
+
+
+ <target name="javadoc" depends="compile"
+ description="Create component Javadoc documentation">
+ <mkdir dir="${dist.home}"/>
+ <mkdir dir="${dist.home}/docs"/>
+ <mkdir dir="${dist.home}/docs/api"/>
+ <javadoc sourcepath="${source.home}"
+ destdir="${dist.home}/docs/api"
+ overview="${source.home}/overview.html"
+ packagenames="org.apache.commons.*"
+ author="true"
+ private="true"
+ version="true"
+ doctitle="<h1>${component.title} (Version ${component.version})</h1>"
+ windowtitle="${component.title} (Version ${component.version})"
+ bottom='Copyright 2002-2004 The Apache Software Foundation.'>
+ <classpath refid="test.classpath"/>
+ </javadoc>
+ </target>
+
+
+ <target name="dist" depends="compile,javadoc"
+ description="Create binary distribution">
+ <mkdir dir="${dist.home}"/>
+ <copy file="LICENSE.txt"
+ todir="${dist.home}"/>
+ <copy file="NOTICE.txt"
+ todir="${dist.home}"/>
+ <copy file="RELEASE-NOTES.txt"
+ todir="${dist.home}"/>
+ <copy file="${build.home}/commons-${component.name}.jar"
+ tofile="${dist.home}/commons-${component.name}.jar" />
+ <copy file="${build.home}/commons-${component.name}-api.jar"
+ tofile="${dist.home}/commons-${component.name}-api.jar" />
+ <ant antfile='build.xml' target='dist' dir='${optional.home}' inheritAll="false" />
+ <copy todir="${dist.home}">
+ <fileset dir='${optional.dist.home}'>
+ <include name='*.jar'/>
+ </fileset>
+ </copy>
+ <copy todir="${dist.home}/docs-optional">
+ <fileset dir='${optional.dist.home}/docs'/>
+ </copy>
+ <mkdir dir="${dist.home}/src"/>
+ <copy todir="${dist.home}/src" filtering="on">
+ <fileset dir="${source.home}"/>
+ </copy>
+ </target>
+
+ <!-- ============================================================ -->
+
+ <target name="jcl-spi.jar">
+ <delete dir="tmp"/>
+ <mkdir dir="tmp/src"/>
+ <mkdir dir="tmp/bin"/>
+
+ <javac destdir="tmp/bin">
+ <src path="src/java"/>
+ <include name="org/apache/commons/logging/*.java"/>
+ </javac>
+
+ <jar destfile="${build.home}/jcl-spi.jar" basedir="tmp/bin"/>
+ </target>
+
+ <!-- ===================================================================
+ - Generic target that can build NOP, Simple and JDK14 implementations
+ - as specified by the "jar-name" and "impl" parameters.
+ -
+ - A tmp directory is created, and the impl.@IMPL@Logger.java and
+ - impl.@IMPL@Factory.java files are copied over. The
+ - LogFactory.java.template file is also copied over, with necessary
+ - substitutions. Everything is then ready for the compilation.
+ - =================================================================== -->
+ <target name="jcl-IMPL.jar" depends="init">
+ <delete dir="tmp"/>
+ <mkdir dir="tmp/src"/>
+ <mkdir dir="tmp/bin"/>
+
+ <!-- copy the IMPL-specific files tmp/src -->
+ <copy todir="tmp/src">
+ <fileset dir="src/java">
+ <include name="org/apache/commons/logging/impl/${IMPL}Logger.java"/>
+ <include name="org/apache/commons/logging/impl/${IMPL}Factory.java"/>
+ </fileset>
+ </copy>
+
+ <!-- copy a filtered version of LogFactory.java to tmp/src -->
+ <copy todir="tmp/src">
+ <fileset dir="src/java">
+ <include name="org/apache/commons/logging/LogFactory.java.template"/>
+ </fileset>
+ <filterset><filter token="IMPL" value="${IMPL}"/></filterset>
+ </copy>
+ <move
+ file="tmp/src/org/apache/commons/logging/LogFactory.java.template"
+ tofile="tmp/src/org/apache/commons/logging/LogFactory.java"/>
+
+
+ <!-- now compile stuff -->
+ <javac srcdir="tmp/src"
+ destdir="tmp/bin"
+ deprecation="on">
+ <classpath>
+ <pathelement location="target/jcl-spi.jar"/>
+ <pathelement location="${log4j.jar}"/>
+ </classpath>
+ </javac>
+
+ <jar jarfile="${build.home}/jcl-${IMPL}.jar" basedir="tmp/bin"
+ includes="**/*.class">
+ </jar>
+
+ </target>
+
+ <target name="jcl-nop.jar" depends="jcl-spi.jar">
+ <antcall target="jcl-IMPL.jar">
+ <param name="IMPL" value="NoOp"/>
+ </antcall>
+ </target>
+
+
+ <target name="jcl-simple.jar" depends="jcl-spi.jar">
+ <antcall target="jcl-IMPL.jar">
+ <param name="IMPL" value="Simple"/>
+ </antcall>
+ </target>
+
+ <target name="jcl-jdk14.jar" depends="jcl-spi.jar">
+ <antcall target="jcl-IMPL.jar">
+ <param name="IMPL" value="Jdk14"/>
+ </antcall>
+ </target>
+
+ <target name="jcl-log4j12.jar" depends="jcl-spi.jar">
+ <antcall target="jcl-IMPL.jar">
+ <param name="IMPL" value="Log4J12"/>
+ </antcall>
+ </target>
+
+
+ <target name="jcl-all"
+ depends="jcl-spi.jar, jcl-nop.jar, jcl-simple.jar, jcl-jdk14.jar, jcl-log4j12.jar"/>
+</project>
Added: jakarta/commons/proper/logging/branches/simon-1.1/maven.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/maven.xml?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/maven.xml (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/maven.xml Mon May 23 03:46:05 2005
@@ -0,0 +1,39 @@
+<!--
+
+ Copyright 2001-2004 The Apache Software Foundation.
+
+ Licensed 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 default="java:jar"
+ xmlns:j="jelly:core">
+
+ <!-- ================================================================== -->
+ <!-- START : C O M M O N S - B U I L D -->
+ <!-- ================================================================== -->
+ <!-- Required: Look and Feel for documentation within distributions -->
+ <!-- ================================================================== -->
+ <postGoal name="xdoc:copy-resources">
+ <copy todir="${basedir}/target/docs/style/" failonerror="false">
+ <fileset dir="${basedir}/../commons-build/xdocs/style">
+ <include name='**/*'/>
+ <exclude name='**/CVS/**'/>
+ </fileset>
+ </copy>
+ </postGoal>
+ <!-- ================================================================== -->
+ <!-- END: C O M M O N S - B U I L D -->
+ <!-- ================================================================== -->
+
+</project>
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/conf/MANIFEST.MF
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/conf/MANIFEST.MF?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/conf/MANIFEST.MF (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/conf/MANIFEST.MF Mon May 23 03:46:05 2005
@@ -0,0 +1,5 @@
+Extension-Name: org.apache.commons.logging
+Specification-Vendor: Apache Software Foundation
+Specification-Version: 1.0
+Implementation-Vendor: Apache Software Foundation
+Implementation-Version: 1.0.5
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging;
+
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.lang.reflect.Method;
+
+/**
+ * <p>Concrete subclass of {@link Factory} that attempts to load a
+ * concrete Factory implementation via the current context classloader.
+ * </p>
+ * <p>
+ * Unlike other XXXFactory classes, it does not manage a set of loggers;
+ * instead it keeps a map of LogFactory objects keyed by context classloader
+ * and simply forwards calls on to whichever entry matches the current
+ * context classloader. When a new context classloader is seen, it tries
+ * to load the class LogFactory via that classloader rather than via the
+ * classloader that loaded this class.
+ * </p>
+ * <p>
+ * In a J2EE/ServletEngine type environment, deploying this class in a shared
+ * classloader makes it possible for code deployed in the shared classloader
+ * to log via a logging library deployed in the child webapp. In particular,
+ * this means that code in the shared classloader is invoked by code in the
+ * webapp and then logs data, it goes to the same destination as log calls
+ * made by code in the webapp.
+ * </p>
+ * <p>
+ * This class requires java 1.2 or later.
+ * </p>
+ */
+
+public class ContextFactory extends Factory {
+
+ private Factory defaultFactory;
+ private HashMap factories = new HashMap();
+
+ // ----------------------------------------------------------- Constructors
+
+ /**
+ * Constructor.
+ */
+ public ContextFactory(Factory defaultFactory) {
+ super();
+ this.defaultFactory = defaultFactory;
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ public Log getLog(String name) {
+ ClassLoader context = getContextClassLoader();
+
+ // If the context classloader is the same as the classloader for the
+ // default factory, then just use the default factory. This means that
+ // when code in a child binds to a local LogFactory, then we get a
+ // pretty quick path to the real factory even when the global system
+ // property is set.
+ if (context == defaultFactory.getClass().getClassLoader()) {
+ return defaultFactory.getLog(name);
+ }
+
+ // ok, here we really need to fetch a factory out of the map.
+ Factory factory = (Factory) factories.get(context);
+ if (factory == null) {
+ factory = newFactory(context);
+ factories.put(context, factory);
+ }
+
+ return factory.getLog(name);
+ }
+
+ public void release(ClassLoader loader) {
+ Factory factory = (Factory) factories.get(loader);
+ if (factory != null) {
+ factory.release(loader);
+ factories.remove(loader);
+ }
+ }
+
+ public void releaseAll() {
+ for(Iterator i = factories.entrySet().iterator(); i.hasNext(); ) {
+ Map.Entry entry = (Map.Entry) i.next();
+ Factory factory = (Factory) entry.getValue();
+ factory.releaseAll();
+ }
+ factories.clear();
+ }
+
+
+ private static ClassLoader getContextClassLoader() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ private Factory newFactory(ClassLoader cl) {
+ try {
+ Class c = cl.loadClass("org.apache.commons.logging.LogFactory");
+
+ // dynamically invoke the "getFactory" method on it
+ Method method = c.getMethod("getInstance", (Class[]) null);
+ Object o = method.invoke(null, (Object[]) null);
+
+ if (!Factory.class.isAssignableFrom(o.getClass())) {
+ // oops, the child probably has its own copy of the Factory
+ // class. Output a diagnostic and fall back to a local logger.
+ System.out.println("Oops - Factory not assignable from loaded class");
+ throw new Exception("Factory in child.");
+ }
+
+ if (o == this) {
+ System.out.println("Oops - cyclic");
+ // oops, the child didn't have a LogFactory class at all,
+ // or the child has parent-first selected. In either case,
+ // the LogFactory lookup returned the object that owns this
+ // object - so let's just drop back to the default!
+ throw new Exception("No LogFactory in child");
+ }
+
+ // ok, we found a new and workable Factory via the child.
+ return (Factory) o;
+ } catch(Throwable t) {
+ return defaultFactory;
+ }
+ }
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/ContextFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,40 @@
+/*
+ * Created on 23/05/2005
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.commons.logging;
+
+/**
+ * The base class that all logging adapter Factory classes extend.
+ */
+
+public abstract class Factory {
+ public abstract Log getLog(String name);
+ public abstract void release(ClassLoader classLoader);
+ public abstract void releaseAll();
+
+ static {
+ // here, we check whether the parent classloader can also load this
+ // class (ie whether any ancestor can load this class assuming a sane
+ // parent classloader). If this is true, then we emit a warning message
+ // as we are almost certainly running in a container environment and
+ // the user has screwed up the deployment.
+ Class thisClass = Factory.class;
+ ClassLoader cl = thisClass.getClassLoader();
+ System.out.println("Factory-classloader=" + cl);
+ if (cl != null) {
+ cl = cl.getParent();
+ try {
+ System.out.println("Looking in classloader" + cl);
+ Class.forName(thisClass.getName(), false, cl);
+ System.err.println(
+ "DEPLOYMENT ERROR: Multiple copies of the JCL spi classes"
+ + " are in the classpath!");
+ } catch(ClassNotFoundException ex) {
+ // ok, this is fine
+ }
+ }
+ }
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Factory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java Mon May 23 03:46:05 2005
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.commons.logging;
+
+/**
+ * <p>A simple logging interface abstracting logging APIs.</p>
+ *
+ * <p> The six logging levels used by <code>Log</code> are (in order):
+ * <ol>
+ * <li>trace (the least serious)</li>
+ * <li>debug</li>
+ * <li>info</li>
+ * <li>warn</li>
+ * <li>error</li>
+ * <li>fatal (the most serious)</li>
+ * </ol>
+ * The mapping of these log levels to the concepts used by the underlying
+ * logging system is implementation dependent.
+ * The implemention should ensure, though, that this ordering behaves
+ * as expected.</p>
+ *
+ * <p>Performance is often a logging concern.
+ * By examining the appropriate property,
+ * a component can avoid expensive operations (producing information
+ * to be logged).</p>
+ *
+ * <p> For example,
+ * <code><pre>
+ * if (log.isDebugEnabled()) {
+ * ... do something expensive ...
+ * log.debug(theResult);
+ * }
+ * </pre></code>
+ * </p>
+ *
+ * <p>Configuration of the underlying logging system will generally be done
+ * external to the Logging APIs, through whatever mechanism is supported by
+ * that system.</p>
+ */
+
+public interface Log {
+
+
+ // ----------------------------------------------------- Logging Properties
+
+
+ /**
+ * <p> Is trace logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than trace. </p>
+ */
+ public boolean isTraceEnabled();
+
+
+ /**
+ * <p> Is debug logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than debug. </p>
+ */
+ public boolean isDebugEnabled();
+
+
+ /**
+ * <p> Is info logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than info. </p>
+ */
+ public boolean isInfoEnabled();
+
+
+ /**
+ * <p> Is warn logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than warn. </p>
+ */
+ public boolean isWarnEnabled();
+
+
+ /**
+ * <p> Is error logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than error. </p>
+ */
+ public boolean isErrorEnabled();
+
+
+ /**
+ * <p> Is fatal logging currently enabled? </p>
+ *
+ * <p> Call this method to prevent having to perform expensive operations
+ * (for example, <code>String</code> concatenation)
+ * when the log level is more than fatal. </p>
+ */
+ public boolean isFatalEnabled();
+
+
+
+ // -------------------------------------------------------- Logging Methods
+
+
+ /**
+ * <p> Log a message with trace log level. </p>
+ *
+ * @param message log this message
+ */
+ public void trace(Object message);
+
+
+ /**
+ * <p> Log an error with trace log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void trace(Object message, Throwable t);
+
+
+ /**
+ * <p> Log a message with debug log level. </p>
+ *
+ * @param message log this message
+ */
+ public void debug(Object message);
+
+
+ /**
+ * <p> Log an error with debug log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void debug(Object message, Throwable t);
+
+
+ /**
+ * <p> Log a message with info log level. </p>
+ *
+ * @param message log this message
+ */
+ public void info(Object message);
+
+
+ /**
+ * <p> Log an error with info log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void info(Object message, Throwable t);
+
+
+ /**
+ * <p> Log a message with warn log level. </p>
+ *
+ * @param message log this message
+ */
+ public void warn(Object message);
+
+
+ /**
+ * <p> Log an error with warn log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void warn(Object message, Throwable t);
+
+
+ /**
+ * <p> Log a message with error log level. </p>
+ *
+ * @param message log this message
+ */
+ public void error(Object message);
+
+
+ /**
+ * <p> Log an error with error log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void error(Object message, Throwable t);
+
+
+ /**
+ * <p> Log a message with fatal log level. </p>
+ *
+ * @param message log this message
+ */
+ public void fatal(Object message);
+
+
+ /**
+ * <p> Log an error with fatal log level. </p>
+ *
+ * @param message log this message
+ * @param t log this cause
+ */
+ public void fatal(Object message, Throwable t);
+
+
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/Log.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/LogFactory.java.template
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/LogFactory.java.template?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/LogFactory.java.template (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/LogFactory.java.template Mon May 23 03:46:05 2005
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+import org.apache.commons.logging.ContextFactory;
+
+
+/**
+ * This is the class that users of JCL interact with, in order to retrieve
+ * Log objects.
+ * <p>
+ * This class has only static methods, and simply delegates to a specific
+ * concrete Factory class which is set at compile-time. In order to bind to
+ * a particular logging library, the user will deploy the variant of this
+ * class which binds to the Factory class for that logging library.
+ * </p>
+ */
+
+public final class LogFactory {
+ private static Factory factory;
+
+ static {
+ /**
+ * The actual class used here is modified during compilation.
+ */
+ factory = new org.apache.commons.logging.impl.@IMPL@Factory();
+
+ String context = System.getProperty("org.apache.commons.logging.context");
+ if (Boolean.parseBoolean(context)) {
+ // presumably this class is being used within a container, and
+ // has been deployed via a shared classloader
+ factory = new ContextFactory(factory);
+ }
+ }
+
+ // --------------------------------------------------------- Static Methods
+
+ public static Factory getInstance() {
+ return factory;
+ }
+
+ /**
+ * Convenience method to return a named logger, without the application
+ * having to care about factories.
+ *
+ * @param clazz Class from which a log name will be derived
+ */
+ public static Log getLog(Class clazz) {
+ return factory.getLog(clazz.getName());
+ }
+
+
+ /**
+ * Convenience method to return a named logger, without the application
+ * having to care about factories.
+ *
+ * @param name Logical name of the <code>Log</code> instance to be
+ * returned (the meaning of this name is only known to the underlying
+ * logging implementation that is being wrapped)
+ */
+ public static Log getLog(String name) {
+ return factory.getLog(name);
+ }
+
+
+ /**
+ * Release any internal references to previously created {@link LogFactory}
+ * instances that have been associated with the specified class loader.
+ *
+ * @param classLoader ClassLoader for which to release the LogFactory
+ */
+ public static void release(ClassLoader classLoader) {
+ factory.release(classLoader);
+ }
+
+
+ /**
+ * Release any internal references to previously created {@link LogFactory}
+ * instances. This is useful in environments like servlet containers,
+ * which implement application reloading by throwing away a ClassLoader.
+ * Dangling references to objects in that class loader would prevent
+ * garbage collection.
+ */
+ public static void releaseAll() {
+ factory.releaseAll();
+ }
+}
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging.impl;
+
+
+import java.util.Hashtable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+
+/**
+ * Concrete subclass of {@link Factory} specific to java.util.logging.
+ */
+public final class Jdk14Factory extends Factory {
+
+ public Jdk14Factory() {
+ super();
+ }
+
+ // Previously returned instances, to avoid creation of proxies
+ private Hashtable instances = new Hashtable();
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Return a logger associated with the specified category name.
+ */
+ public Log getLog(String name) {
+ Log instance = (Log) instances.get(name);
+ if (instance != null)
+ return instance;
+
+ instance = new Jdk14Logger(name);
+ instances.put(name, instance);
+ return instance;
+ }
+
+
+ /**
+ * Release any internal references to previously created {@link Log}
+ * instances returned by this factory. This is useful in environments
+ * like servlet containers, which implement application reloading by
+ * throwing away a ClassLoader. Dangling references to objects in that
+ * class loader would prevent garbage collection.
+ */
+ public void release(ClassLoader cl) {
+ instances.clear();
+ }
+
+ public void releaseAll() {
+ instances.clear();
+ }
+}
\ No newline at end of file
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Factory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java Mon May 23 03:46:05 2005
@@ -0,0 +1,254 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.commons.logging.impl;
+
+
+import java.io.Serializable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.commons.logging.Log;
+
+
+/**
+ * <p>Implementation of the <code>org.apache.commons.logging.Log</code>
+ * interface that wraps the standard JDK logging mechanisms that were
+ * introduced in the Merlin release (JDK 1.4).</p>
+ *
+ * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
+ * @version $Revision: 155426 $ $Date: 2005-02-27 02:10:49 +1300 (Sun, 27 Feb 2005) $
+ */
+
+public class Jdk14Logger implements Log, Serializable {
+
+
+ // ----------------------------------------------------------- Constructors
+
+
+ /**
+ * Construct a named instance of this Logger.
+ *
+ * @param name Name of the logger to be constructed
+ */
+ public Jdk14Logger(String name) {
+
+ this.name = name;
+ logger = getLogger();
+
+ }
+
+
+ // ----------------------------------------------------- Instance Variables
+
+
+ /**
+ * The underlying Logger implementation we are using.
+ */
+ protected transient Logger logger = null;
+
+
+ /**
+ * The name of the logger we are wrapping.
+ */
+ protected String name = null;
+
+
+ // --------------------------------------------------------- Public Methods
+
+ private void log( Level level, String msg, Throwable ex ) {
+
+ Logger logger = getLogger();
+ if (logger.isLoggable(level)) {
+ // Hack (?) to get the stack trace.
+ Throwable dummyException=new Throwable();
+ StackTraceElement locations[]=dummyException.getStackTrace();
+ // Caller will be the third element
+ String cname="unknown";
+ String method="unknown";
+ if( locations!=null && locations.length >2 ) {
+ StackTraceElement caller=locations[2];
+ cname=caller.getClassName();
+ method=caller.getMethodName();
+ }
+ if( ex==null ) {
+ logger.logp( level, cname, method, msg );
+ } else {
+ logger.logp( level, cname, method, msg, ex );
+ }
+ }
+
+ }
+
+ /**
+ * Log a message with debug log level.
+ */
+ public void debug(Object message) {
+ log(Level.FINE, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with debug log level.
+ */
+ public void debug(Object message, Throwable exception) {
+ log(Level.FINE, String.valueOf(message), exception);
+ }
+
+
+ /**
+ * Log a message with error log level.
+ */
+ public void error(Object message) {
+ log(Level.SEVERE, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with error log level.
+ */
+ public void error(Object message, Throwable exception) {
+ log(Level.SEVERE, String.valueOf(message), exception);
+ }
+
+
+ /**
+ * Log a message with fatal log level.
+ */
+ public void fatal(Object message) {
+ log(Level.SEVERE, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with fatal log level.
+ */
+ public void fatal(Object message, Throwable exception) {
+ log(Level.SEVERE, String.valueOf(message), exception);
+ }
+
+
+ /**
+ * Return the native Logger instance we are using.
+ */
+ public Logger getLogger() {
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ }
+ return (logger);
+ }
+
+
+ /**
+ * Log a message with info log level.
+ */
+ public void info(Object message) {
+ log(Level.INFO, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with info log level.
+ */
+ public void info(Object message, Throwable exception) {
+ log(Level.INFO, String.valueOf(message), exception);
+ }
+
+
+ /**
+ * Is debug logging currently enabled?
+ */
+ public boolean isDebugEnabled() {
+ return (getLogger().isLoggable(Level.FINE));
+ }
+
+
+ /**
+ * Is error logging currently enabled?
+ */
+ public boolean isErrorEnabled() {
+ return (getLogger().isLoggable(Level.SEVERE));
+ }
+
+
+ /**
+ * Is fatal logging currently enabled?
+ */
+ public boolean isFatalEnabled() {
+ return (getLogger().isLoggable(Level.SEVERE));
+ }
+
+
+ /**
+ * Is info logging currently enabled?
+ */
+ public boolean isInfoEnabled() {
+ return (getLogger().isLoggable(Level.INFO));
+ }
+
+
+ /**
+ * Is trace logging currently enabled?
+ */
+ public boolean isTraceEnabled() {
+ return (getLogger().isLoggable(Level.FINEST));
+ }
+
+
+ /**
+ * Is warn logging currently enabled?
+ */
+ public boolean isWarnEnabled() {
+ return (getLogger().isLoggable(Level.WARNING));
+ }
+
+
+ /**
+ * Log a message with trace log level.
+ */
+ public void trace(Object message) {
+ log(Level.FINEST, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with trace log level.
+ */
+ public void trace(Object message, Throwable exception) {
+ log(Level.FINEST, String.valueOf(message), exception);
+ }
+
+
+ /**
+ * Log a message with warn log level.
+ */
+ public void warn(Object message) {
+ log(Level.WARNING, String.valueOf(message), null);
+ }
+
+
+ /**
+ * Log a message and exception with warn log level.
+ */
+ public void warn(Object message, Throwable exception) {
+ log(Level.WARNING, String.valueOf(message), exception);
+ }
+
+
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Jdk14Logger.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging.impl;
+
+
+import java.util.Hashtable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+import org.apache.log4j.Logger;
+
+/**
+ * Concrete subclass of {@link Factory} specific to log4j.
+ */
+public final class Log4J11Factory extends Factory {
+
+ public Log4J11Factory() {
+ super();
+ }
+
+ // Previously returned instances, to avoid creation of proxies
+ private Hashtable instances = new Hashtable();
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Return a logger associated with the specified category name.
+ */
+ public Log getLog(String name) {
+ Log instance = (Log) instances.get(name);
+ if (instance != null)
+ return instance;
+
+ instance = new Log4J11Logger(Logger.getLogger(name));
+ instances.put(name, instance);
+ return instance;
+ }
+
+
+ /**
+ * Release any internal references to previously created {@link Log}
+ * instances returned by this factory. This is useful in environments
+ * like servlet containers, which implement application reloading by
+ * throwing away a ClassLoader. Dangling references to objects in that
+ * class loader would prevent garbage collection.
+ */
+ public void release(ClassLoader cl) {
+ instances.clear();
+ }
+
+ public void releaseAll() {
+ instances.clear();
+ }
+}
\ No newline at end of file
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Factory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java Mon May 23 03:46:05 2005
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.commons.logging.impl;
+
+import java.io.Serializable;
+import org.apache.commons.logging.Log;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+/**
+ * <p>Implementation of {@link Log} that maps directly to a Log4J
+ * <strong>Logger</strong>. Initial configuration of the corresponding
+ * Logger instances should be done in the usual manner, as outlined in
+ * the Log4J documentation.</p>
+ *
+ * <p>This supports versions of log4j up to version 1.1.</p>
+ */
+public class Log4J11Logger implements Log, Serializable {
+
+
+ // ------------------------------------------------------------- Attributes
+
+ /** The fully qualified name of the Log4JLogger class. */
+ private static final String FQCN = Log4J11Logger.class.getName();
+
+ /** Log to this logger */
+ private transient Logger logger = null;
+
+ /** Logger name */
+ private String name = null;
+
+
+ // ------------------------------------------------------------ Constructor
+
+ public Log4J11Logger() {
+ }
+
+
+ /**
+ * Base constructor.
+ */
+ public Log4J11Logger(String name) {
+ this.name = name;
+ this.logger = getLogger();
+ }
+
+ /** For use with a log4j factory.
+ */
+ public Log4J11Logger(Logger logger ) {
+ this.name = logger.getName();
+ this.logger=logger;
+ }
+
+
+ // --------------------------------------------------------- Implementation
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>TRACE</code> priority.
+ * Currently logs to <code>DEBUG</code> level in Log4J.
+ */
+ public void trace(Object message) {
+ getLogger().log(FQCN, Level.DEBUG, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>TRACE</code> priority.
+ * Currently logs to <code>DEBUG</code> level in Log4J.
+ */
+ public void trace(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.DEBUG, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>DEBUG</code> priority.
+ */
+ public void debug(Object message) {
+ getLogger().log(FQCN, Level.DEBUG, message, null );
+ }
+
+ /**
+ * Log an error to the Log4j Logger with <code>DEBUG</code> priority.
+ */
+ public void debug(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.DEBUG, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>INFO</code> priority.
+ */
+ public void info(Object message) {
+ getLogger().log(FQCN, Level.INFO, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>INFO</code> priority.
+ */
+ public void info(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.INFO, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>WARN</code> priority.
+ */
+ public void warn(Object message) {
+ getLogger().log(FQCN, Level.WARN, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>WARN</code> priority.
+ */
+ public void warn(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.WARN, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>ERROR</code> priority.
+ */
+ public void error(Object message) {
+ getLogger().log(FQCN, Level.ERROR, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>ERROR</code> priority.
+ */
+ public void error(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.ERROR, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>FATAL</code> priority.
+ */
+ public void fatal(Object message) {
+ getLogger().log(FQCN, Level.FATAL, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>FATAL</code> priority.
+ */
+ public void fatal(Object message, Throwable t) {
+ getLogger().log(FQCN, Level.FATAL, message, t );
+ }
+
+
+ /**
+ * Return the native Logger instance we are using.
+ */
+ public Logger getLogger() {
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ }
+ return (this.logger);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority.
+ */
+ public boolean isDebugEnabled() {
+ return getLogger().isDebugEnabled();
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority.
+ */
+ public boolean isErrorEnabled() {
+ return getLogger().isEnabledFor(Level.ERROR);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority.
+ */
+ public boolean isFatalEnabled() {
+ return getLogger().isEnabledFor(Level.FATAL);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>INFO</code> priority.
+ */
+ public boolean isInfoEnabled() {
+ return getLogger().isInfoEnabled();
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>TRACE</code> priority.
+ * For Log4J, this returns the value of <code>isDebugEnabled()</code>
+ */
+ public boolean isTraceEnabled() {
+ return getLogger().isDebugEnabled();
+ }
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>WARN</code> priority.
+ */
+ public boolean isWarnEnabled() {
+ return getLogger().isEnabledFor(Level.WARN);
+ }
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J11Logger.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging.impl;
+
+
+import java.util.Hashtable;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+import org.apache.log4j.Logger;
+
+/**
+ * Concrete subclass of {@link Factory} specific to log4j.
+ */
+public final class Log4J12Factory extends Factory {
+
+ public Log4J12Factory() {
+ super();
+ }
+
+ // Previously returned instances, to avoid creation of proxies
+ private Hashtable instances = new Hashtable();
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Return a logger associated with the specified category name.
+ */
+ public Log getLog(String name) {
+ Log instance = (Log) instances.get(name);
+ if (instance != null)
+ return instance;
+
+ instance = new Log4J12Logger(Logger.getLogger(name));
+ instances.put(name, instance);
+ return instance;
+ }
+
+
+ /**
+ * Release any internal references to previously created {@link Log}
+ * instances returned by this factory. This is useful in environments
+ * like servlet containers, which implement application reloading by
+ * throwing away a ClassLoader. Dangling references to objects in that
+ * class loader would prevent garbage collection.
+ */
+ public void release(ClassLoader cl) {
+ instances.clear();
+ }
+
+ public void releaseAll() {
+ instances.clear();
+ }
+}
\ No newline at end of file
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Factory.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java Mon May 23 03:46:05 2005
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+
+package org.apache.commons.logging.impl;
+
+import java.io.Serializable;
+import org.apache.commons.logging.Log;
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.apache.log4j.Level;
+
+/**
+ * <p>Implementation of {@link Log} that maps directly to a Log4J
+ * <strong>Logger</strong>. Initial configuration of the corresponding
+ * Logger instances should be done in the usual manner, as outlined in
+ * the Log4J documentation.</p>
+ *
+ * <p>This version requires log4j 1.2 or later.</p>
+ */
+public class Log4J12Logger implements Log, Serializable {
+
+
+ // ------------------------------------------------------------- Attributes
+
+ /** The fully qualified name of the Log4JLogger class. */
+ private static final String FQCN = Log4J12Logger.class.getName();
+
+ /** Log to this logger */
+ private transient Logger logger = null;
+
+ /** Logger name */
+ private String name = null;
+
+
+ // ------------------------------------------------------------ Constructor
+
+ public Log4J12Logger() {
+ }
+
+
+ /**
+ * Base constructor.
+ */
+ public Log4J12Logger(String name) {
+ this.name = name;
+ this.logger = getLogger();
+ }
+
+ /** For use with a log4j factory.
+ */
+ public Log4J12Logger(Logger logger ) {
+ this.name = logger.getName();
+ this.logger=logger;
+ }
+
+
+ // --------------------------------------------------------- Implementation
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>TRACE</code> priority.
+ * Currently logs to <code>DEBUG</code> level in Log4J.
+ */
+ public void trace(Object message) {
+ getLogger().log(FQCN, (Priority) Level.DEBUG, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>TRACE</code> priority.
+ * Currently logs to <code>DEBUG</code> level in Log4J.
+ */
+ public void trace(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.DEBUG, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>DEBUG</code> priority.
+ */
+ public void debug(Object message) {
+ getLogger().log(FQCN, (Priority) Level.DEBUG, message, null );
+ }
+
+ /**
+ * Log an error to the Log4j Logger with <code>DEBUG</code> priority.
+ */
+ public void debug(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.DEBUG, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>INFO</code> priority.
+ */
+ public void info(Object message) {
+ getLogger().log(FQCN, (Priority) Level.INFO, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>INFO</code> priority.
+ */
+ public void info(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.INFO, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>WARN</code> priority.
+ */
+ public void warn(Object message) {
+ getLogger().log(FQCN, (Priority) Level.WARN, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>WARN</code> priority.
+ */
+ public void warn(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.WARN, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>ERROR</code> priority.
+ */
+ public void error(Object message) {
+ getLogger().log(FQCN, (Priority) Level.ERROR, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>ERROR</code> priority.
+ */
+ public void error(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.ERROR, message, t );
+ }
+
+
+ /**
+ * Log a message to the Log4j Logger with <code>FATAL</code> priority.
+ */
+ public void fatal(Object message) {
+ getLogger().log(FQCN, (Priority) Level.FATAL, message, null );
+ }
+
+
+ /**
+ * Log an error to the Log4j Logger with <code>FATAL</code> priority.
+ */
+ public void fatal(Object message, Throwable t) {
+ getLogger().log(FQCN, (Priority) Level.FATAL, message, t );
+ }
+
+
+ /**
+ * Return the native Logger instance we are using.
+ */
+ public Logger getLogger() {
+ if (logger == null) {
+ logger = Logger.getLogger(name);
+ }
+ return (this.logger);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>DEBUG</code> priority.
+ */
+ public boolean isDebugEnabled() {
+ return getLogger().isDebugEnabled();
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>ERROR</code> priority.
+ */
+ public boolean isErrorEnabled() {
+ return getLogger().isEnabledFor((Priority) Level.ERROR);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>FATAL</code> priority.
+ */
+ public boolean isFatalEnabled() {
+ return getLogger().isEnabledFor((Priority) Level.FATAL);
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>INFO</code> priority.
+ */
+ public boolean isInfoEnabled() {
+ return getLogger().isInfoEnabled();
+ }
+
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>TRACE</code> priority.
+ * For Log4J, this returns the value of <code>isDebugEnabled()</code>
+ */
+ public boolean isTraceEnabled() {
+ return getLogger().isDebugEnabled();
+ }
+
+ /**
+ * Check whether the Log4j Logger used is enabled for <code>WARN</code> priority.
+ */
+ public boolean isWarnEnabled() {
+ return getLogger().isEnabledFor((Priority) Level.WARN);
+ }
+}
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/Log4J12Logger.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java?rev=177949&view=auto
==============================================================================
--- jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java (added)
+++ jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java Mon May 23 03:46:05 2005
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+package org.apache.commons.logging.impl;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.Factory;
+
+/**
+ * Concrete subclass of {@link Factory} specific to NoOpLogger.
+ */
+public final class NoOpFactory extends Factory {
+
+ private static Log logger = new NoOpLogger();
+
+ public NoOpFactory() {
+ super();
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Return a logger associated with the specified category name.
+ */
+ public Log getLog(String name) {
+ return logger;
+ }
+
+ public void release(ClassLoader cl) {
+ }
+
+ public void releaseAll() {
+ }
+}
\ No newline at end of file
Propchange: jakarta/commons/proper/logging/branches/simon-1.1/src/java/org/apache/commons/logging/impl/NoOpFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org