Search in sources :

Example 16 with BeanSpec

use of org.osgl.inject.BeanSpec in project actframework by actframework.

the class CliContextParamLoader method findFieldOptionLoaders.

private void findFieldOptionLoaders(Class c, List<OptionLoader> optionLoaders) {
    if (injector.isProvided(c)) {
        // No field injection for a provided host
        return;
    }
    for (Field field : $.fieldsOf(c, true)) {
        Type type = field.getGenericType();
        Annotation[] annotations = field.getAnnotations();
        String bindName = bindName(annotations, field.getName());
        BeanSpec spec = BeanSpec.of(type, annotations, bindName, injector);
        boolean provided = injector.isProvided(spec);
        ParamValueLoader loader = provided ? ProvidedValueLoader.get(spec, injector) : findContextSpecificLoader(bindName, spec);
        if (loader instanceof OptionLoader) {
            optionLoaders.add((OptionLoader) loader);
        }
    }
}
Also used : BeanSpec(org.osgl.inject.BeanSpec) Annotation(java.lang.annotation.Annotation)

Aggregations

BeanSpec (org.osgl.inject.BeanSpec)16 Annotation (java.lang.annotation.Annotation)4 Test (org.junit.Test)4 Genie (org.osgl.inject.Genie)4 DependencyInjector (act.inject.DependencyInjector)2 UnexpectedException (org.osgl.exception.UnexpectedException)2 App (act.app.App)1 DefaultValue (act.inject.DefaultValue)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Inject (javax.inject.Inject)1 Ignore (org.junit.Ignore)1 org.osgl.$ (org.osgl.$)1 ConfigurationValueLoader (org.osgl.inject.loader.ConfigurationValueLoader)1 ISObject (org.osgl.storage.ISObject)1