@Beta public interface TenantControl extends DataSerializable
For example, an instance of tenant control can be created on an application
thread and this tenant control can then be used to establish the same context
on a different thread, e.g.
OperationThread
. Operation
invocations requiring such context can then be handled correctly.
This is used by application servers to establish thread context for class loading, CDI, EJB and JPA invocations
Caveats
Modifier and Type | Interface and Description |
---|---|
static interface |
TenantControl.Closeable
Similar to the
Closeable interface, except the TenantControl.Closeable.close()
method does not throw a IOException . |
Modifier and Type | Field and Description |
---|---|
static TenantControl |
NOOP_TENANT_CONTROL
Default no-op tenant control
|
Modifier and Type | Method and Description |
---|---|
void |
clearThreadContext()
Cleans up all of the thread context to avoid potential class loader leaks
This method should clear all potential context items,
not just the ones set up in
setTenant()
This acts as a catch-all for any potential class loader and thread-local leaks. |
boolean |
isAvailable(Tenantable tenantable)
Checks if the tenant app is loaded and classes are available for the given
Tenantable object. |
void |
registerObject(DestroyEventContext destroyEventContext)
Registers a hook to decouple any Hazelcast object when the tenant is destroyed,
This is used, for example, to delete all associated caches from the application
when it gets undeployed, so there are no
ClassCastException afterwards. |
TenantControl.Closeable |
setTenant()
Establish this tenant's thread-local context.
|
void |
unregisterObject()
Invoked when the distributed object belonging to this tenant control has
been destroyed.
|
readData, writeData
static final TenantControl NOOP_TENANT_CONTROL
TenantControl.Closeable setTenant()
void registerObject(@Nonnull DestroyEventContext destroyEventContext)
ClassCastException
afterwards.destroyEventContext
- the hook to be used by the tenant control implementation
Cannot be null
. This is a functional interface, so no-op lambda
can be used instead.void unregisterObject()
registerObject(DestroyEventContext)
. This is so the TenantControl
itself can be garbage collected.boolean isAvailable(@Nonnull Tenantable tenantable)
Tenantable
object.tenantable
- passed so the tenant can filter on which object is callingtrue
if tenant is loaded and classes are availablevoid clearThreadContext()
setTenant()
This acts as a catch-all for any potential class loader and thread-local leaks.Copyright © 2024 Hazelcast, Inc.. All rights reserved.