[jboss-svn-commits] JBL Code SVN: r24290 - in labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb: jms and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Dec 8 02:55:31 EST 2008


Author: beve
Date: 2008-12-08 02:55:31 -0500 (Mon, 08 Dec 2008)
New Revision: 24290

Modified:
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
   labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java
Log:
Updates for checkstyle


Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java	2008-12-08 06:33:15 UTC (rev 24289)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/classpath/ClassUtil.java	2008-12-08 07:55:31 UTC (rev 24290)
@@ -103,7 +103,8 @@
      */
     public static Class<?> findClass(final String className, final ClassLoader[] classLoaders) throws ClassNotFoundException
     {
-        for(ClassLoader classLoader : classLoaders) {
+        for (ClassLoader classLoader : classLoaders)
+        {
             try
             {
                 return Class.forName(className, true, classLoader);
@@ -219,6 +220,7 @@
      * @param fallbackClassLoaders The {@link ClassLoader ClassLoaders} to be used if the Thread Context Classloader
      * fails to load the resource.
      * @return The resource URLs.
+     * @throws IOException If an IOException occurs while trying to locate the resource.
      */
     public static Enumeration<URL> getResources(final String resourceName, final ClassLoader[] fallbackClassLoaders) throws IOException
     {
@@ -235,7 +237,7 @@
 
         if (fallbackClassLoaders != null)
         {
-            for(ClassLoader fallbackClassLoader : fallbackClassLoaders)
+            for (ClassLoader fallbackClassLoader : fallbackClassLoaders)
             {
                 final Enumeration<URL> resources = fallbackClassLoader.getResources(resourceName);
                 if (resources != null)
@@ -294,7 +296,7 @@
 
         if (fallbackClassLoaders != null)
         {
-            for(ClassLoader fallbackClassLoader : fallbackClassLoaders)
+            for (ClassLoader fallbackClassLoader : fallbackClassLoaders)
             {
                 final InputStream is = fallbackClassLoader.getResourceAsStream(resource);
                 if (is != null)
@@ -584,7 +586,7 @@
      * @param exception The Exception.
      * @throws ClassNotFoundException The Exception.
      */
-    private static void assertThrowClassNotFoundException(ClassNotFoundException exception) throws ClassNotFoundException
+    private static void assertThrowClassNotFoundException(final ClassNotFoundException exception) throws ClassNotFoundException
     {
         Throwable cause = exception.getException();
 

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java	2008-12-08 06:33:15 UTC (rev 24289)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/AbstractMessageHandler.java	2008-12-08 07:55:31 UTC (rev 24290)
@@ -107,11 +107,11 @@
     public final void connect() throws JMSException
     {
         destination = jmsSession.lookupDestination(destinationName);
-        if(jmsSession.getSessionType() == JMSSession.Type.QUEUE && !(destination instanceof Queue))
+        if (jmsSession.getSessionType() == JMSSession.Type.QUEUE && !(destination instanceof Queue))
         {
             throw new JMSException("Handler '" + getClass().getName() + "' destination '" + destinationName + "' cannot be created.  Must be a JMS Queue Destination for this Session type.");
         }
-        else if(jmsSession.getSessionType() == JMSSession.Type.TOPIC && !(destination instanceof Topic))
+        else if (jmsSession.getSessionType() == JMSSession.Type.TOPIC && !(destination instanceof Topic))
         {
             throw new JMSException("Handler '" + getClass().getName() + "' destination '" + destinationName + "' cannot be created.  Must be a JMS Topic Destination for this Session type.");
         }

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java	2008-12-08 06:33:15 UTC (rev 24289)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/jms/JMSSession.java	2008-12-08 07:55:31 UTC (rev 24290)
@@ -81,7 +81,8 @@
     /**
      * Session Type enumeration.
      */
-    public static enum Type {
+    public static enum Type
+    {
         /**
          * Queue Session.
          */
@@ -247,7 +248,7 @@
      */
     private void assertSessionTypeConfigured()
     {
-        if(sessionType == null)
+        if (sessionType == null)
         {
             throw new IllegalStateException("JMS Session type not configured.");
         }
@@ -318,7 +319,7 @@
 
         try
         {
-            if(classLoaders != null)
+            if (classLoaders != null)
             {
                 return (ConnectionFactory) JNDIUtil.lookup(connectionFactoryRuntime, jndiProperties, classLoaders);
             }
@@ -349,7 +350,7 @@
     {
         try
         {
-            if(classLoaders != null)
+            if (classLoaders != null)
             {
                 return (Destination) JNDIUtil.lookup(destinationName, jndiProperties, classLoaders);
             }

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java	2008-12-08 06:33:15 UTC (rev 24289)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/FileUtil.java	2008-12-08 07:55:31 UTC (rev 24290)
@@ -30,17 +30,28 @@
  * Common file utility functions.
  * @author kevin
  */
-public class FileUtil
+public final class FileUtil
 {
-    public static final String classInstanceUUID = UUID.randomUUID().toString();
+    /**
+     * Unique identifier for this class.
+     */
+    public static final String classInstanceUuid = UUID.randomUUID().toString();
 
     /**
      * The logger for this class.
      */
-    private final static Logger LOGGER = Logger.getLogger(FileUtil.class) ;
+    private static final Logger LOGGER = Logger.getLogger(FileUtil.class);
 
     /**
-     * Attempt to rename a file
+     * Private contstructor.
+     */
+    private FileUtil()
+    {
+    }
+
+
+    /**
+     * Attempt to rename a file.
      * @param from The original file
      * @param to The destination file.
      * @return true if the rename succeeded, false otherwise
@@ -50,13 +61,14 @@
         AssertArgument.isNotNull(from, "from");
         AssertArgument.isNotNull(to, "to");
 
-        if(!from.exists())
+        if (!from.exists())
         {
             LOGGER.debug("Unable to rename file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + from.getAbsolutePath() + "' doesn't exist.");
             return false;
         }
 
-        if(to.exists()) {
+        if (to.exists())
+        {
             LOGGER.debug("Unable to rename file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + to.getAbsolutePath() + "' already exist.");
             return false;
         }
@@ -81,18 +93,19 @@
      * @param to The target file.
      * @return True if the move was successful, otherwise false.
      */
-    public static boolean moveFile(File from, File to)
+    public static boolean moveFile(final File from, final File to)
     {
         AssertArgument.isNotNull(from, "from");
         AssertArgument.isNotNull(to, "to");
 
-        if(!from.exists())
+        if (!from.exists())
         {
             LOGGER.debug("Unable to move file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + from.getAbsolutePath() + "' doesn't exist.");
             return false;
         }
 
-        if(to.exists()) {
+        if (to.exists())
+        {
             LOGGER.debug("Unable to move file '" + from.getAbsolutePath() + "' to '" + to.getAbsolutePath() + "'.  '" + to.getAbsolutePath() + "' already exist.");
             return false;
         }
@@ -104,40 +117,41 @@
         // is not picked up too, but it is "stronger"!
 
         File fromFileDir = from.getParentFile();
-        File fromLocalRename = new File(fromFileDir, classInstanceUUID + "." + from.getName() + "." + classInstanceUUID);
+        File fromLocalRename = new File(fromFileDir, classInstanceUuid + "." + from.getName() + "." + classInstanceUuid);
 
-        if(!from.renameTo(fromLocalRename))
+        if (!from.renameTo(fromLocalRename))
         {
                 LOGGER.debug("Unable to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
                 return true;
         }
 
-        if(!fromLocalRename.exists())
+        if (!fromLocalRename.exists())
         {
             LOGGER.debug("Failed to perform local rename of file '" + from.getAbsolutePath() + "' to '" + fromLocalRename.getAbsolutePath() + "'.  Unable to move file.");
             return true;
         }
 
-        final File tmpFile ;
+        final File tmpFile;
         try
         {
-            tmpFile = File.createTempFile("copy", ".tmp", to.getParentFile()) ;
+            tmpFile = File.createTempFile("copy", ".tmp", to.getParentFile());
         }
         catch (final IOException ioe)
         {
-            LOGGER.debug("Could not create temporary file for writing", ioe) ;
+            LOGGER.debug("Could not create temporary file for writing", ioe);
             return true;
         }
 
         try
         {
-            copyFile(fromLocalRename, tmpFile) ;
+            copyFile(fromLocalRename, tmpFile);
             if (!tmpFile.renameTo(to))
             {
-                LOGGER.debug("Could not rename temporary file " + tmpFile.getAbsolutePath()) ;
-                return false ;
+                LOGGER.debug("Could not rename temporary file " + tmpFile.getAbsolutePath());
+                return false;
             }
-            if(!fromLocalRename.delete()) {
+            if (!fromLocalRename.delete())
+            {
                 LOGGER.debug("Failed to delete local rename file '" + fromLocalRename.getAbsolutePath() + "'.");
                 // This is not desireable, but shouldn't be fatal because the from file no longer exists
                 // and the to file has been successfully created.
@@ -145,7 +159,7 @@
         }
         finally
         {
-            tmpFile.delete() ;
+            tmpFile.delete();
         }
 
         return true;
@@ -155,6 +169,7 @@
      * Attempt to copy the file.
      * @param from The original file
      * @param to The destination file.
+     * @return true If the copy operation was successful, false otherwise.
      */
     private static boolean copyFile(final File from, final File to)
     {
@@ -165,8 +180,8 @@
         }
         catch (final IOException ioe)
         {
-            LOGGER.debug("Could not open input file for reading", ioe) ;
-            return false ;
+            LOGGER.debug("Could not open input file for reading", ioe);
+            return false;
         }
         try
         {
@@ -178,7 +193,7 @@
             catch (final IOException ioe)
             {
                 LOGGER.debug("Could not open output file for writing", ioe);
-                return false ;
+                return false;
             }
 
             try
@@ -199,8 +214,8 @@
             catch (final IOException ioe)
             {
                 LOGGER.debug("Error copying file", ioe);
-                to.delete() ;
-                return false ;
+                to.delete();
+                return false;
             }
             finally
             {
@@ -208,7 +223,10 @@
                     {
                             fos.close();
                     }
-                    catch (final IOException ioe) {} // ignore
+                    catch (final IOException ignore)
+                    {
+                        LOGGER.error("IOException while trying to close file input stream:", ignore);
+                    }
             }
         }
         finally
@@ -217,9 +235,12 @@
             {
                     fis.close();
             }
-            catch (final IOException ioe) {} // ignore
+            catch (final IOException ignore)
+            {
+                LOGGER.error("IOException while trying to close file input stream:", ignore);
+            }
         }
-        return true ;
+        return true;
     }
 
     /**
@@ -228,12 +249,13 @@
      * @return String with the content of the file
      * @throws IOException - when we can't read the file
      */
-    public static String readTextFile(File file) throws IOException
+    public static String readTextFile(final File file) throws IOException
     {
         StringBuffer sb = new StringBuffer(1024);
         BufferedReader reader = new BufferedReader(new FileReader(file.getPath()));
         char[] chars = new char[1];
-        while( (reader.read(chars)) > -1){
+        while ((reader.read(chars)) > -1)
+        {
             sb.append(String.valueOf(chars));
             chars = new char[1];
         }
@@ -247,18 +269,23 @@
      * @return The file contents.
      * @throws IOException Error reading the file.
      */
-    public static byte[] readFile(File file) throws IOException {
+    public static byte[] readFile(final File file) throws IOException
+    {
         ByteArrayOutputStream fileBuffer = new ByteArrayOutputStream();
         InputStream fileInStream = new FileInputStream(file);
 
-        try {
+        try
+        {
             byte[] readBuffer = new byte[256];
             int readCount = 0;
 
-            while((readCount = fileInStream.read(readBuffer)) != -1) {
+            while ((readCount = fileInStream.read(readBuffer)) != -1)
+            {
                 fileBuffer.write(readBuffer, 0, readCount);
             }
-        } finally {
+        }
+        finally
+        {
             fileInStream.close();
         }
 
@@ -296,6 +323,12 @@
         return null;
     }
 
+    /**
+     * Replaces the all backslash characters with the forward slash character.
+     *
+     * @param path The path which should be used. Just a string that contains the baskslahes that should be substituted.
+     * @return String The same string but with its backslashed substituted.
+     */
     public static String normalizePathSeparator(final String path)
     {
         if (path != null)

Modified: labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java	2008-12-08 06:33:15 UTC (rev 24289)
+++ labs/jbossesb/workspace/skeagh/commons/src/main/java/org/jboss/esb/util/JNDIUtil.java	2008-12-08 07:55:31 UTC (rev 24290)
@@ -122,7 +122,7 @@
 
         try
         {
-            for(ClassLoader classLoader : classLoaders)
+            for (ClassLoader classLoader : classLoaders)
             {
                 Thread.currentThread().setContextClassLoader(classLoader);
                 try




More information about the jboss-svn-commits mailing list