You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/05/11 11:13:54 UTC

svn commit: r655284 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel: impl/ util/

Author: davsclaus
Date: Sun May 11 02:13:53 2008
New Revision: 655284

URL: http://svn.apache.org/viewvc?rev=655284&view=rev
Log:
Various error reported by IDEA fixed:
- javadoc polished
- changed logger to private
- added logging instead of e.printstacktrace
- avoid potenital NPE if name is null
- added final modified for synchronized object
- added TODO why boolean is not part of primitives (James, you are the one that disabled this)

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/PackageHelper.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterLoader.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterRegistry.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Sun May 11 02:13:53 2008
@@ -66,8 +66,8 @@
     private static int nameSuffix;
 
     private String name;
-    private Map<String, Endpoint> endpoints = new HashMap<String, Endpoint>();
-    private Map<String, Component> components = new HashMap<String, Component>();
+    private final Map<String, Endpoint> endpoints = new HashMap<String, Endpoint>();
+    private final Map<String, Component> components = new HashMap<String, Component>();
     private List<Route> routes;
     private List<Service> servicesToClose = new ArrayList<Service>();
     private TypeConverter typeConverter;
@@ -546,8 +546,7 @@
      * some kind of transformation or wrapper
      *
      * @param uri the uri for the endpoint (and name in the registry)
-     * @param bean the bean to be converted to an endpoint, which will be not
-     *                null
+     * @param bean the bean to be converted to an endpoint, which will be not null
      * @return a new endpoint
      */
     protected Endpoint convertBeanToEndpoint(String uri, Object bean) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java Sun May 11 02:13:53 2008
@@ -32,11 +32,15 @@
 import java.util.Map.Entry;
 import java.util.Set;
 
-
 import org.apache.camel.TypeConverter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 public final class IntrospectionSupport {
 
+    private static final Log LOG = LogFactory.getLog(IntrospectionSupport.class);
+
+
     /**
      * Utility classes should not have a public constructor.
      */
@@ -44,7 +48,6 @@
     }
 
     public static boolean getProperties(Object target, Map props, String optionPrefix) {
-
         boolean rc = false;
         if (target == null) {
             throw new IllegalArgumentException("target was null.");
@@ -64,9 +67,7 @@
             Class type = method.getReturnType();
             Class params[] = method.getParameterTypes();
             if (name.startsWith("get") && params.length == 0 && type != null && isSettableType(type)) {
-
                 try {
-
                     Object value = method.invoke(target, new Object[] {});
                     if (value == null) {
                         continue;
@@ -80,10 +81,9 @@
                     name = name.substring(3, 4).toLowerCase() + name.substring(4);
                     props.put(optionPrefix + name, strValue);
                     rc = true;
-
                 } catch (Throwable ignore) {
+                    // ignore
                 }
-
             }
         }
 
@@ -322,7 +322,6 @@
     }
 
     private static void addFields(Object target, Class startClass, Class stopClass, LinkedHashMap map) {
-
         if (startClass != stopClass) {
             addFields(target, startClass.getSuperclass(), stopClass, map);
         }
@@ -341,14 +340,14 @@
                     try {
                         o = Arrays.asList((Object[])o);
                     } catch (Throwable e) {
+                        // ignore
                     }
                 }
                 map.put(field.getName(), o);
             } catch (Throwable e) {
-                // TODO: LOG or rethrow
-                e.printStackTrace();
+                LOG.debug("Error adding fields", e);
             }
         }
-
     }
+
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/LRUCache.java Sun May 11 02:13:53 2008
@@ -42,7 +42,7 @@
      * @param accessOrder      the ordering mode - <tt>true</tt> for
      *                         access-order, <tt>false</tt> for insertion-order.
      * @throws IllegalArgumentException if the initial capacity is negative
