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 2016/01/05 17:52:22 UTC

[4/4] camel git commit: Fixed CS. This closes #753. This closes #379. This closes #536.

Fixed CS. This closes #753. This closes #379. This closes #536.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6ad29b2e
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6ad29b2e
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6ad29b2e

Branch: refs/heads/master
Commit: 6ad29b2ec304600c54bdbe655bd80644981d073f
Parents: c978bbd
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jan 5 17:50:04 2016 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jan 5 17:50:04 2016 +0100

----------------------------------------------------------------------
 .../apache/camel/impl/DefaultCamelContext.java  | 52 ++++++++++----------
 .../apache/camel/model/ModelCamelContext.java   | 10 ++--
 ...melContextAddRestDefinitionsFromXmlTest.java | 17 +++----
 .../apache/camel/model/LoadRestFromXmlTest.java | 16 +++---
 .../boot/CamelConfigurationProperties.java      | 16 +++---
 .../camel/spring/boot/RoutesCollector.java      | 40 +++++++--------
 6 files changed, 75 insertions(+), 76 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
index cef6b6a..c710713 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
@@ -870,32 +870,32 @@ public class DefaultCamelContext extends ServiceSupport implements ModelCamelCon
     }
 
     public synchronized RestsDefinition loadRestsDefinition(InputStream is) throws Exception {
-    	// load routes using JAXB
-    	if (jaxbContext == null) {
-    		// must use classloader from CamelContext to have JAXB working
-    		jaxbContext = getModelJAXBContextFactory().newJAXBContext();
-    	}
-
-    	Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-    	Object result = unmarshaller.unmarshal(is);
-
-    	if (result == null) {
-    		throw new IOException("Cannot unmarshal to rests using JAXB from input stream: " + is);
-    	}
-
-    	// can either be routes or a single route
-    	RestsDefinition answer;
-    	if (result instanceof RestDefinition) {
-    		RestDefinition rest = (RestDefinition) result;
-    		answer = new RestsDefinition();
-    		answer.getRests().add(rest);
-    	} else if (result instanceof RestsDefinition) {
-    		answer = (RestsDefinition) result;
-    	} else {
-    		throw new IllegalArgumentException("Unmarshalled object is an unsupported type: " + ObjectHelper.className(result) + " -> " + result);
-    	}
-
-    	return answer;
+        // load routes using JAXB
+        if (jaxbContext == null) {
+            // must use classloader from CamelContext to have JAXB working
+            jaxbContext = getModelJAXBContextFactory().newJAXBContext();
+        }
+
+        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+        Object result = unmarshaller.unmarshal(is);
+
+        if (result == null) {
+            throw new IOException("Cannot unmarshal to rests using JAXB from input stream: " + is);
+        }
+
+        // can either be routes or a single route
+        RestsDefinition answer;
+        if (result instanceof RestDefinition) {
+            RestDefinition rest = (RestDefinition) result;
+            answer = new RestsDefinition();
+            answer.getRests().add(rest);
+        } else if (result instanceof RestsDefinition) {
+            answer = (RestsDefinition) result;
+        } else {
+            throw new IllegalArgumentException("Unmarshalled object is an unsupported type: " + ObjectHelper.className(result) + " -> " + result);
+        }
+
+        return answer;
     }
     
     public synchronized void addRouteDefinitions(Collection<RouteDefinition> routeDefinitions) throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/camel-core/src/main/java/org/apache/camel/model/ModelCamelContext.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/ModelCamelContext.java b/camel-core/src/main/java/org/apache/camel/model/ModelCamelContext.java
