org.apache.deltaspike.core.api.config.ConfigProperty Java Examples

The following examples show how to use org.apache.deltaspike.core.api.config.ConfigProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ForgeInitialiser.java    From fabric8-forge with Apache License 2.0 6 votes vote down vote up
/**
 * @param addOnDir the directory where Forge addons will be stored
 */
@Inject
public ForgeInitialiser(@ConfigProperty(name = "FORGE_ADDON_DIRECTORY", defaultValue = "./addon-repository") String addOnDir, FurnaceProducer furnaceProducer) {
    java.util.logging.Logger out = java.util.logging.Logger.getLogger(this.getClass().getName());
    out.info("Logging to JUL to test the configuration");

    // lets ensure that the addons folder is initialised
    File repoDir = new File(addOnDir);
    repoDir.mkdirs();
    LOG.info("initialising furnace with folder: " + repoDir.getAbsolutePath());
    File[] files = repoDir.listFiles();
    if (files == null || files.length == 0) {
        LOG.warn("No files found in the addon directory: " + repoDir.getAbsolutePath());
    } else {
        LOG.warn("Found " + files.length + " addon files in directory: " + repoDir.getAbsolutePath());
    }
    furnaceProducer.setup(repoDir);
}
 
Example #2
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
public <T> ConfigResolver.TypedResolver<T> asResolver(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.UntypedResolver<String> untypedResolver = ConfigResolver.resolve(key);
    final ConfigResolver.TypedResolver<T> resolver =
            (ConfigResolver.Converter.class == converterType ?
                    untypedResolver.as(Class.class.cast(ipCls)) :
                    untypedResolver.as(ipCls, BeanProvider.getContextualReference(converterType)))
                    .withCurrentProjectStage(projectStageAware);
    if (!ConfigProperty.NULL.equals(stringDefault))
    {
        resolver.withStringDefault(stringDefault);
    }
    if (!ConfigProperty.NULL.equals(parameterizedBy))
    {
        resolver.parameterizedBy(parameterizedBy);
    }
    return resolver.evaluateVariables(evaluate);
}
 
Example #3
Source File: DatawaveCommonConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Map<String,AuditType> produceStringAuditTypeMapConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] pairs = StringUtils.split(propertyValue, "|");
    
    Map<String,AuditType> map = new LinkedHashMap<>();
    if (pairs != null) {
        for (String pair : pairs) {
            String[] keyValue = StringUtils.split(pair, ";");
            if (keyValue != null && keyValue.length == 2) {
                map.put(keyValue[0], AuditType.valueOf(keyValue[1]));
            } else {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Map<String,AuditType> property '" + configProperty.name() + "' pair: " + pair + " of "
                                + propertyValue + " happening in bean " + injectionPoint.getBean());
            }
        }
    }
    return map;
}
 
Example #4
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public List<Integer> produceIntegerListConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    
    ArrayList<Integer> list = new ArrayList<>();
    if (values != null) {
        for (String value : values) {
            try {
                list.add(Integer.parseInt(value));
            } catch (NumberFormatException nfe) {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Integer property '" + configProperty.name() + "' value: " + value + " of "
                                + propertyValue + " happening in bean " + injectionPoint.getBean(), nfe);
            }
            
        }
    }
    return list;
}
 
Example #5
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public List<Long> produceLongListConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    
    ArrayList<Long> list = new ArrayList<>();
    if (values != null) {
        for (String value : values) {
            try {
                list.add(Long.parseLong(value));
            } catch (NumberFormatException nfe) {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Long property '" + configProperty.name() + "' value: " + value + " of " + propertyValue
                                + " happening in bean " + injectionPoint.getBean(), nfe);
            }
            
        }
    }
    return list;
}
 
Example #6
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public List<Float> produceFloatListConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    
    ArrayList<Float> list = new ArrayList<>();
    if (values != null) {
        for (String value : values) {
            try {
                list.add(Float.parseFloat(value));
            } catch (NumberFormatException nfe) {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Float property '" + configProperty.name() + "' value: " + value + " of " + propertyValue
                                + " happening in bean " + injectionPoint.getBean(), nfe);
            }
            
        }
    }
    return list;
}
 