-     *                                  or the load factor is nonpositive.
+     *                                  or the load factor is non positive.
      */
     public LRUCache(int initialCapacity, int maximumCacheSize, float loadFactor, boolean accessOrder) {
         super(initialCapacity, loadFactor, accessOrder);
@@ -50,7 +50,7 @@
     }
 
     /**
-     * @return Returns the maxCacheSize.
+     * Returns the maxCacheSize.
      */
     public int getMaxCacheSize() {
         return maxCacheSize;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java Sun May 11 02:13:53 2008
@@ -171,8 +171,11 @@
     }
 
     public static String capitalize(String text) {
+        if (text == null) {
+            return null;
+        }
         int length = text.length();
-        if (text == null || length == 0) {
+        if (length == 0) {
             return text;
         }
         String answer = text.substring(0, 1).toUpperCase();
@@ -404,6 +407,7 @@
                 rc = Short.class;
             } else if (type == byte.class) {
                 rc = Byte.class;
+            // TODO: Why is boolean disabled
 /*
             } else if (type == boolean.class) {
                 rc = Boolean.class;
@@ -530,7 +534,7 @@
     }
 
     /**
-     * returns the type of the given object or null if the value is null
+     * Returns the type of the given object or null if the value is null
      */
     public static Object type(Object bean) {
         return bean != null ? bean.getClass() : null;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/PackageHelper.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/PackageHelper.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/PackageHelper.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/PackageHelper.java Sun May 11 02:13:53 2008
@@ -25,7 +25,8 @@
  * @version $Revision$
  */
 public final class PackageHelper {
-    public static final transient Log LOG = LogFactory.getLog(PackageHelper.class);
+    private static final transient Log LOG = LogFactory.getLog(PackageHelper.class);
+
     private PackageHelper() {
         // Utility Class
     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterLoader.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterLoader.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterLoader.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterLoader.java Sun May 11 02:13:53 2008
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.util;
 
-
-
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterRegistry.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterRegistry.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterRegistry.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ReportingTypeConverterRegistry.java Sun May 11 02:13:53 2008
@@ -31,7 +31,6 @@
     }
 
     public void addTypeConverter(Class toType, Class fromType, TypeConverter typeConverter) {
-
         if (errors.size() == 0) {
             errors.add("Method should not be invoked.");
         }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ResolverUtil.java Sun May 11 02:13:53 2008
@@ -126,7 +126,9 @@
     public static class AnnotatedWith implements Test {
         private Class<? extends Annotation> annotation;
 
-        /** Construts an AnnotatedWith test for the specified annotation type. */
+        /**
+         * Constructs an AnnotatedWith test for the specified annotation type.
+         */
         public AnnotatedWith(Class<? extends Annotation> annotation) {
             this.annotation = annotation;
         }
@@ -323,14 +325,15 @@
             String name = file.getName();
             if (name != null) {
                 name = name.trim();
-            }
-            builder.append(parent).append("/").append(name);
-            String packageOrClass = parent == null ? name : builder.toString();
 
-            if (file.isDirectory()) {
-                loadImplementationsInDirectory(test, packageOrClass, file);
-            } else if (name.endsWith(".class")) {
-                addIfMatching(test, packageOrClass);
+                builder.append(parent).append("/").append(name);
+                String packageOrClass = parent == null ? name : builder.toString();
+
+                if (file.isDirectory()) {
+                    loadImplementationsInDirectory(test, packageOrClass, file);
+                } else if (name.endsWith(".class")) {
+                    addIfMatching(test, packageOrClass);
+                }
             }
         }
     }
@@ -355,9 +358,9 @@
                 String name = entry.getName();
                 if (name != null) {
                     name = name.trim();
-                }
-                if (!entry.isDirectory() && name.startsWith(parent) && name.endsWith(".class")) {
-                    addIfMatching(test, name);
+                    if (!entry.isDirectory() && name.startsWith(parent) && name.endsWith(".class")) {
+                        addIfMatching(test, name);
+                    }
                 }
             }
         } catch (IOException ioe) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java?rev=655284&r1=655283&r2=655284&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/URISupport.java Sun May 11 02:13:53 2008
@@ -31,6 +31,7 @@
  * @version $Revision$
  */
 public class URISupport {
+
     public static class CompositeData {
         public String host;
 
@@ -165,12 +166,6 @@
         return rc;
     }
 
-    /**
-     * @param uri
-     * @param rc
-     * @param ssp
-     * @throws URISyntaxException
-     */
     private static void parseComposite(URI uri, CompositeData rc, String ssp) throws URISyntaxException {
         String componentString;
         String params;
@@ -216,10 +211,6 @@
         }
     }
 
-    /**
-     * @param str
-     * @return
-     */
     private static String[] splitComponents(String str) {
         ArrayList l = new ArrayList();
 
@@ -294,7 +285,7 @@
     }
 
     /**
-     * Creates a URI from the original URI and the remaining paramaters
+     * Creates a URI from the original URI and the remaining parameters
      * 
      * @throws URISyntaxException
      */
@@ -332,6 +323,9 @@
         return result;
     }
 
+    /**
+     * @deprecated this method will be removed in a future release 
+     */
     public int indexOfParenthesisMatch(String str) {
         int result = -1;