camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r618707 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/resources/org/apache/camel/model/ components/camel-jaxb/src/test/resources/org/apache/camel/example/ components/camel-spring/src/main/j...
Date Tue, 05 Feb 2008 17:32:04 GMT
Author: jstrachan
Date: Tue Feb  5 09:31:54 2008
New Revision: 618707

URL: http://svn.apache.org/viewvc?rev=618707&view=rev
Log:
attempted fix for http://issues.apache.org/activemq/browse/CAMEL-295 but cannot get the test
case working...

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
      - copied, changed from r613112, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
  (contents, props changed)
      - copied, changed from r618625, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java
  (with props)
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml
      - copied, changed from r618625, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml
  (with props)
Removed:
    activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
Modified:
    activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
    activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml
    activemq/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml

Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
(from r613112, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java&r1=613112&r2=618707&rev=618707&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/BeanRef.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteBuilderRef.java
Tue Feb  5 09:31:54 2008
@@ -20,45 +20,31 @@
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.camel.Processor;
-import org.apache.camel.component.bean.BeanProcessor;
-import org.apache.camel.component.bean.RegistryBean;
-import org.apache.camel.impl.RouteContext;
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.ObjectHelper;
 
 /**
  * @version $Revision: 1.1 $
  */
-@XmlRootElement(name = "bean")
+@XmlRootElement(name = "routeBuilderRef")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class BeanRef extends OutputType<ProcessorType> {
+public class RouteBuilderRef extends IdentifiedType {
     @XmlAttribute(required = true)
     private String ref;
-    @XmlAttribute(required = false)
-    private String method;
-    @XmlAttribute(required = false)
-    private Class beanType;
-    @XmlTransient
-    private Object bean;
 
-    public BeanRef() {
+    public RouteBuilderRef() {
     }
 
-    public BeanRef(String ref) {
+    public RouteBuilderRef(String ref) {
         this.ref = ref;
     }
 
-    public BeanRef(String ref, String method) {
-        this.ref = ref;
-        this.method = method;
-    }
-
     @Override
     public String toString() {
-        return "Bean[" + getLabel() + "]";
+        return "RouteBuilderRef[" + getRef() + "]";
     }
 
     public String getRef() {
@@ -69,62 +55,9 @@
         this.ref = ref;
     }
 
-    public String getMethod() {
-        return method;
-    }
-
-    public void setMethod(String method) {
-        this.method = method;
-    }
-
-    public void setBean(Object bean) {
-        this.bean = bean;
-    }
-
-    public Class getBeanType() {
-        return beanType;
-    }
-
-    public void setBeanType(Class beanType) {
-        this.beanType = beanType;
-    }
-
-    @Override
-    public Processor createProcessor(RouteContext routeContext) {
-        BeanProcessor answer;
-        if (ref != null) {
-            answer = new BeanProcessor(new RegistryBean(routeContext.getCamelContext(), ref));
-        }
-        else {
-            if (bean == null) {
-                ObjectHelper.notNull(beanType, "bean, ref or beanType");
-                bean = CamelContextHelper.newInstance(routeContext.getCamelContext(), beanType);
-            }
-            answer = new BeanProcessor(bean, routeContext.getCamelContext());
-        }
-        if (method != null) {
-            answer.setMethod(method);
-        }
-        return answer;
-    }
-
-    @Override
-    public String getLabel() {
-        if (ref != null) {
-            String methodText = "";
-            if (method != null) {
-                methodText = " method: " + method;
-            }
-            return "ref: " + ref + methodText;
-        }
-        else if (bean != null) {
-            return bean.toString();
-        }
-        else if (beanType != null) {
-            return beanType.getName();
-        }
-        else {
-            return "";
-        }
+    public RouteBuilder createRouteBuilder(CamelContext camelContext) {
+        ObjectHelper.notNull(camelContext, "camelContext");
+        ObjectHelper.notNull(ref, "ref");
+        return CamelContextHelper.newInstance(camelContext, RouteBuilder.class);
     }
-}
+}
\ No newline at end of file

Modified: activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=618707&r1=618706&r2=618707&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Tue
Feb  5 09:31:54 2008
@@ -38,6 +38,7 @@
 RedeliveryPolicyType
 ResequencerType
 RouteType
+RouteBuilderRef
 RoutesType
 ServiceActivationType
 SplitterType

Modified: activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml?rev=618707&r1=618706&r2=618707&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml
(original)
+++ activemq/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml
Tue Feb  5 09:31:54 2008
@@ -24,6 +24,8 @@
 
   <!-- START SNIPPET: example -->
   <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
+    <jaxb id="myJaxb" prettyPrint="true" contextPath="org.apache.camel.example"/>
+
     <route>
       <from uri="direct:start"/>
       <marshal ref="myJaxb"/>
@@ -35,7 +37,6 @@
       <to uri="mock:result"/>
     </route>
 
-    <jaxb id="myJaxb" prettyPrint="true" contextPath="org.apache.camel.example"/>
   </camelContext>
   <!-- END SNIPPET: example -->
 

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=618707&r1=618706&r2=618707&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 09:31:54 2008
@@ -35,6 +35,7 @@
 import org.apache.camel.model.IdentifiedType;
 import org.apache.camel.model.RouteContainer;
 import org.apache.camel.model.RouteType;
+import org.apache.camel.model.RouteBuilderRef;
 import org.apache.camel.model.dataformat.DataFormatType;
 import org.apache.camel.spi.InstrumentationAgent;
 import org.apache.commons.logging.Log;
@@ -60,21 +61,25 @@
 @XmlAccessorType(XmlAccessType.FIELD)
 public class CamelContextFactoryBean extends IdentifiedType implements RouteContainer, FactoryBean,
InitializingBean, DisposableBean, ApplicationContextAware, ApplicationListener {
     private static final Log LOG = LogFactory.getLog(CamelContextFactoryBean.class);
+    @XmlAttribute(required = false)
+    private Boolean useJmx;
+    @XmlAttribute(required = false)
+    private String mbeanServer;
+    @XmlAttribute(required = false)
+    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)})
     private List beans;
+    @XmlElement(name = "routeBuilderRef", required = false)
+    private List<RouteBuilderRef> builderRefs = new ArrayList<RouteBuilderRef>();;
     @XmlElement(name = "endpoint", required = false)
     private List<EndpointFactoryBean> endpoints;
-    @XmlElement(name = "route", required = false)
-    private List<RouteType> routes = new ArrayList<RouteType>();
     @XmlElementRef
     private List<DataFormatType> dataFormats;
-    @XmlAttribute(required = false)
-    private Boolean useJmx;
-    @XmlAttribute(required = false)
-    private String mbeanServer;
+    @XmlElement(name = "route", required = false)
+    private List<RouteType> routes = new ArrayList<RouteType>();
     @XmlTransient
     private SpringCamelContext context;
     @XmlTransient
@@ -243,6 +248,18 @@
         this.useJmx = useJmx;
     }
 
+    public void setBuilderRefs(List<RouteBuilderRef> builderRefs) {
+        this.builderRefs = builderRefs;
+    }
+
+    /**
+     * If enabled this will force all {@link RouteBuilder} classes configured in the Spring
+     * {@link ApplicationContext} to be registered automatically with this CamelContext.
+     */
+    public void setAutowireRouteBuilders(Boolean autowireRouteBuilders) {
+        this.autowireRouteBuilders = autowireRouteBuilders;
+    }
+
     // Implementation methods
     // -------------------------------------------------------------------------
 
@@ -259,10 +276,12 @@
      * Strategy to install all available routes into the context
      */
     protected void installRoutes() throws Exception {
-        Map builders = getApplicationContext().getBeansOfType(RouteBuilder.class, true, true);
-        if (builders != null) {
-            for (Object builder : builders.values()) {
-                getContext().addRoutes((RouteBuilder) builder);
+        if (autowireRouteBuilders != null && autowireRouteBuilders.booleanValue())
{
+            Map builders = getApplicationContext().getBeansOfType(RouteBuilder.class, true,
true);
+            if (builders != null) {
+                for (Object builder : builders.values()) {
+                    getContext().addRoutes((RouteBuilder) builder);
+                }
             }
         }
         for (RouteBuilder routeBuilder : additionalBuilders) {
@@ -270,6 +289,16 @@
         }
         if (routeBuilder != null) {
             getContext().addRoutes(routeBuilder);
+        }
+
+        System.out.println(">>> CamelContext: " + getId() + " " + " routeBuilderRefs
" + builderRefs);
+        
+        // lets add route builders addef from references
+        if (builderRefs != null) {
+            for (RouteBuilderRef builderRef : builderRefs) {
+                RouteBuilder builder = builderRef.createRouteBuilder(getContext());
+                getContext().addRoutes(builder);
+            }
         }
     }
 

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java?rev=618707&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java
Tue Feb  5 09:31:54 2008
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.config;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.TestSupport;
+import org.apache.camel.spring.config.XmlConfigTestSupport;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.FromType;
+import org.apache.camel.model.ProcessorType;
+import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 566917 $
+ */
+public class AutoRegisteredRouteBuilderTest extends XmlConfigTestSupport {
+
+    public void testUsingAutoRegisteredRouteBuilderUsingXml() throws Exception {
+        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml");
+
+        CamelContext context = (CamelContext) applicationContext.getBean("camel4");
+        assertValidContext(context);
+    }
+
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/AutoRegisteredRouteBuilderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
(from r618625, activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java?p2=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java&p1=activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java&r1=618625&r2=618707&rev=618707&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CamelContextFactoryBeanTest.java
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
Tue Feb  5 09:31:54 2008
@@ -14,13 +14,17 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.spring;
+package org.apache.camel.spring.config;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
 import org.apache.camel.Route;
 import org.apache.camel.TestSupport;
+import org.apache.camel.spring.config.XmlConfigTestSupport;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.FromType;
+import org.apache.camel.model.ProcessorType;
 import org.apache.camel.impl.EventDrivenConsumerRoute;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -35,9 +39,7 @@
 /**
  * @version $Revision$
  */
-public class CamelContextFactoryBeanTest extends TestSupport {
-    private static final transient Log LOG = LogFactory.getLog(CamelContextFactoryBeanTest.class);
-
+public class CamelContextFactoryBeanTest extends XmlConfigTestSupport {
     public void testClassPathRouteLoading() throws Exception {
         ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
 
@@ -62,24 +64,6 @@
         
         CamelContext context = (CamelContext) applicationContext.getBean("camel3");
         assertValidContext(context);
-    }
-
-    protected void assertValidContext(CamelContext context) {
-        assertNotNull("No context found!", context);
-
-        List<Route> routes = context.getRoutes();
-        LOG.debug("Found routes: " + routes);
-
-        assertEquals("One Route should be found", 1, routes.size());
-
-        for (Route route : routes) {
-            Endpoint key = route.getEndpoint();
-            EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class,
route);
-            Processor processor = consumerRoute.getProcessor();
-            assertNotNull(processor);
-
-            assertEndpointUri(key, "seda:test.a");
-        }
     }
 
     public void testXMLRouteLoading() throws Exception {

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=618707&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
Tue Feb  5 09:31:54 2008
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.config;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.TestSupport;
+import org.apache.camel.spring.config.XmlConfigTestSupport;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.FromType;
+import org.apache.camel.model.ProcessorType;
+import org.apache.camel.impl.EventDrivenConsumerRoute;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+
+import java.util.List;
+
+/**
+ * @version $Revision: 566917 $
+ */
+public class RouteBuilderRefTest extends XmlConfigTestSupport {
+    public void testDummy() throws Exception {
+
+    }
+
+    // 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");
+
+        CamelContext context = (CamelContext) applicationContext.getBean("camel5");
+        assertValidContext(context);
+    }
+
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java?rev=618707&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
Tue Feb  5 09:31:54 2008
@@ -0,0 +1,55 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.config;
+
+import java.util.List;
+
+import org.apache.camel.TestSupport;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.config.CamelContextFactoryBeanTest;
+import org.apache.camel.model.RouteType;
+import org.apache.camel.model.FromType;
+import org.apache.camel.model.ProcessorType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class XmlConfigTestSupport extends TestSupport {
+    protected static final transient Log LOG = LogFactory.getLog(CamelContextFactoryBeanTest.class);
+
+    protected void assertValidContext(CamelContext context) {
+        assertNotNull("No context found!", context);
+
+        List<RouteType> routes = context.getRouteDefinitions();
+        LOG.debug("Found routes: " + routes);
+
+        assertEquals("One Route should be found", 1, routes.size());
+
+        for (RouteType route : routes) {
+            List<FromType> inputs = route.getInputs();
+            assertEquals("Number of inputs", 1, inputs.size());
+            FromType fromType = inputs.get(0);
+            assertEquals("from URI", "seda:test.a", fromType.getEndpoint().getEndpointUri());
+
+            List<ProcessorType<?>> outputs = route.getOutputs();
+            assertEquals("Number of outputs", 1, outputs.size());
+        }
+    }
+}

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/XmlConfigTestSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java?rev=618707&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java
Tue Feb  5 09:31:54 2008
@@ -0,0 +1,52 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.spring.xml;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class ConfiguredRouteBuilder extends RouteBuilder {
+    private String fromUri;
+    private String toUri;
+
+    public void configure() throws Exception {
+        ObjectHelper.notNull(fromUri, "fromUri");
+        ObjectHelper.notNull(toUri, "toUri");
+
+        from(fromUri).to(toUri);
+    }
+
+    public String getFromUri() {
+        return fromUri;
+    }
+
+    public void setFromUri(String fromUri) {
+        this.fromUri = fromUri;
+    }
+
+    public String getToUri() {
+        return toUri;
+    }
+
+    public void setToUri(String toUri) {
+        this.toUri = toUri;
+    }
+}

Propchange: activemq/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/xml/ConfiguredRouteBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml?rev=618707&r1=618706&r2=618707&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
Tue Feb  5 09:31:54 2008
@@ -22,6 +22,8 @@
        http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
     ">
 
+
+
   <!-- START SNIPPET: example -->
   <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
     <property name="packages" value="org.apache.camel.spring.example"/>
@@ -42,5 +44,4 @@
     <package>org.apache.camel.spring.example</package>
   </camelContext>
   <!-- END SNIPPET: example3 -->
-
 </beans>

Copied: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml
(from r618625, activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml?p2=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml&p1=activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml&r1=618625&r2=618707&rev=618707&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/camelContextFactoryBean.xml
(original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/autoRegisteredRouteBuilder.xml
Tue Feb  5 09:31:54 2008
@@ -22,25 +22,14 @@
        http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <bean id="camel" class="org.apache.camel.spring.CamelContextFactoryBean">
-    <property name="packages" value="org.apache.camel.spring.example"/>
-  </bean>
-  <!-- END SNIPPET: example -->
-
-  <!-- START SNIPPET: example2 -->
-  <camelContext id="camel2" xmlns="http://activemq.apache.org/camel/schema/spring">
-    <route>
-      <from uri="seda:test.c"/>
-      <to uri="seda:test.d"/>
-    </route>
+  <!-- START SNIPPET: example4 -->
+  <camelContext id="camel4" xmlns="http://activemq.apache.org/camel/schema/spring" autowireRouteBuilders="true">
   </camelContext>
-  <!-- END SNIPPET: example2 -->
+  <!-- END SNIPPET: example4 -->
 
-  <!-- START SNIPPET: example3 -->
-  <camelContext id="camel3" xmlns="http://activemq.apache.org/camel/schema/spring">
-    <package>org.apache.camel.spring.example</package>
-  </camelContext>
-  <!-- END SNIPPET: example3 -->
 
+  <bean id="configuredRouteBuilder" class="org.apache.camel.spring.xml.ConfiguredRouteBuilder">
+    <property name="fromUri" value="seda:test.a"/>
+    <property name="toUri" value="seda:test.b"/>
+  </bean>
 </beans>

Added: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml?rev=618707&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml
(added)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml
Tue Feb  5 09:31:54 2008
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       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.0.xsd
+       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+    ">
+
+
+
+  <!-- START SNIPPET: example5 -->
+  <camelContext id="camel5" xmlns="http://activemq.apache.org/camel/schema/spring" autowireRouteBuilders="false">
+    <routeBuilderRef ref="configuredRouteBuilder"/>
+  </camelContext>
+  <!-- END SNIPPET: example5 -->
+
+
+  <bean id="configuredRouteBuilder" class="org.apache.camel.spring.xml.ConfiguredRouteBuilder">
+    <property name="fromUri" value="seda:test.a"/>
+    <property name="toUri" value="seda:test.b"/>
+  </bean>
+</beans>

Propchange: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/config/routeBuilderRef.xml
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message