camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1101477 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
Date Tue, 10 May 2011 14:34:57 GMT
Author: ningjiang
Date: Tue May 10 14:34:56 2011
New Revision: 1101477

URL: http://svn.apache.org/viewvc?rev=1101477&view=rev
Log:
CAMEL-3954 Fixed the CS errors of AbstractCamelContextFactoryBean and polish the code of CamelContextHelper

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java?rev=1101477&r1=1101476&r2=1101477&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/CamelContextHelper.java Tue
May 10 14:34:56 2011
@@ -319,7 +319,7 @@ public final class CamelContextHelper {
         if (s != null) {
             s = s.trim().toLowerCase();
             if (s.equals("true") || s.equals("false")) {
-                return camelContext.getTypeConverter().mandatoryConvertTo(Boolean.class,
s);
+                return "true".equals(s) ? Boolean.TRUE : Boolean.FALSE;
             } else {
                 if (s.equals(text)) {
                     throw new IllegalArgumentException("Error parsing [" + s + "] as a Boolean.");

Modified: camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java?rev=1101477&r1=1101476&r2=1101477&view=diff
==============================================================================
--- camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
Tue May 10 14:34:56 2011
@@ -94,12 +94,13 @@ import org.slf4j.LoggerFactory;
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 public abstract class AbstractCamelContextFactoryBean<T extends CamelContext> extends
IdentifiedType implements RouteContainer {
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractCamelContextFactoryBean.class);
-
+    
     /**
      * JVM system property to control lazy loading of type converters.
      */
     public static final String LAZY_LOAD_TYPE_CONVERTERS = "CamelLazyLoadTypeConverters";
+    
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractCamelContextFactoryBean.class);
 
     @XmlTransient
     private List<RoutesBuilder> builders = new ArrayList<RoutesBuilder>();
@@ -136,20 +137,7 @@ public abstract class AbstractCamelConte
         }
 
         // set the type converter mode first
-        if (getLazyLoadTypeConverters() != null) {
-            getContext().setLazyLoadTypeConverters(getLazyLoadTypeConverters());
-        } else if (System.getProperty(LAZY_LOAD_TYPE_CONVERTERS) != null) {
-            // suppose a JVM property to control it so we can use that for example for unit
testing
-            // to speedup testing by enabling lazy loading of type converters
-            String lazy = System.getProperty(LAZY_LOAD_TYPE_CONVERTERS);
-            if ("true".equalsIgnoreCase(lazy)) {
-                getContext().setLazyLoadTypeConverters(true);
-            } else if ("false".equalsIgnoreCase(lazy)) {
-                getContext().setLazyLoadTypeConverters(true);
-            } else {
-                throw new IllegalArgumentException("System property with key " + LAZY_LOAD_TYPE_CONVERTERS
+ " has unknown value: " + lazy);
-            }
-        }
+        initLazyLoadTypeConverteres();
 
         PackageScanClassResolver packageResolver = getBeanForType(PackageScanClassResolver.class);
         if (packageResolver != null) {
@@ -332,6 +320,23 @@ public abstract class AbstractCamelConte
     }
 
     protected abstract void initCustomRegistry(T context);
+    
+    protected void initLazyLoadTypeConverteres() {
+        if (getLazyLoadTypeConverters() != null) {
+            getContext().setLazyLoadTypeConverters(getLazyLoadTypeConverters());
+        } else if (System.getProperty(LAZY_LOAD_TYPE_CONVERTERS) != null) {
+            // suppose a JVM property to control it so we can use that for example for unit
testing
+            // to speedup testing by enabling lazy loading of type converters
+            String lazy = System.getProperty(LAZY_LOAD_TYPE_CONVERTERS);
+            if ("true".equalsIgnoreCase(lazy)) {
+                getContext().setLazyLoadTypeConverters(true);
+            } else if ("false".equalsIgnoreCase(lazy)) {
+                getContext().setLazyLoadTypeConverters(false);
+            } else {
+                throw new IllegalArgumentException("System property with key " + LAZY_LOAD_TYPE_CONVERTERS
+ " has unknown value: " + lazy);
+            }
+        }
+    }
 
     protected void initJMXAgent() throws Exception {
         CamelJMXAgentDefinition camelJMXAgent = getCamelJMXAgent();



Mime
View raw message