private String getFromConfigSource(ConfigSource[] configSources, String key) { for (ConfigSource configSource : configSources) { if (configSource.getPropertyValue(key) != null) { return configSource.getConfigName(); } } return null; }
protected <T> T getPropertyValue(InjectionPoint injectionPoint, Class<T> ipCls) { return getUntypedPropertyValue(injectionPoint, ipCls); }
/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { return (configSource1.getOrdinal() > configSource2.getOrdinal()) ? -1 : 1; } });
@Override public String filterConfigValue(String key, String value, boolean forLog) { String filteredValue = value; for (ConfigFilter filter : configFilters) { filteredValue = forLog ? filter.filterValueForLog(key, filteredValue) : filter.filterValue(key, filteredValue); } return filteredValue; }
/** * <p>Inspects the given InjectionPoint and search for a {@link ConfigProperty} * annotation or an Annotation with a {@link ConfigProperty} meta-Annotation. * The name and defaultValue information will be used to resolve the * configured value.</p> * * @param injectionPoint current injection point * @return the configured value for the given InjectionPoint */ protected String getStringPropertyValue(InjectionPoint injectionPoint) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); if (configProperty == null) { throw new IllegalStateException("producer method called without @ConfigProperty being present!"); } return getPropertyValue(injectionPoint, String.class); }
/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { int o1 = configSource1.getOrdinal(); int o2 = configSource2.getOrdinal(); if (o1 == o2) { return configSource1.getConfigName().compareTo(configSource2.getConfigName()); } return (o1 > o2) ? -1 : 1; } });
protected <T> T getUntypedPropertyValue(InjectionPoint injectionPoint, Type ipCls) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); if (configProperty == null) { throw new IllegalStateException("producer method called without @ConfigProperty being present!"); } return readEntry(configProperty.name(), configProperty.defaultValue(), ipCls, configProperty.converter(), configProperty.parameterizedBy(), configProperty.projectStageAware(), configProperty.evaluateVariables()); }
private static String filterConfigValue(String key, String value) { List<ConfigFilter> currentConfigFilters = getConfigFilters(); String filteredValue = value; for (ConfigFilter filter : currentConfigFilters) { filteredValue = filter.filterValue(key, filteredValue); } return filteredValue; }
private static String filterConfigValueForLog(String key, String value) { List<ConfigFilter> currentConfigFilters = getConfigFilters(); String logValue = value; for (ConfigFilter filter : currentConfigFilters) { logValue = filter.filterValueForLog(key, logValue); } return logValue; }
private void setTestConfigSourceValue(String key, String value) { ConfigSource[] configSources = ConfigResolver.getConfigSources(); for (ConfigSource configSource : configSources) { if (configSource instanceof TestConfigSource) { if (value == null) { configSource.getProperties().remove(key); } else { configSource.getProperties().put(key, value); } break; } } }
public <T> T readEntry(final String key, final String stringDefault, final Type ipCls, final Class<? extends ConfigResolver.Converter> converterType, final String parameterizedBy, final boolean projectStageAware, final boolean evaluate) { final ConfigResolver.TypedResolver<T> resolver = asResolver( key, stringDefault, ipCls, converterType, parameterizedBy, projectStageAware, evaluate); return resolver.getValue(); }
private static List<ConfigSource> resolveConfigSources() { List<ConfigSource> appConfigSources = ServiceUtils.loadServiceImplementations(ConfigSource.class); List<ConfigSourceProvider> configSourceProviderServiceLoader = ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class); for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader) { appConfigSources.addAll(configSourceProvider.getConfigSources()); } return appConfigSources; }
protected void processConfigurationValidation(AfterDeploymentValidation adv) { for (ConfigValidator configValidator : ServiceUtils.loadServiceImplementations(ConfigValidator.class)) { Set<String> violations = configValidator.processValidation(); if (violations == null) { continue; } for (String violation : violations) { adv.addDeploymentProblem(new IllegalStateException(violation)); } } }
/** * <p>Inspects the given InjectionPoint and search for a {@link ConfigProperty} * annotation or an Annotation with a {@link ConfigProperty} meta-Annotation. * The name and defaultValue information will be used to resolve the * configured value.</p> * * @param injectionPoint current injection point * @return the configured value for the given InjectionPoint */ protected String getStringPropertyValue(InjectionPoint injectionPoint) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); if (configProperty == null) { throw new IllegalStateException("producer method called without @ConfigProperty being present!"); } return getPropertyValue(injectionPoint, String.class); }
protected <T> T getUntypedPropertyValue(InjectionPoint injectionPoint, Type ipCls) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); if (configProperty == null) { throw new IllegalStateException("producer method called without @ConfigProperty being present!"); } return readEntry(configProperty.name(), configProperty.defaultValue(), ipCls, configProperty.converter(), configProperty.parameterizedBy(), configProperty.projectStageAware(), configProperty.evaluateVariables()); }
protected <T> T getPropertyValue(InjectionPoint injectionPoint, Class<T> ipCls) { return getUntypedPropertyValue(injectionPoint, ipCls); }
/** * {@inheritDoc} */ @Override public int compare(ConfigSource configSource1, ConfigSource configSource2) { return (configSource1.getOrdinal() > configSource2.getOrdinal()) ? 1 : -1; } });
public <T> T readEntry(final String key, final String stringDefault, final Type ipCls, final Class<? extends ConfigResolver.Converter> converterType, final String parameterizedBy, final boolean projectStageAware, final boolean evaluate) { final ConfigResolver.TypedResolver<T> resolver = asResolver( key, stringDefault, ipCls, converterType, parameterizedBy, projectStageAware, evaluate); return resolver.getValue(); }
/** * <p>Inspects the given InjectionPoint and search for a {@link ConfigProperty} * annotation or an Annotation with a {@link ConfigProperty} meta-Annotation. * The name and defaultValue information will be used to resolve the * configured value.</p> * * @param injectionPoint current injection point * @return the configured value for the given InjectionPoint */ protected String getStringPropertyValue(InjectionPoint injectionPoint) { ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class); if (configProperty == null) { throw new IllegalStateException("producer method called without @ConfigProperty being present!"); } String configuredValue; String defaultValue = configProperty.defaultValue(); configuredValue = getPropertyValue(configProperty.name(), defaultValue); return configuredValue; }
@Produces @ConfigProperty(name = "ignored") public Object create(final InjectionPoint ip) { return super.getUntypedPropertyValue(ip, ip.getType()); } }