You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2007/08/05 07:26:23 UTC

svn commit: r562831 - in /openejb/trunk/openejb3/container/openejb-core: ./ src/main/java/org/apache/openejb/ src/main/java/org/apache/openejb/config/ src/main/java/org/apache/openejb/util/ src/main/resources/

Author: dblevins
Date: Sat Aug  4 22:26:22 2007
New Revision: 562831

URL: http://svn.apache.org/viewvc?view=rev&rev=562831
Log:
Patch from Karan Singh Malhi, OPENEJB-601: broken logging
Actually a great new feature of heirarchical logging and better i18n capabilities.
Thanks, Karan!

Added:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java
Modified:
    openejb/trunk/openejb3/container/openejb-core/pom.xml
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEJBErrorHandler.java
    openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.logging.conf

Modified: openejb/trunk/openejb3/container/openejb-core/pom.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/pom.xml?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/pom.xml Sat Aug  4 22:26:22 2007
@@ -79,7 +79,7 @@
             </property>
             <property>
               <name>log4j.configuration</name>
-              <value>${basedir}/target/classes/default.logging.conf</value>
+              <value>file:///${basedir}/target/classes/default.logging.conf</value>
             </property>
           </systemProperties>
           <!--

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java Sat Aug  4 22:26:22 2007
@@ -92,7 +92,7 @@
             }
 
             Logger logger2 = Logger.getInstance("OpenEJB", "org.apache.openejb.util.resources");
-            logger2.i18n.info("startup.banner", versionInfo.getUrl(), new Date(), versionInfo.getCopyright(),
+            logger2.info("startup.banner", versionInfo.getUrl(), new Date(), versionInfo.getCopyright(),
                     versionInfo.getVersion(), versionInfo.getDate(), versionInfo.getTime());
 
             logger.info("openejb.home = " + SystemInstance.get().getHome().getDirectory().getAbsolutePath());
@@ -101,7 +101,7 @@
             Properties props = new Properties(SystemInstance.get().getProperties());
 
             if (initProps == null) {
-                logger.i18n.debug("startup.noInitializationProperties");
+                logger.debug("startup.noInitializationProperties");
             } else {
                 props.putAll(initProps);
             }
@@ -114,20 +114,20 @@
             if (className == null) {
                 className = props.getProperty("openejb.assembler", "org.apache.openejb.assembler.classic.Assembler");
             } else {
-                logger.i18n.warning("startup.deprecatedPropertyName", EnvProps.ASSEMBLER);
+                logger.warning("startup.deprecatedPropertyName", EnvProps.ASSEMBLER);
             }
 
-            logger.i18n.debug("startup.instantiatingAssemberClass", className);
+            logger.debug("startup.instantiatingAssemberClass", className);
             Assembler assembler = null;
 
             try {
                 assembler = (Assembler) toolkit.newInstance(className);
             } catch (OpenEJBException oe) {
-                logger.i18n.fatal("startup.assemblerCannotBeInstanitated", oe);
+                logger.fatal("startup.assemblerCannotBeInstanitated", oe);
                 throw oe;
             } catch (Throwable t) {
                 String msg = messages.message("startup.openEjbEncounterUnexpectedError");
-                logger.i18n.fatal(msg, t);
+                logger.fatal(msg, t);
                 throw new OpenEJBException(msg, t);
             }
 
@@ -136,22 +136,22 @@
             try {
                 assembler.init(props);
             } catch (OpenEJBException oe) {
-                logger.i18n.fatal("startup.assemblerFailedToInitialize", oe);
+                logger.fatal("startup.assemblerFailedToInitialize", oe);
                 throw oe;
             } catch (Throwable t) {
                 String msg = messages.message("startup.assemblerEncounterUnexpectedError");
-                logger.i18n.fatal(msg, t);
+                logger.fatal(msg, t);
                 throw new OpenEJBException(msg, t);
             }
 
             try {
                 assembler.build();
             } catch (OpenEJBException oe) {
-                logger.i18n.fatal("startup.assemblerFailedToBuild", oe);
+                logger.fatal("startup.assemblerFailedToBuild", oe);
                 throw oe;
             } catch (Throwable t) {
                 String msg = messages.message("startup.assemblerEncounterUnexpectedBuildError");
-                logger.i18n.fatal(msg, t);
+                logger.fatal(msg, t);
                 throw new OpenEJBException(msg, t);
             }
 
@@ -159,18 +159,18 @@
 
             if (containerSystem == null) {
                 String msg = messages.message("startup.assemblerReturnedNullContainer");
-                logger.i18n.fatal(msg);
+                logger.fatal(msg);
                 throw new OpenEJBException(msg);
             }
 
             system.setComponent(ContainerSystem.class, containerSystem);
 
             if (logger.isDebugEnabled()) {
-                logger.i18n.debug("startup.debugContainers", containerSystem.containers().length);
+                logger.debug("startup.debugContainers", containerSystem.containers().length);
 
                 if (containerSystem.containers().length > 0) {
                     Container[] c = containerSystem.containers();
-                    logger.i18n.debug("startup.debugContainersType");
+                    logger.debug("startup.debugContainersType");
                     for (int i = 0; i < c.length; i++) {
                         String entry = "   ";
                         switch (c[i].getContainerType()) {
@@ -191,13 +191,13 @@
                                 break;
                         }
                         entry += c[i].getContainerID();
-                        logger.i18n.debug("startup.debugEntry", entry);
+                        logger.debug("startup.debugEntry", entry);
                     }
                 }
 
-                logger.i18n.debug("startup.debugDeployments", containerSystem.deployments().length);
+                logger.debug("startup.debugDeployments", containerSystem.deployments().length);
                 if (containerSystem.deployments().length > 0) {
-                    logger.i18n.debug("startup.debugDeploymentsType");
+                    logger.debug("startup.debugDeploymentsType");
                     DeploymentInfo[] d = containerSystem.deployments();
                     for (int i = 0; i < d.length; i++) {
                         String entry = "   ";
@@ -219,7 +219,7 @@
                                 break;
                         }
                         entry += d[i].getDeploymentID();
-                        logger.i18n.debug("startup.debugEntry", entry);
+                        logger.debug("startup.debugEntry", entry);
                     }
                 }
             }
