@Override
public ErrorHandlerBuilder getObject() throws Exception {
ErrorHandlerBuilder errorHandler = getObjectType().newInstance();
if (errorHandler instanceof DefaultErrorHandlerBuilder) {
DefaultErrorHandlerBuilder handler = (DefaultErrorHandlerBuilder) errorHandler;
if (deadLetterUri != null) {
handler.setDeadLetterUri(deadLetterUri);
}
if (useOriginalMessage != null) {
handler.setUseOriginalMessage(useOriginalMessage);
}
if (redeliveryPolicy != null) {
handler.setRedeliveryPolicy(redeliveryPolicy.createRedeliveryPolicy(getCamelContext(), null));
}
if (redeliveryPolicyRef != null) {
// lookup redelivery
RedeliveryPolicy policy = CamelContextHelper.mandatoryLookup(getCamelContext(), redeliveryPolicyRef, RedeliveryPolicy.class);
handler.setRedeliveryPolicy(policy);
}
if (onRedeliveryRef != null) {
handler.setOnRedelivery(lookup(onRedeliveryRef, Processor.class));
}
if (retryWhileRef != null) {
handler.setRetryWhileRef(retryWhileRef);
}
if (executorServiceRef != null) {
handler.setExecutorServiceRef(executorServiceRef);
}
} else if (errorHandler instanceof LoggingErrorHandlerBuilder) {
LoggingErrorHandlerBuilder handler = (LoggingErrorHandlerBuilder) errorHandler;
if (level != null) {
handler.setLevel(level);
}
if (logName != null) {
handler.setLogName(logName);
}
}
return errorHandler;
}