[jboss-svn-commits] JBL Code SVN: r28990 - in labs/jbosstm/trunk: ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging and 14 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Aug 19 12:16:00 EDT 2009


Author: jhalliday
Date: 2009-08-19 12:15:57 -0400 (Wed, 19 Aug 2009)
New Revision: 28990

Added:
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java
   labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/tsLogger.java
   labs/jbosstm/trunk/ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging/tsmxLogger.java
   labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/logging/txojLogger.java
   labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java
   labs/jbosstm/trunk/XTS/WS-C/dev/src/com/arjuna/webservices/logging/WSCLogger.java
   labs/jbosstm/trunk/XTS/WS-T/dev/src/com/arjuna/webservices/logging/WSTLogger.java
   labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mw/wsas/logging/wsasLogger.java
   labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/logging/wscfLogger.java
   labs/jbosstm/trunk/XTS/WSTX/classes/com/arjuna/mw/wstx/logging/wstxLogger.java
   labs/jbosstm/trunk/XTS/recovery/src/org/jboss/jbossts/xts/logging/XTSLogger.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java
   labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
   labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java
   labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java
   labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java
Log:
Convert common logging (CLF) properties to bean style config. JBTM-596


Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/tsLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/tsLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/tsLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -57,8 +57,8 @@
 
 		arjLogger = LogFactory.getLogNoi18n("com.arjuna.ats.arjuna.logging.arjLogger");
 
-		language = commonPropertyManager.getPropertyManager().getProperty("language", "en");
-		country = commonPropertyManager.getPropertyManager().getProperty("country", "US");
+		language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+		country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 		currentLocale = new Locale(language, country);
 		

Modified: labs/jbosstm/trunk/ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging/tsmxLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging/tsmxLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging/tsmxLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -57,8 +57,8 @@
 
 		logger = LogFactory.getLogNoi18n("com.arjuna.ats.tsmx.logging.tsmxLogger");
 
-		language = commonPropertyManager.getPropertyManager().getProperty("language", "en");
-		country = commonPropertyManager.getPropertyManager().getProperty("country", "US");
+		language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+		country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 		currentLocale = new Locale(language, country);
 		

Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/logging/txojLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/logging/txojLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/logging/txojLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -46,9 +46,9 @@
 
 		aitLogger = LogFactory.getLogNoi18n("com.arjuna.ats.txoj.logging.txojLogger");
 
-		language = commonPropertyManager.getPropertyManager().getProperty("language", "en");
+		language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
 
-		country = commonPropertyManager.getPropertyManager().getProperty("country", "US");
+		country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 		currentLocale = new Locale(language, country);
 		

Modified: labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -47,9 +47,9 @@
 
 		logger = LogFactory.getLogNoi18n("com.arjuna.orbportability.logging.logger");
 
-		_language = commonPropertyManager.getPropertyManager().getProperty("language", "en");
+		_language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
 
-		_country = commonPropertyManager.getPropertyManager().getProperty("country", "US");
+		_country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 		_currentLocale = new Locale(_language, _country);
 		

Modified: labs/jbosstm/trunk/XTS/WS-C/dev/src/com/arjuna/webservices/logging/WSCLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/dev/src/com/arjuna/webservices/logging/WSCLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/WS-C/dev/src/com/arjuna/webservices/logging/WSCLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -65,8 +65,8 @@
             
     	arjLogger = LogFactory.getLogNoi18n("com.arjuna.wsc.logging.WSCLogger");
     
-        final String language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-        final String country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+        final String language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+        final String country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
     
     	final Locale currentLocale = new Locale(language, country);
     	log_mesg = ResourceBundle.getBundle("wsc_msg",currentLocale);

Modified: labs/jbosstm/trunk/XTS/WS-T/dev/src/com/arjuna/webservices/logging/WSTLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-T/dev/src/com/arjuna/webservices/logging/WSTLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/WS-T/dev/src/com/arjuna/webservices/logging/WSTLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -53,8 +53,8 @@
             
     	arjLogger = LogFactory.getLogNoi18n("com.arjuna.webservices.logging.WSTLogger");
     
-        final String language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-        final String country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+        final String language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+        final String country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
     
     	final Locale currentLocale = new Locale(language, country);
     	log_mesg = ResourceBundle.getBundle("wst_msg",currentLocale);

Modified: labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mw/wsas/logging/wsasLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mw/wsas/logging/wsasLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/WSAS/classes/com/arjuna/mw/wsas/logging/wsasLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -57,8 +57,8 @@
         
 	arjLogger = LogFactory.getLogNoi18n("com.arjuna.mw.wsas.logging.wsasLogger");
 
