svn commit: r962425 - /camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java
Author: davsclaus Date: Fri Jul 9 06:12:52 2010 New Revision: 962425 URL: http://svn.apache.org/viewvc?rev=962425&view=rev Log: CAMEL-2919: Polished Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java?rev=962425&r1=962424&r2=962425&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java Fri Jul 9 06:12:52 2010 @@ -330,6 +330,8 @@ public class DefaultDebugger implements camelContext.addService(tracer); camelContext.addInterceptStrategy(tracer); } +// make sure tracer is enabled so the debugger can leverage the tracer for debugging purposes +tracer.setEnabled(true); } public void stop() throws Exception {
svn commit: r962423 - /camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/
Author: davsclaus Date: Fri Jul 9 06:03:52 2010 New Revision: 962423 URL: http://svn.apache.org/viewvc?rev=962423&view=rev Log: CAMEL-2927: Fixed examples a bit. Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeBatchSizeTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeMultipleCorrelationTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizePredicateTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizeTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/DefaultAggregatorCollectionTest.java Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeBatchSizeTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeBatchSizeTest.java?rev=962423&r1=962422&r2=962423&view=diff == --- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeBatchSizeTest.java (original) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeBatchSizeTest.java Fri Jul 9 06:03:52 2010 @@ -74,8 +74,9 @@ public class AggregateGroupedExchangeBat // START SNIPPET: e1 // our route is aggregating from the direct queue and sending the response to the mock from("direct:start") +.log("Aggregator received ${body}") // aggregated all use same expression -.aggregate().constant(true).completionSize(2) +.aggregate(constant(true)).completionSize(2) // wait for 0.5 seconds to aggregate .completionTimeout(500L) // group the exchanges so we get one single exchange containing all the others Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeMultipleCorrelationTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeMultipleCorrelationTest.java?rev=962423&r1=962422&r2=962423&view=diff == --- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeMultipleCorrelationTest.java (original) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeMultipleCorrelationTest.java Fri Jul 9 06:03:52 2010 @@ -78,7 +78,7 @@ public class AggregateGroupedExchangeMul // our route is aggregating from the direct queue and sending the response to the mock from("direct:start") // aggregate all using the foo header -.aggregate().header("foo") +.aggregate(header("foo")) // group the exchanges so we get one single exchange containing all the others .groupExchanges() // wait for 1 seconds to aggregate Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizePredicateTest.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizePredicateTest.java?rev=962423&r1=962422&r2=962423&view=diff == --- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizePredicateTest.java (original) +++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizePredicateTest.java Fri Jul 9 06:03:52 2010 @@ -64,7 +64,7 @@ public class AggregateGroupedExchangeSiz public void configure() throws Exception { from("direct:start") // must use eagerCheckCompletion so we can check the groupSize header on the incoming exchange - .aggregate().constant(true).groupExchanges().eagerCheckCompletion().completionSize(header("groupSize")) + .aggregate(constant(true)).groupExchanges().eagerCheckCompletion().completionSize(header("groupSize")) .to("mock:result") .end(); } Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeSizeTest
[CONF] Apache Camel > Camel 2.x - Debugger API
Camel 2.x - Debugger API Page edited by Claus Ibsen Changes (2) ... In the Java editor the debugger is capable of single stepping when a breakpoint is hit. The idea in Camel is that you want to single step an [Exchange] so you can step through how its routed and follow it from the 3rd party tooling. {tip:title=Only one single step active} The [Debugger] only allows one active breakpoint during single step, which means that if you try to activate a 2nd single step, then it will disregarded. In this case the {{addSingleStepBreakpoint}} method will return {{false}} to indicate this. {tip} The {{Debugger}} has API for single stepping. For example to single step the first message arrived in Camel you can do {code} ... } {code} h2. Notes - The single step feature should only allow one _active_ at any time. So if there is already a single step message in process other messages should be disregarded from debugging - Should other breakpoints be active during single step? In case you have another breakpoint somewhere which may get triggered? - Should we add a fluent builder syntax for sugar, so its easier to use common conditions? h2. Use cases Full Content Camel 2.x - Debugger API Available as of Camel 2.4 There is a new org.apache.camel.spi.Debugger API which allows 3rd party to attach a debugger tooling to debug Exchanges in Camel routes. There is a default implementation in camel-core as the org.apache.camel.impl.DefaultDebugger. Enabling You can enable the debugger from the CamelContext using the setDebugger. We may add a nicer API for this in the future. Breakpoint There is a org.apache.camel.spi.Breakpoint API in which the 3rd party tooling implement logic what should happen when the breakpoint is hit. The breakpoint can be invoked in 2 kind of styles in Camel: processing based event based The processing is based on a before and after callback when the Exchange is being routed and thus a Processor is invoked. The event is based on the EventNotifier emitting events such as ExchangeCreatedEvent, ExchangeFailureEvent etc. This allows you to have breakpoints when a given Exchange has failed. Or when they are done, so you can inspect the result etc. There is a org.apache.camel.impl.BreakpointSupport class which can be used to extend, to avoid implementing all the methods from the interface. Condition There is a org.apache.camel.spi.Condition API in which the 3rd party tooling can provide conditions when the breakpoints should apply. For example a conditional breakpoint which only triggers if the message body is a certain message / type etc. The condition can be invoked in 2 kind of styles in Camel: processing based event based Where there is a match method for each style. There is a org.apache.camel.impl.ConditionSupport class which can be used to extend, to avoid implementing all the methods from the interface. Example For example we can have this breakpoint breakpoint = new BreakpointSupport() { public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { String body = exchange.getIn().getBody(String.class); logs.add("Breakpoint at " + definition + " with body: " + body); } } In which we want to trigger when the message contains Camel. So we can create this Condition: camelCondition = new ConditionSupport() { public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { return body().contains("Camel").matches(exchange); } }; And to use this we just tell the Debugger as follows: public void testDebug() throws Exception { context.getDebugger().addBreakpoint(breakpoint, camelCondition); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Camel"); template.sendBody("direct:start", "Hello World"); template.sendBody("direct:start", "Hello Camel"); assertMockEndpointsSatisfied(); assertEquals(2, logs.size()); assertEquals("Breakpoint at To[log:foo] with body: Hello Camel", logs.get(0)); assertEquals("Breakpoint at To[mock:result] with body: Hello Camel", logs.get(1)); } Which then will only invoke the breakpoint callback for the "Hello Camel" message. Single step In the Java editor the debugger is capable of single stepping when a breakpoint is hit. The idea in Camel is that you want to single step an Exchange so you can step through how its routed and follow it from the 3rd party tooling. Only one single step activeThe Debugger only allows one active breakpoint during single step, which mea
[CONF] Apache Camel > Camel 2.4.0 Release
Camel 2.4.0 Release Page edited by Claus Ibsen Changes (1) ... * Introduced [ProcessorFactory] to be able to use a custom factory to be able to manipulate [Processor] creation process. For example to add additional outputs or manipulate the route model. * [camel-jms|JMS] now supports Oracle AQ * Added a [Debugger|Camel 2.x - Debugger API] API to be leveraged by 3rd party tooling. h3. New [Enterprise Integration Patterns] ... Full Content Camel 2.4.0 release (currently in progress) New and Noteworthy Welcome to the 2.4.0 release which approx XXX issues resolved (new features, improvements and bug fixes such as...) Fully non blocking asynchronous routing engine which all EIPs and some Camel Components supported. New feature to use scheduled delayed redelivery attempts (they are fully asynchronous and non blocking). You need to enable this using the option asyncDelayedRedelivery. Fixed a potential dead-lock when using Aggregator with timeout completion set. The camel-spring module now supports OSGi out of box, which renders camel-osgi as @deprecated. OSGi blueprint is now supported Added new to scan the Registry for RouteBuilder instances, just as scanning the classpath etc. Manually started routes is now also Graceful Shutdown by Camel Fixed issue using RouteContextRef with multiple CamelContext from the same Spring ApplicationContext. Bindy now supports Fixed-Length format message with padding, alignment (Left or Right) Improved and fixes some issues with the FTP component. Improved and fixed some issues using MultiPartForm with Jetty. Add ability to configure Bindy to remove whitespace when binding Numeric positions Added option useOriginalBody to OnCompletion Fixed issue when using mockito for testing when it uses CGLib proxies Fixed issue with @Consume not running in an unit of work to ensure callbacks is invoked when its done Routing Slip now uses _expression_ to define the slip. This is similar to the Recipient List pattern The security context can be passed from CXF to other camel Components. ManagementAgent settings can now be set using setters from Java, instead of having to use JVM system properties. See tip in Camel JMX wiki page. Resequencer in batch mode has two new options allowDuplicates and reverse which allows you to use it for re-ordering messages from JMS queues based on JMSPriority Tighten up the ProducerTemplate API a bit, see more details in the section Important changes to consider when upgrading. HTTP now better supports sending binary files. Fixed problem with using Quartz in OSGi and having Camel applications being hot-deployed which potentially could cause Quartz to stop scheduling in applications which haven't been stopped. Fixed issue with pausing and resuming jobs when running Quartz in clustered mode Added options on Quartz component to specify location of custom quartz.properties file to load from classpath. Upgraded to latest Quartz release 1.8.3. Introduced StartupListener to allow components/endpoints/producers/consumers etc. as a listener to be notified when CamelContext have just been started. This allows any custom logic to be executed as a late starter. This ensures Quartz scheduler is only started when all the routes and so forth is started and running. Fixed issue with FTP configuring starting directory from uri not accepting an absolute path. In the endpoint uri just define two leading / to indicate absolute, eg "ftp:admin:sec...@someserver//absolutepath/foo/bar". Added fromRoute to NotifyBuilder. Improved the CSV component. Fixed issue with Direct endpoint having no consumers if endpoint have been evicted from CamelContext internal LRUCache. The RouteBuilder now have simple and xpath _expression_ builder methods out of the box. Upgraded to latest release of Scala 2.8.0RC7 in Scala DSL camel-hawtdb updated to HawtDB 1.1 picks up several bug fixes that improves stability and performance. Fixed issue with splitting files using tokenizer not being able to delete/move file after processing is done on Windows platform. maxMessagesPerPoll is now applied eagerly to limit intaking files earlier for the File and FTP components, Thus avoid excessive memory consumption if you poll directories which contains 100.000+ files. Added connectTimeout, soTimeout and timeout to FTP so its easier to configure timeouts. Consolidated support for per platform disabling of tests across the entire test suite. Introduced ProcessorFactory to be able to use a custom factory to be able to manipulate Processor creation process. For example to add additional outputs or manipulate the route model. camel-jms now supports Oracle AQ Added a Debugger API to be leveraged by 3rd party tooling. New Enterprise In
svn commit: r962415 - in /camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios: NagiosConfiguraitonRefTest.java NagiosEventNotifierTest.java NagiosTest.java
Author: davsclaus Date: Fri Jul 9 05:40:26 2010 New Revision: 962415 URL: http://svn.apache.org/viewvc?rev=962415&view=rev Log: Fixed test Modified: camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosConfiguraitonRefTest.java camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosEventNotifierTest.java camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosTest.java Modified: camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosConfiguraitonRefTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosConfiguraitonRefTest.java?rev=962415&r1=962414&r2=962415&view=diff == --- camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosConfiguraitonRefTest.java (original) +++ camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosConfiguraitonRefTest.java Fri Jul 9 05:40:26 2010 @@ -37,6 +37,8 @@ public class NagiosConfiguraitonRefTest @Before @Override public void setUp() throws Exception { +canRun = true; + nagios = new NagiosNscaStub(25668, "secret"); try { nagios.start(); @@ -46,7 +48,6 @@ public class NagiosConfiguraitonRefTest } super.setUp(); -canRun = true; } @After Modified: camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosEventNotifierTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosEventNotifierTest.java?rev=962415&r1=962414&r2=962415&view=diff == --- camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosEventNotifierTest.java (original) +++ camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosEventNotifierTest.java Fri Jul 9 05:40:26 2010 @@ -42,6 +42,8 @@ public class NagiosEventNotifierTest ext @Before @Override public void setUp() throws Exception { +canRun = true; + nagios = new NagiosNscaStub(25669, "password"); try { nagios.start(); @@ -51,7 +53,6 @@ public class NagiosEventNotifierTest ext } super.setUp(); -canRun = true; } @After Modified: camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosTest.java?rev=962415&r1=962414&r2=962415&view=diff == --- camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosTest.java (original) +++ camel/trunk/components/camel-nagios/src/test/java/org/apache/camel/component/nagios/NagiosTest.java Fri Jul 9 05:40:26 2010 @@ -39,6 +39,8 @@ public class NagiosTest extends CamelTes @Before @Override public void setUp() throws Exception { +canRun = true; + nagios = new NagiosNscaStub(25667, "secret"); try { nagios.start(); @@ -48,7 +50,6 @@ public class NagiosTest extends CamelTes } super.setUp(); -canRun = true; } @After
svn commit: r962396 - in /camel/trunk/examples: camel-example-cxf/pom.xml camel-example-loan-broker/pom.xml camel-example-route-throttling/pom.xml
Author: hadrian Date: Fri Jul 9 04:14:30 2010 New Revision: 962396 URL: http://svn.apache.org/viewvc?rev=962396&view=rev Log: CAMEL-2925. Set forkMode=once Modified: camel/trunk/examples/camel-example-cxf/pom.xml camel/trunk/examples/camel-example-loan-broker/pom.xml camel/trunk/examples/camel-example-route-throttling/pom.xml Modified: camel/trunk/examples/camel-example-cxf/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf/pom.xml?rev=962396&r1=962395&r2=962396&view=diff == --- camel/trunk/examples/camel-example-cxf/pom.xml (original) +++ camel/trunk/examples/camel-example-cxf/pom.xml Fri Jul 9 04:14:30 2010 @@ -289,7 +289,7 @@ maven-surefire-plugin - pertest + once false true Modified: camel/trunk/examples/camel-example-loan-broker/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-loan-broker/pom.xml?rev=962396&r1=962395&r2=962396&view=diff == --- camel/trunk/examples/camel-example-loan-broker/pom.xml (original) +++ camel/trunk/examples/camel-example-loan-broker/pom.xml Fri Jul 9 04:14:30 2010 @@ -142,7 +142,7 @@ maven-surefire-plugin - pertest + once false true Modified: camel/trunk/examples/camel-example-route-throttling/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-route-throttling/pom.xml?rev=962396&r1=962395&r2=962396&view=diff == --- camel/trunk/examples/camel-example-route-throttling/pom.xml (original) +++ camel/trunk/examples/camel-example-route-throttling/pom.xml Fri Jul 9 04:14:30 2010 @@ -154,7 +154,7 @@ maven-surefire-plugin - pertest + once false true
svn commit: r961922 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/dataformat/ components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/ components/camel-xstream/
Author: hadrian Date: Thu Jul 8 20:35:28 2010 New Revision: 961922 URL: http://svn.apache.org/viewvc?rev=961922&view=rev Log: CAMEL-2915. Patch for camel-xstream applied with thanks to Mark Added: camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/PurchaseHistory.java camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.java camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/XStreamConfigurationTest.java camel/trunk/components/camel-xstream/src/test/resources/org/apache/camel/dataformat/xstream/SpringXStreamConfigurationTest.xml Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/AbstractXStreamWrapper.java camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/XStreamDataFormat.java camel/trunk/components/camel-xstream/src/test/java/org/apache/camel/dataformat/xstream/PurchaseOrder.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java?rev=961922&r1=961921&r2=961922&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java Thu Jul 8 20:35:28 2010 @@ -71,12 +71,20 @@ public class XStreamDataFormat extends D setEncoding(encoding); } +public String getEncoding() { +return encoding; +} + public void setEncoding(String encoding) { this.encoding = encoding; } -public String getEncoding() { -return encoding; +public String getDriver() { +return driver; +} + +public void setDriver(String driver) { +this.driver = driver; } public List getConverters() { Modified: camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/AbstractXStreamWrapper.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/AbstractXStreamWrapper.java?rev=961922&r1=961921&r2=961922&view=diff == --- camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/AbstractXStreamWrapper.java (original) +++ camel/trunk/components/camel-xstream/src/main/java/org/apache/camel/dataformat/xstream/AbstractXStreamWrapper.java Thu Jul 8 20:35:28 2010 @@ -18,15 +18,20 @@ package org.apache.camel.dataformat.xstr import java.io.InputStream; import java.io.OutputStream; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import javax.xml.stream.XMLStreamException; import com.thoughtworks.xstream.XStream; +import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import org.apache.camel.Exchange; import org.apache.camel.converter.jaxp.StaxConverter; +import org.apache.camel.spi.ClassResolver; import org.apache.camel.spi.DataFormat; /** @@ -40,18 +45,20 @@ public abstract class AbstractXStreamWra private XStream xstream; private StaxConverter staxConverter; - +private List converters; +private Map aliases; +private Map implicitCollections; + public AbstractXStreamWrapper() { - } public AbstractXStreamWrapper(XStream xstream) { this.xstream = xstream; } -public XStream getXStream() { +public XStream getXStream(ClassResolver resolver) { if (xstream == null) { -xstream = createXStream(); +xstream = createXStream(resolver); } return xstream; } @@ -59,11 +66,37 @@ public abstract class AbstractXStreamWra public void setXStream(XStream xstream) { this.xstream = xstream; } - -protected XStream createXStream() { -return new XStream(); + +protected XStream createXStream(ClassResolver resolver) { +xstream = new XStream(); + +try { +if (this.implicitCollections != null) { +for (Entry entry : this.implicitCollections.entrySet()) { +for (String name : entry.getValue()) { + xstream.addImplicitCollection(resolver.resolveMandatoryClass(entry.getKey()), name); +} +} +} + +if (this.aliases != null) { +
svn commit: r961881 - /camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java
Author: hadrian Date: Thu Jul 8 19:04:00 2010 New Revision: 961881 URL: http://svn.apache.org/viewvc?rev=961881&view=rev Log: CAMEL-2915. Changes in camel-core for the XStreamDataFormat Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java?rev=961881&r1=961880&r2=961881&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XStreamDataFormat.java Thu Jul 8 19:04:00 2010 @@ -16,15 +16,24 @@ */ package org.apache.camel.model.dataformat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.namespace.QName; +import javax.xml.bind.annotation.XmlTransient; +import javax.xml.bind.annotation.adapters.XmlAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.apache.camel.model.DataFormatDefinition; import org.apache.camel.spi.DataFormat; -import org.apache.camel.util.ObjectHelper; +import org.apache.camel.spi.RouteContext; /** * Represents the XStream XML {...@link org.apache.camel.spi.DataFormat} @@ -32,11 +41,27 @@ import org.apache.camel.util.ObjectHelpe * @version $Revision$ */ @XmlRootElement(name = "xstream") -...@xmlaccessortype(XmlAccessType.FIELD) +...@xmlaccessortype(XmlAccessType.NONE) public class XStreamDataFormat extends DataFormatDefinition { @XmlAttribute private String encoding; +@XmlAttribute +private String driver = "xml"; + +@XmlJavaTypeAdapter(ConvertersAdapter.class) +@XmlElement(name = "converters") +private List converters; + +@XmlJavaTypeAdapter(AliasAdapter.class) +@XmlElement(name = "aliases") +private Map aliases; + +@XmlJavaTypeAdapter(ImplicitCollectionsAdapter.class) +@XmlElement(name = "implicitCollections") +private Map implicitCollections; + + public XStreamDataFormat() { super("xstream"); } @@ -53,12 +78,274 @@ public class XStreamDataFormat extends D public String getEncoding() { return encoding; } - + +public List getConverters() { +return converters; +} + +public void setConverters(List converters) { +this.converters = converters; +} + +public Map getAliases() { +return aliases; +} + +public void setAliases(Map aliases) { +this.aliases = aliases; +} + +public Map getImplicitCollections() { +return implicitCollections; +} + +public void setImplicitCollection(Map implicitCollections) { +this.implicitCollections = implicitCollections; +} + +@Override +protected DataFormat createDataFormat(RouteContext routeContext) { +if ("json".equals(this.driver)) { +setProperty(this, "dataFormatName", "json-xstream"); +} +return super.createDataFormat(routeContext); +} + @Override protected void configureDataFormat(DataFormat dataFormat) { if (encoding != null) { setProperty(dataFormat, "encoding", encoding); } + +if (this.converters != null) { +setProperty(dataFormat, "converters", this.converters); +} + +if (this.aliases != null) { +setProperty(dataFormat, "aliases", this.aliases); +} + +if (this.implicitCollections != null) { +setProperty(dataFormat, "implicitCollections", this.implicitCollections); +} +} + + +@XmlTransient +public static class ConvertersAdapter extends XmlAdapter> { +@Override +public ConverterList marshal(List v) throws Exception { +List list = new ArrayList(); +for (String str : v) { +ConverterEntry entry = new ConverterEntry(); +entry.setClsName(str); +list.add(entry); +} + +ConverterList converterList = new ConverterList(); +converterList.setList(list); +return converterList; +} + +@Override +public List unmarshal(ConverterList v) throws Exception { +List list = new ArrayList(); +for (ConverterEntry entry : v.getList()) { +list.add(entry.getClsName()); +} +return list; +} +} + +
[CONF] Apache Camel > Camel 2.4.0 Release
Camel 2.4.0 Release Page edited by Claus Ibsen Changes (1) ... * Consolidated support for per platform disabling of tests across the entire test suite. * Introduced [ProcessorFactory] to be able to use a custom factory to be able to manipulate [Processor] creation process. For example to add additional outputs or manipulate the route model. * [camel-jms|JMS] now supports Oracle AQ h3. New [Enterprise Integration Patterns] ... Full Content Camel 2.4.0 release (currently in progress) New and Noteworthy Welcome to the 2.4.0 release which approx XXX issues resolved (new features, improvements and bug fixes such as...) Fully non blocking asynchronous routing engine which all EIPs and some Camel Components supported. New feature to use scheduled delayed redelivery attempts (they are fully asynchronous and non blocking). You need to enable this using the option asyncDelayedRedelivery. Fixed a potential dead-lock when using Aggregator with timeout completion set. The camel-spring module now supports OSGi out of box, which renders camel-osgi as @deprecated. OSGi blueprint is now supported Added new to scan the Registry for RouteBuilder instances, just as scanning the classpath etc. Manually started routes is now also Graceful Shutdown by Camel Fixed issue using RouteContextRef with multiple CamelContext from the same Spring ApplicationContext. Bindy now supports Fixed-Length format message with padding, alignment (Left or Right) Improved and fixes some issues with the FTP component. Improved and fixed some issues using MultiPartForm with Jetty. Add ability to configure Bindy to remove whitespace when binding Numeric positions Added option useOriginalBody to OnCompletion Fixed issue when using mockito for testing when it uses CGLib proxies Fixed issue with @Consume not running in an unit of work to ensure callbacks is invoked when its done Routing Slip now uses _expression_ to define the slip. This is similar to the Recipient List pattern The security context can be passed from CXF to other camel Components. ManagementAgent settings can now be set using setters from Java, instead of having to use JVM system properties. See tip in Camel JMX wiki page. Resequencer in batch mode has two new options allowDuplicates and reverse which allows you to use it for re-ordering messages from JMS queues based on JMSPriority Tighten up the ProducerTemplate API a bit, see more details in the section Important changes to consider when upgrading. HTTP now better supports sending binary files. Fixed problem with using Quartz in OSGi and having Camel applications being hot-deployed which potentially could cause Quartz to stop scheduling in applications which haven't been stopped. Fixed issue with pausing and resuming jobs when running Quartz in clustered mode Added options on Quartz component to specify location of custom quartz.properties file to load from classpath. Upgraded to latest Quartz release 1.8.3. Introduced StartupListener to allow components/endpoints/producers/consumers etc. as a listener to be notified when CamelContext have just been started. This allows any custom logic to be executed as a late starter. This ensures Quartz scheduler is only started when all the routes and so forth is started and running. Fixed issue with FTP configuring starting directory from uri not accepting an absolute path. In the endpoint uri just define two leading / to indicate absolute, eg "ftp:admin:sec...@someserver//absolutepath/foo/bar". Added fromRoute to NotifyBuilder. Improved the CSV component. Fixed issue with Direct endpoint having no consumers if endpoint have been evicted from CamelContext internal LRUCache. The RouteBuilder now have simple and xpath _expression_ builder methods out of the box. Upgraded to latest release of Scala 2.8.0RC7 in Scala DSL camel-hawtdb updated to HawtDB 1.1 picks up several bug fixes that improves stability and performance. Fixed issue with splitting files using tokenizer not being able to delete/move file after processing is done on Windows platform. maxMessagesPerPoll is now applied eagerly to limit intaking files earlier for the File and FTP components, Thus avoid excessive memory consumption if you poll directories which contains 100.000+ files. Added connectTimeout, soTimeout and timeout to FTP so its easier to configure timeouts. Consolidated support for per platform disabling of tests across the entire test suite. Introduced ProcessorFactory to be able to use a custom factory to be able to manipulate Processor creation process. For example to add additional outputs or manipulate the route model. camel-jms now supports Oracle AQ New Enterprise Integration Patterns New Components EJB to access EJB bea
svn commit: r961848 - /camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Author: davsclaus Date: Thu Jul 8 17:53:08 2010 New Revision: 961848 URL: http://svn.apache.org/viewvc?rev=961848&view=rev Log: CAMEL-2909: OracleAQ does not support JMSType header. Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=961848&r1=961847&r2=961848&view=diff == --- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java (original) +++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Thu Jul 8 17:53:08 2010 @@ -183,7 +183,7 @@ public class JmsBinding { try { map.put("JMSType", jmsMessage.getJMSType()); } catch (JMSException e) { -LOG.trace("Cannot read JMSReplyTo header. Will ignore this exception.", e); +LOG.trace("Cannot read JMSType header. Will ignore this exception.", e); } // this works around a bug in the ActiveMQ property handling
svn commit: r961847 - /camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java
Author: davsclaus Date: Thu Jul 8 17:52:34 2010 New Revision: 961847 URL: http://svn.apache.org/viewvc?rev=961847&view=rev Log: CAMEL-2909: OracleAQ does not support JMSType header. Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Modified: camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java?rev=961847&r1=961846&r2=961847&view=diff == --- camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java (original) +++ camel/trunk/components/camel-jms/src/main/java/org/apache/camel/component/jms/JmsBinding.java Thu Jul 8 17:52:34 2010 @@ -171,14 +171,20 @@ public class JmsBinding { map.put("JMSMessageID", jmsMessage.getJMSMessageID()); map.put("JMSPriority", jmsMessage.getJMSPriority()); map.put("JMSRedelivered", jmsMessage.getJMSRedelivered()); +map.put("JMSTimestamp", jmsMessage.getJMSTimestamp()); + // to work around OracleAQ not supporting the JMSReplyTo header (CAMEL-2909) try { map.put("JMSReplyTo", jmsMessage.getJMSReplyTo()); } catch (JMSException e) { LOG.trace("Cannot read JMSReplyTo header. Will ignore this exception.", e); } -map.put("JMSTimestamp", jmsMessage.getJMSTimestamp()); -map.put("JMSType", jmsMessage.getJMSType()); +// to work around OracleAQ not supporting the JMSType header (CAMEL-2909) +try { +map.put("JMSType", jmsMessage.getJMSType()); +} catch (JMSException e) { +LOG.trace("Cannot read JMSReplyTo header. Will ignore this exception.", e); +} // this works around a bug in the ActiveMQ property handling map.put("JMSXGroupID", jmsMessage.getStringProperty("JMSXGroupID"));
svn commit: r961801 - in /camel/trunk/components/camel-spring: pom.xml src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java src/test/java/org/apache/camel/spring/example/MyProc
Author: hadrian Date: Thu Jul 8 15:21:34 2010 New Revision: 961801 URL: http://svn.apache.org/viewvc?rev=961801&view=rev Log: Speed up tests a bit Modified: camel/trunk/components/camel-spring/pom.xml camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyProcessor.java Modified: camel/trunk/components/camel-spring/pom.xml URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/pom.xml?rev=961801&r1=961800&r2=961801&view=diff == --- camel/trunk/components/camel-spring/pom.xml (original) +++ camel/trunk/components/camel-spring/pom.xml Thu Jul 8 15:21:34 2010 @@ -233,7 +233,7 @@ false true - pertest + once **/*Test.java Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java?rev=961801&r1=961800&r2=961801&view=diff == --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java (original) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/CustomProcessorWithNamespacesTest.java Thu Jul 8 15:21:34 2010 @@ -53,7 +53,8 @@ public class CustomProcessorWithNamespac }); template.stop(); -List list = MyProcessor.getExchanges(); +MyProcessor myProcessor = (MyProcessor) applicationContext.getBean("myProcessor"); +List list = myProcessor.getExchanges(); assertEquals("Should have received a single exchange: " + list, 1, list.size()); } Modified: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyProcessor.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyProcessor.java?rev=961801&r1=961800&r2=961801&view=diff == --- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyProcessor.java (original) +++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/example/MyProcessor.java Thu Jul 8 15:21:34 2010 @@ -26,10 +26,10 @@ import org.apache.camel.Processor; * @version $Revision$ */ public class MyProcessor implements Processor { -private static List exchanges = new CopyOnWriteArrayList(); +private List exchanges = new CopyOnWriteArrayList(); private String name = "James"; -public static List getExchanges() { +public List getExchanges() { return exchanges; }
svn commit: r961767 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: impl/DefaultDebugger.java spi/Debugger.java
Author: davsclaus Date: Thu Jul 8 13:46:09 2010 New Revision: 961767 URL: http://svn.apache.org/viewvc?rev=961767&view=rev Log: CAMEL-2919: only one single step at a given time is allowed. Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java?rev=961767&r1=961766&r2=961767&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java Thu Jul 8 13:46:09 2010 @@ -52,8 +52,8 @@ public class DefaultDebugger implements private static final Log LOG = LogFactory.getLog(DefaultDebugger.class); private final List breakpoints = new ArrayList(); -// TODO: Should we support multiple single steps? -private final Map singleSteps = new HashMap(); +private final int maxConcurrentSingleSteps = 1; +private final Map singleSteps = new HashMap(maxConcurrentSingleSteps); private CamelContext camelContext; /** @@ -97,11 +97,11 @@ public class DefaultDebugger implements } public void addBreakpoint(Breakpoint breakpoint) { -breakpoints.add(new BreakpointConditions(breakpoint)); +addBreakpoint(breakpoint, (Condition) null); } public void addBreakpoint(Breakpoint breakpoint, Condition... conditions) { -if (conditions != null) { +if (conditions != null && conditions.length > 0) { breakpoints.add(new BreakpointConditions(breakpoint, Arrays.asList(conditions))); } else { breakpoints.add(new BreakpointConditions(breakpoint)); @@ -109,7 +109,7 @@ public class DefaultDebugger implements } public void addSingleStepBreakpoint(final Breakpoint breakpoint) { -addSingleStepBreakpoint(breakpoint, null); +breakpoints.add(new BreakpointConditions(breakpoint)); } public void addSingleStepBreakpoint(final Breakpoint breakpoint, Condition... conditions) { @@ -177,8 +177,14 @@ public class DefaultDebugger implements return Collections.unmodifiableList(answer); } -public void startSingleStepExchange(String exchangeId, Breakpoint breakpoint) { +public boolean startSingleStepExchange(String exchangeId, Breakpoint breakpoint) { +// can we accept single stepping the given exchange? +if (singleSteps.size() >= maxConcurrentSingleSteps) { +return false; +} + singleSteps.put(exchangeId, breakpoint); +return true; } public void stopSingleStepExchange(String exchangeId) { Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java?rev=961767&r1=961766&r2=961767&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java Thu Jul 8 13:46:09 2010 @@ -96,8 +96,10 @@ public interface Debugger extends Servic * * @param exchangeId the exchange id * @param breakpoint the breakpoint + * @return true if the debugger will single step the given exchange, false if the debugger is already + * single stepping another, and thus cannot simultaneously single step another exchange */ -void startSingleStepExchange(String exchangeId, Breakpoint breakpoint); +boolean startSingleStepExchange(String exchangeId, Breakpoint breakpoint); /** * Stops the single step debug mode for the given exchange.
svn commit: r961759 - /camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java
Author: jstrachan Date: Thu Jul 8 13:16:54 2010 New Revision: 961759 URL: http://svn.apache.org/viewvc?rev=961759&view=rev Log: made it easier to reuse the CamelResourceConfig class, letting you pass in the packages as a constructor Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java?rev=961759&r1=961758&r2=961759&view=diff == --- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java (original) +++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java Thu Jul 8 13:16:54 2010 @@ -34,13 +34,17 @@ import org.apache.camel.web.resources.Co public class CamelResourceConfig extends PackagesResourceConfig { public CamelResourceConfig() { -super(createProperties()); +this("org.apache.camel.web"); } -protected static Map createProperties() { +public CamelResourceConfig(String packages) { +super(createProperties(packages)); +} + +protected static Map createProperties(String packages) { Map properties = new HashMap(); -properties.put(PackagesResourceConfig.PROPERTY_PACKAGES, getResourcePackages()); +properties.put(PackagesResourceConfig.PROPERTY_PACKAGES, packages); WadlGeneratorConfig config = WadlGeneratorConfig .generator(WadlGeneratorApplicationDoc.class) @@ -63,8 +67,4 @@ public class CamelResourceConfig extends m.put("dot", MediaType.valueOf(Constants.DOT_MIMETYPE)); return m; } - -protected static String getResourcePackages() { -return "org.apache.camel.web"; -} } \ No newline at end of file
svn commit: r961755 - /camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java
Author: jstrachan Date: Thu Jul 8 13:11:50 2010 New Revision: 961755 URL: http://svn.apache.org/viewvc?rev=961755&view=rev Log: made it easier to reuse the CamelResourceConfig class Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java Modified: camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java?rev=961755&r1=961754&r2=961755&view=diff == --- camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java (original) +++ camel/trunk/components/camel-web/src/main/java/org/apache/camel/web/util/CamelResourceConfig.java Thu Jul 8 13:11:50 2010 @@ -40,7 +40,7 @@ public class CamelResourceConfig extends protected static Map createProperties() { Map properties = new HashMap(); -properties.put(PackagesResourceConfig.PROPERTY_PACKAGES, "org.apache.camel.web"); +properties.put(PackagesResourceConfig.PROPERTY_PACKAGES, getResourcePackages()); WadlGeneratorConfig config = WadlGeneratorConfig .generator(WadlGeneratorApplicationDoc.class) @@ -63,4 +63,8 @@ public class CamelResourceConfig extends m.put("dot", MediaType.valueOf(Constants.DOT_MIMETYPE)); return m; } + +protected static String getResourcePackages() { +return "org.apache.camel.web"; +} } \ No newline at end of file
[CONF] Apache Camel > Camel 2.x - Debugger API
Camel 2.x - Debugger API Page edited by Claus Ibsen Changes (3) ... The processing is based on a {{before}} and {{after}} callback when the [Exchange] is being routed and thus a [Processor] is invoked. The event is based on the [EventNotifer] {{EventNotifier}} emitting events such as {{ExchangeCreatedEvent}}, {{ExchangeFailureEvent}} etc. This allows you to have breakpoints when a given Exchange has failed. Or when they are done, so you can inspect the result etc. There is a {{org.apache.camel.impl.BreakpointSupport}} class which can be used to extend, to avoid implementing all the methods from the interface. ... h3. Single step TODO: bla bla In the Java editor the debugger is capable of single stepping when a breakpoint is hit. The idea in Camel is that you want to single step an [Exchange] so you can step through how its routed and follow it from the 3rd party tooling. The {{Debugger}} has API for single stepping. For example to single step the first message arrived in Camel you can do {code} context.getDebugger().addSingleStepBreakpoint(breakpoint); {code} However what if you have multiple routes or the likes and only want to single step from route X, well you can just add a {{Condition}}: This {{beerCondition}} will only match [Exchange] coming from the {{beer}} route: {code} beerCondition = new ConditionSupport() { public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { return "beer".equals(exchange.getFromRouteId()); } }; {code} So you just provide the condition when adding the breakpoint: {code} // we only want to single step the beer route context.getDebugger().addSingleStepBreakpoint(breakpoint, beerCondition); {code} And the routes could be as follows: {code} public void configure() throws Exception { // use debugger context.setDebugger(new DefaultDebugger()); from("direct:start").routeId("foo").to("log:foo").to("log:bar").to("mock:result"); from("direct:beer").routeId("beer").to("log:beer").to("mock:result"); } {code} Which will cause the debugger to only single step when a message arrives on {{beer}} route: {code} public void testDebug() throws Exception { // we only want to single step the beer route context.getDebugger().addSingleStepBreakpoint(breakpoint, beerCondition); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Carlsberg"); template.sendBody("direct:start", "Hello World"); template.sendBody("direct:beer", "Carlsberg"); assertMockEndpointsSatisfied(); assertEquals(2, logs.size()); assertEquals("Single stepping at log:beer with body: Carlsberg", logs.get(0)); assertEquals("Single stepping at mock:result with body: Carlsberg", logs.get(1)); } {code} h2. Notes - The single step feature should only allow one _active_ at any time. So if there is already a single step message in process other messages should be disregarded from debugging - Should other breakpoints be active during single step? In case you have another breakpoint somewhere which may get triggered? - Should we add a fluent builder syntax for sugar, so its easier to use common conditions? h2. Use cases Full Content Camel 2.x - Debugger API Available as of Camel 2.4 There is a new org.apache.camel.spi.Debugger API which allows 3rd party to attach a debugger tooling to debug Exchanges in Camel routes. There is a default implementation in camel-core as the org.apache.camel.impl.DefaultDebugger. Enabling You can enable the debugger from the CamelContext using the setDebugger. We may add a nicer API for this in the future. Breakpoint There is a org.apache.camel.spi.Breakpoint API in which the 3rd party tooling implement logic what should happen when the breakpoint is hit. The breakpoint can be invoked in 2 kind of styles in Camel: processing based event based The processing is based on a before and after callback when the Exchange is being routed and thus a Processor is invoked. The event is based on the EventNotifier emitting events such as ExchangeCreatedEvent, ExchangeFailureEvent etc. This allows you to have breakpoints when a given Exchange has failed. Or when they are done, so you can inspect the result etc. There is a org.apache.camel.impl.BreakpointSupport class which can be used to extend, to avoid implementing all the methods from the interface. Condition There is a org.apache.camel.spi.Condition API in which the 3rd party tooling can provide conditions when the breakpoints should apply. For exam
[CONF] Apache Camel > Camel 2.x - Debugger API
Camel 2.x - Debugger API Page added by Claus Ibsen Camel 2.x - Debugger API Available as of Camel 2.4 There is a new org.apache.camel.spi.Debugger API which allows 3rd party to attach a debugger tooling to debug Exchanges in Camel routes. There is a default implementation in camel-core as the org.apache.camel.impl.DefaultDebugger. Enabling You can enable the debugger from the CamelContext using the setDebugger. We may add a nicer API for this in the future. Breakpoint There is a org.apache.camel.spi.Breakpoint API in which the 3rd party tooling implement logic what should happen when the breakpoint is hit. The breakpoint can be invoked in 2 kind of styles in Camel: processing based event based The processing is based on a before and after callback when the Exchange is being routed and thus a Processor is invoked. The event is based on the EventNotifer emitting events such as ExchangeCreatedEvent, ExchangeFailureEvent etc. This allows you to have breakpoints when a given Exchange has failed. Or when they are done, so you can inspect the result etc. There is a org.apache.camel.impl.BreakpointSupport class which can be used to extend, to avoid implementing all the methods from the interface. Condition There is a org.apache.camel.spi.Condition API in which the 3rd party tooling can provide conditions when the breakpoints should apply. For example a conditional breakpoint which only triggers if the message body is a certain message / type etc. The condition can be invoked in 2 kind of styles in Camel: processing based event based Where there is a match method for each style. There is a org.apache.camel.impl.ConditionSupport class which can be used to extend, to avoid implementing all the methods from the interface. Example For example we can have this breakpoint breakpoint = new BreakpointSupport() { public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { String body = exchange.getIn().getBody(String.class); logs.add("Breakpoint at " + definition + " with body: " + body); } } In which we want to trigger when the message contains Camel. So we can create this Condition: camelCondition = new ConditionSupport() { public boolean matchProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { return body().contains("Camel").matches(exchange); } }; And to use this we just tell the Debugger as follows: public void testDebug() throws Exception { context.getDebugger().addBreakpoint(breakpoint, camelCondition); getMockEndpoint("mock:result").expectedBodiesReceived("Hello World", "Hello Camel"); template.sendBody("direct:start", "Hello World"); template.sendBody("direct:start", "Hello Camel"); assertMockEndpointsSatisfied(); assertEquals(2, logs.size()); assertEquals("Breakpoint at To[log:foo] with body: Hello Camel", logs.get(0)); assertEquals("Breakpoint at To[mock:result] with body: Hello Camel", logs.get(1)); } Which then will only invoke the breakpoint callback for the "Hello Camel" message. Single step TODO: bla bla Change Notification Preferences View Online | Add Comment
svn commit: r961732 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ main/java/org/apache/camel/spi/ test/java/org/apache/camel/processor/interceptor/
Author: davsclaus Date: Thu Jul 8 12:23:02 2010 New Revision: 961732 URL: http://svn.apache.org/viewvc?rev=961732&view=rev Log: CAMEL-2919: Added single step feature to Debugger. Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugSingleStepConditionTest.java (with props) camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugSingleStepTest.java (with props) Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java?rev=961732&r1=961731&r2=961732&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java Thu Jul 8 12:23:02 2010 @@ -20,7 +20,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EventObject; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.CamelContextAware; @@ -30,6 +32,8 @@ import org.apache.camel.Processor; import org.apache.camel.RouteNode; import org.apache.camel.management.EventNotifierSupport; import org.apache.camel.management.event.AbstractExchangeEvent; +import org.apache.camel.management.event.ExchangeCompletedEvent; +import org.apache.camel.management.event.ExchangeCreatedEvent; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.processor.interceptor.Tracer; import org.apache.camel.spi.Breakpoint; @@ -48,6 +52,8 @@ public class DefaultDebugger implements private static final Log LOG = LogFactory.getLog(DefaultDebugger.class); private final List breakpoints = new ArrayList(); +// TODO: Should we support multiple single steps? +private final Map singleSteps = new HashMap(); private CamelContext camelContext; /** @@ -95,7 +101,56 @@ public class DefaultDebugger implements } public void addBreakpoint(Breakpoint breakpoint, Condition... conditions) { -breakpoints.add(new BreakpointConditions(breakpoint, Arrays.asList(conditions))); +if (conditions != null) { +breakpoints.add(new BreakpointConditions(breakpoint, Arrays.asList(conditions))); +} else { +breakpoints.add(new BreakpointConditions(breakpoint)); +} +} + +public void addSingleStepBreakpoint(final Breakpoint breakpoint) { +addSingleStepBreakpoint(breakpoint, null); +} + +public void addSingleStepBreakpoint(final Breakpoint breakpoint, Condition... conditions) { +// wrap the breakpoint into single step breakpoint so we can automatic enable/disable the single step mode +Breakpoint singlestep = new Breakpoint() { +public State getState() { +return breakpoint.getState(); +} + +public void suspend() { +breakpoint.suspend(); +} + +public void activate() { +breakpoint.activate(); +} + +public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { +breakpoint.beforeProcess(exchange, processor, definition); +} + +public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition definition, long timeTaken) { +breakpoint.afterProcess(exchange, processor, definition, timeTaken); +} + +public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition definition) { +if (event instanceof ExchangeCreatedEvent) { + exchange.getContext().getDebugger().startSingleStepExchange(exchange.getExchangeId(), this); +} else if (event instanceof ExchangeCompletedEvent) { + exchange.getContext().getDebugger().stopSingleStepExchange(exchange.getExchangeId()); +} +breakpoint.onEvent(exchange, event, definition); +} + +@Override +public String toString() { +return breakpoint.toString(); +} +}; + +addBreakpoint(singlestep, conditions); } public void removeBreakpoint(Breakpoint breakpoint) { @@ -122,10 +177,24 @@ public class DefaultDebugger implements return Collections.unmodifiableList(answer); } +public void startSingleStepExchange(String exchangeId, Breakpoint breakpoint) { +singleSteps.put(exchangeId, breakpoint); +} + +public v
svn commit: r961627 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/impl/ main/java/org/apache/camel/processor/interceptor/ main/java/org/apache/camel/spi/ tes
Author: davsclaus Date: Thu Jul 8 08:29:21 2010 New Revision: 961627 URL: http://svn.apache.org/viewvc?rev=961627&view=rev Log: CAMEL-2919: Debugger API Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debug.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Breakpoint.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java camel/trunk/camel-core/src/test/java/org/apache/camel/TestSupportJmxCleanup.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=961627&r1=961626&r2=961627&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Thu Jul 8 08:29:21 2010 @@ -40,32 +40,28 @@ public interface Exchange { String AGGREGATION_STRATEGY = "CamelAggregationStrategy"; String ASYNC_WAIT = "CamelAsyncWait"; -String BATCH_INDEX= "CamelBatchIndex"; -String BATCH_SIZE = "CamelBatchSize"; -String BATCH_COMPLETE = "CamelBatchComplete"; - +String BATCH_INDEX= "CamelBatchIndex"; +String BATCH_SIZE = "CamelBatchSize"; +String BATCH_COMPLETE = "CamelBatchComplete"; String BEAN_METHOD_NAME = "CamelBeanMethodName"; String BEAN_MULTI_PARAMETER_ARRAY = "CamelBeanMultiParameterArray"; - -String BINDING = "CamelBinding"; +String BINDING= "CamelBinding"; String CHARSET_NAME = "CamelCharsetName"; String CONTENT_ENCODING = "Content-Encoding"; String CONTENT_TYPE = "Content-Type"; String CORRELATION_ID = "CamelCorrelationId"; -String DATASET_INDEX = "CamelDataSetIndex"; -String DEFAULT_CHARSET_PROPERTY = "org.apache.camel.default.charset"; - +String DATASET_INDEX = "CamelDataSetIndex"; +String DEFAULT_CHARSET_PROPERTY = "org.apache.camel.default.charset"; String DISABLE_HTTP_STREAM_CACHE = "CamelDisableHttpStreamCache"; String EXCEPTION_CAUGHT = "CamelExceptionCaught"; String ERRORHANDLER_HANDLED = "CamelErrorHandlerHandled"; + String FAILURE_HANDLED = "CamelFailureHandled"; String FAILURE_ENDPOINT = "CamelFailureEndpoint"; - String FILTER_NON_XML_CHARS = "CamelFilterNonXmlChars"; - String FILE_LOCAL_WORK_PATH = "CamelFileLocalWorkPath"; String FILE_NAME= "CamelFileName"; String FILE_NAME_ONLY = "CamelFileNameOnly"; @@ -85,11 +81,10 @@ public interface Exchange { String HTTP_URI= "CamelHttpUri"; String HTTP_URL= "CamelHttpUrl"; String HTTP_CHUNKED= "CamelHttpChunked"; -String HTTP_SERVLET_REQUEST = "CamelHttpServletRequest"; -String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse"; +String HTTP_SERVLET_REQUEST= "CamelHttpServletRequest"; +String HTTP_SERVLET_RESPONSE = "CamelHttpServletResponse"; String INTERCEPTED_ENDPOINT = "CamelInterceptedEndpoint"; -String TO_ENDPOINT = "CamelToEndpoint"; String LOG_DEBUG_BODY_MAX_CHARS = "CamelLogDebugBodyMaxChars"; String LOG_DEBUG_BODY_STREAMS = "CamelLogDebugStreams"; @@ -102,29 +97,29 @@ public interface Exchange { String ON_COMPLETION = "CamelOnCompletion"; -String ROUTE_STOP = "CamelRouteStop"; String REDELIVERED = "CamelRedelivered"; String REDELIVERY_COUNTER = "CamelRedeliveryCounter"; String REDELIVERY_EXHAUSTED = "CamelRedeliveryExhausted"; String ROLLBACK_ONLY= "CamelRollbackOnly"; String ROLLBACK_ONLY_LAST = "CamelRollbackOnlyLast"; - +String ROUTE_STOP = "CamelRouteStop"; + String SOAP_ACTION= "CamelSoapAction"; String SKIP_GZIP_ENCODING = "CamelSkipGzipEncoding"; String SPLIT_INDEX= "CamelSplitIndex"; String SPLIT_COMPLETE = "CamelSplitComplete"; String SPLIT_SIZE = "CamelSplitSize"; -String TRANSFER_ENCODING = "Transfer-Encoding"; +String TIMER_FIRED_TIME = "CamelTimerFiredTime"; +String TIMER_NAME= "CamelTimerName"; +String TIMER_PERIOD = "CamelTimerPeriod"; +String TIMER_TIME= "CamelTimerTime"; +String TO_ENDPOINT = "CamelToEndpoint"; String TRACE_EVENT = "
svn commit: r961615 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/impl/ main/java/org/apache/camel/management/event/ main/java/org/apache/camel/processor/interceptor/ main/java/org/apac
Author: davsclaus Date: Thu Jul 8 07:43:35 2010 New Revision: 961615 URL: http://svn.apache.org/viewvc?rev=961615&view=rev Log: CAMEL-2919: Debugger API Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConditionSupport.java (with props) camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/AbstractExchangeEvent.java (with props) camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java (with props) camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionEventBreakpointTest.java (contents, props changed) - copied, changed from r961578, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultDebugger.java camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCompletedEvent.java camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeCreatedEvent.java camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureEvent.java camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeFailureHandledEvent.java camel/trunk/camel-core/src/main/java/org/apache/camel/management/event/ExchangeSentEvent.java camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debug.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Breakpoint.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Condition.java camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Debugger.java camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugTest.java Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java?rev=961615&r1=961614&r2=961615&view=diff == --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java (original) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/BreakpointSupport.java Thu Jul 8 07:43:35 2010 @@ -16,13 +16,17 @@ */ package org.apache.camel.impl; +import java.util.EventObject; + import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.spi.Breakpoint; /** * A support class for {...@link Breakpoint} implementations to use as base class. * - * Will be in active state and match any {...@link Exchange}s. + * Will be in active state. * * @version $Revision$ */ @@ -42,4 +46,15 @@ public abstract class BreakpointSupport state = State.Active; } +public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { +// noop +} + +public void afterProcess(Exchange exchange, Processor processor, ProcessorDefinition definition) { +// noop +} + +public void onEvent(Exchange exchange, EventObject event, ProcessorDefinition definition) { +// noop +} } Added: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConditionSupport.java URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConditionSupport.java?rev=961615&view=auto == --- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConditionSupport.java (added) +++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/ConditionSupport.java Thu Jul 8 07:43:35 2010 @@ -0,0 +1,40 @@ +/** + * 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. + */ +package org.apache.camel.impl; + +import java.util.EventObject; + +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +