Package tigase.kernel.beans.config

## Class AbstractBeanConfigurator

- java.lang.Object
- - tigase.kernel.beans.config.AbstractBeanConfigurator

- All Implemented Interfaces:
    `BeanConfigurator`
  Direct Known Subclasses:
    `DSLBeanConfigurator`

      public abstract class AbstractBeanConfigurator
      extends java.lang.Object
      implements BeanConfigurator

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `AbstractBeanConfigurator.BeanDefinition` |

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected TypesConverter` | `defaultTypesConverter` |
    `protected Kernel` | `kernel` |

    - ### Fields inherited from interface tigase.kernel.beans.config.BeanConfigurator

      `DEFAULT_CONFIGURATOR_NAME`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractBeanConfigurator()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `configurationChanged()` | Method applies configuration changes to bean.
    `void` | `configure​(BeanConfig beanConfig, java.lang.Object bean)` | Configure bean.
    `void` | `configure​(BeanConfig beanConfig, java.lang.Object bean, java.util.Map<java.lang.String,​java.lang.Object> values)` | Method configures passed bean with provided values.
    `static java.util.Map<java.lang.String,​java.lang.Class<?>>` | `getBeanClassesFromAnnotations​(Kernel kernel, java.lang.Class<?> requiredClass)` | Method looks for bean classes (classes annotated with `@Bean` which has `parent` property set to passed class.
    `protected java.util.ArrayDeque<java.lang.String>` | `getBeanConfigPath​(BeanConfig beanConfig)` | Method returns queue of kernel and bean names to find bean config (path to the bean config from root of the config).
    `protected java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition>` | `getBeanDefinitions​(java.util.Map<java.lang.String,​java.lang.Object> values)` | Method returns map of bean definitions found in the configuration
    `protected abstract java.util.Map<java.lang.String,​java.lang.Object>` | `getConfiguration​(BeanConfig beanConfig)` | Method returns configuration of a bean.
    `TypesConverter` | `getDefaultTypesConverter()` | Method returns default types converter used by bean configurator.
    `Kernel` | `getKernel()` |
    `abstract java.util.Map<java.lang.String,​java.lang.Object>` | `getProperties()` | Method returns current configuration map.
    `protected java.util.Map<java.lang.reflect.Field,​java.lang.Object>` | `grabCurrentConfig​(java.lang.Object bean, java.lang.String beanName)` |
    `protected java.util.Map<java.lang.reflect.Field,​java.lang.Object>` | `grabDefaultConfig​(BeanConfig beanConfig, java.lang.Object bean)` |
    `protected abstract boolean` | `hasDirectConfiguration​(BeanConfig bc)` |
    `boolean` | `isAccessToAllFields()` |
    `protected static boolean` | `isBeanClassRegisteredInParentKernel​(Kernel kernel, java.lang.String name, java.lang.Class<?> clazz)` | Method checkes if bean is already registered in parent kernel.
    `protected static java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition>` | `mergeWithBeansPropertyValue​(java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition> beanPropConfigMap, java.util.Map<java.lang.String,​java.lang.Object> values)` |
    `protected void` | `refreshConfiguration​(Kernel kernel)` |
    `protected void` | `refreshConfiguration_removeUndefinedBeans​(Kernel kernel)` |
    `protected void` | `refreshConfiguration_updateConfiguration​(Kernel kernel)` |
    `void` | `registerBeans​(BeanConfig beanConfig, java.lang.Object bean, java.util.Map<java.lang.String,​java.lang.Object> values)` | Method registers all beans which are annotated by `@Bean` and which `parent` property is set to class which instance is passed.
    `static void` | `registerBeansForBeanOfClass​(Kernel kernel, java.lang.Class<?> cls)` | Method registers beans which classes are annotated with `@Bean` and have `parent` set to the class passed as parameter.
    `protected static void` | `registerBeansForBeanOfClass​(Kernel kernel, java.lang.Class<?> requiredClass, java.util.Set<java.lang.Class<?>> classes)` |
    `protected static java.util.List<java.lang.Class<?>>` | `registerBeansForBeanOfClassGetBeansToRegister​(Kernel kernel, java.lang.Class<?> requiredClass, java.util.Set<java.lang.Class<?>> classes)` |
    `protected static Bean` | `registerBeansForBeanOfClassShouldRegister​(Kernel kernel, java.lang.Class<?> requiredClass, java.lang.Class<?> cls)` |
    `void` | `restoreDefaults​(java.lang.String beanName)` | Method restors default configuration of a bean
    `void` | `setAccessToAllFields​(boolean accessToAllFields)` |
    `void` | `setDefaultTypesConverter​(TypesConverter defaultTypesConverter)` |
    `void` | `setKernel​(Kernel kernel)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### defaultTypesConverter

          @Inject(bean="defaultTypesConverter")
          protected TypesConverter defaultTypesConverter

    - #### kernel

          @Inject(bean="kernel",
                  nullAllowed=false)
          protected Kernel kernel

  - ### Constructor Detail

    - #### AbstractBeanConfigurator

          public AbstractBeanConfigurator()

  - ### Method Detail

    - #### getBeanClassesFromAnnotations

          public static java.util.Map<java.lang.String,​java.lang.Class<?>> getBeanClassesFromAnnotations​(Kernel kernel,
                                                                                                               java.lang.Class<?> requiredClass)

      Method looks for bean classes (classes annotated with `@Bean` which has `parent` property set to passed class.
      Parameters:
        `kernel` - instance of the Kernel
        `requiredClass` - class to look for as `parent` property value of `@Bean` annotation
      Returns:
        map of bean classes in for of "bean name" - "class"

    - #### isBeanClassRegisteredInParentKernel

          protected static boolean isBeanClassRegisteredInParentKernel​(Kernel kernel,
                                                                       java.lang.String name,
                                                                       java.lang.Class<?> clazz)

      Method checkes if bean is already registered in parent kernel.
      Parameters:
        `kernel` - kernel instance to check
        `name` - name of the bean
        `clazz` - expected class of the bean

    - #### mergeWithBeansPropertyValue

          protected static java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition> mergeWithBeansPropertyValue​(java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition> beanPropConfigMap,
                                                                                                                                     java.util.Map<java.lang.String,​java.lang.Object> values)

    - #### registerBeansForBeanOfClass

          public static void registerBeansForBeanOfClass​(Kernel kernel,
                                                         java.lang.Class<?> cls)

      Method registers beans which classes are annotated with `@Bean` and have `parent` set to the class passed as parameter.

    - #### registerBeansForBeanOfClass

          protected static void registerBeansForBeanOfClass​(Kernel kernel,
                                                            java.lang.Class<?> requiredClass,
                                                            java.util.Set<java.lang.Class<?>> classes)

    - #### registerBeansForBeanOfClassGetBeansToRegister

          protected static java.util.List<java.lang.Class<?>> registerBeansForBeanOfClassGetBeansToRegister​(Kernel kernel,
                                                                                                            java.lang.Class<?> requiredClass,
                                                                                                            java.util.Set<java.lang.Class<?>> classes)

    - #### registerBeansForBeanOfClassShouldRegister

          protected static Bean registerBeansForBeanOfClassShouldRegister​(Kernel kernel,
                                                                          java.lang.Class<?> requiredClass,
                                                                          java.lang.Class<?> cls)

    - #### getProperties

          public abstract java.util.Map<java.lang.String,​java.lang.Object> getProperties()

      Method returns current configuration map.

    - #### configure

          public void configure​(BeanConfig beanConfig,
                                java.lang.Object bean,
                                java.util.Map<java.lang.String,​java.lang.Object> values)

      Method configures passed bean with provided values.

    - #### configure

          public void configure​(BeanConfig beanConfig,
                                java.lang.Object bean)
                         throws KernelException

      Description copied from interface: `BeanConfigurator`
      Configure bean.
      Specified by:
        `configure` in interface `BeanConfigurator`
      Parameters:
        `beanConfig` - internal bean configuration.
        `bean` - bean to configure.
      Throws:
        `KernelException`

    - #### getDefaultTypesConverter

          public TypesConverter getDefaultTypesConverter()

      Method returns default types converter used by bean configurator.

    - #### setDefaultTypesConverter

          public void setDefaultTypesConverter​(TypesConverter defaultTypesConverter)

    - #### getKernel

          public Kernel getKernel()

    - #### setKernel

          public void setKernel​(Kernel kernel)

    - #### isAccessToAllFields

          public boolean isAccessToAllFields()

    - #### setAccessToAllFields

          public void setAccessToAllFields​(boolean accessToAllFields)

    - #### registerBeans

          public void registerBeans​(BeanConfig beanConfig,
                                    java.lang.Object bean,
                                    java.util.Map<java.lang.String,​java.lang.Object> values)

      Method registers all beans which are annotated by `@Bean` and which `parent` property is set to class which instance is passed. Additionally this method registers beans which definitions are passed in the configuration.
      Specified by:
        `registerBeans` in interface `BeanConfigurator`
      Parameters:
        `beanConfig` - bean config of initializing bean
        `bean` - instance of initializing bean
        `values` - configuration of a bean

    - #### configurationChanged

          public void configurationChanged()

      Method applies configuration changes to bean. Should be called after configuration is updated.
      Specified by:
        `configurationChanged` in interface `BeanConfigurator`

    - #### restoreDefaults

          public void restoreDefaults​(java.lang.String beanName)

      Method restors default configuration of a bean

    - #### getConfiguration

          protected abstract java.util.Map<java.lang.String,​java.lang.Object> getConfiguration​(BeanConfig beanConfig)

      Method returns configuration of a bean.

    - #### grabDefaultConfig

          protected java.util.Map<java.lang.reflect.Field,​java.lang.Object> grabDefaultConfig​(BeanConfig beanConfig,
                                                                                                    java.lang.Object bean)

    - #### grabCurrentConfig

          protected java.util.Map<java.lang.reflect.Field,​java.lang.Object> grabCurrentConfig​(java.lang.Object bean,
                                                                                                    java.lang.String beanName)

    - #### getBeanDefinitions

          protected java.util.Map<java.lang.String,​AbstractBeanConfigurator.BeanDefinition> getBeanDefinitions​(java.util.Map<java.lang.String,​java.lang.Object> values)

      Method returns map of bean definitions found in the configuration
      Parameters:
        `values` - configuration map

    - #### getBeanConfigPath

          protected java.util.ArrayDeque<java.lang.String> getBeanConfigPath​(BeanConfig beanConfig)

      Method returns queue of kernel and bean names to find bean config (path to the bean config from root of the config).

    - #### hasDirectConfiguration

          protected abstract boolean hasDirectConfiguration​(BeanConfig bc)

    - #### refreshConfiguration

          protected void refreshConfiguration​(Kernel kernel)

    - #### refreshConfiguration_removeUndefinedBeans

          protected void refreshConfiguration_removeUndefinedBeans​(Kernel kernel)

    - #### refreshConfiguration_updateConfiguration

          protected void refreshConfiguration_updateConfiguration​(Kernel kernel)