-	language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-	country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+	language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+	country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 	currentLocale = new Locale(language,country);
 	log_mesg = ResourceBundle.getBundle("wsas_msg",currentLocale);

Modified: labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/logging/wscfLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/logging/wscfLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/WSCF/classes/com/arjuna/mw/wscf/logging/wscfLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -57,8 +57,8 @@
         
 	arjLogger = LogFactory.getLogNoi18n("com.arjuna.mw.wscf.logging.wscfLogger");
 
-	language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-	country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+	language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+	country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 	currentLocale = new Locale(language,country);
 	log_mesg = ResourceBundle.getBundle("wscf_msg",currentLocale);

Modified: labs/jbosstm/trunk/XTS/WSTX/classes/com/arjuna/mw/wstx/logging/wstxLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/WSTX/classes/com/arjuna/mw/wstx/logging/wstxLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/WSTX/classes/com/arjuna/mw/wstx/logging/wstxLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -57,8 +57,8 @@
         
 	arjLogger = LogFactory.getLogNoi18n("com.arjuna.mw.wstx.logging.wstxLogger");
 
-	language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-	country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+	language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+	country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
 	currentLocale = new Locale(language,country);
 	log_mesg = ResourceBundle.getBundle("wstx_msg",currentLocale);

Modified: labs/jbosstm/trunk/XTS/recovery/src/org/jboss/jbossts/xts/logging/XTSLogger.java
===================================================================
--- labs/jbosstm/trunk/XTS/recovery/src/org/jboss/jbossts/xts/logging/XTSLogger.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/XTS/recovery/src/org/jboss/jbossts/xts/logging/XTSLogger.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -22,8 +22,8 @@
 
     	arjLogger = LogFactory.getLogNoi18n("com.arjuna.webservices.logging.XTSLogger");
 
-        final String language = commonPropertyManager.getPropertyManager().getProperty("language","en");
-        final String country  = commonPropertyManager.getPropertyManager().getProperty("country","US");
+        final String language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+        final String country  = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
 
     	final Locale currentLocale = new Locale(language, country);
     	log_mesg = ResourceBundle.getBundle("recovery_msg",currentLocale);

Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLog.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -151,38 +151,18 @@
 
     // ------------------------------------------------------------ Initializer
 
