use of org.apache.camel.builder.ErrorHandlerBuilderRef in project camel by apache.
the class CamelServletContextListener method initCamelContext.
/**
* Initializes the {@link ServletCamelContext} by setting the supported init parameters.
*/
private void initCamelContext(ServletCamelContext camelContext, Map<String, Object> parameters) throws Exception {
String messageHistory = (String) parameters.remove("messageHistory");
if (messageHistory != null) {
camelContext.setMessageHistory(CamelContextHelper.parseBoolean(camelContext, messageHistory));
}
String streamCache = (String) parameters.remove("streamCache");
if (streamCache != null) {
camelContext.setStreamCaching(CamelContextHelper.parseBoolean(camelContext, streamCache));
}
String trace = (String) parameters.remove("trace");
if (trace != null) {
camelContext.setTracing(CamelContextHelper.parseBoolean(camelContext, trace));
}
String delayer = (String) parameters.remove("delayer");
if (delayer != null) {
camelContext.setDelayer(CamelContextHelper.parseLong(camelContext, delayer));
}
String handleFault = (String) parameters.remove("handleFault");
if (handleFault != null) {
camelContext.setHandleFault(CamelContextHelper.parseBoolean(camelContext, handleFault));
}
String errorHandlerRef = (String) parameters.remove("errorHandlerRef");
if (errorHandlerRef != null) {
camelContext.setErrorHandlerBuilder(new ErrorHandlerBuilderRef(errorHandlerRef));
}
String autoStartup = (String) parameters.remove("autoStartup");
if (autoStartup != null) {
camelContext.setAutoStartup(CamelContextHelper.parseBoolean(camelContext, autoStartup));
}
String useMDCLogging = (String) parameters.remove("useMDCLogging");
if (useMDCLogging != null) {
camelContext.setUseMDCLogging(CamelContextHelper.parseBoolean(camelContext, useMDCLogging));
}
String useBreadcrumb = (String) parameters.remove("useBreadcrumb");
if (useBreadcrumb != null) {
camelContext.setUseBreadcrumb(CamelContextHelper.parseBoolean(camelContext, useBreadcrumb));
}
String managementNamePattern = (String) parameters.remove("managementNamePattern");
if (managementNamePattern != null) {
camelContext.getManagementNameStrategy().setNamePattern(managementNamePattern);
}
String threadNamePattern = (String) parameters.remove("threadNamePattern");
if (threadNamePattern != null) {
camelContext.getExecutorServiceManager().setThreadNamePattern(threadNamePattern);
}
// extract any additional properties. prefixes
Map<String, Object> properties = IntrospectionSupport.extractProperties(parameters, "properties.");
if (properties != null && !properties.isEmpty()) {
for (Map.Entry<String, Object> entry : properties.entrySet()) {
camelContext.getProperties().put(entry.getKey(), "" + entry.getValue());
}
}
}
use of org.apache.camel.builder.ErrorHandlerBuilderRef in project camel by apache.
the class OnExceptionErrorHandlerRefIssueTwoRoutesTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(new ErrorHandlerBuilderRef("myDLC"));
from("direct:foo").to("mock:foo").throwException(new IllegalArgumentException("Damn Foo"));
from("direct:start").onException(IllegalArgumentException.class).handled(true).to("mock:handled").end().to("mock:a").throwException(new IllegalArgumentException("Damn"));
}
};
}
use of org.apache.camel.builder.ErrorHandlerBuilderRef in project camel by apache.
the class OnExceptionNotHandledRouteScopedErrorHandlerRefIssueTwoRoutesTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:foo").errorHandler(new ErrorHandlerBuilderRef("myDLC")).to("mock:foo").throwException(new IllegalArgumentException("Damn Foo"));
from("direct:start").errorHandler(new ErrorHandlerBuilderRef("myDLC")).onException(IllegalArgumentException.class).handled(false).to("mock:handled").end().to("mock:a").throwException(new IllegalArgumentException("Damn"));
}
};
}
use of org.apache.camel.builder.ErrorHandlerBuilderRef in project camel by apache.
the class ContextScopedOnExceptionErrorHandlerRefIssueTwoRoutesTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(IllegalArgumentException.class).handled(true).to("mock:handled").end();
from("direct:foo").errorHandler(new ErrorHandlerBuilderRef("myDLC")).to("mock:foo").throwException(new IOException("Damn IO"));
from("direct:start").errorHandler(new ErrorHandlerBuilderRef("myDLC")).to("mock:a").throwException(new IllegalArgumentException("Damn"));
}
};
}
use of org.apache.camel.builder.ErrorHandlerBuilderRef in project camel by apache.
the class ContextScopedOnExceptionNotHandledErrorHandlerRefIssueTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(IllegalArgumentException.class).handled(false).to("mock:handled").end();
errorHandler(new ErrorHandlerBuilderRef("myDLC"));
from("direct:start").to("mock:a").throwException(new IllegalArgumentException("Damn"));
}
};
}
Aggregations