@@ -227,24 +227,24 @@
             SecurityService securityService = assembler.getSecurityService();
             if (securityService == null) {
                 String msg = messages.message("startup.assemblerReturnedNullSecurityService");
-                logger.i18n.fatal(msg);
+                logger.fatal(msg);
                 throw new OpenEJBException(msg);
             } else {
-                logger.i18n.debug("startup.securityService", securityService.getClass().getName());
+                logger.debug("startup.securityService", securityService.getClass().getName());
             }
             system.setComponent(SecurityService.class, securityService);
 
             TransactionManager transactionManager = assembler.getTransactionManager();
             if (transactionManager == null) {
                 String msg = messages.message("startup.assemblerReturnedNullTransactionManager");
-                logger.i18n.fatal(msg);
+                logger.fatal(msg);
                 throw new OpenEJBException(msg);
             } else {
-                logger.i18n.debug("startup.transactionManager", transactionManager.getClass().getName());
+                logger.debug("startup.transactionManager", transactionManager.getClass().getName());
             }
             SystemInstance.get().setComponent(TransactionManager.class, transactionManager);
 
-            logger.i18n.info("startup.ready");
+            logger.info("startup.ready");
 
             String loader = initProps.getProperty("openejb.loader");
             String nobanner = initProps.getProperty("openejb.nobanner");
@@ -275,7 +275,7 @@
     public static void init(Properties initProps, ApplicationServer appServer) throws OpenEJBException {
         if (isInitialized()) {
             String msg = messages.message("startup.alreadyInitialized");
-            logger.i18n.error(msg);
+            logger.error(msg);
             throw new OpenEJBException(msg);
         } else {
             instance = new Instance(initProps, appServer);

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java Sat Aug  4 22:26:22 2007
@@ -330,7 +330,7 @@
                 appInfo.ejbJars.add(ejbJarInfo);
 
             } catch (OpenEJBException e) {
-                ConfigUtils.logger.i18n.warning("conf.0004", ejbModule.getJarURI(), e.getMessage());
+                ConfigUtils.logger.warning("conf.0004", ejbModule.getJarURI(), e.getMessage());
                 throw e;
             }
         }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbJarInfoBuilder.java Sat Aug  4 22:26:22 2007
@@ -109,7 +109,7 @@
             Map<String, EjbDeployment> deployed = jar.getOpenejbJar().getDeploymentsByEjbName();
             for (EnterpriseBean bean : jar.getEjbJar().getEnterpriseBeans()) {
                 if (!deployed.containsKey(bean.getEjbName())){
-                    ConfigUtils.logger.i18n.warning("conf.0018", bean.getEjbName(), jar.getJarURI());
+                    ConfigUtils.logger.warning("conf.0018", bean.getEjbName(), jar.getJarURI());
                 }
             }
             String message = messages.format("conf.0008", jar.getJarURI(), "" + beansInEjbJar, "" + beansDeployed);
