public CircuitBreakerLoadBalancerDefinition() {
}
@Override
protected LoadBalancer createLoadBalancer(RouteContext routeContext) {
CircuitBreakerLoadBalancer answer;
if (!exceptions.isEmpty()) {
List<Class<?>> classes = new ArrayList<Class<?>>();
for (String name : exceptions) {
Class<?> type = routeContext.getCamelContext().getClassResolver().resolveClass(name);
if (type == null) {
throw new IllegalArgumentException("Cannot find class: " + name + " in the classpath");
}
if (!ObjectHelper.isAssignableFrom(Throwable.class, type)) {
throw new IllegalArgumentException("Class is not an instance of Throwable: " + type);
}
classes.add(type);
}
answer = new CircuitBreakerLoadBalancer(classes);
} else {
answer = new CircuitBreakerLoadBalancer();
}
if (getHalfOpenAfter() != null) {
answer.setHalfOpenAfter(getHalfOpenAfter());
}
if (getThreshold() != null) {
answer.setThreshold(getThreshold());
}
return answer;
}