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 2010/03/01 11:44:31 UTC
svn commit: r917460 - in
/camel/trunk/camel-core/src/main/java/org/apache/camel/impl:
DefaultShutdownStrategy.java MainSupport.java
Author: davsclaus
Date: Mon Mar 1 10:44:31 2010
New Revision: 917460
URL: http://svn.apache.org/viewvc?rev=917460&view=rev
Log:
CAMEL-2508: Added callbacks for afterStart and beforeStop in MainSupport.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java?rev=917460&r1=917459&r2=917460&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultShutdownStrategy.java Mon Mar 1 10:44:31 2010
@@ -299,7 +299,7 @@
if (shutdown) {
// if we are to shutdown then check whether we can suspend instead as its a more
- // gentle wat to graceful shutdown
+ // gentle way to graceful shutdown
// some consumers do not support shutting down so let them decide
// if a consumer is suspendable then prefer to use that and then shutdown later
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java?rev=917460&r1=917459&r2=917460&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/MainSupport.java Mon Mar 1 10:44:31 2010
@@ -80,7 +80,7 @@
}
});
addOption(new ParameterOption("d", "duration",
- "Sets the time duration that the applicaiton will run for, by default in milliseconds. You can use '10s' for 10 seconds etc",
+ "Sets the time duration that the application will run for, by default in milliseconds. You can use '10s' for 10 seconds etc",
"duration") {
protected void doProcess(String arg, String parameter, LinkedList<String> remainingArgs) {
String value = parameter.toUpperCase();
@@ -113,16 +113,32 @@
// if we have an issue starting the propagate exception to caller
start();
try {
- // while running then just log errors
+ afterStart();
waitUntilCompleted();
+ beforeStop();
stop();
} catch (Exception e) {
+ // while running then just log errors
LOG.error("Failed: " + e, e);
}
}
}
/**
+ * Callback to run custom logic after CamelContext has been started
+ */
+ protected void afterStart() {
+ // noop
+ }
+
+ /**
+ * Callback to run custom logic before CamelContext is being stopped
+ */
+ protected void beforeStop() {
+ // noop
+ }
+
+ /**
* Marks this process as being completed
*/
public void completed() {
@@ -130,6 +146,8 @@
latch.countDown();
}
+
+
/**
* Displays the command line options
*/
@@ -319,7 +337,7 @@
protected void postProcessContext() throws Exception {
Map<String, CamelContext> map = getCamelContextMap();
if (map.size() == 0) {
- throw new CamelException("Can't find any Camel Context from the Application Context. Please check your Application Context setting");
+ throw new CamelException("Cannot find any Camel Context from the Application Context. Please check your Application Context setting");
}
Set<Map.Entry<String, CamelContext>> entries = map.entrySet();
int size = entries.size();
@@ -328,7 +346,7 @@
CamelContext camelContext = entry.getValue();
camelContexts.add(camelContext);
generateDot(name, camelContext, size);
- postProcesCamelContext(camelContext);
+ postProcessCamelContext(camelContext);
}
if (isAggregateDot()) {
@@ -377,7 +395,7 @@
}
}
- protected void postProcesCamelContext(CamelContext camelContext) throws Exception {
+ protected void postProcessCamelContext(CamelContext camelContext) throws Exception {
for (RouteBuilder routeBuilder : routeBuilders) {
camelContext.addRoutes(routeBuilder);
}