camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r618910 - in /activemq/camel/trunk: 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/handler/ components/camel-spri...
Date Wed, 06 Feb 2008 06:55:20 GMT
Author: hadrian
Date: Tue Feb  5 22:55:19 2008
New Revision: 618910

URL: http://svn.apache.org/viewvc?rev=618910&view=rev
Log:
CAMEL-295.  Fixed injection of RouteBuilder(s).

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java?rev=618910&r1=618909&r2=618910&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
Tue Feb  5 22:55:19 2008
@@ -58,6 +58,7 @@
     public RouteBuilder createRouteBuilder(CamelContext camelContext) {
         ObjectHelper.notNull(camelContext, "camelContext");
         ObjectHelper.notNull(ref, "ref");
-        return CamelContextHelper.newInstance(camelContext, RouteBuilder.class);
+        RouteBuilder builder = CamelContextHelper.lookup(camelContext, ref, RouteBuilder.class);
+        return builder != null ? builder : CamelContextHelper.newInstance(camelContext, RouteBuilder.class);
     }
 }

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=618910&r1=618909&r2=618910&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Tue Feb  5 22:55:19 2008
@@ -69,8 +69,11 @@
     private Boolean autowireRouteBuilders = Boolean.TRUE;
     @XmlElement(name = "package", required = false)
     private String[] packages = {};
-    @XmlElements({@XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class,
required = false), @XmlElement(name = "proxy", type = CamelProxyFactoryType.class, required
= false),
-    @XmlElement(name = "export", type = CamelServiceExporterType.class, required = false),
@XmlElement(name = "jmxAgent", required = false)})
+    @XmlElements({
+        @XmlElement(name = "beanPostProcessor", type = CamelBeanPostProcessor.class, required
= false), 
+        @XmlElement(name = "proxy", type = CamelProxyFactoryType.class, required = false),
+        @XmlElement(name = "export", type = CamelServiceExporterType.class, required = false),

+        @XmlElement(name = "jmxAgent", required = false)})
     private List beans;
     @XmlElement(name = "routeBuilderRef", required = false)
     private List<RouteBuilderRef> builderRefs = new ArrayList<RouteBuilderRef>();;
@@ -248,6 +251,10 @@
         this.useJmx = useJmx;
     }
 
+    public List<RouteBuilderRef> getBuilderRefs() {
+        return builderRefs;
+    }
+
     public void setBuilderRefs(List<RouteBuilderRef> builderRefs) {
         this.builderRefs = builderRefs;
     }
@@ -291,9 +298,7 @@
             getContext().addRoutes(routeBuilder);
         }
 
-        //System.out.println(">>> CamelContext: " + getId() + " " + " routeBuilderRefs
" + builderRefs);
-        
-        // lets add route builders addef from references
+        // lets add route builders added from references
         if (builderRefs != null) {
             for (RouteBuilderRef builderRef : builderRefs) {
                 RouteBuilder builder = builderRef.createRouteBuilder(getContext());

Modified: activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java?rev=618910&r1=618909&r2=618910&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/handler/CamelNamespaceHandler.java
Tue Feb  5 22:55:19 2008
@@ -159,6 +159,7 @@
                 CamelContextFactoryBean factoryBean = (CamelContextFactoryBean) value;
                 builder.addPropertyValue("id", contextId);
                 builder.addPropertyValue("routes", factoryBean.getRoutes());
+                builder.addPropertyValue("builderRefs", factoryBean.getBuilderRefs());
 
                 if (factoryBean.getPackages().length > 0) {
                     builder.addPropertyValue("packages", factoryBean.getPackages());

Modified: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java?rev=618910&r1=618909&r2=618910&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
Tue Feb  5 22:55:19 2008
@@ -44,9 +44,9 @@
 
     }
 
-    // TODO for some reason this doesn't get injected with the RouteBuilderRef object!
-    public void TODO_testUsingRouteBuilderRefInCamelXml() throws Exception {
-        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");
+    public void testUsingRouteBuilderRefInCamelXml() throws Exception {
+        ApplicationContext applicationContext = 
+            new ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");
 
         CamelContext context = (CamelContext) applicationContext.getBean("camel5");
         assertValidContext(context);



Mime
View raw message