index e2fa327..aea0aac 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ModelCamelContext.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ModelCamelContext.java
@@ -56,11 +56,11 @@ public interface ModelCamelContext extends CamelContext {
 
     /**
      * Loads a collection of rest definitions from the given {@link java.io.InputStream}.
-	 *
-	 * @param is input stream with the rest(s) definition to add
-	 * @throws Exception if the rest definitions could not be loaded for whatever reason
-	 * @return the rest definitions
-	 */
+     *
+     * @param is input stream with the rest(s) definition to add
+     * @return the rest definitions
+     * @throws Exception if the rest definitions could not be loaded for whatever reason
+     */
     RestsDefinition loadRestsDefinition(InputStream is) throws Exception;
     
     /**

http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/camel-core/src/test/java/org/apache/camel/impl/CamelContextAddRestDefinitionsFromXmlTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/CamelContextAddRestDefinitionsFromXmlTest.java b/camel-core/src/test/java/org/apache/camel/impl/CamelContextAddRestDefinitionsFromXmlTest.java
index 2a6025b..e395bfa 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/CamelContextAddRestDefinitionsFromXmlTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/CamelContextAddRestDefinitionsFromXmlTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.impl;
 
 import java.net.URL;
 import java.util.List;
-
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
@@ -31,7 +30,7 @@ import org.apache.camel.model.RouteDefinition;
 import org.apache.camel.model.rest.RestDefinition;
 
 /**
- * @version 
+ * @version
  */
 public class CamelContextAddRestDefinitionsFromXmlTest extends ContextTestSupport {
 
@@ -44,7 +43,7 @@ public class CamelContextAddRestDefinitionsFromXmlTest extends ContextTestSuppor
         jndi.bind("dummy-rest-api", new DummyRestProcessorFactory());
         return jndi;
     }
-    
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
@@ -65,7 +64,7 @@ public class CamelContextAddRestDefinitionsFromXmlTest extends ContextTestSuppor
     }
 
     public void testAddRestDefinitionsFromXml() throws Exception {
-    	RestDefinition rest = loadRest("rest1.xml");
+        RestDefinition rest = loadRest("rest1.xml");
         assertNotNull(rest);
 
         assertEquals("foo", rest.getId());
@@ -75,13 +74,13 @@ public class CamelContextAddRestDefinitionsFromXmlTest extends ContextTestSuppor
         assertEquals(1, context.getRestDefinitions().size());
 
         final List<RouteDefinition> routeDefinitions = rest.asRouteDefinition(context);
-        
+
         for (final RouteDefinition routeDefinition : routeDefinitions) {
-        	context.addRouteDefinition(routeDefinition);
-		}
+            context.addRouteDefinition(routeDefinition);
+        }
 
         assertEquals(2, context.getRoutes().size());
-        
+
         assertTrue("Route should be started", context.getRouteStatus("route1").isStarted());
 
         getMockEndpoint("mock:bar").expectedBodiesReceived("Hello World");
@@ -98,5 +97,5 @@ public class CamelContextAddRestDefinitionsFromXmlTest extends ContextTestSuppor
             }
         };
     }
