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 2009/06/17 15:01:55 UTC
svn commit: r785578 - in /camel/branches/camel-1.x: ./
components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Author: davsclaus
Date: Wed Jun 17 13:01:54 2009
New Revision: 785578
URL: http://svn.apache.org/viewvc?rev=785578&view=rev
Log:
Merged revisions 785564 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r785564 | davsclaus | 2009-06-17 13:54:25 +0200 (Wed, 17 Jun 2009) | 1 line
CAMEL-1711: Fixed bug where the Camel routes will be started more than once if spring sends multiple refresh events.
........
Modified:
camel/branches/camel-1.x/ (props changed)
camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jun 17 13:01:54 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,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704
+/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,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java?rev=785578&r1=785577&r2=785578&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java (original)
+++ camel/branches/camel-1.x/components/camel-spring/src/main/java/org/apache/camel/spring/SpringCamelContext.java Wed Jun 17 13:01:54 2009
@@ -54,7 +54,8 @@
* @version $Revision$
*/
public class SpringCamelContext extends DefaultCamelContext implements InitializingBean, DisposableBean,
- ApplicationContextAware, ApplicationListener {
+ ApplicationContextAware, ApplicationListener {
+
private static final transient Log LOG = LogFactory.getLog(SpringCamelContext.class);
private ApplicationContext applicationContext;
private EventEndpoint eventEndpoint;
@@ -80,7 +81,6 @@
return answer;
}
-
public static SpringCamelContext springCamelContext(String configLocations) throws Exception {
return springCamelContext(new ClassPathXmlApplicationContext(configLocations));
}
@@ -90,11 +90,17 @@
}
private void maybeStart() throws Exception {
- if (getShouldStartContext()) {
- LOG.debug("Starting the CamelContext now that the ApplicationContext has started");
+ if (!getShouldStartContext()) {
+ LOG.info("Not starting Apache Camel as property ShouldStartContext is false");
+ return;
+ }
+
+ if (!isStarted()) {
+ LOG.info("Starting Apache Camel as property ShouldStartContext is true");
start();
} else {
- LOG.debug("Not starting the CamelContext since shouldStartContext property was false.");
+ // ignore as Camel is already started
+ LOG.trace("Ignoring maybeStart() as Apache Camel is already started");
}
}
@@ -104,7 +110,7 @@
public void onApplicationEvent(ApplicationEvent event) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Publishing spring-event: " + event);
+ LOG.debug("onApplicationEvent: " + event);
}
if (event instanceof ContextRefreshedEvent) {
@@ -117,15 +123,12 @@
} catch (Exception e) {
throw wrapRuntimeCamelException(e);
}
- if (eventEndpoint != null) {
- eventEndpoint.onApplicationEvent(event);
- }
+ }
+
+ if (eventEndpoint != null) {
+ eventEndpoint.onApplicationEvent(event);
} else {
- if (eventEndpoint != null) {
- eventEndpoint.onApplicationEvent(event);
- } else {
- LOG.warn("No spring-event endpoint enabled for: " + event);
- }
+ LOG.warn("No spring-event endpoint enabled to handle event: " + event);
}
}
@@ -181,8 +184,7 @@
}
protected EventEndpoint createEventEndpoint() {
- EventEndpoint endpoint = getEndpoint("spring-event:default", EventEndpoint.class);
- return endpoint;
+ return getEndpoint("spring-event:default", EventEndpoint.class);
}
protected Endpoint convertBeanToEndpoint(String uri, Object bean) {
@@ -211,6 +213,16 @@
public boolean getShouldStartContext() {
return shouldStartContext;
- }
-
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("SpringCamelContext(").append(getName()).append(")");
+ if (applicationContext != null) {
+ sb.append(" with spring id ").append(applicationContext.getId());
+ }
+ return sb.toString();
+ }
+
}