Updated Branches:
refs/heads/camel-2.10.x e6adc77fd -> e4e5aeac9
Close the Spring context properly when done.
Conflicts:
components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e4e5aeac
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e4e5aeac
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e4e5aeac
Branch: refs/heads/camel-2.10.x
Commit: e4e5aeac95354c59ed2813a6c2ff1beb1d696824
Parents: e6adc77
Author: Babak Vahdat <[email protected]>
Authored: Wed May 15 10:24:51 2013 +0200
Committer: Babak Vahdat <[email protected]>
Committed: Wed May 15 11:07:42 2013 +0200
----------------------------------------------------------------------
.../jms/reply/PersistentQueueReplyManager.java | 2 +-
.../SpringQuartzPersistentStoreRestartAppTest.java | 4 +
.../camel/spring/DefaultStreamCachingTest.java | 8 +-
.../camel/spring/config/AnotherCamelProxyTest.java | 9 +-
.../spring/config/CamelContextFactoryBeanTest.java | 25 ++-
.../apache/camel/spring/config/CamelProxyTest.java | 8 +-
.../spring/config/CamelProxyUsingRefTest.java | 9 +-
.../camel/spring/config/RouteBuilderRefTest.java | 9 +-
.../config/scan/SpringComponentScanTest.java | 16 +-
...ingComponentScanWithDeprecatedPackagesTest.java | 16 +-
.../apache/camel/example/client/CamelClient.java | 9 +-
.../camel/example/client/CamelFileClient.java | 8 +-
.../example/spring/javaconfig/IntegrationTest.java | 8 +-
.../apache/camel/example/client/CamelClient.java | 8 +-
.../camel/example/client/CamelClientEndpoint.java | 12 +-
.../camel/example/client/CamelClientRemoting.java | 8 +-
.../src/main/resources/camel-context.xml | 196 +++++++-------
.../customerrelations/CustomerServicesTest.java | 9 +-
.../CustomerServicesWsAddressingTest.java | 9 +-
19 files changed, 215 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
----------------------------------------------------------------------
diff --git
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
index ddcabb4..491d782 100644
---
a/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
+++
b/components/camel-jms/src/main/java/org/apache/camel/component/jms/reply/PersistentQueueReplyManager.java
@@ -213,7 +213,7 @@ public class PersistentQueueReplyManager extends
ReplyManagerSupport {
answer.setTaskExecutor(endpoint.getTaskExecutor());
}
- // setup a bean name which is used ny Spring JMS as the thread name
+ // setup a bean name which is used by Spring JMS as the thread name
String name = "PersistentQueueReplyManager[" +
answer.getDestinationName() + "]";
answer.setBeanName(name);
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppTest.java
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppTest.java
index 471d8c1..b080b4e 100644
---
a/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppTest.java
+++
b/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreRestartAppTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.quartz;
import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.junit4.TestSupport;
+import org.apache.camel.util.IOHelper;
import org.junit.Test;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -70,6 +71,9 @@ public class SpringQuartzPersistentStoreRestartAppTest
extends TestSupport {
mock2.assertIsSatisfied();
app2.stop();
+
+ // we're done so let's properly close the application contexts
+ IOHelper.close(app, app2);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultStreamCachingTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultStreamCachingTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultStreamCachingTest.java
index 9a1f9b4..c017729 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultStreamCachingTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultStreamCachingTest.java
@@ -18,16 +18,20 @@ package org.apache.camel.spring;
import junit.framework.TestCase;
import org.apache.camel.CamelContext;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DefaultStreamCachingTest extends TestCase {
public void testStreamCaching() throws Exception {
- ApplicationContext appContext = new ClassPathXmlApplicationContext(new
String[] {"org/apache/camel/spring/streamCaching.xml"});
+ AbstractApplicationContext appContext = new
ClassPathXmlApplicationContext(new String[]
{"org/apache/camel/spring/streamCaching.xml"});
CamelContext camelContext = appContext.getBean("camelContext",
CamelContext.class);
assertFalse("StreamCaching should not be enabled",
camelContext.isStreamCaching());
+
+ // we're done so let's properly close the application context
+ IOHelper.close(appContext);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java
index 630f9d1..21cf67e 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/AnotherCamelProxyTest.java
@@ -17,7 +17,9 @@
package org.apache.camel.spring.config;
import junit.framework.TestCase;
-import org.springframework.context.ApplicationContext;
+
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -27,12 +29,15 @@ public class AnotherCamelProxyTest extends TestCase {
public void testAnotherCamelProxy() throws Exception {
// START SNIPPET: e1
- ApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/AnotherCamelProxyTest.xml");
+ AbstractApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/AnotherCamelProxyTest.xml");
MyProxySender sender = ac.getBean("myProxySender",
MyProxySender.class);
String reply = sender.hello("Camel");
assertEquals("Bye Camel", reply);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(ac);
// END SNIPPET: e1
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
index 4916377..c1fc216 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelContextFactoryBeanTest.java
@@ -25,8 +25,10 @@ import org.apache.camel.Route;
import org.apache.camel.impl.EventDrivenConsumerRoute;
import org.apache.camel.management.JmxSystemPropertyKeys;
import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.ClassPathResource;
@@ -36,6 +38,8 @@ import org.springframework.core.io.ClassPathResource;
*/
public class CamelContextFactoryBeanTest extends XmlConfigTestSupport {
+ private AbstractApplicationContext applicationContext;
+
@Override
protected void setUp() throws Exception {
// disable JMX
@@ -48,25 +52,30 @@ public class CamelContextFactoryBeanTest extends
XmlConfigTestSupport {
super.tearDown();
// enable JMX
System.clearProperty(JmxSystemPropertyKeys.DISABLED);
+
+ if (applicationContext != null) {
+ // we're done so let's properly close the application context
+ IOHelper.close(applicationContext);
+ }
}
public void testClassPathRouteLoading() throws Exception {
- ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = (CamelContext)
applicationContext.getBean("camel");
assertValidContext(context);
}
public void testClassPathRouteLoadingUsingNamespaces() throws Exception {
- ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = applicationContext.getBean("camel3",
CamelContext.class);
assertValidContext(context);
}
public void testGenericApplicationContextUsingNamespaces() throws
Exception {
- GenericApplicationContext applicationContext = new
GenericApplicationContext();
- XmlBeanDefinitionReader xmlReader = new
XmlBeanDefinitionReader(applicationContext);
+ applicationContext = new GenericApplicationContext();
+ XmlBeanDefinitionReader xmlReader = new
XmlBeanDefinitionReader((BeanDefinitionRegistry) applicationContext);
xmlReader.loadBeanDefinitions(new
ClassPathResource("org/apache/camel/spring/camelContextFactoryBean.xml"));
// lets refresh to inject the applicationContext into beans
@@ -77,7 +86,7 @@ public class CamelContextFactoryBeanTest extends
XmlConfigTestSupport {
}
public void testXMLRouteLoading() throws Exception {
- ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
CamelContext context = applicationContext.getBean("camel2",
CamelContext.class);
assertNotNull("No context found!", context);
@@ -99,7 +108,7 @@ public class CamelContextFactoryBeanTest extends
XmlConfigTestSupport {
}
public void testRouteBuilderRef() throws Exception {
- ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextRouteBuilderRef.xml");
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextRouteBuilderRef.xml");
CamelContext context = applicationContext.getBean("camel5",
CamelContext.class);
assertNotNull("No context found!", context);
@@ -108,7 +117,7 @@ public class CamelContextFactoryBeanTest extends
XmlConfigTestSupport {
}
public void testAutoStartup() throws Exception {
- ApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");
SpringCamelContext context = applicationContext.getBean("camel4",
SpringCamelContext.class);
assertFalse(context.isAutoStartup());
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyTest.java
index 521f4d4..79b63e1 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyTest.java
@@ -19,7 +19,8 @@ package org.apache.camel.spring.config;
import org.apache.camel.TestSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.SpringCamelContext;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -28,7 +29,7 @@ import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class CamelProxyTest extends TestSupport {
public void testCamelProxy() throws Exception {
- ApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyTest.xml");
+ AbstractApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyTest.xml");
MyProxySender sender = ac.getBean("myProxySender",
MyProxySender.class);
String reply = sender.hello("World");
@@ -51,6 +52,9 @@ public class CamelProxyTest extends TestSupport {
result.expectedBodiesReceived("Hello my friends again!");
myProxySenderWithCamelContextId.greeting("Hello my friends again!");
result.assertIsSatisfied();
+
+ // we're done so let's properly close the application context
+ IOHelper.close(ac);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyUsingRefTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyUsingRefTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyUsingRefTest.java
index c65a345..12a0462 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyUsingRefTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/CamelProxyUsingRefTest.java
@@ -17,7 +17,9 @@
package org.apache.camel.spring.config;
import junit.framework.TestCase;
-import org.springframework.context.ApplicationContext;
+
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -26,12 +28,15 @@ import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class CamelProxyUsingRefTest extends TestCase {
public void testCamelProxyUsingRef() throws Exception {
- ApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyUsingRefTest.xml");
+ AbstractApplicationContext ac = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelProxyUsingRefTest.xml");
MyProxySender sender = ac.getBean("myProxySender",
MyProxySender.class);
String reply = sender.hello("World");
assertEquals("Hello World", reply);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(ac);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
index 6e86fbe..9a00735 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/RouteBuilderRefTest.java
@@ -17,7 +17,8 @@
package org.apache.camel.spring.config;
import org.apache.camel.CamelContext;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -26,11 +27,13 @@ import
org.springframework.context.support.ClassPathXmlApplicationContext;
public class RouteBuilderRefTest extends XmlConfigTestSupport {
public void testUsingRouteBuilderRefInCamelXml() throws Exception {
- ApplicationContext applicationContext =
- new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");
+ AbstractApplicationContext applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/routeBuilderRef.xml");
CamelContext context = applicationContext.getBean("camel5",
CamelContext.class);
assertValidContext(context);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(applicationContext);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
index c6f6e5b..fa3b91e 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanTest.java
@@ -21,26 +21,32 @@ import java.util.concurrent.TimeUnit;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.ModelCamelContext;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringComponentScanTest extends ContextTestSupport {
+ private AbstractApplicationContext applicationContext;
+
@Override
protected void setUp() throws Exception {
super.setUp();
if (context != null) {
context.stop();
}
- ApplicationContext c = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScan.xml");
- context = c.getBean("camelScan", ModelCamelContext.class);
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScan.xml");
+ context = applicationContext.getBean("camelScan",
ModelCamelContext.class);
template = context.createProducerTemplate();
- template.start();
}
@Override
protected void tearDown() throws Exception {
- template.stop();
+ if (applicationContext != null) {
+ // we're done so let's properly close the application context
+ IOHelper.close(applicationContext);
+ }
+
super.tearDown();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
----------------------------------------------------------------------
diff --git
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
index 7515b0b..0b224f6 100644
---
a/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
+++
b/components/camel-spring/src/test/java/org/apache/camel/spring/config/scan/SpringComponentScanWithDeprecatedPackagesTest.java
@@ -20,23 +20,29 @@ package org.apache.camel.spring.config.scan;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.ModelCamelContext;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringComponentScanWithDeprecatedPackagesTest extends
ContextTestSupport {
+ private AbstractApplicationContext applicationContext;
+
@Override
protected void setUp() throws Exception {
super.setUp();
- ApplicationContext c = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScanWithPackages.xml");
- context = c.getBean("camelContext", ModelCamelContext.class);
+ applicationContext = new
ClassPathXmlApplicationContext("org/apache/camel/spring/config/scan/componentScanWithPackages.xml");
+ context = applicationContext.getBean("camelContext",
ModelCamelContext.class);
template = context.createProducerTemplate();
- template.start();
}
@Override
protected void tearDown() throws Exception {
- template.stop();
+ if (applicationContext != null) {
+ // we're done so let's properly close the application context
+ IOHelper.close(applicationContext);
+ }
+
super.tearDown();
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelClient.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelClient.java
b/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelClient.java
index ce3dd9a..c2c41d1 100644
---
a/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelClient.java
+++
b/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelClient.java
@@ -22,7 +22,8 @@ import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.apache.camel.ProducerTemplate;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -42,7 +43,7 @@ public final class CamelClient {
public static void main(final String[] args) throws Exception {
System.out.println("Notice this client requires that the CamelServer
is already running!");
- ApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
// get the camel template for Spring template style sending of
messages (= producer)
final ProducerTemplate producer = context.getBean("camelTemplate",
ProducerTemplate.class);
@@ -71,7 +72,9 @@ public final class CamelClient {
latch.await(300, TimeUnit.SECONDS);
System.out.println("... Send " + SIZE + " message to JMS broker");
executors.shutdownNow();
- System.exit(0);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelFileClient.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelFileClient.java
b/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelFileClient.java
index 1c31ea2..a940e6d 100644
---
a/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelFileClient.java
+++
b/examples/camel-example-route-throttling/src/main/java/org/apache/camel/example/client/CamelFileClient.java
@@ -18,7 +18,8 @@ package org.apache.camel.example.client;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -33,7 +34,7 @@ public final class CamelFileClient {
}
public static void main(final String[] args) throws Exception {
- ApplicationContext context = new
ClassPathXmlApplicationContext("camel-file-client.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("camel-file-client.xml");
// get the camel template for Spring template style sending of
messages (= producer)
final ProducerTemplate producer = context.getBean("camelTemplate",
ProducerTemplate.class);
@@ -47,7 +48,8 @@ public final class CamelFileClient {
System.out.println("... Wrote " + SIZE + " files");
- System.exit(0);
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
b/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
index 43ad0a1..5f35530 100644
---
a/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
+++
b/examples/camel-example-spring-javaconfig/src/test/java/org/apache/camel/example/spring/javaconfig/IntegrationTest.java
@@ -18,9 +18,10 @@ package org.apache.camel.example.spring.javaconfig;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.javaconfig.Main;
+import org.apache.camel.util.IOHelper;
import org.junit.Assert;
import org.junit.Test;
-import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -37,11 +38,14 @@ public class IntegrationTest extends Assert {
@Test
public void testStartApplicationContext() throws Exception {
// test to boot up the application context from spring configuration
- ApplicationContext context = new
ClassPathXmlApplicationContext("/META-INF/spring/camel-context.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("/META-INF/spring/camel-context.xml");
String[] names = context.getBeanNamesForType(CamelContext.class);
assertEquals("There should be a camel context ", 1, names.length);
CamelContext camelContext = context.getBean(names[0],
CamelContext.class);
assertNotNull(camelContext);
Thread.sleep(2000);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
index b76bd3f..ff6417a 100644
---
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
+++
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClient.java
@@ -18,7 +18,8 @@ package org.apache.camel.example.client;
import org.apache.camel.ExchangePattern;
import org.apache.camel.ProducerTemplate;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -35,7 +36,7 @@ public final class CamelClient {
public static void main(final String[] args) throws Exception {
System.out.println("Notice this client requires that the CamelServer
is already running!");
- ApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
// get the camel template for Spring template style sending of
messages (= producer)
ProducerTemplate camelTemplate = context.getBean("camelTemplate",
ProducerTemplate.class);
@@ -45,7 +46,8 @@ public final class CamelClient {
int response = (Integer)camelTemplate.sendBody("jms:queue:numbers",
ExchangePattern.InOut, 22);
System.out.println("... the result is: " + response);
- System.exit(0);
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java
index 6c813bd..a4a4379 100644
---
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java
+++
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientEndpoint.java
@@ -21,7 +21,8 @@ import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Producer;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -42,7 +43,7 @@ public final class CamelClientEndpoint {
public static void main(final String[] args) throws Exception {
System.out.println("Notice this client requires that the CamelServer
is already running!");
- ApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("camel-client.xml");
CamelContext camel = context.getBean("camel-client",
CamelContext.class);
// get the endpoint from the camel context
@@ -68,9 +69,12 @@ public final class CamelClientEndpoint {
int response = exchange.getOut().getBody(Integer.class);
System.out.println("... the result is: " + response);
- // stop and exit the client
+ // stopping the JMS producer has the side effect of the "ReplyTo
Queue" being properly
+ // closed, making this client not to try any further reads for the
replies from the server
producer.stop();
- System.exit(0);
+
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java
----------------------------------------------------------------------
diff --git
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java
index 9ca35f9..dbbb3a7 100644
---
a/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java
+++
b/examples/camel-example-spring-jms/src/main/java/org/apache/camel/example/client/CamelClientRemoting.java
@@ -17,7 +17,8 @@
package org.apache.camel.example.client;
import org.apache.camel.example.server.Multiplier;
-import org.springframework.context.ApplicationContext;
+import org.apache.camel.util.IOHelper;
+import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
@@ -34,7 +35,7 @@ public final class CamelClientRemoting {
public static void main(final String[] args) {
System.out.println("Notice this client requires that the CamelServer
is already running!");
- ApplicationContext context = new
ClassPathXmlApplicationContext("camel-client-remoting.xml");
+ AbstractApplicationContext context = new
ClassPathXmlApplicationContext("camel-client-remoting.xml");
// just get the proxy to the service and we as the client can use the
"proxy" as it was
// a local object we are invoking. Camel will under the covers do the
remote communication
// to the remote ActiveMQ server and fetch the response.
@@ -44,7 +45,8 @@ public final class CamelClientRemoting {
int response = multiplier.multiply(33);
System.out.println("... the result is: " + response);
- System.exit(0);
+ // we're done so let's properly close the application context
+ IOHelper.close(context);
}
// END SNIPPET: e1
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/examples/camel-example-spring-security/src/main/resources/camel-context.xml
----------------------------------------------------------------------
diff --git
a/examples/camel-example-spring-security/src/main/resources/camel-context.xml
b/examples/camel-example-spring-security/src/main/resources/camel-context.xml
index 2c171e2..e8b16cc 100644
---
a/examples/camel-example-spring-security/src/main/resources/camel-context.xml
+++
b/examples/camel-example-spring-security/src/main/resources/camel-context.xml
@@ -1,98 +1,98 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- START SNIPPET: example -->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:spring-security="http://www.springframework.org/schema/security"
- xsi:schemaLocation="
- http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
- http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
- http://camel.apache.org/schema/spring-security
http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
- http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
-
- <spring-security:http realm="User Restrict Realm">
- <spring-security:intercept-url pattern="/camel/**" access="ROLE_USER"/>
- <spring-security:http-basic/>
- <spring-security:remember-me/>
- </spring-security:http>
-
- <!-- set up the user configuration here -->
- <spring-security:authentication-manager alias="authenticationManager">
- <spring-security:authentication-provider
user-service-ref="userDetailsService"/>
- </spring-security:authentication-manager>
-
- <spring-security:user-service id="userDetailsService">
- <spring-security:user name="jim" password="jimspassword"
authorities="ROLE_USER, ROLE_ADMIN"/>
- <spring-security:user name="bob" password="bobspassword"
authorities="ROLE_USER"/>
- </spring-security:user-service>
-
- <bean id="accessDecisionManager"
class="org.springframework.security.access.vote.AffirmativeBased">
- <property name="allowIfAllAbstainDecisions" value="true"/>
- <property name="decisionVoters">
- <list>
- <bean class="org.springframework.security.access.vote.RoleVoter"/>
- </list>
- </property>
- </bean>
-
- <!-- The Policy for checking the authentication role of ADMIN -->
- <authorizationPolicy id="admin" access="ROLE_ADMIN"
- authenticationManager="authenticationManager"
- accessDecisionManager="accessDecisionManager"
- xmlns="http://camel.apache.org/schema/spring-security"/>
-
- <!-- The Policy for checking the authentication role of USER -->
- <authorizationPolicy id="user" access="ROLE_USER"
- xmlns="http://camel.apache.org/schema/spring-security"/>
-
- <camelContext id="myCamelContext"
xmlns="http://camel.apache.org/schema/spring">
- <!-- Catch the authorization exception and set the Access Denied message
back -->
- <onException>
- <exception>org.apache.camel.CamelAuthorizationException</exception>
- <handled>
- <constant>true</constant>
- </handled>
- <transform>
- <simple>Access Denied with the Policy of ${exception.policyId}
!</simple>
- </transform>
- </onException>
-
- <route>
- <from uri="servlet:///user"/>
- <!-- wrap the route in the policy which enforces security check -->
- <policy ref="user">
- <transform>
- <simple>Normal user can access this service</simple>
- </transform>
- </policy>
- </route>
-
- <route>
- <from uri="servlet:///admin"/>
- <!-- wrap the route in the policy which enforces security check -->
- <policy ref="admin">
- <transform>
- <simple>Call the admin operation OK</simple>
- </transform>
- </policy>
- </route>
-
- </camelContext>
-
-</beans>
- <!-- END SNIPPET: example -->
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- START SNIPPET: example -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:spring-security="http://www.springframework.org/schema/security"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
+ http://camel.apache.org/schema/spring-security
http://camel.apache.org/schema/spring-security/camel-spring-security.xsd
+ http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
+
+ <spring-security:http realm="User Restrict Realm">
+ <spring-security:intercept-url pattern="/camel/**" access="ROLE_USER"/>
+ <spring-security:http-basic/>
+ <spring-security:remember-me/>
+ </spring-security:http>
+
+ <!-- set up the user configuration here -->
+ <spring-security:authentication-manager alias="authenticationManager">
+ <spring-security:authentication-provider
user-service-ref="userDetailsService"/>
+ </spring-security:authentication-manager>
+
+ <spring-security:user-service id="userDetailsService">
+ <spring-security:user name="jim" password="jimspassword"
authorities="ROLE_USER, ROLE_ADMIN"/>
+ <spring-security:user name="bob" password="bobspassword"
authorities="ROLE_USER"/>
+ </spring-security:user-service>
+
+ <bean id="accessDecisionManager"
class="org.springframework.security.access.vote.AffirmativeBased">
+ <property name="allowIfAllAbstainDecisions" value="true"/>
+ <property name="decisionVoters">
+ <list>
+ <bean class="org.springframework.security.access.vote.RoleVoter"/>
+ </list>
+ </property>
+ </bean>
+
+ <!-- The Policy for checking the authentication role of ADMIN -->
+ <authorizationPolicy id="admin" access="ROLE_ADMIN"
+ authenticationManager="authenticationManager"
+ accessDecisionManager="accessDecisionManager"
+ xmlns="http://camel.apache.org/schema/spring-security"/>
+
+ <!-- The Policy for checking the authentication role of USER -->
+ <authorizationPolicy id="user" access="ROLE_USER"
+ xmlns="http://camel.apache.org/schema/spring-security"/>
+
+ <camelContext id="myCamelContext"
xmlns="http://camel.apache.org/schema/spring">
+ <!-- Catch the authorization exception and set the Access Denied message
back -->
+ <onException>
+ <exception>org.apache.camel.CamelAuthorizationException</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <transform>
+ <simple>Access Denied with the Policy of ${exception.policyId}
!</simple>
+ </transform>
+ </onException>
+
+ <route>
+ <from uri="servlet:///user"/>
+ <!-- wrap the route in the policy which enforces security check -->
+ <policy ref="user">
+ <transform>
+ <simple>Normal user can access this service</simple>
+ </transform>
+ </policy>
+ </route>
+
+ <route>
+ <from uri="servlet:///admin"/>
+ <!-- wrap the route in the policy which enforces security check -->
+ <policy ref="admin">
+ <transform>
+ <simple>Call the admin operation OK</simple>
+ </transform>
+ </policy>
+ </route>
+
+ </camelContext>
+
+</beans>
+ <!-- END SNIPPET: example -->
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
----------------------------------------------------------------------
diff --git
a/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
index 528f1a3..e235667 100644
---
a/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
+++
b/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.itest.customerrelations;
import java.util.List;
import java.util.Map;
+import org.apache.camel.util.IOHelper;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.jaxws.EndpointImpl;
@@ -58,12 +59,8 @@ public class CustomerServicesTest extends Assert {
Customer customer = customerService.getCustomer("12345");
assertNotNull("We should get Customer here", customer);
} finally {
- if (clientContext != null) {
- clientContext.destroy();
- }
- if (serverContext != null) {
- serverContext.destroy();
- }
+ // we're done so let's properly close the application contexts
+ IOHelper.close(clientContext, serverContext);
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e4e5aeac/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesWsAddressingTest.java
----------------------------------------------------------------------
diff --git
a/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesWsAddressingTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesWsAddressingTest.java
index b00c934..2e4a9f7 100644
---
a/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesWsAddressingTest.java
+++
b/tests/camel-itest/src/test/java/org/apache/camel/itest/customerrelations/CustomerServicesWsAddressingTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.camel.itest.customerrelations;
+import org.apache.camel.util.IOHelper;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -39,12 +40,8 @@ public class CustomerServicesWsAddressingTest extends Assert
{
Customer customer = customerService.getCustomer("12345");
assertNotNull("We should get Customer here", customer);
} finally {
- if (clientContext != null) {
- clientContext.destroy();
- }
- if (serverContext != null) {
- serverContext.destroy();
- }
+ // we're done so let's properly close the application context
+ IOHelper.close(clientContext, serverContext);
}
}