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/05/09 10:48:24 UTC
svn commit: r773182 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/impl/
camel-core/src/main/java/org/apache/camel/util/
camel-core/src/test/java/org/apache/camel/impl/ tests/camel-itest/src/test...
Author: davsclaus
Date: Sat May 9 08:48:24 2009
New Revision: 773182
URL: http://svn.apache.org/viewvc?rev=773182&view=rev
Log:
CAMEL-1572: Renamed to better name suggested by Willem.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java?rev=773182&r1=773181&r2=773182&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/ProducerTemplate.java Sat May 9 08:48:24 2009
@@ -790,7 +790,7 @@
* @return the result (see class javadoc)
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T asyncExtractBody(Future future, Class<T> type);
+ <T> T extractFutureBody(Future future, Class<T> type);
/**
* Gets the response body from the future handle, will wait at most the given time for the response to be ready.
@@ -806,6 +806,6 @@
* @throws java.util.concurrent.TimeoutException if the wait timed out
* @throws CamelExecutionException if the processing of the exchange failed
*/
- <T> T asyncExtractBody(Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException;
+ <T> T extractFutureBody(Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException;
}
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java?rev=773182&r1=773181&r2=773182&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultProducerTemplate.java Sat May 9 08:48:24 2009
@@ -563,12 +563,12 @@
return executor.submit(task);
}
- public <T> T asyncExtractBody(Future future, Class<T> type) {
- return ExchangeHelper.asyncExtractBody(context, future, type);
+ public <T> T extractFutureBody(Future future, Class<T> type) {
+ return ExchangeHelper.extractFutureBody(context, future, type);
}
- public <T> T asyncExtractBody(Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException {
- return ExchangeHelper.asyncExtractBody(context, future, timeout, unit, type);
+ public <T> T extractFutureBody(Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException {
+ return ExchangeHelper.extractFutureBody(context, future, timeout, unit, type);
}
}
\ No newline at end of file
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java?rev=773182&r1=773181&r2=773182&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/util/ExchangeHelper.java Sat May 9 08:48:24 2009
@@ -470,9 +470,9 @@
* @return the result body, can be <tt>null</tt>.
* @throws CamelExecutionException if the processing of the exchange failed
*/
- public static <T> T asyncExtractBody(CamelContext context, Future future, Class<T> type) {
+ public static <T> T extractFutureBody(CamelContext context, Future future, Class<T> type) {
try {
- return doExtractBody(context, future.get(), type);
+ return doExtractFutureBody(context, future.get(), type);
} catch (InterruptedException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
} catch (ExecutionException e) {
@@ -495,12 +495,12 @@
* @throws CamelExecutionException if the processing of the exchange failed
* @throws java.util.concurrent.TimeoutException is thrown if a timeout triggered
*/
- public static <T> T asyncExtractBody(CamelContext context, Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException {
+ public static <T> T extractFutureBody(CamelContext context, Future future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException {
try {
if (timeout > 0) {
- return doExtractBody(context, future.get(timeout, unit), type);
+ return doExtractFutureBody(context, future.get(timeout, unit), type);
} else {
- return doExtractBody(context, future.get(), type);
+ return doExtractFutureBody(context, future.get(), type);
}
} catch (InterruptedException e) {
throw ObjectHelper.wrapRuntimeCamelException(e);
@@ -510,7 +510,7 @@
}
}
- private static <T> T doExtractBody(CamelContext context, Object result, Class<T> type) {
+ private static <T> T doExtractFutureBody(CamelContext context, Object result, Class<T> type) {
if (result == null) {
return null;
}
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java?rev=773182&r1=773181&r2=773182&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/impl/DefaultProducerTemplateAsyncTest.java Sat May 9 08:48:24 2009
@@ -85,7 +85,7 @@
assertEquals("HiHi", echo);
// we can use extract body to convert to expect body type
- String result = template.asyncExtractBody(future, String.class);
+ String result = template.extractFutureBody(future, String.class);
long delta = System.currentTimeMillis() - start;
assertTrue("Should take longer than: " + delta, delta > 250);
@@ -121,7 +121,7 @@
assertEquals("HiHi", echo);
// we can use extract body to convert to expect body type
- String result = template.asyncExtractBody(future, String.class);
+ String result = template.extractFutureBody(future, String.class);
assertMockEndpointsSatisfied();
@@ -169,7 +169,7 @@
assertEquals("HiHi", echo);
// we can use extract body to convert to expect body type
- String result = template.asyncExtractBody(future, String.class);
+ String result = template.extractFutureBody(future, String.class);
assertMockEndpointsSatisfied();
@@ -216,7 +216,7 @@
assertEquals("HiHi", echo);
try {
- Exchange result = template.asyncExtractBody(future, Exchange.class);
+ Exchange result = template.extractFutureBody(future, Exchange.class);
fail("Should have thrown exception");
} catch (RuntimeCamelException e) {
assertEquals("Damn forced by unit test", e.getCause().getMessage());
@@ -235,7 +235,7 @@
assertEquals("HiHi", echo);
try {
- String result = template.asyncExtractBody(future, String.class);
+ String result = template.extractFutureBody(future, String.class);
fail("Should have thrown exception");
} catch (RuntimeCamelException e) {
assertEquals("Damn forced by unit test", e.getCause().getMessage());
@@ -263,7 +263,7 @@
String echo = template.requestBody("direct:echo", "Hi", String.class);
assertEquals("HiHi", echo);
- String result = template.asyncExtractBody(future, String.class);
+ String result = template.extractFutureBody(future, String.class);
assertMockEndpointsSatisfied();
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java?rev=773182&r1=773181&r2=773182&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncTest.java Sat May 9 08:48:24 2009
@@ -30,26 +30,27 @@
public void testAsyncAndSyncAtSameTimeWithHttp() throws Exception {
// START SNIPPET: e2
MockEndpoint mock = getMockEndpoint("mock:result");
- // we expect the name job to be faster than the async job even though the async job
+ // We expect the name job to be faster than the async job even though the async job
// was started first
mock.expectedBodiesReceived("Claus", "Bye World");
- // send a async request/reply message to the http endpoint
+ // Send a async request/reply message to the http endpoint
Future future = template.asyncRequestBody("http://0.0.0.0:9080/myservice", "Hello World");
- // we got the future so in the meantime we can do other stuff, as this is Camel
+ // We got the future so in the meantime we can do other stuff, as this is Camel
// so lets invoke another request/reply route but this time is synchronous
String name = template.requestBody("direct:name", "Give me a name", String.class);
assertEquals("Claus", name);
- // okay we got a name and we have done some other work at the same time
+ // Okay we got a name and we have done some other work at the same time
// the async route is running, but now its about time to wait and get
// get the response from the async task
- // so we use the async extract body to return a string body response
- // this allows us to do this in a single code line instead of using the
+ // We use the extract future body to get the response from the future
+ // (waiting if needed) and then return a string body response.
+ // This allows us to do this in a single code line instead of using the
// JDK Future API to get hold of it, but you can also use that if you want
- String response = template.asyncExtractBody(future, String.class);
+ String response = template.extractFutureBody(future, String.class);
assertEquals("Bye World", response);
assertMockEndpointsSatisfied();
@@ -62,13 +63,12 @@
@Override
public void configure() throws Exception {
// START SNIPPET: e1
- // the mocks are here for unit test
+ // The mocks are here for unit test
- // some other service to return a name, this is invoked
- // synhronously
+ // Some other service to return a name, this is invoked synhronously
from("direct:name").transform(constant("Claus")).to("mock:result");
- // simulate a slow http service we want to invoke async
+ // Simulate a slow http service (delaying 1 sec) we want to invoke async
from("jetty:http://0.0.0.0:9080/myservice")
.delay(1000)
.transform(constant("Bye World"))