com.holonplatform.spring

## Annotation Type EnableBeanContext

-     @Target(value=TYPE)
       @Retention(value=RUNTIME)
       @Documented
       @Import(value=com.holonplatform.spring.internal.context.BeanFactoryScopeRegistrar.class)
      public @interface EnableBeanContext

  Setup a `Context` scope using Spring application context (or in exact terms, using the application context `BeanFactory`) to provide context resource instances as Spring beans.

  When a context resource is requested (using `Context.resource(String, Class)`), the scope strategy to provide a matching Spring bean is defined as follow:

  - If a Spring bean with a name equal to the context resource key and with the same required type is found, this is returned;
  - Otherwise, if `lookupByType()` is `true` and a Spring bean of the required type, ignoring the name, is present and only one candidate is available, this instance is returned.

  The Spring BeanFactory behaviour is preserved during beans lookup, so, for example, Spring beans scopes strategy is applied, just like bean retrieval using `BeanFactory.getBean(String, Class)` and similar methods.

  Since:
    5.0.0

- - ### Field Summary

    Fields
    Modifier and Type | Fields and Description
    --- | ---
    `static String` | `LOOKUP_BY_TYPE_PROPERTY_NAME` Property which can be used to configure the `lookupByType()` behaviour using a Spring `Environment` configuration property.

  - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `boolean` | `lookupByType` Whether to lookup context resource bean candidates by type, ignoring bean name, when default lookup by name and type fails.

- - ### Field Detail

    - #### LOOKUP_BY_TYPE_PROPERTY_NAME

          public static final String LOOKUP_BY_TYPE_PROPERTY_NAME

      Property which can be used to configure the `lookupByType()` behaviour using a Spring `Environment` configuration property. If setted, overrides the `lookupByType()` annotation attribute value.

  - ### Element Detail

    - #### lookupByType

          public abstract boolean lookupByType

      Whether to lookup context resource bean candidates by type, ignoring bean name, when default lookup by name and type fails. Only consistent type beans with a single instance retuned by BeanFactory are taken into account.
      Returns:
        `true` to lookup context resource bean candidates by type ignoring bean name and context resource key match
      Default:
        true

Copyright © 2017 The Holon Platform. All rights reserved.