vmassol 01/06/18 13:23:36
Modified: cactus/conf/sample/build/servlet22 build.properties.sample
cactus/conf/sample/build/servlet23 build.properties.sample
cactus/conf/sample/build/share build-share.xml
cactus/docs/framework/xdocs changes.xml
cactus/src/framework/share/org/apache/commons/cactus/util/log
BaseLog.java Log.java LogService.java
Added: cactus/src/framework/share/org/apache/commons/cactus/util/log
BaseLogDummy.java
Log:
make it so that Log4j is only mandatory for building Cactus from the source and
optional for end users. If they dont provide a log4j jar file then no log will be
generated by everything else will run fine
Revision Changes Path
1.5 +8 -1
jakarta-commons/cactus/conf/sample/build/servlet22/build.properties.sample
Index: build.properties.sample
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/conf/sample/build/servlet22/build.properties.sample,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- build.properties.sample 2001/06/18 12:53:34 1.4
+++ build.properties.sample 2001/06/18 20:23:05 1.5
@@ -6,7 +6,14 @@
cactus.jar = ../lib/commons-cactus.jar
cactus.ant.jar = ../lib/commons-cactus-ant.jar
junit.jar = f:/applis/jakarta-ant-1.4alpha/lib/junit.jar
-log4j.jar = ../lib/log4j-core.jar
+
+# You have 2 options. Define a property named "log4j.jar" and point it to the
+# log4j jar file. In that case, Cactus will generate log files (named
+# cactus_server.log and cactus_client.log). the second option is not to define
+# a "log4j.jar" property and not provide the log4j jar. In that case nothing
+# will be logged but everything will still run.
+
+#log4j.jar = ../lib/log4j-core.jar
# Servlet engine locations for the tests
1.4 +8 -1
jakarta-commons/cactus/conf/sample/build/servlet23/build.properties.sample
Index: build.properties.sample
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/conf/sample/build/servlet23/build.properties.sample,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build.properties.sample 2001/06/17 13:33:28 1.3
+++ build.properties.sample 2001/06/18 20:23:13 1.4
@@ -6,7 +6,14 @@
cactus.jar = ../lib/commons-cactus.jar
cactus.ant.jar = ../lib/commons-cactus-ant.jar
junit.jar = f:/applis/jakarta-ant-1.4alpha/lib/junit.jar
-log4j.jar = ../lib/log4j-core.jar
+
+# You have 2 options. Define a property named "log4j.jar" and point it to the
+# log4j jar file. In that case, Cactus will generate log files (named
+# cactus_server.log and cactus_client.log). the second option is not to define
+# a "log4j.jar" property and not provide the log4j jar. In that case nothing
+# will be logged but everything will still run.
+
+#log4j.jar = ../lib/log4j-core.jar
# Servlet engine locations for the tests
1.3 +0 -1 jakarta-commons/cactus/conf/sample/build/share/build-share.xml
Index: build-share.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/cactus/conf/sample/build/share/build-share.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- build-share.xml 2001/06/18 08:17:34 1.2
+++ build-share.xml 2001/06/18 20:23:18 1.3
@@ -117,7 +117,6 @@
<echo message="servlet.jar = ${servlet.jar}"/>
<echo message="cactus.jar = ${cactus.jar}"/>
<echo message="junit.jar = ${junit.jar}"/>
- <echo message="log4j.jar = ${log4j.jar}"/>
<echo message="cactus.ant.jar = ${cactus.ant.jar}"/>
<!-- Filters -->
1.22 +4 -3 jakarta-commons/cactus/docs/framework/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/cactus/docs/framework/xdocs/changes.xml,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- changes.xml 2001/06/18 19:31:26 1.21
+++ changes.xml 2001/06/18 20:23:23 1.22
@@ -35,9 +35,10 @@
</action>
<action dev="VMA" type="add">
Added logging facility to Cactus, using the Log4j logging framework.
- Note that according to the result of the message I posted on
- <code>jakarta-commons</code>, this function may be deleted or
- implemented differently in the 1.2 version of Cactus.
+ In order to make it easy on end users, Log4j is only required when
+ building Cactus from the sources. It is however optional when running
+ Cactus tests. If the log4j jar is present logs will be generated and if
+ not, then no log will be generated.
</action>
<action dev="VMA" type="fix" due-to="Bob Davison"
due-to-email="[EMAIL PROTECTED]">
(<link href="http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1612">
1.2 +0 -14
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/BaseLog.java
Index: BaseLog.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/BaseLog.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseLog.java 2001/06/17 13:40:42 1.1
+++ BaseLog.java 2001/06/18 20:23:28 1.2
@@ -56,7 +56,6 @@
import java.util.*;
import org.apache.log4j.Category;
-import org.apache.log4j.Appender;
/**
* Wrapper around the Log4j <code>Category</code> class. A category is
@@ -204,17 +203,4 @@
return category.isDebugEnabled();
}
- /**
- * Special method that returns the Log4j root <code>Appender</code>. This
- * method is useful for unit testing, where you can define a test
- * <code>Appender</code> and use it to verify the result of a log.
- *
- * @param theAppenderName the name of the <code>Appender</code> to return.
- * It is the name defined in the log properties file.
- * @return the root appender or null if not found
- */
- public Appender getRootAppender(String theAppenderName)
- {
- return category.getRoot().getAppender(theAppenderName);
- }
}
1.2 +0 -2
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/Log.java
Index: Log.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/Log.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Log.java 2001/06/17 13:40:42 1.1
+++ Log.java 2001/06/18 20:23:29 1.2
@@ -53,8 +53,6 @@
*/
package org.apache.commons.cactus.util.log;
-import org.apache.log4j.Category;
-
/**
* Interface for logging implementation classes
*/
1.2 +26 -2
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/LogService.java
Index: LogService.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/LogService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LogService.java 2001/06/17 13:40:42 1.1
+++ LogService.java 2001/06/18 20:23:30 1.2
@@ -76,6 +76,11 @@
private boolean isInitialized = false;
/**
+ * Is Log4j in the classpath ?
+ */
+ private boolean isLog4jInClasspath = false;
+
+ /**
* The singleton's unique instance
*/
private static LogService instance;
@@ -85,6 +90,16 @@
*/
private LogService()
{
+ // Check if Log4j is in the classpath. If not, use a dummy
+ // implementation that does nothing. This is to make it easy on user
+ // who do not want to have to download log4j and put it in their
+ // classpath !
+ isLog4jInClasspath = true;
+ try {
+ Class aClass = Class.forName("org.apache.log4j.PropertyConfigurator");
+ } catch (ClassNotFoundException e) {
+ isLog4jInClasspath = false;
+ }
}
/**
@@ -107,8 +122,12 @@
public void init(String theFileName)
{
URL url = LogService.class.getResource(theFileName);
- PropertyConfigurator.configure(url);
+ if (isLog4jInClasspath) {
+ // Initialize Log4j
+ PropertyConfigurator.configure(url);
+ }
+
isInitialized = true;
}
@@ -128,8 +147,13 @@
Log log = (Log)logCategories.get(theCategoryName);
if (log == null) {
+
+ if (isLog4jInClasspath) {
+ log = new BaseLog(theCategoryName);
+ } else {
+ log = new BaseLogDummy(theCategoryName);
+ }
- log = new BaseLog(theCategoryName);
logCategories.put(theCategoryName, log);
}
1.1
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/util/log/BaseLogDummy.java
Index: BaseLogDummy.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.commons.cactus.util.log;
import java.util.*;
/**
* Dummy class that logs nothing.
*/
public class BaseLogDummy implements Log
{
/**
* @param theCategoryName the category's name. Usually, it is the full
* name of the class being logged, including the package name
*/
public BaseLogDummy(String theCategoryName)
{
}
/**
* Log a DEBUG level message.
*
* @param theMessage the message to log
*/
public void debug(String theMessage)
{
}
/**
* Log a DEBUG level message along with an exception
*
* @param theMessage the message to log
* @param theThrowable the exception to log
*/
public void debug(String theMessage, Throwable theThrowable)
{
}
/**
* Log an ERROR level message.
*
* @param theMessage the message to log
*/
public void error(String theMessage)
{
}
/**
* Log an ERROR level message along with an exception
*
* @param theMessage the message to log
* @param theThrowable the exception to log
*/
public void error(String theMessage, Throwable theThrowable)
{
}
/**
* Log an ERROR level exception only
*
* @param theMessage the message to log
* @param theThrowable the exception to log
*/
public void error(Throwable theThrowable)
{
}
/**
* Log an INFO level message.
*
* @param theMessage the message to log
*/
public void info(String theMessage)
{
}
/**
* Log an INFO level message along with an exception
*
* @param theMessage the message to log
* @param theThrowable the exception to log
*/
public void info(String theMessage, Throwable theThrowable)
{
}
/**
* Log a WARNING level message.
*
* @param theMessage the message to log
*/
public void warn(String theMessage)
{
}
/**
* Log a WARNING level message along with an exception
*
* @param theMessage the message to log
* @param theThrowable the exception to log
*/
public void warn(String theMessage, Throwable theThrowable)
{
}
/**
* Used to log a message when entering a method.
*
* @param theMessage the message to log
*/
public void entry(String theMessage)
{
}
/**
* Used to log a message when exiting a method.
*
* @param theMessage the message to log
*/
public void exit(String theMessage)
{
}
/**
* @return true if the Log4j priority level is debugging
*/
public boolean isDebugEnabled()
{
return false;
}
}