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 Object
      implements BeanConfigurator

- - ### Nested Class Summary

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

  - ### Field Summary

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

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

      `DEFAULT_CONFIGURATOR_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractBeanConfigurator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `configurationChanged()` Method applies configuration changes to bean.
    `void` | `configure(BeanConfig beanConfig, Object bean)` Configure bean.
    `void` | `configure(BeanConfig beanConfig, Object bean, Map<String,Object> values)` Method configures passed bean with provided values.
    `static Map<String,Class<?>>` | `getBeanClassesFromAnnotations(Kernel kernel, Class<?> requiredClass)` Method looks for bean classes (classes annotated with `@Bean` which has `parent` property set to passed class.
    `protected ArrayDeque<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 Map<String,AbstractBeanConfigurator.BeanDefinition>` | `getBeanDefinitions(Map<String,Object> values)` Method returns map of bean definitions found in the configuration
    `protected abstract Map<String,Object>` | `getConfiguration(BeanConfig beanConfig)` Method returns configuration of a bean.
    `TypesConverter` | `getDefaultTypesConverter()` Method returns default types converter used by bean configurator.
    `Kernel` | `getKernel()`
    `abstract Map<String,Object>` | `getProperties()` Method returns current configuration map.
    `protected Map<Field,Object>` | `grabCurrentConfig(Object bean, String beanName)`
    `protected Map<Field,Object>` | `grabDefaultConfig(BeanConfig beanConfig, Object bean)`
    `protected abstract boolean` | `hasDirectConfiguration(BeanConfig bc)`
    `boolean` | `isAccessToAllFields()`
    `protected static boolean` | `isBeanClassRegisteredInParentKernel(Kernel kernel, String name, Class<?> clazz)` Method checkes if bean is already registered in parent kernel.
    `protected static Map<String,AbstractBeanConfigurator.BeanDefinition>` | `mergeWithBeansPropertyValue(Map<String,AbstractBeanConfigurator.BeanDefinition> beanPropConfigMap, Map<String,Object> values)`
    `protected void` | `refreshConfiguration_removeUndefinedBeans(Kernel kernel)`
    `protected void` | `refreshConfiguration_updateConfiguration(Kernel kernel)`
    `protected void` | `refreshConfiguration(Kernel kernel)`
    `void` | `registerBeans(BeanConfig beanConfig, Object bean, Map<String,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, 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, Class<?> requiredClass, Set<Class<?>> classes)`
    `protected static List<Class<?>>` | `registerBeansForBeanOfClassGetBeansToRegister(Kernel kernel, Class<?> requiredClass, Set<Class<?>> classes)`
    `protected static Bean` | `registerBeansForBeanOfClassShouldRegister(Kernel kernel, Class<?> requiredClass, Class<?> cls)`
    `void` | `restoreDefaults(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 Map<String,Class<?>> getBeanClassesFromAnnotations(Kernel kernel,
                                                                           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,
                                                                       String name,
                                                                       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 Map<String,AbstractBeanConfigurator.BeanDefinition> mergeWithBeansPropertyValue(Map<String,AbstractBeanConfigurator.BeanDefinition> beanPropConfigMap,
                                                                                                           Map<String,Object> values)

    - #### registerBeansForBeanOfClass

          public static void registerBeansForBeanOfClass(Kernel kernel,
                                                         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,
                                                            Class<?> requiredClass,
                                                            Set<Class<?>> classes)

    - #### registerBeansForBeanOfClassGetBeansToRegister

          protected static List<Class<?>> registerBeansForBeanOfClassGetBeansToRegister(Kernel kernel,
                                                                                        Class<?> requiredClass,
                                                                                        Set<Class<?>> classes)

    - #### registerBeansForBeanOfClassShouldRegister

          protected static Bean registerBeansForBeanOfClassShouldRegister(Kernel kernel,
                                                                          Class<?> requiredClass,
                                                                          Class<?> cls)

    - #### getProperties

          public abstract Map<String,Object> getProperties()

      Method returns current configuration map.

    - #### configure

          public void configure(BeanConfig beanConfig,
                                Object bean,
                                Map<String,Object> values)

      Method configures passed bean with provided values.

    - #### configure

          public void configure(BeanConfig beanConfig,
                                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,
                                    Object bean,
                                    Map<String,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(String beanName)

      Method restors default configuration of a bean

    - #### getConfiguration

          protected abstract Map<String,Object> getConfiguration(BeanConfig beanConfig)

      Method returns configuration of a bean.

    - #### grabDefaultConfig

          protected Map<Field,Object> grabDefaultConfig(BeanConfig beanConfig,
                                                        Object bean)

    - #### grabCurrentConfig

          protected Map<Field,Object> grabCurrentConfig(Object bean,
                                                        String beanName)

    - #### getBeanDefinitions

          protected Map<String,AbstractBeanConfigurator.BeanDefinition> getBeanDefinitions(Map<String,Object> values)

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

    - #### getBeanConfigPath

          protected ArrayDeque<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)

Copyright © 2004–2020 "Tigase, Inc.". All rights reserved.