Author: davsclaus
Date: Wed Feb 11 13:44:04 2009
New Revision: 743337
URL: http://svn.apache.org/viewvc?rev=743337&view=rev
Log:
Using executor service for stream background thread. Fixed example not having
its schema update to TLP location
Modified:
camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
camel/trunk/examples/camel-example-spring-xquery/src/main/resources/META-INF/spring/camelContext.xml
camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml
Modified:
camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java?rev=743337&r1=743336&r2=743337&view=diff
==============================================================================
---
camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
(original)
+++
camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamConsumer.java
Wed Feb 11 13:44:04 2009
@@ -27,6 +27,9 @@
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
@@ -46,11 +49,11 @@
private static final String TYPES = "in,file,url";
private static final String INVALID_URI = "Invalid uri, valid form:
'stream:{" + TYPES + "}'";
private static final List<String> TYPES_LIST =
Arrays.asList(TYPES.split(","));
+ private ExecutorService executor;
private InputStream inputStream = System.in;
private StreamEndpoint endpoint;
private String uri;
private boolean initialPromptDone;
- private Thread scanThread;
public StreamConsumer(StreamEndpoint endpoint, Processor processor, String
uri) throws Exception {
super(endpoint, processor);
@@ -71,23 +74,21 @@
inputStream = resolveStreamFromUrl();
}
- scanThread = new Thread(this,
getThreadName(endpoint.getEndpointUri()));
- scanThread.setDaemon(true);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Starting thread: " + scanThread.getName());
- }
- scanThread.start();
+ executor = Executors.newSingleThreadExecutor(new ThreadFactory() {
+ public Thread newThread(Runnable runnable) {
+ Thread thread = new Thread(runnable,
getThreadName(endpoint.getEndpointUri()));
+ thread.setDaemon(true);
+ return thread;
+ }
+ });
+ executor.execute(this);
}
@Override
public void doStop() throws Exception {
// important: do not close the stream as it will close the standard
system.in etc.
- if (LOG.isDebugEnabled()) {
- LOG.debug("Stopping thread: " + scanThread.getName());
- }
- // must use timeout to let this thread die
- scanThread.join(1000);
- scanThread = null;
+ executor.shutdownNow();
+ executor = null;
super.doStop();
}
Modified:
camel/trunk/examples/camel-example-spring-xquery/src/main/resources/META-INF/spring/camelContext.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-spring-xquery/src/main/resources/META-INF/spring/camelContext.xml?rev=743337&r1=743336&r2=743337&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-spring-xquery/src/main/resources/META-INF/spring/camelContext.xml
(original)
+++
camel/trunk/examples/camel-example-spring-xquery/src/main/resources/META-INF/spring/camelContext.xml
Wed Feb 11 13:44:04 2009
@@ -23,7 +23,7 @@
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- START SNIPPET: example -->
- <camelContext useJmx="true" xmlns="http://camel.apache.org/schema/spring">
+ <camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- lets parse files, transform them with XQuery and send them to JMS -->
<route>
Modified:
camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml?rev=743337&r1=743336&r2=743337&view=diff
==============================================================================
---
camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml
(original)
+++
camel/trunk/examples/camel-example-tracer/src/main/resources/META-INF/spring/camel-context.xml
Wed Feb 11 13:44:04 2009
@@ -22,9 +22,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+ http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
- <camelContext id="camel"
xmlns="http://activemq.apache.org/camel/schema/spring">
+ <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- START SNIPPET: e3 -->
<endpoint id="traced"
uri="jpa://org.apache.camel.processor.interceptor.JpaTraceEventMessage?persistenceUnit=tracer"/>
<!-- END SNIPPET: e3 -->