Example #7
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public List<Double> produceDoubleListConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    
    ArrayList<Double> list = new ArrayList<>();
    if (values != null) {
        for (String value : values) {
            try {
                list.add(Double.parseDouble(value));
            } catch (NumberFormatException nfe) {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Double property '" + configProperty.name() + "' value: " + value + " of "
                                + propertyValue + " happening in bean " + injectionPoint.getBean(), nfe);
            }
            
        }
    }
    return list;
}
 
Example #8
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Map<String,String> produceStringStringMapConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] pairs = StringUtils.split(propertyValue, "|");
    
    Map<String,String> map = new LinkedHashMap<>();
    if (pairs != null) {
        for (String pair : pairs) {
            String[] keyValue = StringUtils.split(pair, ";");
            if (keyValue != null && (keyValue.length == 1 || keyValue.length == 2)) {
                map.put(keyValue[0], keyValue.length == 1 ? "" : keyValue[1]);
            } else {
                ConfigProperty configProperty = getAnnotation(injectionPoint, ConfigProperty.class);
                throw new RuntimeException("Error while converting Map<String,String> property '" + configProperty.name() + "' pair: " + pair + " of "
                                + propertyValue + " happening in bean " + injectionPoint.getBean());
            }
        }
    }
    return map;
}
 
Example #9
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #10
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public String produceStringConfiguration(InjectionPoint injectionPoint) {
    return super.produceStringConfiguration(injectionPoint);
}
 
Example #11
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * @param propertyName the name of the property key
 * @param defaultValue the default value to return if no configured property is found or
 *                     {@link ConfigProperty#NULL} if no default value should be returned.
 * @return the configured value or the defaultValue according to the NULL logic.
 */
protected String getPropertyValue(String propertyName, String defaultValue)
{
    String configuredValue;
    if (ConfigProperty.NULL.equals(defaultValue))
    {
        // no special defaultValue has been configured
        configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName);
    }
    else
    {
        configuredValue = ConfigResolver.getProjectStageAwarePropertyValue(propertyName, defaultValue);
    }
    return configuredValue;
}
 
Example #12
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public String produceStringConfiguration(InjectionPoint injectionPoint)
{
    return getStringPropertyValue(injectionPoint);
}
 
Example #13
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Class produceClassConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Class.class);
}
 
Example #14
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Boolean produceBooleanConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Boolean.class);
}
 
Example #15
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Integer produceIntegerConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Integer.class);
}
 
Example #16
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Long produceLongConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Long.class);
}
 
Example #17
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Float produceFloatConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Float.class);

}
 
Example #18
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored") // we actually don't need the name
public Double produceDoubleConfiguration(InjectionPoint injectionPoint)
{
    return getPropertyWithException(injectionPoint, Double.class);

}
 
Example #19
Source File: DefaultConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
private <T> T getPropertyWithException(InjectionPoint ip, Type ipCls)
{
    try
    {
        return getUntypedPropertyValue(ip, ipCls);
    }
    catch (RuntimeException rte)
    {
        ConfigProperty configProperty = getAnnotation(ip, ConfigProperty.class);
        throw new RuntimeException("Error while converting property '" + configProperty.name() +
                "' happening in bean " + ip.getBean(), rte);
    }
}
 
Example #20
Source File: ConfigurationExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public void collectDynamicTypes(@Observes ProcessBean<?> processBean)
{
    for (final InjectionPoint ip : processBean.getBean().getInjectionPoints())
    {
        final ConfigProperty annotation = ip.getAnnotated().getAnnotation(ConfigProperty.class);
        if (annotation == null || annotation.converter() == ConfigResolver.Converter.class)
        {
            continue;
        }

        dynamicConfigTypes.add(ip.getType());
    }
}
 
Example #21
Source File: GitUserHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Inject
public GitUserHelper(@ConfigProperty(name = "JENKINS_GOGS_USER") String gitUser,
                     @ConfigProperty(name = "JENKINS_GOGS_PASSWORD") String gitPassword,
                     KubernetesClient kubernetesClient) {
    this.gitUser = gitUser;
    this.gitPassword = gitPassword;
    this.kubernetesClient = kubernetesClient;
}
 
Example #22
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * <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);
}
 
Example #23
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Integer produceIntegerConfiguration(InjectionPoint injectionPoint) {
    return super.produceIntegerConfiguration(injectionPoint);
}
 
Example #24
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Long produceLongConfiguration(InjectionPoint injectionPoint) {
    return super.produceLongConfiguration(injectionPoint);
}
 
