@Test public void serviceReturnsCorrectlyFromCall() { assertThat(loadRetryPolicy(environment.configuration(), environment, "myRetry.factory", RetryPolicy.class).get(), is(instanceOf(RetryPolicy.class))); }
public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class); JsonNodeConfig config = factoryConfig.config(); return serviceClass.cast(factory.create(environment, config)); }); }
ServiceProvision { public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class); JsonNodeConfig config = factoryConfig.config(); return serviceClass.cast(factory.create(environment, config)); }); } }
ServiceProvision { public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class); JsonNodeConfig config = factoryConfig.config(); return serviceClass.cast(factory.create(environment, config)); }); } private  ServiceProvision(); }
ServiceProvision { public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class); JsonNodeConfig config = factoryConfig.config(); return serviceClass.cast(factory.create(environment, config)); }); } private  ServiceProvision(); static Optional<E> loadLoadBalancer(
            Configuration configuration,
            Environment environment,
            String key,
            Class<? extends E> serviceClass,
            ActiveOrigins activeOrigins); static Optional<E> loadRetryPolicy(
            Configuration configuration,
            Environment environment,
            String key,
            Class<? extends E> serviceClass); static Map<String, T> loadServices(Configuration configuration, Environment environment, String key, Class<? extends T> serviceClass); }
ServiceProvision { public static <E extends RetryPolicy> Optional<E> loadRetryPolicy( Configuration configuration, Environment environment, String key, Class<? extends E> serviceClass) { return configuration .get(key, ServiceFactoryConfig.class) .map(factoryConfig -> { RetryPolicyFactory factory = newInstance(factoryConfig.factory(), RetryPolicyFactory.class); JsonNodeConfig config = factoryConfig.config(); return serviceClass.cast(factory.create(environment, config)); }); } private  ServiceProvision(); static Optional<E> loadLoadBalancer(
            Configuration configuration,
            Environment environment,
            String key,
            Class<? extends E> serviceClass,
            ActiveOrigins activeOrigins); static Optional<E> loadRetryPolicy(
            Configuration configuration,
            Environment environment,
            String key,
            Class<? extends E> serviceClass); static Map<String, T> loadServices(Configuration configuration, Environment environment, String key, Class<? extends T> serviceClass);  }