Search in sources :

Example 11 with ErrorHandlerBuilderRef

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());
        }
    }
}
Also used : ErrorHandlerBuilderRef(org.apache.camel.builder.ErrorHandlerBuilderRef) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 12 with ErrorHandlerBuilderRef

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"));
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ErrorHandlerBuilderRef(org.apache.camel.builder.ErrorHandlerBuilderRef)

Example 13 with ErrorHandlerBuilderRef

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"));
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ErrorHandlerBuilderRef(org.apache.camel.builder.ErrorHandlerBuilderRef)

Example 14 with ErrorHandlerBuilderRef

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"));
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) IOException(java.io.IOException) ErrorHandlerBuilderRef(org.apache.camel.builder.ErrorHandlerBuilderRef)

Example 15 with ErrorHandlerBuilderRef

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"));
        }
    };
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) ErrorHandlerBuilderRef(org.apache.camel.builder.ErrorHandlerBuilderRef)

Aggregations

ErrorHandlerBuilderRef (org.apache.camel.builder.ErrorHandlerBuilderRef)17 RouteBuilder (org.apache.camel.builder.RouteBuilder)13 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 XmlAttribute (javax.xml.bind.annotation.XmlAttribute)1 ErrorHandlerFactory (org.apache.camel.ErrorHandlerFactory)1 ErrorHandlerBuilder (org.apache.camel.builder.ErrorHandlerBuilder)1