Search in sources :

Example 1 with ConfigurationValue

use of org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue in project wildfly-swarm by wildfly-swarm.

the class ConfigurationValueProducer method produceOptionalConfigValue.

@SuppressWarnings("unchecked")
@ConfigurationValue("")
@Dependent
@Produces
<T> Optional<T> produceOptionalConfigValue(InjectionPoint injectionPoint) {
    Type type = injectionPoint.getAnnotated().getBaseType();
    final Class<T> valueType;
    if (type instanceof ParameterizedType) {
        ParameterizedType parameterizedType = (ParameterizedType) type;
        Type[] typeArguments = parameterizedType.getActualTypeArguments();
        valueType = unwrapType(typeArguments[0]);
    } else {
        valueType = (Class<T>) String.class;
    }
    return Optional.ofNullable(resolve(injectionPoint, valueType));
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ConfigurationValue(org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue) Produces(javax.enterprise.inject.Produces) Dependent(javax.enterprise.context.Dependent)

Aggregations

ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 Dependent (javax.enterprise.context.Dependent)1 Produces (javax.enterprise.inject.Produces)1 ConfigurationValue (org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue)1