tigase.kernel.core

## Class BeanConfigBuilder

- java.lang.Object
- - tigase.kernel.core.BeanConfigBuilder

-     public class BeanConfigBuilder
      extends Object

  Builder to help register beans in Kernel.

  Usage:

        // If Bean1.class is annotated by @Bean annotation.
        registerBean(Bean1.class).exec();

        // If Bean2 isn't annotated or should be registered with different name.
        krnl.registerBean("bean2").asClass(Bean2.class).exec();

        // To register already created variable bean4 as bean "bean4".
        krnl.registerBean("bean4").asInstance(bean4).exec();

        // If Bean5 have to been created by Bean5Factory.
        krnl.registerBean("bean5").asClass(Bean5.class).withFactory(Bean5Factory.class).exec();

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Logger` | `log`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BeanConfigBuilder` | `asClass(Class<?> cls)` Registers bean as type to be created when it will be required.
    `BeanConfigBuilder` | `asInstance(Object bean)` Registers class instance as bean.
    `void` | `exec()` Finishing registration of bean.
    `BeanConfig` | `execWithoutInject()`
    `BeanConfigBuilder` | `exportable()` Mark bean as 'exportable'.
    `String` | `getBeanName()` Returns name of bean.
    `BeanConfigBuilder` | `registeredBy(BeanConfig parent)`
    `BeanConfigBuilder` | `setActive(boolean active)`
    `BeanConfigBuilder` | `setPinned(boolean pinned)`
    `BeanConfigBuilder` | `setSource(BeanConfig.Source source)`
    `protected void` | `throwException(KernelException e)`
    `BeanConfigBuilder` | `withFactory(Class<? extends BeanFactory> beanFactoryClass)` Defines factory for currently registered bean.

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

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

- - ### Field Detail

    - #### log

          protected final Logger log

  - ### Method Detail

    - #### asClass

          public BeanConfigBuilder asClass(Class<?> cls)

      Registers bean as type to be created when it will be required.
      Parameters:
        `cls` - class of bean.
      Returns:
        `BeanConfigBuilder`.

    - #### asInstance

          public BeanConfigBuilder asInstance(Object bean)

      Registers class instance as bean.
      Parameters:
        `bean` - instance of bean.
      Returns:
        `BeanConfigBuilder`.

    - #### exec

          public void exec()

      Finishing registration of bean.

    - #### execWithoutInject

          public BeanConfig execWithoutInject()

    - #### exportable

          public BeanConfigBuilder exportable()

      Mark bean as 'exportable'. It means that bean will be visible for all child Kernels registered in current Kernel.
      Returns:
        `BeanConfigBuilder`.

    - #### getBeanName

          public String getBeanName()

      Returns name of bean.
      Returns:
        name of bean.

    - #### setActive

          public BeanConfigBuilder setActive(boolean active)

    - #### setPinned

          public BeanConfigBuilder setPinned(boolean pinned)

    - #### setSource

          public BeanConfigBuilder setSource(BeanConfig.Source source)

    - #### registeredBy

          public BeanConfigBuilder registeredBy(BeanConfig parent)

    - #### withFactory

          public BeanConfigBuilder withFactory(Class<? extends BeanFactory> beanFactoryClass)

      Defines factory for currently registered bean.
      Parameters:
        `beanFactoryClass` - bean factory class.
      Returns:
        `BeanConfigBuilder`.

    - #### throwException

          protected void throwException(KernelException e)

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