class CircuitBreakerFactory {

    public synchronized CircuitBreaker createCircuitBreaker(String name,
            CircuitBreakerConfig config) {
        CircuitBreaker circuitBreaker = findCircuitBreaker(name);

        if (circuitBreaker == null) {
            circuitBreaker = new CircuitBreaker(name);

            configureCircuitBreaker(name, circuitBreaker, config);
            addCircuitBreakerToMap(name, circuitBreaker);
        }

        return circuitBreaker;
    }

}