Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This feature also appears frequently. In the try...catch DSL or onException DSL, we may use some external or custom exception classes. But current groovy renderer doesn't process the import packages, so if you should manually add the import lines each time you edit it. Another problem is that groovy renderer can't return the instance name of that class. For example, you may define a route like:

Code Block

import org.apache.camel.*;
import org.apache.camel.processor.*;
import org.apache.camel.language.groovy.GroovyRouteBuilder;
class GroovyRoute extends GroovyRouteBuilder { 
  void configure() {
    MyValidator validator = new MyValidator();
    from("direct:start")
      .doTry().process(validator).to("mock:valid")
      .doCatch(ValidationException.class).to("mock:invalid")
  }
}

For this route, groovy renderer can't return the name: validator and it only know there is a processor instance here.

  • happen to: doTry...doCatch(...doFinally), onException, throwException, pollEnrich, process, etc.
  • improving suggestion: let groovy renderer add the import packages automatically, but I am afraid it can't process them at all times.

...