@Override public ThrottlingPolicy createPolicy(SharedLimiterKey key, SharedResourcesBroker<ThrottlingServerScopes> broker, Config config) { return new NoopPolicy(); } }
@Override public SharedResourceFactoryResponse<ThrottlingPolicy> createResource(SharedResourcesBroker<ThrottlingServerScopes> broker, ScopedConfigView<ThrottlingServerScopes, SharedLimiterKey> configView) throws NotConfiguredException { Config config = configView.getConfig(); if (!config.hasPath(POLICY_KEY)) { if (config.hasPath(FAIL_ON_UNKNOWN_RESOURCE_ID) && config.getBoolean(FAIL_ON_UNKNOWN_RESOURCE_ID)) { throw new NotConfiguredException("Missing key " + POLICY_KEY); } else { return new TTLResourceEntry<ThrottlingPolicy>(new NoopPolicy(), ConfigUtils.getLong(config, RELOAD_FREQUENCY_KEY, DEFAULT_RELOAD_FREQUENCY), false); } } try { SpecificPolicyFactory factory = POLICY_CLASS_RESOLVER.resolveClass(config.getString(POLICY_KEY)).newInstance(); return new TTLResourceEntry<>(factory.createPolicy(configView.getKey(), broker, config), ConfigUtils.getLong(config, RELOAD_FREQUENCY_KEY, DEFAULT_RELOAD_FREQUENCY), false); } catch (ReflectiveOperationException roe) { throw new RuntimeException(roe); } }
@Override public ThrottlingPolicy createPolicy(SharedLimiterKey key, SharedResourcesBroker<ThrottlingServerScopes> broker, Config config) { return new NoopPolicy(); } }
@Override public SharedResourceFactoryResponse<ThrottlingPolicy> createResource(SharedResourcesBroker<ThrottlingServerScopes> broker, ScopedConfigView<ThrottlingServerScopes, SharedLimiterKey> configView) throws NotConfiguredException { Config config = configView.getConfig(); if (!config.hasPath(POLICY_KEY)) { if (config.hasPath(FAIL_ON_UNKNOWN_RESOURCE_ID) && config.getBoolean(FAIL_ON_UNKNOWN_RESOURCE_ID)) { throw new NotConfiguredException("Missing key " + POLICY_KEY); } else { return new TTLResourceEntry<ThrottlingPolicy>(new NoopPolicy(), ConfigUtils.getLong(config, RELOAD_FREQUENCY_KEY, DEFAULT_RELOAD_FREQUENCY), false); } } try { SpecificPolicyFactory factory = POLICY_CLASS_RESOLVER.resolveClass(config.getString(POLICY_KEY)).newInstance(); return new TTLResourceEntry<>(factory.createPolicy(configView.getKey(), broker, config), ConfigUtils.getLong(config, RELOAD_FREQUENCY_KEY, DEFAULT_RELOAD_FREQUENCY), false); } catch (ReflectiveOperationException roe) { throw new RuntimeException(roe); } }