android-beans / rocks.frieler.android.beans / DeclarativeBeanConfiguration

DeclarativeBeanConfiguration

abstract class DeclarativeBeanConfiguration : BeanConfiguration

Abstract super-class for BeanConfigurations to define their beans in a declarative fashion.

Usage example:

// 1. extend BeanConfiguration:
class MyBeanConfiguration : DeclarativeBeanConfiguration() {

  override fun beans() {
    // 2. define your beans:
    bean("my_bean") {
      // 3. obtain dependency to another bean:
    	 val anotherBean = lookUpBean(AnotherBean::class)
      MyBean(anotherBean!!)
    }
  }
}

Author
Christopher Frieler

Constructors

<init>

DeclarativeBeanConfiguration()

Abstract super-class for BeanConfigurations to define their beans in a declarative fashion.

Functions

bean

fun <T : Any> bean(beanDefinition: BeanDefinition<T>): Unit

Defines a bean through a BeanDefinition.

fun <T : Any> bean(name: String? = null, definition: BeansProvider.() -> T): Unit

Defines a bean, optionally with the specified name.

fun <T : Any> bean(name: String? = null, type: Class<T>, definition: BeansProvider.() -> T): Unit
fun <T : Any> bean(name: String? = null, type: Class<T>, definition: () -> T): Unit

Defines a bean (optionally with the specified name) of a Java type.

beans

abstract fun beans(): Unit

getBeanDefinitions

fun getBeanDefinitions(): List<BeanDefinition<*>>

Returns BeanDefinitions for the beans defined by this BeanConfiguration.

Inherited Functions

addBeanDefinition

fun <T : Any> addBeanDefinition(beanDefinition: BeanDefinition<T>): Unit

Adds a BeanDefinition to this BeanConfiguration.

Extension Functions

activityScopedBean

fun <T : Any> DeclarativeBeanConfiguration.activityScopedBean(name: String? = null, definition: BeansProvider.() -> T): Unit

Adds a BeanDefinition for an ActivityScopedFactoryBean that produces a bean with the given definition, optionally with the specified name.

lazyInstantiatedBean

fun <T : Any> DeclarativeBeanConfiguration.lazyInstantiatedBean(name: String? = null, definition: BeansProvider.() -> T): Unit

Adds a BeanDefinition for a SingletonScopedFactoryBean that produces a bean with the given definition, optionally with the specified name.

prototypeBean

fun <T : Any> DeclarativeBeanConfiguration.prototypeBean(name: String? = null, definition: BeansProvider.() -> T): Unit

Adds a BeanDefinition for a PrototypeScopedFactoryBean that produces a bean with the given definition, optionally with the specified name.