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 2013/03/20 10:36:53 UTC
svn commit: r1458701 - in
/camel/trunk/camel-core/src/main/java/org/apache/camel: CamelContext.java
impl/DefaultCamelContext.java
Author: davsclaus
Date: Wed Mar 20 09:36:52 2013
New Revision: 1458701
URL: http://svn.apache.org/r1458701
Log:
CAMEL-6184: removeComponent should stop component first to be similar to removeEndpoints
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=1458701&r1=1458700&r2=1458701&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Wed Mar 20 09:36:52 2013
@@ -240,6 +240,8 @@ public interface CamelContext extends Su
/**
* Removes a previously added component.
+ * <p/>
+ * The component being removed will be stopped first.
*
* @param componentName the component name to remove
* @return the previously added component or null if it had not been previously added.
@@ -305,6 +307,8 @@ public interface CamelContext extends Su
/**
* Removes all endpoints with the given URI.
+ * <p/>
+ * The endpoints being removed will be stopped first.
*
* @param pattern an uri or pattern to match
* @return a collection of endpoints removed which could be empty if there are no endpoints found for the given <tt>pattern</tt>
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=1458701&r1=1458700&r2=1458701&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Wed Mar 20 09:36:52 2013
@@ -355,17 +355,22 @@ public class DefaultCamelContext extends
public Component removeComponent(String componentName) {
synchronized (components) {
- Component answer = components.remove(componentName);
- if (answer != null) {
+ Component oldComponent = components.remove(componentName);
+ if (oldComponent != null) {
+ try {
+ stopServices(oldComponent);
+ } catch (Exception e) {
+ log.warn("Error stopping component " + oldComponent + ". This exception will be ignored.", e);
+ }
for (LifecycleStrategy strategy : lifecycleStrategies) {
- strategy.onComponentRemove(componentName, answer);
+ strategy.onComponentRemove(componentName, oldComponent);
}
}
// keep reference to properties component up to date
- if (answer != null && "properties".equals(componentName)) {
+ if (oldComponent != null && "properties".equals(componentName)) {
propertiesComponent = null;
}
- return answer;
+ return oldComponent;
}
}
@@ -416,11 +421,11 @@ public class DefaultCamelContext extends
if (EndpointHelper.matchEndpoint(this, oldEndpoint.getEndpointUri(), uri)) {
try {
stopServices(oldEndpoint);
- answer.add(oldEndpoint);
- endpoints.remove(entry.getKey());
} catch (Exception e) {
- log.warn("Error stopping endpoint {}. This exception will be ignored.", oldEndpoint);
+ log.warn("Error stopping endpoint " + oldEndpoint + ". This exception will be ignored.", e);
}
+ answer.add(oldEndpoint);
+ endpoints.remove(entry.getKey());
}
}
}