-    
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/camel-core/src/test/java/org/apache/camel/model/LoadRestFromXmlTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/model/LoadRestFromXmlTest.java b/camel-core/src/test/java/org/apache/camel/model/LoadRestFromXmlTest.java
index 38fe66a..c188c2f 100644
--- a/camel-core/src/test/java/org/apache/camel/model/LoadRestFromXmlTest.java
+++ b/camel-core/src/test/java/org/apache/camel/model/LoadRestFromXmlTest.java
@@ -29,7 +29,7 @@ import org.apache.camel.model.rest.RestDefinition;
 import org.apache.camel.model.rest.RestsDefinition;
 
 /**
- * @version 
+ * @version
  */
 public class LoadRestFromXmlTest extends ContextTestSupport {
 
@@ -40,10 +40,10 @@ public class LoadRestFromXmlTest extends ContextTestSupport {
         jndi.bind("dummy-rest-api", new DummyRestProcessorFactory());
         return jndi;
     }
-	
+
     public void testLoadRestFromXml() throws Exception {
         assertNotNull("Existing foo route should be there", context.getRoute("foo"));
-        
+
         assertEquals(2, context.getRoutes().size());
 
         // test that existing route works
@@ -56,11 +56,11 @@ public class LoadRestFromXmlTest extends ContextTestSupport {
         InputStream is = getClass().getResourceAsStream("barRest.xml");
         RestsDefinition rests = context.loadRestsDefinition(is);
         context.addRestDefinitions(rests.getRests());
-        
+
         for (final RestDefinition restDefinition : rests.getRests()) {
             List<RouteDefinition> routeDefinitions = restDefinition.asRouteDefinition(context);
             context.addRouteDefinitions(routeDefinitions);
-		}
+        }
 
         assertNotNull("Loaded rest route should be there", context.getRoute("route1"));
         assertEquals(3, context.getRoutes().size());
@@ -77,10 +77,10 @@ public class LoadRestFromXmlTest extends ContextTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-            	restConfiguration().host("localhost").component("dummy-rest").apiContextPath("/api-docs");
-            	
+                restConfiguration().host("localhost").component("dummy-rest").apiContextPath("/api-docs");
+
                 from("direct:foo").routeId("foo")
-                    .to("mock:foo");
+                        .to("mock:foo");
             }
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
index be07ff1..c8f1793 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/CamelConfigurationProperties.java
@@ -110,12 +110,12 @@ public class CamelConfigurationProperties {
         this.xmlRoutes = xmlRoutes;
     }
 
-	public String getXmlRests() {
-		return xmlRests;
-	}
-
-	public void setXmlRests(String xmlRests) {
-		this.xmlRests = xmlRests;
-	}
-    
+    public String getXmlRests() {
+        return xmlRests;
+    }
+
+    public void setXmlRests(String xmlRests) {
+        this.xmlRests = xmlRests;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/6ad29b2e/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
----------------------------------------------------------------------
diff --git a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
index 33947c0..61b5378 100644
--- a/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
+++ b/components/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/RoutesCollector.java
@@ -96,20 +96,20 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
 
                     boolean scanRests = !configurationProperties.getXmlRests().equals("false");
                     if (scanRests) {
-                    	loadXmlRests(applicationContext, camelContext, configurationProperties.getXmlRests());
+                        loadXmlRests(applicationContext, camelContext, configurationProperties.getXmlRests());
                     }
-                    
+
                     for (CamelContextConfiguration camelContextConfiguration : camelContextConfigurations) {
                         LOG.debug("CamelContextConfiguration found. Invoking: {}", camelContextConfiguration);
                         camelContextConfiguration.beforeApplicationStart(camelContext);
                     }
 
                     camelContext.start();
-                    
+
                     for (CamelContextConfiguration camelContextConfiguration : camelContextConfigurations) {
                         camelContextConfiguration.afterApplicationStart(camelContext);
                     }
-                    
+
                 } catch (Exception e) {
                     throw new CamelSpringBootInitializationException(e);
                 }
@@ -138,22 +138,22 @@ public class RoutesCollector implements ApplicationListener<ContextRefreshedEven
     }
 
     private void loadXmlRests(ApplicationContext applicationContext, CamelContext camelContext, String directory) {
-    	LOG.info("Loading additional Camel XML rests from: {}", directory);
-    	try {
-    		final Resource[] xmlRests = applicationContext.getResources(directory);
-    		for (final Resource xmlRest : xmlRests) {
-    			final RestsDefinition xmlDefinitions = camelContext.loadRestsDefinition(xmlRest.getInputStream());
-    			camelContext.addRestDefinitions(xmlDefinitions.getRests());
-    			for (final RestDefinition xmlDefinition : xmlDefinitions.getRests()) {
-    				final List<RouteDefinition> routeDefinitions = xmlDefinition.asRouteDefinition(camelContext);
-    				camelContext.addRouteDefinitions(routeDefinitions);
-    			}
-    		}
-    	} catch (FileNotFoundException e) {
+        LOG.info("Loading additional Camel XML rests from: {}", directory);
+        try {
+            final Resource[] xmlRests = applicationContext.getResources(directory);
+            for (final Resource xmlRest : xmlRests) {
+                final RestsDefinition xmlDefinitions = camelContext.loadRestsDefinition(xmlRest.getInputStream());
+                camelContext.addRestDefinitions(xmlDefinitions.getRests());
+                for (final RestDefinition xmlDefinition : xmlDefinitions.getRests()) {
+                    final List<RouteDefinition> routeDefinitions = xmlDefinition.asRouteDefinition(camelContext);
+                    camelContext.addRouteDefinitions(routeDefinitions);
+                }
+            }
+        } catch (FileNotFoundException e) {
             LOG.debug("No XML rests found in {}. Skipping XML rests detection.", directory);
-    	} catch (Exception e) {
-    		throw new RuntimeException(e);
-    	}
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
     }
-    
+
 }