Java Code Examples for org.apache.deltaspike.core.api.config.ConfigResolver#getProjectStageAwarePropertyValue()

The following examples show how to use org.apache.deltaspike.core.api.config.ConfigResolver#getProjectStageAwarePropertyValue() . 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: AbstractQuartzScheduler.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private String evaluateExpression(Scheduled scheduled)
{
    String expression = scheduled.cronExpression();

    if (expression.startsWith("{") && expression.endsWith("}"))
    {
        String configKey = expression.substring(1, expression.length() - 1);
        expression = ConfigResolver.getProjectStageAwarePropertyValue(configKey, null);

        if (expression == null)
        {
            throw new IllegalStateException("No config-value found for config-key: " + configKey);
        }
    }
    return expression;
}
 
Example 2
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 3
Source File: ConfigResolverTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testProjectStageAwarePropertyValueReference_1() {
    final String expectedFooUrl =
            "http://bar-dev/services";

    final String actualFooUrl =
            ConfigResolver.getProjectStageAwarePropertyValue(
            "foo.url");

    Assert.assertEquals(expectedFooUrl, actualFooUrl);
}
 
Example 4
Source File: ConfigResolverTest.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Test
public void testProjectStageAwarePropertyValueReference_2() {
    final String expected =
            "projectStageAware-exampleEntry-1-is-tomato-UnitTest";

    final String projectStageAwareExampleEntry1 =
            ConfigResolver.getProjectStageAwarePropertyValue(
            "deltaspike.test.exampleEntry-2", 
            "");

    Assert.assertEquals(expected, projectStageAwareExampleEntry1);
}
 
Example 5
Source File: CdiTestSuiteRunner.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
public static Properties getTestContainerConfig()
{
    String cdiTestRunnerConfig = ConfigResolver.getProjectStageAwarePropertyValue(
        CUSTOM_TEST_CONTAINER_CONFIG_FILE_KEY, DEFAULT_TEST_CONTAINER_CONFIG_FILE_NAME);
    return PropertyLoader.getProperties(cdiTestRunnerConfig);
}
 
Example 6
Source File: ExcludeExtension.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("UnusedDeclaration")
protected void init(@Observes BeforeBeanDiscovery beforeBeanDiscovery, BeanManager beanManager)
{
    isActivated =
            ClassDeactivationUtils.isActivated(getClass());

    isCustomProjectStageBeanFilterActivated =
            ClassDeactivationUtils.isActivated(CustomProjectStageBeanFilter.class);

    isGlobalAlternativeActivated =
            ClassDeactivationUtils.isActivated(GlobalAlternative.class);
    if (isGlobalAlternativeActivated)
    {
        loadGlobalAlternativeConfigs();

        if (globalAlternatives.isEmpty())
        {
            isGlobalAlternativeActivated = false;
        }

        if (isGlobalAlternativeActivated)
        {
            int priorityValue = CoreBaseConfig.InterceptorCustomization.PRIORITY;
            priorityAnnotationInstance = AnnotationInstanceUtils.getPriorityAnnotationInstance(priorityValue);
        }
    }

    boolean isClassFilterActivated = ClassDeactivationUtils.isActivated(ClassFilter.class);

    if (isClassFilterActivated)
    {
        String classFilterClassName = ClassFilter.class.getName();
        String activeClassFilterName =
            ConfigResolver.getProjectStageAwarePropertyValue(classFilterClassName, classFilterClassName);

        if (!classFilterClassName.equals(activeClassFilterName))
        {
            classFilter = ClassUtils.tryToInstantiateClassForName(activeClassFilterName, ClassFilter.class);
        }
    }
}
 
Example 7
Source File: PropertyExpressionInterpreter.java    From deltaspike with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected String getConfiguredValue(String key)
{
    return ConfigResolver.getProjectStageAwarePropertyValue(key);
}