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/04/13 09:36:32 UTC
svn commit: r1467570 - in /camel/branches/camel-2.10.x: ./
camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java
Author: davsclaus
Date: Sat Apr 13 07:36:31 2013
New Revision: 1467570
URL: http://svn.apache.org/r1467570
Log:
CAMEL-6265: direct-vm component - The processor should support async routing engine
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1467569
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java?rev=1467570&r1=1467569&r2=1467570&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java (original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/component/directvm/DirectVmProcessor.java Sat Apr 13 07:36:31 2013
@@ -16,9 +16,10 @@
*/
package org.apache.camel.component.directvm;
+import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
-import org.apache.camel.processor.DelegateProcessor;
+import org.apache.camel.processor.DelegateAsyncProcessor;
import org.apache.camel.util.ExchangeHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -26,7 +27,7 @@ import org.slf4j.LoggerFactory;
/**
*
*/
-public final class DirectVmProcessor extends DelegateProcessor {
+public final class DirectVmProcessor extends DelegateAsyncProcessor {
private static final transient Logger LOG = LoggerFactory.getLogger(DirectVmProcessor.class);
private final DirectVmEndpoint endpoint;
@@ -37,9 +38,9 @@ public final class DirectVmProcessor ext
}
@Override
- public void process(Exchange exchange) throws Exception {
+ public boolean process(final Exchange exchange, final AsyncCallback callback) {
// need to use a copy of the incoming exchange, so we route using this camel context
- Exchange copy = prepareExchange(exchange);
+ final Exchange copy = prepareExchange(exchange);
ClassLoader current = Thread.currentThread().getContextClassLoader();
boolean changed = false;
@@ -51,10 +52,19 @@ public final class DirectVmProcessor ext
Thread.currentThread().setContextClassLoader(appClassLoader);
changed = true;
}
- getProcessor().process(copy);
+ return getProcessor().process(copy, new AsyncCallback() {
+ @Override
+ public void done(boolean done) {
+ try {
+ // make sure to copy results back
+ ExchangeHelper.copyResults(exchange, copy);
+ } finally {
+ // must call callback when we are done
+ callback.done(done);
+ }
+ }
+ });
} finally {
- // make sure to copy results back
- ExchangeHelper.copyResults(exchange, copy);
// restore TCCL if it was changed during processing
if (changed) {
LOG.trace("Restoring Thread ContextClassLoader to {}", current);