Example #25
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Boolean produceBooleanConfiguration(InjectionPoint injectionPoint) {
    return super.produceBooleanConfiguration(injectionPoint);
}
 
Example #26
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
@Alternative
@Specializes
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Float produceFloatConfiguration(InjectionPoint injectionPoint) {
    return super.produceFloatConfiguration(injectionPoint);
}
 
Example #27
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Produces
@Dependent
@ConfigProperty(name = "ignored")
// we actually don't need the name
public Set<String> produceStringSetConfiguration(InjectionPoint injectionPoint) {
    String propertyValue = getStringPropertyValue(injectionPoint);
    String[] values = StringUtils.split(propertyValue, ",");
    return values == null ? Collections.emptySet() : new HashSet<>(Arrays.asList(values));
}
 
Example #28
Source File: DatawaveConfigPropertyProducer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Override
protected String getPropertyValue(String propertyName, String defaultValue) {
    String value = super.getPropertyValue(propertyName, defaultValue);
    while (value != null && value.startsWith("$")) {
        String newPropertyName = value.substring(1);
        value = super.getPropertyValue(newPropertyName, ConfigProperty.NULL);
    }
    return value;
}
 
Example #29
Source File: SharedCacheCoordinator.java    From datawave with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new {@link SharedCacheCoordinator}
 * 
 * @param namespace
 *            the Zookeeper namespace to use for grouping all entries created by this coordinator
 * @param zookeeperConnectionString
 *            the Zookeeper connection to use
 */
@Inject
public SharedCacheCoordinator(@ConfigProperty(name = "dw.cache.coordinator.namespace") String namespace,
                @ConfigProperty(name = "dw.warehouse.zookeepers") String zookeeperConnectionString, @ConfigProperty(
                                name = "dw.cacheCoordinator.evictionReaperIntervalSeconds", defaultValue = "30") int evictionReaperIntervalInSeconds,
                @ConfigProperty(name = "dw.cacheCoordinator.numLocks", defaultValue = "300") int numLocks, @ConfigProperty(
                                name = "dw.cacheCoordinator.maxRetries", defaultValue = "10") int maxRetries) {
    ArgumentChecker.notNull(namespace, zookeeperConnectionString);
    
    locks = new HashMap<>();
    localCounters = new HashMap<>();
    localBooleans = new HashMap<>();
    
    localTriStates = new HashMap<>();
    
    sharedCounters = new HashMap<>();
    sharedCountListeners = new HashMap<>();
    sharedBooleans = new HashMap<>();
    sharedBooleanListeners = new HashMap<>();
    
    sharedTriStates = new HashMap<>();
    sharedTriStateListeners = new HashMap<>();
    
    this.numLocks = numLocks;
    this.evictionReaperIntervalInSeconds = evictionReaperIntervalInSeconds;
    this.maxRetries = maxRetries;
    
    curatorClient = CuratorFrameworkFactory.builder().namespace(namespace).retryPolicy(new BoundedExponentialBackoffRetry(100, 5000, 10))
                    .connectString(zookeeperConnectionString).build();
    
    evictionReaper = new Timer("cache-eviction-reaper-" + namespace, true);
}
 
Example #30
Source File: ProjectFileSystem.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
@Inject
public ProjectFileSystem(RepositoryCache repositoryCache,
                         @ConfigProperty(name = "PROJECT_FOLDER", defaultValue = "/tmp/fabric8-forge") String rootProjectFolder,
                         @ConfigProperty(name = "GIT_REMOTE_BRANCH_NAME", defaultValue = "origin") String remote,
                         @ConfigProperty(name = "JENKINSFILE_LIBRARY_GIT_REPOSITORY") String jenkinsfileLibraryGitUrl,
                         @ConfigProperty(name = "JENKINSFILE_LIBRARY_GIT_TAG") String jenkinsfileLibraryGitTag) {
    this.repositoryCache = repositoryCache;
    this.rootProjectFolder = rootProjectFolder;
    this.remote = remote;
    this.jenkinsfileLibraryGitUrl = jenkinsfileLibraryGitUrl;
    this.jenkinsfileLibraryGitTag = jenkinsfileLibraryGitTag;
    LOG.info("Using jenkins workflow library: " + this.jenkinsfileLibraryGitUrl);
    LOG.info("Using jenkins workflow library version: " + this.jenkinsfileLibraryGitTag);
}