camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r763492 - in /camel/branches/camel-1.x: ./ camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/main/java/org/apache/camel/spring/ components/camel-spring/src/main/java/org/apache/camel/spring/spi/ components/camel-s...
Date Thu, 09 Apr 2009 01:39:28 GMT
Author: ningjiang
Date: Thu Apr  9 01:39:28 2009
New Revision: 763492

URL: http://svn.apache.org/viewvc?rev=763492&view=rev
Log:
Merged revisions 763484 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r763484 | ningjiang | 2009-04-09 08:57:42 +0800 (Thu, 09 Apr 2009) | 1 line
  
  CAMEL-1522 CamelContextFactoryBean - support proxied RouteBuilders
........

Added:
    camel/branches/camel-1.x/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java
      - copied unchanged from r763484, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/RouteRefCamelContextFactoryBeanTest.java
    camel/branches/camel-1.x/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
      - copied, changed from r763484, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
Modified:
    camel/branches/camel-1.x/   (props changed)
    camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
    camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Apr  9 01:39:28 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484

Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java?rev=763492&r1=763491&r2=763492&view=diff
==============================================================================
--- camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
(original)
+++ camel/branches/camel-1.x/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
Thu Apr  9 01:39:28 2009
@@ -22,6 +22,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Routes;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -59,8 +60,13 @@
 
     public RouteBuilder createRouteBuilder(CamelContext camelContext) {
         ObjectHelper.notNull(camelContext, "camelContext");
-        ObjectHelper.notNull(ref, "ref");
-        RouteBuilder builder = CamelContextHelper.lookup(camelContext, ref, RouteBuilder.class);
-        return builder != null ? builder : CamelContextHelper.newInstance(camelContext, RouteBuilder.class);
+        ObjectHelper.notNull(ref, "ref");        
+        return CamelContextHelper.lookup(camelContext, ref, RouteBuilder.class);        
+    }
+
+    public Routes createRoutes(CamelContext camelContext) {
+        ObjectHelper.notNull(camelContext, "camelContext", this);
+        ObjectHelper.notNull(ref, "ref", this);
+        return CamelContextHelper.lookup(camelContext, ref, Routes.class);
     }
 }
\ No newline at end of file

Modified: camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=763492&r1=763491&r2=763492&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Thu Apr  9 01:39:28 2009
@@ -28,6 +28,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
+import org.apache.camel.CamelException;
 import org.apache.camel.Routes;
 import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.RouteBuilder;
@@ -67,6 +68,7 @@
 
 import static org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException;
 
+
 /**
  * A Spring {@link FactoryBean} to create and initialize a
  * {@link SpringCamelContext} and install routes either explicitly configured in
@@ -579,11 +581,22 @@
         if (builderRefs != null) {
             for (RouteBuilderRef builderRef : builderRefs) {
                 RouteBuilder builder = builderRef.createRouteBuilder(getContext());
-                if (beanPostProcessor != null) {
-                    // Inject the annotated resource
-                    beanPostProcessor.postProcessBeforeInitialization(builder, builder.toString());
+                if (builder != null) {
+                    if (beanPostProcessor != null) {
+                        // Inject the annotated resource
+                        beanPostProcessor.postProcessBeforeInitialization(builder, builder.toString());
+                    }
+                    getContext().addRoutes(builder);
+                } else {
+                    // support to get the route here
+                    Routes routes = builderRef.createRoutes(getContext());
+                    if (routes != null) {
+                        getContext().addRoutes(routes);
+                    } else {
+                        // Throw the exception that we can't find any build here
+                        throw new CamelException("Can't find any routes info with this RouteBuilderDefinition
" + builderRef);
+                    }
                 }
-                getContext().addRoutes(builder);
             }
         }
     }

Modified: camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java?rev=763492&r1=763491&r2=763492&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java
(original)
+++ camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/spi/ApplicationContextRegistry.java
Thu Apr  9 01:39:28 2009
@@ -18,6 +18,7 @@
 
 import org.apache.camel.spi.Registry;
 
+import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
 import org.springframework.context.ApplicationContext;
 
@@ -40,6 +41,8 @@
             return type.cast(value);
         } catch (NoSuchBeanDefinitionException e) {
             return null;
+        } catch (BeanNotOfRequiredTypeException e) {
+            return null;
         }
     }
 

Copied: camel/branches/camel-1.x/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
(from r763484, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml)
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml?p2=camel/branches/camel-1.x/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml&r1=763484&r2=763492&rev=763492&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
(original)
+++ camel/branches/camel-1.x/components/camel-spring/src/test/resources/org/apache/camel/spring/routeRefCamelContextFactory.xml
Thu Apr  9 01:39:28 2009
@@ -19,12 +19,12 @@
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
-       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
     ">
 
   <!-- START SNIPPET: example -->
-  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    <routeBuilder ref="myRoutes"/>
+  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <routeBuilderRef ref="myRoutes"/>
   </camelContext>
   <!-- END SNIPPET: example -->
   <bean id="myRoutes" class="org.apache.camel.spring.RouteRefCamelContextFactoryBeanTest$MyRoutes"/>



Mime
View raw message