Author: dblevins
Date: Wed Sep 19 20:58:29 2007
New Revision: 577530

URL: http://svn.apache.org/viewvc?rev=577530&view=rev
Log:
reformatted

Modified:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Logger.java

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?rev=577530&r1=577529&r2=577530&view=diff
==============================================================================
--- 
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
 Wed Sep 19 20:58:29 2007
@@ -32,10 +32,10 @@
 import java.io.InputStream;
 import java.net.URL;
 import java.text.MessageFormat;
+import java.util.Map;
 import java.util.MissingResourceException;
 import java.util.Properties;
 import java.util.ResourceBundle;
-import java.util.Map;
 
 public class Logger {
 
@@ -118,46 +118,47 @@
     private static final Computable<String, MessageFormat> messageFormatCache 
= new Memoizer<String, MessageFormat>(
             messageFormatResolver);
 
-       private static final String LOGGING_PROPERTIES_FILE = 
"logging.properties";
-       private static final String EMBEDDED_PROPERTIES_FILE = 
"embedded.logging.properties";
-       static {
-               try {
-                       String prop = 
System.getProperty("openejb.logger.external","false");
-                       boolean externalLogging = Boolean.parseBoolean(prop);
-                       if(!externalLogging)
-                               configureInternal();
-               } catch (Exception e) {
-         // The fall back here is that if log4j.configuration system property 
is set, then that configuration file will be used. 
-                       e.printStackTrace();
-               }
-       }
-
-       private static void configureInternal() throws IOException {
-               
-               System.setProperty("openjpa.Log", "log4j");
-               SystemInstance system = SystemInstance.get();
-               FileUtils base = system.getBase();
-               File confDir = base.getDirectory("conf");
-               File loggingPropertiesFile = new File(confDir, 
LOGGING_PROPERTIES_FILE);
-               if (confDir.exists()) {
-                       if (loggingPropertiesFile.exists()) {
-                               BufferedInputStream bis = new 
BufferedInputStream(new FileInputStream(loggingPropertiesFile));
-                               Properties props = new Properties();
-                               props.load(bis);
+    private static final String LOGGING_PROPERTIES_FILE = "logging.properties";
+    private static final String EMBEDDED_PROPERTIES_FILE = 
"embedded.logging.properties";
+
+    static {
+        try {
+            String prop = System.getProperty("openejb.logger.external", 
"false");
+            boolean externalLogging = Boolean.parseBoolean(prop);
+            if (!externalLogging)
+                configureInternal();
+        } catch (Exception e) {
+            // The fall back here is that if log4j.configuration system 
property is set, then that configuration file will be used.
+            e.printStackTrace();
+        }
+    }
+
+    private static void configureInternal() throws IOException {
+
+        System.setProperty("openjpa.Log", "log4j");
+        SystemInstance system = SystemInstance.get();
+        FileUtils base = system.getBase();
+        File confDir = base.getDirectory("conf");
+        File loggingPropertiesFile = new File(confDir, 
LOGGING_PROPERTIES_FILE);
+        if (confDir.exists()) {
+            if (loggingPropertiesFile.exists()) {
+                BufferedInputStream bis = new BufferedInputStream(new 
FileInputStream(loggingPropertiesFile));
+                Properties props = new Properties();
+                props.load(bis);
                 preprocessProperties(props);
                 PropertyConfigurator.configure(props);
-                               try{
-                                       bis.close();
-                               }catch(IOException e){
-                                       
-                               }
-                       } else {
-                               
installLoggingPropertiesFile(loggingPropertiesFile);
-                       }
-               }else{
-                       configureEmbedded();
-               } 
-       }
+                try {
+                    bis.close();
+                } catch (IOException e) {
+
+                }
+            } else {
+                installLoggingPropertiesFile(loggingPropertiesFile);
+            }
+        } else {
+            configureEmbedded();
+        }
+    }
 
     private static void preprocessProperties(Properties props) {
         String openejbHome = 
SystemInstance.get().getHome().getDirectory().getAbsolutePath();
@@ -170,50 +171,51 @@
         }
     }
 
