camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r781349 - in /camel/trunk/components/camel-spring/src: main/java/org/apache/camel/component/event/ main/java/org/apache/camel/spring/ test/java/org/apache/camel/component/event/
Date Wed, 03 Jun 2009 12:04:39 GMT
Author: davsclaus
Date: Wed Jun  3 12:04:38 2009
New Revision: 781349

URL: http://svn.apache.org/viewvc?rev=781349&view=rev
Log:
CAMEL-1663: Fixed bug with using Camel and other annotations in same POJO and RouteBuilder
classes.

Modified:
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/event/EventRouteTest.java

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java?rev=781349&r1=781348&r2=781349&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/component/event/EventEndpoint.java
Wed Jun  3 12:04:38 2009
@@ -64,16 +64,17 @@
     }
 
     public Producer createProducer() throws Exception {
-        ObjectHelper.notNull(getApplicationContext(), "applicationContext");
+        ObjectHelper.notNull(applicationContext, "applicationContext");
         return new DefaultProducer(this) {
             public void process(Exchange exchange) throws Exception {
                 ApplicationEvent event = toApplicationEvent(exchange);
-                getApplicationContext().publishEvent(event);
+                applicationContext.publishEvent(event);
             }
         };
     }
 
     public EventConsumer createConsumer(Processor processor) throws Exception {
+        ObjectHelper.notNull(applicationContext, "applicationContext");
         return new EventConsumer(this, processor);
     }
 

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=781349&r1=781348&r2=781349&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
Wed Jun  3 12:04:38 2009
@@ -434,18 +434,23 @@
     }
 
     public void onApplicationEvent(ApplicationEvent event) {
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Publishing spring-event: " + event);
-        }
+        if (context != null) {
+            // let the spring camel context handle the events
+            context.onApplicationEvent(event);
+        } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Publishing spring-event: " + event);
+            }
 
-        if (event instanceof ContextRefreshedEvent) {
-            // now lets start the CamelContext so that all its possible
-            // dependencies are initialized
-            try {
-                LOG.debug("Starting the context now!");
-                getContext().start();
-            } catch (Exception e) {
-                throw wrapRuntimeCamelException(e);
+            if (event instanceof ContextRefreshedEvent) {
+                // now lets start the CamelContext so that all its possible
+                // dependencies are initialized
+                try {
+                    LOG.debug("Starting the context now!");
+                    getContext().start();
+                } catch (Exception e) {
+                    throw wrapRuntimeCamelException(e);
+                }
             }
         }
     }

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=781349&r1=781348&r2=781349&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
(original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Wed Jun  3 12:04:38 2009
@@ -66,8 +66,7 @@
         setApplicationContext(applicationContext);
     }
 
-    public static SpringCamelContext springCamelContext(ApplicationContext applicationContext)
-        throws Exception {
+    public static SpringCamelContext springCamelContext(ApplicationContext applicationContext)
throws Exception {
         // lets try and look up a configured camel context in the context
         String[] names = applicationContext.getBeanNamesForType(SpringCamelContext.class);
         if (names.length == 1) {

Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/event/EventRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/event/EventRouteTest.java?rev=781349&r1=781348&r2=781349&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/event/EventRouteTest.java
(original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/event/EventRouteTest.java
Wed Jun  3 12:04:38 2009
@@ -31,10 +31,6 @@
     protected String uri = "spring-event:default";
 
     public void testSendingCamelExchangeToEndpointResultsInValidApplicationEventAfterTheRefreshEvent()
throws Exception {
-        // TODO: CAMEL-1663: spring-event is broken
-
-        /*
-
         MockEndpoint result = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
         result.expectedMessageCount(2);
 
@@ -55,7 +51,6 @@
         CamelEvent event = assertIsInstanceOf(CamelEvent.class, body);
         Object actualBody = event.getExchange().getIn().getBody();
         assertEquals("Received event body", expectedBody, actualBody);
-        */
     }
 
     protected AbstractXmlApplicationContext createApplicationContext() {



Mime
View raw message