T
- The type of the bean that we are protecting.public abstract class TenantGate<T> extends Object implements org.springframework.beans.factory.FactoryBean<T>
The default behaviour is to escape with a VacantException
, but the gate can also delegate to a vacant
implementation which could behave somehow differently.
This class should be considered a temporary solution on the way to multi-tenancy. It's sole purpose is
currently to delay the initialisation of SessionFactory
beans until a system tenant arrived.
I've seen things you people wouldn't believe. Attack ships on fire off the shoulder of Orion. I watched C-beams glitter in the dark near the TenantGate. All those moments will be lost in time... like tears in rain... Time to die.
SystemTenant
Modifier and Type | Field and Description |
---|---|
protected Class[] |
proxyInterfaces
Deprecated.
since 7.0. Access via
getProxyInterfaces() . |
protected TenantRegistry |
tenantRegistry
Deprecated.
Since 7.0. Access via
getTenantRegistry() . |
Modifier | Constructor and Description |
---|---|
protected |
TenantGate(TenantRegistry tenantRegistry,
Class[] proxyInterfaces) |
Modifier and Type | Method and Description |
---|---|
static <T> Callable<T> |
close(Callable<T> callback)
Close all gates for the given closure on the current thread.
|
protected abstract T |
createTenantedDelegate()
Returns the delegate to be used when the tenant is present.
|
protected T |
createVacantDelegate()
Returns the delegate to be used when the tenant is vacant.
|
T |
getObject() |
Class |
getObjectType() |
protected Class[] |
getProxyInterfaces() |
protected TenantRegistry |
getTenantRegistry() |
boolean |
isPermitted() |
boolean |
isSingleton() |
static <T> Callable<T> |
open(Callable<T> callback)
Open all gates for the given closure on the current thread.
|
static <T> Callable<T> |
permit(boolean permitted,
Callable<T> callback) |
@Deprecated protected final TenantRegistry tenantRegistry
getTenantRegistry()
.@Deprecated protected final Class[] proxyInterfaces
getProxyInterfaces()
.protected TenantGate(TenantRegistry tenantRegistry, Class[] proxyInterfaces)
protected TenantRegistry getTenantRegistry()
protected Class[] getProxyInterfaces()
public boolean isPermitted()
public static <T> Callable<T> open(Callable<T> callback)
This only makes sense in a pre-tenanted state, e.g. during setup allow code to prepare the database before it's made available to a broader audience.
callback
- the function allowed to pass through the gatepublic static <T> Callable<T> close(Callable<T> callback)
This only makes sense in a pre-tenanted state, if you want to ensure that the given code can not access
tenanted resources even though an outer closure might have granted that access, e.g. loading DefaultPluginManager.earlyStartup()
plugins which should not be able to eagerly
access tenanted resources.
callback
- the function allowed to pass through the gateprotected T createVacantDelegate()
protected abstract T createTenantedDelegate()
public final T getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<T>
public final Class getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<T>
public final boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<T>
Copyright © 2003–2020 Atlassian. All rights reserved.