public abstract class TenantGate extends Object implements org.springframework.beans.factory.FactoryBean
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 |
protected TenantRegistry |
tenantRegistry |
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 Object |
createTenantedDelegate() |
protected Object |
createVacantDelegate() |
Object |
getObject() |
Class |
getObjectType() |
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) |
protected final TenantRegistry tenantRegistry
protected final Class[] proxyInterfaces
protected TenantGate(TenantRegistry tenantRegistry, Class[] proxyInterfaces)
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 Object createVacantDelegate()
protected abstract Object createTenantedDelegate()
public final Object getObject() throws Exception
getObject
in interface org.springframework.beans.factory.FactoryBean
Exception
public final Class getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean
public final boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean
Copyright © 2003–2016 Atlassian. All rights reserved.