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, mBeanClassHierarchy);
          final Injector<Object> injector =
              getPropertyInjector(propertyName, mBeanClassHierarchy, createDestroyService, value);
          mBeanServices.addAttribute(injectConfig.getBeanName(), injector);
        } else if (valueFactoryConfig != null) {
          final Value<?> value = getValue(valueFactoryConfig, mBeanClassHierarchy, 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);
        }
      }
    }
  }
  private static Value<?> getValue(
      final JBossServiceAttributeConfig attributeConfig,
      final List<ClassReflectionIndex> mBeanClassHierarchy) {
    final String attributeName = attributeConfig.getName();
    final Method setterMethod = ReflectionUtils.getSetter(mBeanClassHierarchy, attributeName);
    final Class<?> setterType = setterMethod.getParameterTypes()[0];

    return new ImmediateValue<Object>(newValue(setterType, attributeConfig.getValue()));
  }