[jboss-svn-commits] JBL Code SVN: r28999 - in labs/jbosstm/trunk/common: classes/com/arjuna/common/internal/util/logging and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 20 11:38:35 EDT 2009
Author: jhalliday
Date: 2009-08-20 11:38:35 -0400 (Thu, 20 Aug 2009)
New Revision: 28999
Removed:
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/simpleLog/
labs/jbosstm/trunk/common/lib/ext/
Modified:
labs/jbosstm/trunk/common/build.xml
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaRelevelingLogFactory.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
Log:
Fix CLF logger selection and remove obsolete loggers. JBTM-607
Modified: labs/jbosstm/trunk/common/build.xml
===================================================================
--- labs/jbosstm/trunk/common/build.xml 2009-08-20 15:34:42 UTC (rev 28998)
+++ labs/jbosstm/trunk/common/build.xml 2009-08-20 15:38:35 UTC (rev 28999)
@@ -22,6 +22,8 @@
<property name="modulename" value="common"/>
+ <property name="global.ext.libs" value="commons-logging-1.1.jar log4j-1.2.14.jar"/>
+
<import file="../sharedbuild.xml"/>
<target name="run.tests">
@@ -75,6 +77,9 @@
<run.tests.macro>
<tests><fileset dir="tests" includes="**/EnvironmentBeanTest.java"/></tests>
</run.tests.macro>
+ <run.tests.macro>
+ <tests><fileset dir="tests" includes="**/BeanPopulatorTest.java"/></tests>
+ </run.tests.macro>
</target>
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java 2009-08-20 15:34:42 UTC (rev 28998)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaLogFactory.java 2009-08-20 15:38:35 UTC (rev 28999)
@@ -30,6 +30,7 @@
import com.arjuna.common.internal.util.logging.LogFactoryInterface;
import com.arjuna.common.internal.util.logging.AbstractLogInterface;
+import com.arjuna.common.internal.util.logging.LogInterface;
import com.arjuna.common.util.exceptions.LogConfigurationException;
/**
@@ -41,6 +42,14 @@
*/
public class JakartaLogFactory implements LogFactoryInterface
{
+ // the value for org.apache.commons.logging.Log, usually a classname starting org.apache.commons.logging.impl.
+ // use null for default search order per http://commons.apache.org/logging/apidocs/index.html
+ private String logImpl = null;
+
+ public JakartaLogFactory(String logImpl) {
+ this.logImpl = logImpl;
+ }
+
/**
* Convenience method to return a named logger, without the application
* having to care about factories.
@@ -58,7 +67,7 @@
// configure the underlying apache factory
oldConfig = configureFactory();
// get a new logger from the log subsystem's factory and wrap it into a LogInterface
- return new JakartaLogger(org.apache.commons.logging.LogFactory.getLog(clazz));
+ return createLogWrapper(org.apache.commons.logging.LogFactory.getLog(clazz));
}
catch (org.apache.commons.logging.LogConfigurationException lce)
{
@@ -89,7 +98,7 @@
// configure the underlying apache factory
oldConfig = configureFactory();
// get a new logger from the log subsystem's factory and wrap it into a LogInterface
- return new JakartaLogger(org.apache.commons.logging.LogFactory.getLog(name));
+ return createLogWrapper(org.apache.commons.logging.LogFactory.getLog(name));
}
catch (org.apache.commons.logging.LogConfigurationException lce)
{
@@ -101,6 +110,10 @@
}
}
+ protected LogInterface createLogWrapper(org.apache.commons.logging.Log log) {
+ return new JakartaLogger(log);
+ }
+
/*
Note: the apache LogFactory configuration is basically global to the JVM (actually the classloader)
This braindead design decision has the potential to cause trouble, since multiple users may each
@@ -117,7 +130,7 @@
private Object configureFactory()
{
Object oldValue = org.apache.commons.logging.LogFactory.getFactory().getAttribute("org.apache.commons.logging.Log");
- org.apache.commons.logging.LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", Log4JLogger.class.getName());
+ org.apache.commons.logging.LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", logImpl);
return oldValue;
}
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaRelevelingLogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaRelevelingLogFactory.java 2009-08-20 15:34:42 UTC (rev 28998)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/jakarta/JakartaRelevelingLogFactory.java 2009-08-20 15:38:35 UTC (rev 28999)
@@ -20,9 +20,7 @@
*/
package com.arjuna.common.internal.util.logging.jakarta;
-import com.arjuna.common.internal.util.logging.LogFactoryInterface;
-import com.arjuna.common.internal.util.logging.AbstractLogInterface;
-import com.arjuna.common.util.exceptions.LogConfigurationException;
+import com.arjuna.common.internal.util.logging.LogInterface;
/**
* JavaDoc
@@ -30,93 +28,13 @@
* @author Jonathan Halliday <jonathan.halliday at redhat.com>
* @version $Revision: 2342 $ $Date: 2006-03-30 14:06:17 +0100 (Thu, 30 Mar 2006) $
*/
-public class JakartaRelevelingLogFactory implements LogFactoryInterface
+public class JakartaRelevelingLogFactory extends JakartaLogFactory
{
- /**
- * Convenience method to return a named logger, without the application
- * having to care about factories.
- *
- * @param clazz Class for which a log name will be derived
- *
- * @exception com.arjuna.common.util.exceptions.LogConfigurationException if a suitable <code>Log</code>
- * instance cannot be returned
- */
- public AbstractLogInterface getLog(Class clazz) throws LogConfigurationException
- {
- Object oldConfig = null;
- try
- {
- // configure the underlying apache factory
- oldConfig = configureFactory();
- // get a new logger from the log subsystem's factory and wrap it into a LogInterface
- return new JakartaRelevelingLogger(org.apache.commons.logging.LogFactory.getLog(clazz));
- }
- catch (org.apache.commons.logging.LogConfigurationException lce)
- {
- throw new LogConfigurationException(lce.getMessage(), lce);
- }
- finally
- {
- resetFactory(oldConfig);
- }
- }
+ public JakartaRelevelingLogFactory(String logImpl) {
+ super(logImpl);
+ }
- /**
- * 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)
- *
- * @exception LogConfigurationException if a suitable <code>Log</code>
- * instance cannot be returned
- */
- public AbstractLogInterface getLog(String name) throws LogConfigurationException
- {
- Object oldConfig = null;
- try
- {
- // configure the underlying apache factory
- oldConfig = configureFactory();
- // get a new logger from the log subsystem's factory and wrap it into a LogInterface
- return new JakartaRelevelingLogger(org.apache.commons.logging.LogFactory.getLog(name));
- }
- catch (org.apache.commons.logging.LogConfigurationException lce)
- {
- throw new LogConfigurationException(lce.getMessage(), lce);
- }
- finally
- {
- resetFactory(oldConfig);
- }
- }
-
- /*
- Note: the apache LogFactory configuration is basically global to the JVM (actually the classloader)
- This braindead design decision has the potential to cause trouble, since multiple users may each
- set factory attributes and there is no thread safety. This occurs e.g. when we run embedded in
- JBossAS. To minimise the risks (we can't eliminate then entirely without using an isolated classloader)
- we set the configuration we need on each factory use and reset it afterwards, so as to try and
- minimise interference with anything else that may be overriding the same factory attributes.
- */
-
-
- /**
- * Install our custom logger by setting the factory attribute
- */
- private Object configureFactory()
- {
- Object oldValue = org.apache.commons.logging.LogFactory.getFactory().getAttribute("org.apache.commons.logging.Log");
- org.apache.commons.logging.LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", Log4JLogger.class.getName());
- return oldValue;
- }
-
- /**
- * Restore the factory configuration to the provided value.
- */
- private void resetFactory(Object value)
- {
- org.apache.commons.logging.LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", value);
- }
-}
+ protected LogInterface createLogWrapper(org.apache.commons.logging.Log log) {
+ return new JakartaRelevelingLogger(log);
+ }
+}
\ No newline at end of file
Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java 2009-08-20 15:34:42 UTC (rev 28998)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java 2009-08-20 15:38:35 UTC (rev 28999)
@@ -29,7 +29,6 @@
package com.arjuna.common.util.logging;
import com.arjuna.common.internal.util.logging.*;
-import com.arjuna.common.internal.util.logging.simpleLog.SimpleLogFactory;
import com.arjuna.common.internal.util.logging.jakarta.JakartaLogFactory;
import com.arjuna.common.internal.util.logging.jakarta.JakartaRelevelingLogFactory;
import com.arjuna.common.util.exceptions.LogConfigurationException;
@@ -49,7 +48,6 @@
* <li>console</li>
* </ul>
* </li>
- * <li><code><b>dotnet</b></code> .net logging. (must be JDK 1.1 compliant for compilation by the Microsoft compiler)</li>
* </ul>
* Note: Log subsystems are not configured through CLF but instead rely on their own configuration files for
* the setup of eg. debug level, appenders, etc...
@@ -109,6 +107,7 @@
*
* See the class description for supported values.
*/
+ @Deprecated
public static final String LOGGER_PROPERTY = "com.arjuna.common.util.logger";
@@ -120,20 +119,15 @@
* we might also want to explore dynamic proxies to automaticlaly obtain debug
* output for all methods & constructors, etc ...
*/
+ @Deprecated
public static final String DEBUG_LEVEL = "com.arjuna.common.util.logging.DebugLevel";
+ @Deprecated
public static final String FACILITY_LEVEL = "com.arjuna.common.util.logging.FacilityLevel";
+ @Deprecated
public static final String VISIBILITY_LEVEL = "com.arjuna.common.util.logging.VisibilityLevel";
- /**
- * this property is used by the Jakarta Commons Logging implementation to select the underlying
- * logging framework to use. This can be set as a system property. if this property is not set,
- * JCL will select the implementation to use by
- */
- private static final String JCL_LOG_CONFIGURATION = "org.apache.commons.logging.Log";
-
//private static final String CSF_LOGGER = "csf";
private static final String JAKARTA_LOGGER = "jakarta";
- private static final String DOTNET_LOGGER = "dotnet";
private static final String LOG4J = "log4j";
private static final String JDK14 = "jdk14";
private static final String SIMPLE = "simple";
@@ -321,48 +315,31 @@
m_debugLevel = 0xfffffff;
}
- // .net simple logging is not currenlty supported, instead use
- // jakarta commons simple logging (it is pure Java 1.1) in the
- // current release:
- if (logSystem.equals(DOTNET_LOGGER)) logSystem = SIMPLE;
-
-
// ALL THESE ARE SUPPORTED BY JAKARTA COMMONS LOGGING
if (logSystem.equals(LOG4J)) {
- System.setProperty(JCL_LOG_CONFIGURATION, "org.apache.commons.logging.impl.Log4JLogger");
- m_logFactory = new JakartaLogFactory();
+ m_logFactory = new JakartaLogFactory("com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
} else if (logSystem.equals(JDK14)) {
- System.setProperty(JCL_LOG_CONFIGURATION, "org.apache.commons.logging.impl.Jdk14Logger");
- m_logFactory = new JakartaLogFactory();
+ m_logFactory = new JakartaLogFactory("org.apache.commons.logging.impl.Jdk14Logger");
} else if (logSystem.equals(SIMPLE)) {
- System.setProperty(JCL_LOG_CONFIGURATION, "org.apache.commons.logging.impl.SimpleLog");
- m_logFactory = new JakartaLogFactory();
+ m_logFactory = new JakartaLogFactory("org.apache.commons.logging.impl.SimpleLog");
} else if (logSystem.equals(NOOP)) {
- System.setProperty(JCL_LOG_CONFIGURATION, "org.apache.commons.logging.impl.NoOpLog");
- m_logFactory = new JakartaLogFactory();
-
+ m_logFactory = new JakartaLogFactory("org.apache.commons.logging.impl.NoOpLog");
}
// we use a slightly modified wrapper to do log statement level modification
// for support of JBossAS log level semantics, see JakartaRelevelingLogger javadoc
else if (logSystem.equals(RELEVELER)) {
- System.setProperty(JCL_LOG_CONFIGURATION, "org.apache.commons.logging.impl.Log4JLogger");
- m_logFactory = new JakartaRelevelingLogFactory();
+ m_logFactory = new JakartaRelevelingLogFactory("com.arjuna.common.internal.util.logging.jakarta.Log4JLogger");
}
// USE JAKARTA COMMONS LOGGINGS OWN DISCOVERY MECHANISM
else if (logSystem.equals(JAKARTA_LOGGER)) {
- m_logFactory = new JakartaLogFactory();
+ m_logFactory = new JakartaLogFactory(null);
}
- // OUR IMPLEMNETATION OF .net LOGGING BYPASSES JAKARTA COMMONS LOGGING
- else if (logSystem.equals(DOTNET_LOGGER)) {
- m_logFactory = new SimpleLogFactory();
- }
-
// by default, use jakarta logging ...
else {
- m_logFactory = new JakartaLogFactory();
+ m_logFactory = new JakartaLogFactory(null);
}
} catch (LogConfigurationException e) {
More information about the jboss-svn-commits
mailing list