@@ -328,7 +328,7 @@
             info.roleName = sr.getRoleName();
 
             if (securityRoles.contains(sr.getRoleName())) {
-                ConfigUtils.logger.i18n.warning("conf.0102", jar.getJarURI(), sr.getRoleName());
+                ConfigUtils.logger.warning("conf.0102", jar.getJarURI(), sr.getRoleName());
             } else {
                 securityRoles.add(sr.getRoleName());
             }

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java?view=auto&rev=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Computable.java Sat Aug  4 22:26:22 2007
@@ -0,0 +1,21 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.util;
+
+public interface Computable<K, V> {
+ V compute(K key) throws InterruptedException;
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java Sat Aug  4 22:26:22 2007
@@ -16,15 +16,6 @@
  */
 package org.apache.openejb.util;
 
-import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.loader.FileUtils;
-import org.apache.xbean.finder.ResourceFinder;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.SimpleLayout;
-
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -33,769 +24,590 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.MissingResourceException;
 import java.util.Properties;
+import java.util.ResourceBundle;
+
+import org.apache.log4j.Appender;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.SimpleLayout;
+import org.apache.openejb.loader.FileUtils;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.xbean.finder.ResourceFinder;
 
 public class Logger {
 
-    protected static final HashMap _loggers = new HashMap();
-    protected Category _logger = null;
-    public I18N i18n = null;
-
-    /**
-     * @deprecated Use {@link #init()} instead
-     */
-    public static void initialize(Properties props) {
-        Log4jConfigUtils log4j = new Logger.Log4jConfigUtils(props);
-
-        log4j.configure();
-    }
-
-    /**
-     * Initialise using {@link SystemInstance} as the source of properties
-     */
-    public static void init() {
-        initialize(SystemInstance.get().getProperties());
-    }
-
-    static public Logger getInstance(String category, String resourceName) {
-        HashMap bundles = (HashMap) _loggers.get(category);
-        Logger logger = null;
-
-        if (bundles == null) {
-            synchronized (Logger.class) {
-                bundles = (HashMap) _loggers.get(category);
-                if (bundles == null) {
-                    bundles = new HashMap();
-                    _loggers.put(category, bundles);
-                }
-            }
-        }
-
-        logger = (Logger) bundles.get(resourceName);
-        if (logger == null) {
-            synchronized (Logger.class) {
-                logger = (Logger) bundles.get(resourceName);
-                if (logger == null) {
-                    logger = new Logger(resourceName);
-                    logger._logger = Category.getInstance(category);
-
-                    bundles.put(resourceName, logger);
-                }
-            }
-        }
-
-        return logger;
-    }
-
-    protected Logger(String resourceName) {
-        i18n = new I18N(resourceName);
-    }
-
-    public boolean isDebugEnabled() {
-        return _logger.isDebugEnabled();
-    }
-
-    public boolean isErrorEnabled() {
-        return _logger.isEnabledFor(Level.ERROR);
-    }
-
-    public boolean isFatalEnabled() {
-        return _logger.isEnabledFor(Level.FATAL);
-    }
-
-    public boolean isInfoEnabled() {
-        return _logger.isInfoEnabled();
-    }
-
-    public boolean isWarningEnabled() {
-        return _logger.isEnabledFor(Level.WARN);
-    }
-
-    public void debug(String message) {
-        if (isDebugEnabled()) _logger.debug(message);
-    }
-
-    public void debug(String message, Throwable t) {
-        if (isDebugEnabled()) _logger.debug(message, t);
-    }
-
-    public void error(String message) {
-        if (isErrorEnabled()) _logger.error(message);
-    }
-
-    public void error(String message, Throwable t) {
-        if (isErrorEnabled()) _logger.error(message, t);
-    }
-
-    public void fatal(String message) {
-        if (isFatalEnabled()) _logger.fatal(message);
-    }
-
-    public void fatal(String message, Throwable t) {
-        if (isFatalEnabled()) _logger.fatal(message, t);
-    }
-
-    public void info(String message) {
-        if (isInfoEnabled()) _logger.info(message);
-    }
-
-    public void info(String message, Throwable t) {
-        if (isInfoEnabled()) _logger.info(message, t);
-    }
-
-    public void warning(String message) {
-        if (isWarningEnabled()) _logger.warn(message);
-    }
-
-    public void warning(String message, Throwable t) {
-        if (isWarningEnabled()) _logger.warn(message, t);
-    }
-
-    public class I18N {
-
-        protected Messages _messages = null;
-
-        protected I18N(String resourceName) {
-            _messages = new Messages(resourceName);
-        }
-
-        public void info(String code) {
-            if (isInfoEnabled()) _logger.info(_messages.message(code));
-        }
-
-        public void info(String code, Throwable t) {
-            if (isInfoEnabled()) _logger.info(_messages.message(code), t);
-        }
-
-        public void info(String code, Object arg0) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object arg0, Object arg1) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0, Object arg1) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object arg0, Object arg1, Object arg2) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0, Object arg1, Object arg2) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                info(code, args);
-            }
-        }
-
-        public void info(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isInfoEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                info(code, t, args);
-            }
-        }
-
-        public void info(String code, Object[] args) {
-            _logger.info(_messages.format(code, args));
-        }
-
-        public void info(String code, Throwable t, Object[] args) {
-            _logger.info(_messages.format(code, args), t);
-        }
-
-        public void warning(String code) {
-            if (isWarningEnabled()) _logger.warn(_messages.message(code));
-        }
-
-        public void warning(String code, Throwable t) {
-            if (isWarningEnabled()) _logger.warn(_messages.message(code), t);
-        }
-
-        public void warning(String code, Object arg0) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object arg0, Object arg1) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0, Object arg1) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object arg0, Object arg1, Object arg2) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0, Object arg1, Object arg2) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                warning(code, args);
-            }
-        }
-
-        public void warning(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isWarningEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                warning(code, t, args);
-            }
-        }
-
-        public void warning(String code, Object[] args) {
-            _logger.warn(_messages.format(code, args));
-        }
-
-        public void warning(String code, Throwable t, Object[] args) {
-            _logger.warn(_messages.format(code, args), t);
-        }
-
-        public void error(String code) {
-            if (isErrorEnabled()) _logger.error(_messages.message(code));
-        }
-
-        public void error(String code, Throwable t) {
-            if (isErrorEnabled()) _logger.error(_messages.message(code), t);
-        }
-
-        public void error(String code, Object arg0) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object arg0, Object arg1) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0, Object arg1) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object arg0, Object arg1, Object arg2) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0, Object arg1, Object arg2) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                error(code, args);
-            }
-        }
-
-        public void error(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isErrorEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                error(code, t, args);
-            }
-        }
-
-        public void error(String code, Object[] args) {
-            _logger.error(_messages.format(code, args));
-        }
-
-        public void error(String code, Throwable t, Object[] args) {
-            _logger.error(_messages.format(code, args), t);
-        }
-
-        public void fatal(String code) {
-            _logger.fatal(_messages.message(code));
-        }
-
-        public void fatal(String code, Throwable t) {
-            _logger.fatal(_messages.message(code), t);
-        }
-
-        public void fatal(String code, Object arg0) {
-            Object[] args = {arg0};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0) {
-            Object[] args = {arg0};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object arg0, Object arg1) {
-            Object[] args = {arg0, arg1};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0, Object arg1) {
-            Object[] args = {arg0, arg1};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object arg0, Object arg1, Object arg2) {
-            Object[] args = {arg0, arg1, arg2};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0, Object arg1, Object arg2) {
-            Object[] args = {arg0, arg1, arg2};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object arg0, Object arg1, Object arg2, Object arg3) {
-            Object[] args = {arg0, arg1, arg2, arg3};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3) {
-            Object[] args = {arg0, arg1, arg2, arg3};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            Object[] args = {arg0, arg1, arg2, arg3, arg4};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            Object[] args = {arg0, arg1, arg2, arg3, arg4};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-            fatal(code, args);
-        }
-
-        public void fatal(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-            fatal(code, t, args);
-        }
-
-        public void fatal(String code, Object[] args) {
-            _logger.fatal(_messages.format(code, args));
-        }
-
-        public void fatal(String code, Throwable t, Object[] args) {
-            _logger.fatal(_messages.format(code, args), t);
-        }
-
-        public void debug(String code) {
-            if (isDebugEnabled()) _logger.debug(_messages.message(code));
-        }
-
-        public void debug(String code, Throwable t) {
-            if (isDebugEnabled()) _logger.debug(_messages.message(code), t);
-        }
-
-        public void debug(String code, Object arg0) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object arg0, Object arg1) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0, Object arg1) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object arg0, Object arg1, Object arg2) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0, Object arg1, Object arg2) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                debug(code, args);
-            }
-        }
-
-        public void debug(String code, Throwable t, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {
-            if (isDebugEnabled()) {
-                Object[] args = {arg0, arg1, arg2, arg3, arg4, arg5};
-                debug(code, t, args);
-            }
-        }
-
-        public void debug(String code, Object[] args) {
-            _logger.debug(_messages.format(code, args));
-        }
-
-        public void debug(String code, Throwable t, Object[] args) {
-            _logger.debug(_messages.format(code, args), t);
-        }
-    }
-
-    static class Log4jConfigUtils {
-
-        Properties props;
-
-        public Log4jConfigUtils(Properties props) {
-            this.props = props;
-        }
-
-        public void configure() {
-            // make openjpa use log4j
-            System.setProperty("openjpa.Log", "log4j");
-
-            Properties properties = null;
-
-            String config = props.getProperty("log4j.configuration");
-            String[] search = {config, "logging.properties", "logging.conf"};
-
-            FileUtils base = SystemInstance.get().getBase();
-            File confDir = new File(base.getDirectory(), "conf");
-            File baseDir = base.getDirectory();
-            File userDir = new File("foo").getParentFile();
-
-            File[] paths = {confDir, baseDir, userDir};
-
-            for (int i = 0; i < search.length && properties == null; i++) {
-                String fileName = search[i];
-                if (fileName == null) {
-                    continue;
-                }
-
-                for (int j = 0; j < paths.length; j++) {
-                    File path = paths[j];
-
-                    File configFile = new File(path, fileName);
-
-                    if (configFile.exists()) {
-
-                        InputStream in = null;
-                        try {
-                            in = new FileInputStream(configFile);
-                            in = new BufferedInputStream(in);
-                            properties = new Properties();
-                            properties.load(in);
-                        } catch (IOException e) {
-                            org.apache.log4j.Logger logger = doFallbackConfiguration();
-                            logger.error("Unable to read logging config file " + configFile.getAbsolutePath(), e);
-                        } finally {
-                            try {
-                                in.close();
-                            } catch (IOException e) {
-                            }
-                        }
-                    }
-                }
-            }
-
-            if (properties == null) {
-                String configData = null;
-                try {
-                    ResourceFinder finder = new ResourceFinder("");
-                    configData = finder.findString("default.logging.conf");
-                    properties = new Properties();
-                    properties.load(new ByteArrayInputStream(configData.getBytes()));
-                } catch (IOException e) {
-                    org.apache.log4j.Logger logger = doFallbackConfiguration();
-                    logger.error("Unable to read default logging config file.", e);
-                    return;
-                }
-
-                if (confDir.exists()) {
-                    OutputStream out = null;
-                    File configFile = new File(confDir, "logging.properties");
-                    try {
-                        out = new FileOutputStream(configFile);
-                        out.write(configData.getBytes());
-                    } catch (IOException e) {
-                        org.apache.log4j.Logger logger = doFallbackConfiguration();
-                        logger.warn("Unable write default logging config file to " + configFile.getAbsolutePath(), e);
-                    } finally {
-                        try {
-                            out.close();
-                        } catch (IOException e) {
-                        }
-                    }
-                }
-            }
-
-
-            List missing = new ArrayList();
-
-            for (Iterator iterator = properties.entrySet().iterator(); iterator.hasNext();) {
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String key = (String) entry.getKey();
-                String value = (String) entry.getValue();
-
-
-                if (key.endsWith(".File")) {
-
-                    boolean found = false;
-                    for (int i = 0; i < paths.length && !found; i++) {
-                        File path = paths[i];
-                        File logfile = new File(path, value);
-                        if (logfile.getParentFile().exists()) {
-                            properties.setProperty(key, logfile.getAbsolutePath());
-                            found = true;
-                        }
-                    }
-
-                    if (!found) {
-                        File logfile = new File(paths[0], value);
-                        missing.add(logfile);
-                    }
-                }
-            }
-
-            if (missing.size() > 0) {
-                org.apache.log4j.Logger logger = doFallbackConfiguration();
-
-                logger.warn("Unable use logging config as there are "+missing.size()+" file references containing directories which have not been created.  See the list below.");
-                for (int i = 0; i < missing.size(); i++) {
-                    File file = (File) missing.get(i);
-                    logger.warn("["+i+"] "+file.getAbsolutePath());
-                }
-            } else {
-                PropertyConfigurator.configure(properties);
-            }
-
-        }
-
-        private org.apache.log4j.Logger doFallbackConfiguration() {
-            set("org.apache.activemq", Level.INFO);
-            set("openjpa", Level.WARN);
-            set("Transaction", Level.WARN);
-            set("OpenEJB.startup", Level.INFO);
-            set("OpenEJB.startup.config", Level.WARN);
-            set("OpenEJB", Level.WARN);
-
-            org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("OpenEJB");
-
-            SimpleLayout simpleLayout = new SimpleLayout();
-            ConsoleAppender newAppender = new ConsoleAppender(simpleLayout);
-            logger.addAppender(newAppender);
-            return logger;
-
-        }
-
-        private void set(String category, Level level) {
-            org.apache.log4j.Logger.getLogger(category).setLevel(level);
-//            Enumeration allAppenders = org.apache.log4j.Logger.getLogger(category).getAllAppenders();
-//            while (allAppenders.hasMoreElements()) {
-//                Object object = allAppenders.nextElement();
-//                System.out.println(category +" = " + object);
-//            }
-        }
+	protected org.apache.log4j.Logger _logger = null;
+
+	private String baseName;
+
+	private static final String SUFFIX = ".Messages";
 
+	private static final String OPENEJB = "org.apache.openejb";
+	/**
+	 * Computes the parent of a resource name. E.g. if we pass in a key of
+	 * a.b.c, it returns the value a.b
+	 * 
+	 */
+	private static final Computable<String, String> heirarchyResolver = new Computable<String, String>() {
+		public String compute(String key) throws InterruptedException {
+			int index = key.lastIndexOf(".");
+			String parent = key.substring(0, index);
+			if (parent.contains(OPENEJB))
+				return parent;
+			return null;
+		}
+	};
+	/**
+	 * Simply returns the ResourceBundle for a given baseName
+	 */
+	private static final Computable<String, ResourceBundle> bundleResolver = new Computable<String, ResourceBundle>() {
+		public ResourceBundle compute(String baseName)
+				throws InterruptedException {
+			try {
+				return ResourceBundle.getBundle(baseName + SUFFIX);
+			} catch (MissingResourceException e) {
+				return null;
+			}
+		}
+	};
+	/**
+	 * Builds a Logger object and returns it
+	 */
+	private static final Computable<String[], Logger> loggerResolver = new Computable<String[], Logger>() {
+		public Logger compute(String[] args) throws InterruptedException {
+
+			Logger logger = new Logger();
+			logger._logger = org.apache.log4j.Logger.getLogger(args[0]);
+			logger.baseName = args[1];
+			return logger;
+
+		}
+	};
+	/**
+	 * Creates a MessageFormat object for a message and returns it
+	 */
+	private static final Computable<String, MessageFormat> messageFormatResolver = new Computable<String, MessageFormat>() {
+		public MessageFormat compute(String message)
+				throws InterruptedException {
+
+			return new MessageFormat(message);
+
+		}
+	};
+	/**
+	 * Cache of parent-child relationships between resource names
+	 */
+	private static final Computable<String, String> heirarchyCache = new Memoizer<String, String>(
+			heirarchyResolver);
+	/**
+	 * Cache of ResourceBundles
+	 */
+	private static final Computable<String, ResourceBundle> bundleCache = new Memoizer<String, ResourceBundle>(
+			bundleResolver);
+	/**
+	 * Cache of Loggers
+	 */
+	private static final Computable<String[], Logger> loggerCache = new Memoizer<String[], Logger>(
+			loggerResolver);
+	/**
+	 * Cache of MessageFormats
+	 */
+	private static final Computable<String, MessageFormat> messageFormatCache = new Memoizer<String, MessageFormat>(
+			messageFormatResolver);
+
+	/**
+	 * Given a key and a baseName, this method computes a message for a key. if
+	 * the key is not found in this ResourceBundle for this baseName, then it
+	 * recursively looks up its parent to find the message for a key. If no
+	 * message is found for a key, the key is returned as is and is logged by
+	 * the logger.
+	 * 
+	 */
+	private String getMessage(String key, String baseName) {
+		try {
+
+			ResourceBundle bundle = bundleCache.compute(baseName);
+			if (bundle != null) {
+				String message = null;
+				try {
+					message = bundle.getString(key);
+					return message;
+				} catch (MissingResourceException e) {
+					String parentName = heirarchyCache.compute(baseName);
+					if (parentName == null)
+						return key;
+					else
+						return getMessage(key, parentName);
+				}
+
+			} else {
+				String parentName = heirarchyCache.compute(baseName);
+				if (parentName == null)
+					return key;
+				else
+					return getMessage(key, parentName);
+
+			}
+		} catch (InterruptedException e) {
+			// ignore
+		}
+		return key;
+	}
+
+	/**
+	 * @deprecated Use {@link #init()} instead
+	 */
+	public static void initialize(Properties props) {
+		Log4jConfigUtils log4j = new Logger.Log4jConfigUtils(props);
+
+		log4j.configure();
+	}
+
+	/**
+	 * Initialise using {@link SystemInstance} as the source of properties
+	 */
+	public static void init() {
+		initialize(SystemInstance.get().getProperties());
+	}
+/**
+ * Finds a Logger from the cache and returns it. If not found in cache then builds a Logger and returns it.
+ * @param name - The name of the logger
+ * @param baseName - The baseName for the ResourceBundle
+ * @return Logger
+ */
+	public static Logger getInstance(String name, String baseName) {
+		try {
+			Logger logger = loggerCache
+					.compute(new String[] { name, baseName });
+			return logger;
+		} catch (InterruptedException e) {
+			/*
+			 * Don't return null here. Just create a new Logger and set it up.
+			 * It will not be stored in the cache, but a later lookup for the
+			 * same Logger would probably end up in the cache
+			 */
+			Logger logger = new Logger();
+			logger._logger = org.apache.log4j.Logger.getLogger(name);
+			logger.baseName = baseName;
+			return logger;
+		}
+
+	}
+/**
+ * Formats a given message
+ * @param message
+ * @param args
+ * @return
+ */
+	private String formatMessage(String message, Object... args) {
+		try {
+			MessageFormat mf = messageFormatCache.compute(message);
+			String msg = mf.format(args);
+			return msg;
+		} catch (InterruptedException e) {
+			return "Error in formatting message " + message;
+		}
+
+	}
+
+	private Logger() {
+	}
+
+	public boolean isDebugEnabled() {
+		return _logger.isDebugEnabled();
+	}
+
+	public boolean isErrorEnabled() {
+		return _logger.isEnabledFor(Level.ERROR);
+	}
+
+	public boolean isFatalEnabled() {
+		return _logger.isEnabledFor(Level.FATAL);
+	}
+
+	public boolean isInfoEnabled() {
+		return _logger.isInfoEnabled();
+	}
+
+	public boolean isWarningEnabled() {
+		return _logger.isEnabledFor(Level.WARN);
+	}
+/**
+ * If this level is enabled, then it finds a message for the given key  and logs it
+ * @param message - This could be a plain message or a key in Messages.properties
+ * @return
+ */
+	public String debug(String message) {
+
+		if (isDebugEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.debug(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String debug(String message, Object... args) {
+
+		if (isDebugEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.debug(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String debug(String message, Throwable t) {
+
+		if (isDebugEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.debug(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String debug(String message, Throwable t, Object... args) {
+
+		if (isDebugEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.debug(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String error(String message) {
+
+		if (isErrorEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.error(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String error(String message, Object... args) {
+
+		if (isErrorEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.error(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String error(String message, Throwable t) {
+
+		if (isErrorEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.error(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String error(String message, Throwable t, Object... args) {
+
+		if (isErrorEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.error(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String fatal(String message) {
+		if (isFatalEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.fatal(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String fatal(String message, Object... args) {
+		if (isFatalEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.fatal(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String fatal(String message, Throwable t) {
+		if (isFatalEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.fatal(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String fatal(String message, Throwable t, Object... args) {
+		if (isFatalEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.fatal(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String info(String message) {
+		if (isInfoEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.info(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String info(String message, Object... args) {
+		if (isInfoEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.info(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String info(String message, Throwable t) {
+		if (isInfoEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.info(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String info(String message, Throwable t, Object... args) {
+		if (isInfoEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.info(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String warning(String message) {
+		if (isWarningEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.warn(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String warning(String message, Object... args) {
+		if (isWarningEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.warn(msg);
+			return msg;
+		}
+		return message;
+	}
+
+	public String warning(String message, Throwable t) {
+		if (isWarningEnabled()) {
+			String msg = getMessage(message, baseName);
+			_logger.warn(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	public String warning(String message, Throwable t, Object... args) {
+		if (isWarningEnabled()) {
+			String msg = getMessage(message, baseName);
+			msg = formatMessage(msg, args);
+			_logger.warn(msg, t);
+			return msg;
+		}
+		return message;
+	}
+
+	static class Log4jConfigUtils {
+
+		Properties props;
+
+		public Log4jConfigUtils(Properties props) {
+			this.props = props;
+		}
+
+		public void configure() {
+			// make openjpa use log4j
+			System.setProperty("openjpa.Log", "log4j");
+
+			Properties properties = null;
+
+			String config = props.getProperty("log4j.configuration");
+			String[] search = { config, "logging.properties", "logging.conf" };
+
+			FileUtils base = SystemInstance.get().getBase();
+			File confDir = new File(base.getDirectory(), "conf");
+			File baseDir = base.getDirectory();
+			File userDir = new File("foo").getParentFile();
+
+			File[] paths = { confDir, baseDir, userDir };
+
+			for (int i = 0; i < search.length && properties == null; i++) {
+				String fileName = search[i];
+				if (fileName == null) {
+					continue;
+				}
+
+				for (int j = 0; j < paths.length; j++) {
+					File path = paths[j];
+
+					File configFile = new File(path, fileName);
+
+					if (configFile.exists()) {
+
+						InputStream in = null;
+						try {
+							in = new FileInputStream(configFile);
+							in = new BufferedInputStream(in);
+							properties = new Properties();
+							properties.load(in);
+						} catch (IOException e) {
+							org.apache.log4j.Logger logger = doFallbackConfiguration();
+							logger.error("Unable to read logging config file "
+									+ configFile.getAbsolutePath(), e);
+						} finally {
+							try {
+								in.close();
+							} catch (IOException e) {
+							}
+						}
+					}
+				}
+			}
+
+			if (properties == null) {
+				String configData = null;
+				try {
+					ResourceFinder finder = new ResourceFinder("");
+					configData = finder.findString("default.logging.conf");
+					properties = new Properties();
+					properties.load(new ByteArrayInputStream(configData
+							.getBytes()));
+				} catch (IOException e) {
+					org.apache.log4j.Logger logger = doFallbackConfiguration();
+					logger.error("Unable to read default logging config file.",
+							e);
+					return;
+				}
+
+				if (confDir.exists()) {
+					OutputStream out = null;
+					File configFile = new File(confDir, "logging.properties");
+					try {
+						out = new FileOutputStream(configFile);
+						out.write(configData.getBytes());
+					} catch (IOException e) {
+						org.apache.log4j.Logger logger = doFallbackConfiguration();
+						logger.warn(
+								"Unable write default logging config file to "
+										+ configFile.getAbsolutePath(), e);
+					} finally {
+						try {
+							out.close();
+						} catch (IOException e) {
+						}
+					}
+				}
+			}
+
+			List missing = new ArrayList();
+
+			for (Iterator iterator = properties.entrySet().iterator(); iterator
+					.hasNext();) {
+				Map.Entry entry = (Map.Entry) iterator.next();
+				String key = (String) entry.getKey();
+				String value = (String) entry.getValue();
+
+				if (key.endsWith(".File")) {
+
+					boolean found = false;
+					for (int i = 0; i < paths.length && !found; i++) {
+						File path = paths[i];
+						File logfile = new File(path, value);
+						if (logfile.getParentFile().exists()) {
+							properties.setProperty(key, logfile
+									.getAbsolutePath());
+							found = true;
+						}
+					}
+
+					if (!found) {
+						File logfile = new File(paths[0], value);
+						missing.add(logfile);
+					}
+				}
+			}
+
+			if (missing.size() > 0) {
+				org.apache.log4j.Logger logger = doFallbackConfiguration();
+
+				logger
+						.warn("Unable use logging config as there are "
+								+ missing.size()
+								+ " file references containing directories which have not been created.  See the list below.");
+				for (int i = 0; i < missing.size(); i++) {
+					File file = (File) missing.get(i);
+					logger.warn("[" + i + "] " + file.getAbsolutePath());
+				}
+			} else {
+				PropertyConfigurator.configure(properties);
+			}
+
+		}
+
+		private org.apache.log4j.Logger doFallbackConfiguration() {
+			set("org.apache.activemq", Level.INFO);
+			set("openjpa", Level.WARN);
+			set("Transaction", Level.WARN);
+			set("OpenEJB.startup", Level.INFO);
+			set("OpenEJB.startup.config", Level.WARN);
+			set("OpenEJB", Level.WARN);
+
+			org.apache.log4j.Logger logger = org.apache.log4j.Logger
+					.getLogger("OpenEJB");
+
+			SimpleLayout simpleLayout = new SimpleLayout();
+			ConsoleAppender newAppender = new ConsoleAppender(simpleLayout);
+			logger.addAppender(newAppender);
+			return logger;
+
+		}
+
+		private void set(String category, Level level) {
+			org.apache.log4j.Logger.getLogger(category).setLevel(level);
+			// Enumeration allAppenders =
+			// org.apache.log4j.Logger.getLogger(category).getAllAppenders();
+			// while (allAppenders.hasMoreElements()) {
+			// Object object = allAppenders.nextElement();
+			// System.out.println(category +" = " + object);
+			// }
+		}
 
-    }
-}
\ No newline at end of file
+	}
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java?view=auto&rev=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Memoizer.java Sat Aug  4 22:26:22 2007
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.openejb.util;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+
+public class Memoizer<K, V> implements Computable<K, V> {
+	private final ConcurrentMap<K, Future<V>> cache = new ConcurrentHashMap<K, Future<V>>();
+
+	private final Computable<K, V> c;
+
+	public Memoizer(Computable<K, V> c) {
+		this.c = c;
+	}
+
+	public V compute(final K key) throws InterruptedException {
+		while (true) {
+			Future<V> future = cache.get(key);
+			if (future == null) {
+
+				Callable<V> eval = new Callable<V>() {
+					public V call() throws Exception {
+						return c.compute(key);
+					}
+				};
+				FutureTask<V> futureTask = new FutureTask<V>(eval);
+				future = cache.putIfAbsent(key, futureTask);
+				if (future == null) {
+					future = futureTask;
+					futureTask.run();
+				}
+			}
+			try {
+				return future.get();
+			} catch (ExecutionException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEJBErrorHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEJBErrorHandler.java?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEJBErrorHandler.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEJBErrorHandler.java Sat Aug  4 22:26:22 2007
@@ -34,7 +34,7 @@
         pw.flush();
         pw.close();
 
-        _logger.i18n.error("ge0001", systemLocation, new String(baos.toByteArray()));
+        _logger.error("ge0001", systemLocation, new String(baos.toByteArray()));
 
         /*
          * An error broadcasting system is under development.
@@ -99,7 +99,7 @@
 
     public static void configurationParsingError(String messageType, String message, String line, String column) {
 
-        _logger.i18n.error("as0001", messageType, message, line, column);
+        _logger.error("as0001", messageType, message, line, column);
         /*
          * An error broadcasting system is under development.
          * At this point an appropriate error would be broadcast to all listeners.

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.logging.conf
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.logging.conf?view=diff&rev=562831&r1=562830&r2=562831
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.logging.conf (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/resources/default.logging.conf Sat Aug  4 22:26:22 2007
@@ -47,9 +47,10 @@
 #
 # =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
+
 log4j.category.OpenEJB             = warn, R
 log4j.category.OpenEJB.server      = info, R
-log4j.category.OpenEJB.startup     = debug
+log4j.category.OpenEJB.startup     = debug,C
 log4j.category.CORBA-Adapter       = debug, R
 log4j.category.Transaction         = warn, TX
 log4j.category.org.apache.activemq = error, R
@@ -69,3 +70,16 @@
 log4j.appender.TX.MaxBackupIndex           = 100
 log4j.appender.TX.layout                   = org.apache.log4j.PatternLayout
 log4j.appender.TX.layout.ConversionPattern = %p %t %c - %m%n
+
+log4j.appender.C                           = org.apache.log4j.ConsoleAppender
+log4j.appender.C.layout                    = org.apache.log4j.SimpleLayout
+
+
+log4j.additivity.OpenEJB=false
+log4j.additivity.OpenEJB.server=false
+log4j.additivity.OpenEJB.startup=false
+log4j.additivity.CORBA-Adapter=false
+log4j.additivity.Transaction=false
+log4j.additivity.org.apache.activemq=false
+log4j.additivity.org.apache.geronimo=false
+log4j.additivity.openjpa=false