-    private static void configureEmbedded(){
-       URL resource = 
Thread.currentThread().getContextClassLoader().getResource(EMBEDDED_PROPERTIES_FILE);
-       if(resource != null)
-               PropertyConfigurator.configure(resource);
-       else
-               System.out.println("FATAL ERROR WHILE CONFIGURING LOGGING!!!. 
MISSING embedded.logging.properties FILE ");
+    private static void configureEmbedded() {
+        URL resource = 
Thread.currentThread().getContextClassLoader().getResource(EMBEDDED_PROPERTIES_FILE);
+        if (resource != null)
+            PropertyConfigurator.configure(resource);
+        else
+            System.out.println("FATAL ERROR WHILE CONFIGURING LOGGING!!!. 
MISSING embedded.logging.properties FILE ");
     }
 
     private static void installLoggingPropertiesFile(File 
loggingPropertiesFile) throws IOException {
-       URL resource = 
Thread.currentThread().getContextClassLoader().getResource(LOGGING_PROPERTIES_FILE);
-        if(resource == null){
-               System.out.println("FATAL ERROR WHILE CONFIGURING LOGGING!!!. 
MISSING logging.properties FILE ");
-               return;
-        }
-       InputStream in = resource.openStream();
-       in = new BufferedInputStream(in);
-       ByteArrayOutputStream bao = new ByteArrayOutputStream();
+        URL resource = 
Thread.currentThread().getContextClassLoader().getResource(LOGGING_PROPERTIES_FILE);
+        if (resource == null) {
+            System.out.println("FATAL ERROR WHILE CONFIGURING LOGGING!!!. 
MISSING logging.properties FILE ");
+            return;
+        }
+        InputStream in = resource.openStream();
+        in = new BufferedInputStream(in);
+        ByteArrayOutputStream bao = new ByteArrayOutputStream();
         byte buf[] = new byte[4096];
         int i = in.read(buf);
-        while(i != -1){
-               bao.write(buf);
-               i = in.read(buf);
+        while (i != -1) {
+            bao.write(buf);
+            i = in.read(buf);
         }
         byte[] byteArray = bao.toByteArray();
         ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
-        
+
         Properties props = new Properties();
         props.load(bis);
         preprocessProperties(props);
-               BufferedOutputStream bout = new BufferedOutputStream(new 
FileOutputStream(loggingPropertiesFile));
-               bout.write(byteArray);
+        BufferedOutputStream bout = new BufferedOutputStream(new 
FileOutputStream(loggingPropertiesFile));
+        bout.write(byteArray);
         PropertyConfigurator.configure(props);
         try {
-                       bout.close();
-               } catch (IOException e) {
-                       
-               }
+            bout.close();
+        } catch (IOException e) {
+
+        }
         try {
-                       in.close();
-               } catch (IOException e) {
+            in.close();
+        } catch (IOException e) {
 
-               }
+        }
 
     }
+
     /**
      * 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
@@ -256,7 +258,7 @@
     /**
      * Finds a Logger from the cache and returns it. If not found in cache 
then builds a Logger and returns it.
      *
-     * @param category     - The category of the logger
+     * @param category - The category of the logger
      * @param baseName - The baseName for the ResourceBundle
      * @return Logger
      */
@@ -287,11 +289,12 @@
         String name = clazz.getName();
         return name.substring(0, name.lastIndexOf("."));
     }
-    
-    public Logger getLogger(String moduleId){
-       return Logger.getInstance(this.category,this.baseName);
-       
+
+    public Logger getLogger(String moduleId) {
+        return Logger.getInstance(this.category, this.baseName);
+
     }
+
     /**
      * Formats a given message
      *


Reply via email to