-    private static String getStringProperty(String name) {
-        String prop = commonPropertyManager.getPropertyManager().getProperty(name);
-        // if the property manager has no info set, use the system property
-        // and if this isn't set either, default to JAKARTA simple logging.
-        if (prop == null) {
-            prop = System.getProperty(name);
-        }
-        return (prop == null) ? simpleLogProps.getProperty(name) : prop;
-	}
-
-    private static String getStringProperty(String name, String dephault) {
-        String prop = getStringProperty(name);
-        return (prop == null) ? dephault : prop;
-    }
-
-    private static boolean getBooleanProperty(String name, boolean dephault) {
-        String prop = getStringProperty(name);
-        return (prop == null) ? dephault : "true".equalsIgnoreCase(prop);
-    }
-
     // Initialize class attributes.
     // Load properties file, if found.
     // Override with system properties.
     static {
 
-        showLogName = getBooleanProperty( SHOW_LOG_NAME, showLogName);
-        showShortName = getBooleanProperty( SHOW_SHORT_LOG_NAME, showShortName);
-        showDateTime = getBooleanProperty( SHOW_DATE, showDateTime);
+        showLogName = commonPropertyManager.getDefaultLogEnvironmentBean().isShowLogName();
+        showShortName = commonPropertyManager.getDefaultLogEnvironmentBean().isShowShortLogName();
+        showDateTime = commonPropertyManager.getDefaultLogEnvironmentBean().isShowDate();
         dateFormatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss:SSS zzz");
 
-        String fileName = getStringProperty(LOG_FILE, LOG_FILE_DEFAULT);
-        boolean fileAppend = getBooleanProperty(LOG_FILE_APPEND, true);
+        String fileName = commonPropertyManager.getDefaultLogEnvironmentBean().getLogFile();
+        boolean fileAppend = commonPropertyManager.getDefaultLogEnvironmentBean().isLogFileAppend();
         try {
             FileOutputStream fOut = new FileOutputStream(fileName, fileAppend);
             defaultLogFile = new PrintStream(fOut, true);
@@ -227,7 +207,7 @@
         setLevel(DefaultLog.LOG_LEVEL_INFO);
 
         // Set log level from properties
-        String lvl = commonPropertyManager.getPropertyManager().getProperty(LOG_LEVEL, null);
+        String lvl = commonPropertyManager.getDefaultLogEnvironmentBean().getDefaultLevel();
         if(null == lvl) {
             lvl =  System.getProperty(LOG_LEVEL + "info");
         }

Added: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/DefaultLogEnvironmentBean.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.arjuna.common.internal.util.logging;
+
+import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
+
+/**
+ * A JavaBean containing configuration properties for the default log system.
+ *
+ * TODO testcase
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+ at PropertyPrefix(prefix = "com.arjuna.common.util.logging.default.")
+public class DefaultLogEnvironmentBean
+{
+    private boolean showLogName = false;
+    private boolean showShortLogName = true;
+    private boolean showDate = true;
+    private boolean logFileAppend = true;
+
+    private String defaultLevel = "info";
+
+    private String logFile = "error.log";
+
+
+    public boolean isShowLogName()
+    {
+        return showLogName;
+    }
+
+    public void setShowLogName(boolean showLogName)
+    {
+        this.showLogName = showLogName;
+    }
+
+    public boolean isShowShortLogName()
+    {
+        return showShortLogName;
+    }
+
+    public void setShowShortLogName(boolean showShortLogName)
+    {
+        this.showShortLogName = showShortLogName;
+    }
+
+    public boolean isShowDate()
+    {
+        return showDate;
+    }
+
+    public void setShowDate(boolean showDate)
+    {
+        this.showDate = showDate;
+    }
+
+    public boolean isLogFileAppend()
+    {
+        return logFileAppend;
+    }
+
+    public void setLogFileAppend(boolean logFileAppend)
+    {
+        this.logFileAppend = logFileAppend;
+    }
+
+    public String getDefaultLevel()
+    {
+        return defaultLevel;
+    }
+
+    public void setDefaultLevel(String defaultLevel)
+    {
+        this.defaultLevel = defaultLevel;
+    }
+
+    public String getLogFile()
+    {
+        return logFile;
+    }
+
+    public void setLogFile(String logFile)
+    {
+        this.logFile = logFile;
+    }
+}

Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LogImpl.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -89,25 +89,8 @@
 
     private void setupDefaultLog(String name)
     {
-        String defaultLog = "false";
-
-        try {
-            defaultLog = commonPropertyManager.getPropertyManager().getProperty(DefaultLog.LOG_ENABLED_PROPERTY, null);
-            // if the property manager has no info set, use the system property
-            // and if this isn't set either, default to false.
-            if (defaultLog == null) {
-                defaultLog = System.getProperty(DefaultLog.LOG_ENABLED_PROPERTY, "false");
-            }
-        }
-        catch (Throwable t)
+        if (commonPropertyManager.getLoggingEnvironmentBean().isUseDefaultLog())
         {
-            // an exception could occur when trying to read system properties when we run in an applet
-            // sandbox. therefore, ignore the trowable and just keep with the default settings above.
-
-        }
-
-        if (defaultLog.equals("true"))
-        {
             m_defaultLog = new DefaultLog(name);
             defaultLogSet = true;
         }

Added: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java	                        (rev 0)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/LoggingEnvironmentBean.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.arjuna.common.internal.util.logging;
+
+import com.arjuna.common.internal.util.propertyservice.PropertyPrefix;
+import com.arjuna.common.internal.util.propertyservice.FullPropertyName;
+
+/**
+ * A JavaBean containing configuration properties for the logging system.
+ *
+ * @author Jonathan Halliday (jonathan.halliday at redhat.com)
+ */
+ at PropertyPrefix(prefix = "com.arjuna.common.util.logging.")
+public class LoggingEnvironmentBean
+{
+    // don't mess with language and country defaults unless
+    // you also change the way logging bundles are built.
+    private String language = "en";
+    private String country = "US";
+
+    @FullPropertyName(name = "com.arjuna.common.util.logging.default")
+    private boolean useDefaultLog = false;
+
+    @FullPropertyName(name = "com.arjuna.common.util.logger")
+    private String loggingSystem = "log4j";
+
+    @FullPropertyName(name = "com.arjuna.common.util.logging.DebugLevel")
+    private String debugLevel = "0xffffffff";
+
+    @FullPropertyName(name = "com.arjuna.common.util.logging.FacilityLevel")
+    private String facilityLevel = "0xffffffff";
+
+    @FullPropertyName(name = "com.arjuna.common.util.logging.VisibilityLevel")
+    private String visibilityLevel = "0xffffffff";
+
+
+    public String getLanguage()
+    {
+        return language;
+    }
+
+    public void setLanguage(String language)
+    {
+        this.language = language;
+    }
+
+    public String getCountry()
+    {
+        return country;
+    }
+
+    public void setCountry(String country)
+    {
+        this.country = country;
+    }
+
+    public boolean isUseDefaultLog()
+    {
+        return useDefaultLog;
+    }
+
+    public void setUseDefaultLog(boolean useDefaultLog)
+    {
+        this.useDefaultLog = useDefaultLog;
+    }
+
+    public String getLoggingSystem()
+    {
+        return loggingSystem;
+    }
+
+    public void setLoggingSystem(String loggingSystem)
+    {
+        this.loggingSystem = loggingSystem;
+    }
+
+    public String getDebugLevel()
+    {
+        return debugLevel;
+    }
+
+    public void setDebugLevel(String debugLevel)
+    {
+        this.debugLevel = debugLevel;
+    }
+
+    public String getFacilityLevel()
+    {
+        return facilityLevel;
+    }
+
+    public void setFacilityLevel(String facilityLevel)
+    {
+        this.facilityLevel = facilityLevel;
+    }
+
+    public String getVisibilityLevel()
+    {
+        return visibilityLevel;
+    }
+
+    public void setVisibilityLevel(String visibilityLevel)
+    {
+        this.visibilityLevel = visibilityLevel;
+    }
+}

Modified: labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java
===================================================================
--- labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/internal/util/logging/commonPropertyManager.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -35,11 +35,58 @@
 
 import com.arjuna.common.util.propertyservice.PropertyManager;
 import com.arjuna.common.util.propertyservice.PropertyManagerFactory;
+import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
 
+import java.util.concurrent.atomic.AtomicBoolean;
+
 public class commonPropertyManager
 {
+    /**
+     * @deprecated use LoggingEnvironmentBean instead
+     * @return
+     */
+    @Deprecated
     public static PropertyManager getPropertyManager()
     {
         return PropertyManagerFactory.getPropertyManagerForModule("common", "com.arjuna.common.util.logging.propertiesFile");
     }
+
+    public static LoggingEnvironmentBean getLoggingEnvironmentBean()
+    {
+        synchronized (loggingEnvironmentBeanInit) {
+            if(!loggingEnvironmentBeanInit.get()) {
+                try {
+                    BeanPopulator.configureFromPropertyManager(loggingEnvironmentBean,  getPropertyManager());
+                    loggingEnvironmentBeanInit.set(true);
+                } catch(Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+
+        return loggingEnvironmentBean;
+    }
+
+    private static final AtomicBoolean loggingEnvironmentBeanInit = new AtomicBoolean(false);
+    private static final LoggingEnvironmentBean loggingEnvironmentBean = new LoggingEnvironmentBean();
+
+
+    public static DefaultLogEnvironmentBean getDefaultLogEnvironmentBean()
+    {
+        synchronized (defaultLogEnvironmentBeanInit) {
+            if(!defaultLogEnvironmentBeanInit.get()) {
+                try {
+                    BeanPopulator.configureFromPropertyManager(defaultLogEnvironmentBean,  getPropertyManager());
+                    defaultLogEnvironmentBeanInit.set(true);
+                } catch(Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+
+        return defaultLogEnvironmentBean;
+    }
+
+    private static final AtomicBoolean defaultLogEnvironmentBeanInit = new AtomicBoolean(false);
+    private static final DefaultLogEnvironmentBean defaultLogEnvironmentBean = new DefaultLogEnvironmentBean();
 }

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-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -286,11 +286,11 @@
             try
             {
                 // find out which log subsystem to use; by default log4j:
-                logSystem = commonPropertyManager.getPropertyManager().getProperty(LOGGER_PROPERTY, "log4j");
+                logSystem = commonPropertyManager.getLoggingEnvironmentBean().getLoggingSystem();
 
-                debugLevel = commonPropertyManager.getPropertyManager().getProperty(DEBUG_LEVEL, "0xffffffff");
-                facLevel = commonPropertyManager.getPropertyManager().getProperty(FACILITY_LEVEL, "0xfffffff");
-                visLevel = commonPropertyManager.getPropertyManager().getProperty(VISIBILITY_LEVEL, "0xfffffff");
+                debugLevel = commonPropertyManager.getLoggingEnvironmentBean().getDebugLevel();
+                facLevel = commonPropertyManager.getLoggingEnvironmentBean().getFacilityLevel();
+                visLevel = commonPropertyManager.getLoggingEnvironmentBean().getVisibilityLevel();
             }
             catch (Throwable t)
             {

Added: labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/common/tests/com/arjuna/common/tests/simple/BeanPopulatorTest.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -0,0 +1,62 @@
+package com.arjuna.common.tests.simple;
+
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+import com.arjuna.common.internal.util.propertyservice.BeanPopulator;
+import com.arjuna.common.internal.util.logging.LoggingEnvironmentBean;
+import com.arjuna.common.internal.util.logging.DefaultLogEnvironmentBean;
+
+import java.util.Set;
+import java.util.HashSet;
+
+public class BeanPopulatorTest
+{
+    @Test
+    public void testLoggingPropertiesPopulation() throws Exception {
+
+        // check that all the Environment properties are looked for
+        // by the set of beans which wrap them and conversely that no undefined
+        // properties are looked for. i.e. that the Environment and Beans are in sync
+
+        DummyPropertyManager testManager = new DummyPropertyManager(null);
+
+        BeanPopulator.configureFromPropertyManager(new LoggingEnvironmentBean(), testManager);
+
+        Set<String> expectedKeys = new HashSet<String>();
+
+        expectedKeys.add("com.arjuna.common.util.logging.language");
+        expectedKeys.add("com.arjuna.common.util.logging.country");
+        expectedKeys.add("com.arjuna.common.util.logging.default");
+        expectedKeys.add("com.arjuna.common.util.logger");
+        expectedKeys.add("com.arjuna.common.util.logging.DebugLevel");
+        expectedKeys.add("com.arjuna.common.util.logging.FacilityLevel");
+        expectedKeys.add("com.arjuna.common.util.logging.VisibilityLevel");
+
+        System.out.println("expected: "+expectedKeys);
+        System.out.println("used: "+testManager.usedKeys);
+
+        assertTrue( testManager.usedKeys.containsAll(expectedKeys) );
+    }
+
+    @Test
+    public void testDefaultLogPropertiesPopulation() throws Exception {
+
+        DummyPropertyManager testManager = new DummyPropertyManager(null);
+
+        BeanPopulator.configureFromPropertyManager(new DefaultLogEnvironmentBean(), testManager);
+
+        Set<String> expectedKeys = new HashSet<String>();
+
+        expectedKeys.add("com.arjuna.common.util.logging.default.showLogName");
+        expectedKeys.add("com.arjuna.common.util.logging.default.showShortLogName");
+        expectedKeys.add("com.arjuna.common.util.logging.default.showDate");
+        expectedKeys.add("com.arjuna.common.util.logging.default.logFileAppend");
+        expectedKeys.add("com.arjuna.common.util.logging.default.defaultLevel");
+        expectedKeys.add("com.arjuna.common.util.logging.default.logFile");
+
+        System.out.println("expected: "+expectedKeys);
+        System.out.println("used: "+testManager.usedKeys);
+
+        assertTrue( testManager.usedKeys.containsAll(expectedKeys) );
+    }
+}
\ No newline at end of file

Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/debugextension/DebugExt.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -38,7 +38,7 @@
 		PrintStream originalStream = System.out;
 
 		// TODO: how to configure this on a per-test (not per-JVM) basis?
-		commonPropertyManager.getPropertyManager().setProperty(LogFactory.LOGGER_PROPERTY, "log4j");
+		commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j");
 
 		System.setOut(bufferedStream);
 		writeLogMessages();

Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/i18n/logi18n.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -42,7 +42,7 @@
 		PrintStream originalStream = System.out;
 
 		// TODO: how to configure this on a per-test (not per-JVM) basis?
-		commonPropertyManager.getPropertyManager().setProperty(LogFactory.LOGGER_PROPERTY, "log4j");
+        commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j");		
 
 		System.setOut(bufferedStream);
 		writeLogMessages();

Modified: labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java
===================================================================
--- labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java	2009-08-19 13:32:03 UTC (rev 28989)
+++ labs/jbosstm/trunk/common/tests/com/hp/mwtests/commonlogging/testlevels/TestLevels.java	2009-08-19 16:15:57 UTC (rev 28990)
@@ -73,7 +73,7 @@
 
 		// test the releveling for AS integration:
 		// TODO: how to configure this on a per-test (not per-JVM) basis?
-		commonPropertyManager.getPropertyManager().setProperty(LogFactory.LOGGER_PROPERTY, "log4j_releveler");
+        commonPropertyManager.getLoggingEnvironmentBean().setLoggingSystem("log4j_releveler");
 
 		System.setOut(bufferedStream);
 		writeLogMessages();



More information about the jboss-svn-commits mailing list