camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1100547 - in /camel/trunk/components: camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
Date Sat, 07 May 2011 14:18:12 GMT
Author: davsclaus
Date: Sat May  7 14:18:11 2011
New Revision: 1100547

URL: http://svn.apache.org/viewvc?rev=1100547&view=rev
Log:
CAMEL-3954: Speedup spring-test by lazy loading type converters.

Modified:
    camel/trunk/components/camel-core-xml/src/main/java/org/apache/camel/core/xml/AbstractCamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java

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=1100547&r1=1100546&r2=1100547&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
Sat May  7 14:18:11 2011
@@ -96,6 +96,11 @@ import org.slf4j.LoggerFactory;
 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";
+
     @XmlTransient
     private List<RoutesBuilder> builders = new ArrayList<RoutesBuilder>();
     @XmlTransient
@@ -133,6 +138,17 @@ 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);
+            }
         }
 
         PackageScanClassResolver packageResolver = getBeanForType(PackageScanClassResolver.class);

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java?rev=1100547&r1=1100546&r2=1100547&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
Sat May  7 14:18:11 2011
@@ -25,6 +25,7 @@ import java.util.Set;
 import org.apache.camel.CamelContext;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Route;
+import org.apache.camel.core.xml.AbstractCamelContextFactoryBean;
 import org.apache.camel.impl.DefaultPackageScanClassResolver;
 import org.apache.camel.impl.scan.AssignableToPackageScanFilter;
 import org.apache.camel.impl.scan.InvertingPackageScanFilter;
@@ -44,6 +45,12 @@ public abstract class SpringTestSupport 
 
     @Override
     protected void setUp() throws Exception {
+        if (isLazyLoadingTypeConverter()) {
+            System.setProperty(AbstractCamelContextFactoryBean.LAZY_LOAD_TYPE_CONVERTERS,
"true");
+        } else {
+            System.setProperty(AbstractCamelContextFactoryBean.LAZY_LOAD_TYPE_CONVERTERS,
"false");
+        }
+
         applicationContext = createApplicationContext();
         assertNotNull("Should have created a valid spring context", applicationContext);
         super.setUp();



Mime
View raw message