com.hazelcast.spi.tenantcontrol

## Interface TenantControl

- All Superinterfaces:
    Serializable

      @Beta
      public interface TenantControl
      extends Serializable

  Hooks for multi-tenancy for application servers Hazelcast uses separate threads to invoke operations this interface acts a hook to establish a thread-local tenant context so that operation invocations into application servers are handled correctly This is used by application servers to establish thread context for class loading, CDI, EJB and JPA invocations
  Author:
    lprimak

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static TenantControl` | `NOOP_TENANT_CONTROL` Default no-op tenant control

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Closeable` | `setTenant(boolean createRequestScope)` Establish this tenant's thread-local context Particular TenantControl implementation will control the details of how createRequestScope parameter is handled, but in general, if createRequestScope = false, only ClassLoader is set up, if createRequestScope = true, in addition to ClassLoader, other things like invocation, EJB/JPA/CDI context should be set up as well In other words, if only app class needs to be resolved, set createRequestScope to false If actually calling into user's code, set createRequestScope to true
    `void` | `unregister()` To be called when the Hazelcast object attached to this tenant is destroyed.

- - ### Field Detail

    - #### NOOP_TENANT_CONTROL

          static final TenantControl NOOP_TENANT_CONTROL

      Default no-op tenant control

  - ### Method Detail

    - #### setTenant

          Closeable setTenant(boolean createRequestScope)

      Establish this tenant's thread-local context Particular TenantControl implementation will control the details of how createRequestScope parameter is handled, but in general, if createRequestScope = false, only ClassLoader is set up, if createRequestScope = true, in addition to ClassLoader, other things like invocation, EJB/JPA/CDI context should be set up as well In other words, if only app class needs to be resolved, set createRequestScope to false If actually calling into user's code, set createRequestScope to true
      Parameters:
        `createRequestScope` - whether to create CDI request scope for this context
      Returns:
        handle to be able to close the tenant's scope.

    - #### unregister

          void unregister()

      To be called when the Hazelcast object attached to this tenant is destroyed. The implementor may unregister it's own event listeners here. This is used with conjunction with DestroyEvent, because the listeners are probably used to call the DestroyEvent, this just acts as the other event that will decouple Hazelcast object from the tenant This is so the TenantControl itself can be garbage collected

Copyright © 2020. All rights reserved.