com.holonplatform.spring

## Annotation Type EnableTenantScope

-     @Target(value=TYPE)
       @Retention(value=RUNTIME)
       @Documented
       @Import(value=com.holonplatform.spring.internal.tenant.TenantScopeRegistrar.class)
      public @interface EnableTenantScope

  Setup and register a tenant scope with the name `TenantScope.SCOPE_NAME`.

  A `TenantResolver` bean must be available in context to use the tenant scope. The `TenantResolver` bean definition name can be configured using the `tenantResolver()` attribute or the `TENANT_RESOLVER_PROPERTY_NAME` configuration property when more than one `TenantResolver` type bean is available in context.

  The convenience `ScopeTenant` annotation can be used to declare tenant scoped beans.

  If the `enableTenantScopeManager()` attribute is `true`, a `TenantScopeManager` bean is registered and made available in Spring context to manage the tenant scoped beans lifecycle.

  See Also:
    `ScopeTenant`

- - ### Field Summary

    Fields
    Modifier and Type | Fields and Description
    --- | ---
    `static String` | `TENANT_RESOLVER_PROPERTY_NAME` Property which can be used to configure the `TenantResolver` type bean definition name to be used to obtain the current tenant id.

  - ### Optional Element Summary

    Optional Elements
    Modifier and Type | Optional Element and Description
    --- | ---
    `boolean` | `enableTenantScopeManager` Whether to enable and register a `TenantScopeManager` type bean definition, which can be obtained as any other Spring bean, for example through dependency injection.
    `String` | `tenantResolver` Configures the name of the `TenantResolver` type bean definition to be used to obtain the current tenant id.

- - ### Field Detail

    - #### TENANT_RESOLVER_PROPERTY_NAME

          public static final String TENANT_RESOLVER_PROPERTY_NAME

      Property which can be used to configure the `TenantResolver` type bean definition name to be used to obtain the current tenant id. It has the same meaning of the `tenantResolver()` attribute, but higher precedence.

  - ### Element Detail

    - #### tenantResolver

          public abstract String tenantResolver

      Configures the name of the `TenantResolver` type bean definition to be used to obtain the current tenant id.

      If not provided, the scope registrar will lookup for an unique `TenantResolver` type bean definition in the Spring application context. If not found, or more than one `TenantResolver` type bean definition is found, a scope configuration error is thrown.

      Returns:
        The optional name of the `TenantResolver` type bean definition
      Default:
        ""

  - - #### enableTenantScopeManager

          public abstract boolean enableTenantScopeManager

      Whether to enable and register a `TenantScopeManager` type bean definition, which can be obtained as any other Spring bean, for example through dependency injection.

      The `TenantScopeManager` API allows to manage the tenant scoped beans lifecycle, for example discarding scoped bean instances for a specific tenant id, invoking any destruction callback accordingly.

      The attribute value is `true` by default.

      Returns:
        Whether to enable and register a `TenantScopeManager` bean
      See Also:
        `TenantScopeManager`
      Default:
        true

Copyright © 2019 The Holon Platform. All rights reserved.