Search in sources :

Example 1 with ValueFactory

use of org.jboss.as.service.descriptor.JBossServiceAttributeConfig.ValueFactory in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addAttributes.

private void addAttributes(final JBossServiceAttributeConfig[] attributeConfigs, final List<ClassReflectionIndex> mBeanClassHierarchy, final MBeanServices mBeanServices, final ClassLoader classLoader) throws DeploymentUnitProcessingException {
    if (attributeConfigs != null) {
        final Service<Object> createDestroyService = mBeanServices.getCreateDestroyService();
        for (final JBossServiceAttributeConfig attributeConfig : attributeConfigs) {
            final String propertyName = attributeConfig.getName();
            final Inject injectConfig = attributeConfig.getInject();
            final ValueFactory valueFactoryConfig = attributeConfig.getValueFactory();
            if (injectConfig != null) {
                final Value<?> value = getValue(injectConfig);
                final Injector<Object> injector = getPropertyInjector(propertyName, mBeanClassHierarchy, createDestroyService, value);
                mBeanServices.addAttribute(injectConfig.getBeanName(), injector);
            } else if (valueFactoryConfig != null) {
                final Value<?> value = getValue(valueFactoryConfig, classLoader);
                final Injector<Object> injector = getPropertyInjector(propertyName, mBeanClassHierarchy, createDestroyService, value);
                mBeanServices.addAttribute(valueFactoryConfig.getBeanName(), injector);
            } else {
                final Value<?> value = getValue(attributeConfig, mBeanClassHierarchy);
                final Injector<Object> injector = getPropertyInjector(propertyName, mBeanClassHierarchy, createDestroyService, Values.injectedValue());
                mBeanServices.addInjectionValue(injector, value);
            }
        }
    }
}
Also used : Inject(org.jboss.as.service.descriptor.JBossServiceAttributeConfig.Inject) MethodInjector(org.jboss.msc.inject.MethodInjector) Injector(org.jboss.msc.inject.Injector) JBossServiceAttributeConfig(org.jboss.as.service.descriptor.JBossServiceAttributeConfig) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MethodValue(org.jboss.msc.value.MethodValue) ValueFactory(org.jboss.as.service.descriptor.JBossServiceAttributeConfig.ValueFactory)

Aggregations

JBossServiceAttributeConfig (org.jboss.as.service.descriptor.JBossServiceAttributeConfig)1 Inject (org.jboss.as.service.descriptor.JBossServiceAttributeConfig.Inject)1 ValueFactory (org.jboss.as.service.descriptor.JBossServiceAttributeConfig.ValueFactory)1 Injector (org.jboss.msc.inject.Injector)1 MethodInjector (org.jboss.msc.inject.MethodInjector)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1 MethodValue (org.jboss.msc.value.MethodValue)1 Value (org.jboss.msc.value.Value)1