[jboss-svn-commits] JBL Code SVN: r30967 - in labs/jbosstm/trunk: ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 7 06:28:15 EST 2010
Author: jhalliday
Date: 2010-01-07 06:28:14 -0500 (Thu, 07 Jan 2010)
New Revision: 30967
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/ArjunaJTA/jdbc/classes/com/arjuna/ats/jdbc/logging/jdbcLogger.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/logging/jtaLogger.java
labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jtaxLogger.java
labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/logging/jtsLogger.java
labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java
labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/logging/jbossatxLogger.java
labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java
Log:
refactor per-module logger initialization code to reduce duplication. JBTM-680
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 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/tsLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -44,54 +44,14 @@
public static LogNoi18n arjLogger;
public static Logi18n arjLoggerI18N;
- private static ResourceBundle log_mesg;
-
- private static String language;
- private static String country;
- private static Locale currentLocale;
- private static String dirLocale;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ arjLogger = noi18n;
+ arjLoggerI18N = i18n;
+ }
- static
- {
- arjLogger = LogFactory.getLogNoi18n("com.arjuna.ats.arjuna.logging.arjLogger");
-
- language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
- country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
-
- currentLocale = new Locale(language, country);
-
- try
- {
- log_mesg = ResourceBundle.getBundle("arjuna_msg", currentLocale);
- }
- catch (Throwable ex)
- {
- log_mesg = null;
- }
-
- // the default
-
- if (log_mesg == null)
- {
- currentLocale = new Locale("en", "US");
-
- log_mesg = ResourceBundle.getBundle("arjuna_msg", currentLocale);
- }
-
- try
- {
- arjLoggerI18N = LogFactory.getLogi18n("com.arjuna.ats.arjuna.logging.arjLoggerI18N", "arjuna_msg_"
- + language + "_" + country);
- }
- catch (Throwable ex)
- {
- arjLoggerI18N = null;
- }
-
- // the default
-
- if (arjLoggerI18N == null)
- arjLoggerI18N = LogFactory.getLogi18n("com.arjuna.ats.arjuna.logging.arjLoggerI18N", "arjuna_msg_en_US");
- }
-
+ static
+ {
+ LogFactory.initializeModuleLogger(tsLogger.class, "arjuna_msg", "com.arjuna.ats.arjuna");
+ }
}
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 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaCore/tsmx/classes/com/arjuna/ats/tsmx/logging/tsmxLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -45,49 +45,14 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle log_mesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String language;
- private static String country;
- private static Locale currentLocale;
-
- static
- {
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.tsmx.logging.tsmxLogger");
-
- language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
- country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
-
- currentLocale = new Locale(language, country);
-
- try
- {
- log_mesg = ResourceBundle.getBundle("arjuna_msg", currentLocale);
- }
- catch (Throwable ex)
- {
- log_mesg = null;
- }
-
- if (log_mesg == null)
- {
- currentLocale = new Locale("en", "US");
-
- log_mesg = ResourceBundle.getBundle("arjuna_msg", currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.tsmx.logging.tsmxLoggerI18N", "tsmx_msg_"
- + language + "_" + country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.tsmx.logging.tsmxLoggerI18N", "tsmx_msg_en_US");
- }
-
+ static
+ {
+ LogFactory.initializeModuleLogger(tsmxLogger.class, "tsmx_msg", "com.arjuna.ats.tsmx");
+ }
}
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 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/logging/txojLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -34,50 +34,14 @@
public static LogNoi18n aitLogger;
public static Logi18n aitLoggerI18N;
- private static ResourceBundle log_mesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ aitLogger = noi18n;
+ aitLoggerI18N = i18n;
+ }
- private static String language;
- private static String country;
- private static Locale currentLocale;
-
- static
- {
- aitLogger = LogFactory.getLogNoi18n("com.arjuna.ats.txoj.logging.txojLogger");
-
- language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
-
- country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
-
- currentLocale = new Locale(language, country);
-
- try
- {
- log_mesg = ResourceBundle.getBundle("txoj_msg", currentLocale);
- }
- catch (Throwable ex)
- {
- log_mesg = null;
- }
-
- if (log_mesg == null)
- {
- currentLocale = new Locale("en", "US");
-
- log_mesg = ResourceBundle.getBundle("txoj_msg", currentLocale);
- }
-
- try
- {
- aitLoggerI18N = LogFactory.getLogi18n("com.arjuna.ats.txoj.logging.txojLoggerI18N", "txoj_msg_"
- + language + "_" + country);
- }
- catch (Throwable ex)
- {
- aitLoggerI18N = null;
- }
-
- if (aitLoggerI18N == null)
- aitLoggerI18N = LogFactory.getLogi18n("com.arjuna.ats.txoj.logging.txojLoggerI18N", "txoj_msg_en_US");
- }
-
+ static
+ {
+ LogFactory.initializeModuleLogger(txojLogger.class, "txoj_msg", "com.arjuna.ats.txoj");
+ }
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/jdbc/logging/jdbcLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/jdbc/logging/jdbcLogger.java 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/jdbc/logging/jdbcLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -43,50 +43,14 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
-
static
{
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.jdbc.logging.logger");
-
- _language = System.getProperty("language","en");
- _country = System.getProperty("country","US");
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("jdbc_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("jdbc_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jdbc.logging.loggerI18N", "jdbc_msg_"+_language+"_"+_country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jdbc.logging.loggerI18N", "jdbc_msg_en_US");
+ LogFactory.initializeModuleLogger(jdbcLogger.class, "jdbc_msg", "com.arjuna.ats.jdbc");
}
}
-
-
-
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/logging/jtaLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/logging/jtaLogger.java 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/logging/jtaLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -44,51 +44,18 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
-
static
{
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.jta.logging.logger");
-
- _language = System.getProperty("language","en");
- _country = System.getProperty("country","US");
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("jta_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("jta_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jta.logging.loggerI18N", "jta_msg_"+_language+"_"+_country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jta.logging.loggerI18N", "jta_msg_en_US");
+ LogFactory.initializeModuleLogger(jtaLogger.class, "jta_msg", "com.arjuna.ats.jta");
}
-
}
+
Modified: labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jtaxLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jtaxLogger.java 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaJTS/jtax/classes/com/arjuna/ats/internal/jta/utils/jtaxLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -36,47 +36,14 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
-
static
{
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.jtax.logging.logger");
-
- _language = System.getProperty("language","en");
- _country = System.getProperty("country","US");
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("jtax_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("jtax_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jtax.logging.loggerI18N", "jtax_msg_"+_language+"_"+_country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jtax.logging.loggerI18N", "jtax_msg_en_US");
+ LogFactory.initializeModuleLogger(jtaxLogger.class, "jtax_msg", "com.arjuna.ats.jtax");
}
}
Modified: labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/logging/jtsLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/logging/jtsLogger.java 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaJTS/jts/classes/com/arjuna/ats/jts/logging/jtsLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -44,51 +44,14 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
-
static
{
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.jts.logging.logger");
-
- _language = System.getProperty("language","en");
- _country = System.getProperty("country","US");
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("jts_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("jts_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jts.logging.loggerI18N", "jts_msg_"+_language+"_"+_country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jts.logging.loggerI18N", "jts_msg_en_US");
+ LogFactory.initializeModuleLogger(jtsLogger.class, "jts_msg", "com.arjuna.ats.jts");
}
-
-}
-
-
-
+}
\ No newline at end of file
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 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/ArjunaJTS/orbportability/classes/com/arjuna/orbportability/logging/opLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -35,50 +35,14 @@
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
-
- static
- {
- logger = LogFactory.getLogNoi18n("com.arjuna.orbportability.logging.logger");
-
- _language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
-
- _country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("orbportability_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("orbportability_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.orbportability.logging.loggerI18N", "orbportability_msg_"
- + _language + "_" + _country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.orbportability.logging.loggerI18N", "orbportability_msg_en_US");
- }
-
+ static
+ {
+ LogFactory.initializeModuleLogger(opLogger.class, "orbportability_msg", "com.arjuna.orbportability");
+ }
}
Modified: labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/logging/jbossatxLogger.java
===================================================================
--- labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/logging/jbossatxLogger.java 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/atsintegration/classes/com/arjuna/ats/jbossatx/logging/jbossatxLogger.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -41,50 +41,15 @@
{
public static LogNoi18n logger;
public static Logi18n loggerI18N;
- private static ResourceBundle logMesg;
- private static String _language;
- private static String _country;
- private static Locale _currentLocale;
+ public static void initialize(LogNoi18n noi18n, Logi18n i18n)
+ {
+ logger = noi18n;
+ loggerI18N = i18n;
+ }
static
{
- logger = LogFactory.getLogNoi18n("com.arjuna.ats.jbossatx.logging.logger");
-
- _language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
- _country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
-
- _currentLocale = new Locale(_language, _country);
-
- try
- {
- logMesg = ResourceBundle.getBundle("jbossatx_msg", _currentLocale);
- }
- catch (Throwable ex)
- {
- logMesg = null;
- }
-
- if (logMesg == null)
- {
- _currentLocale = new Locale("en", "US");
-
- logMesg = ResourceBundle.getBundle("jbossatx_msg", _currentLocale);
- }
-
- try
- {
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jbossatx.logging.loggerI18N", "jbossatx_msg_"+_language+"_"+_country);
- }
- catch (Throwable ex)
- {
- loggerI18N = null;
- }
-
- if (loggerI18N == null)
- loggerI18N = LogFactory.getLogi18n("com.arjuna.ats.jbossatx.logging.loggerI18N", "jbossatx_msg_en_US");
+ LogFactory.initializeModuleLogger(jbossatxLogger.class, "jbossatx_msg", "com.arjuna.ats.jbossatx");
}
}
-
-
-
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 2010-01-07 09:23:57 UTC (rev 30966)
+++ labs/jbosstm/trunk/common/classes/com/arjuna/common/util/logging/LogFactory.java 2010-01-07 11:28:14 UTC (rev 30967)
@@ -32,6 +32,9 @@
import com.arjuna.common.util.exceptions.LogConfigurationException;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.util.Locale;
+import java.util.ResourceBundle;
/**
* Factory for {@link Logi18n} and {@link LogNoi18n} objects.
@@ -93,6 +96,32 @@
*/
private static long m_facLevel = FacilityCode.FAC_ALL;
+ public static void initializeModuleLogger(Class moduleLogger, String bundleName, String name) {
+
+ LogNoi18n logger = getLogNoi18n(name);
+
+ String _language = commonPropertyManager.getLoggingEnvironmentBean().getLanguage();
+ String _country = commonPropertyManager.getLoggingEnvironmentBean().getCountry();
+
+ Logi18n loggerI18N;
+ try
+ {
+ loggerI18N = getLogi18n(name, bundleName+"_"+_language+"_"+_country);
+ }
+ catch (Throwable ex)
+ {
+ loggerI18N = getLogi18n(name, bundleName+"_en_US");
+ }
+
+ try {
+ Method initializer = moduleLogger.getMethod("initialize", new Class[] {LogNoi18n.class, Logi18n.class});
+ initializer.invoke(null, new Object[] {logger, loggerI18N});
+ } catch(Exception e) {
+ throw new RuntimeException("An unexpected exception occurred while initializing the logger: " + e.getMessage(), e);
+ }
+ }
+
+
/**
* Convenience method to return a named logger, without the application
* having to care about factories.
More information about the jboss-svn-commits
mailing list