Class TenantGate<T>

  • Type Parameters:
    T - The type of the bean that we are protecting.
    All Implemented Interfaces:
    org.springframework.beans.factory.FactoryBean<T>

    @Deprecated(forRemoval=true)
    public abstract class TenantGate<T>
    extends Object
    implements org.springframework.beans.factory.FactoryBean<T>
    Deprecated, for removal: This API element is subject to removal in a future version.
    since 7.5
    Prevents access to tenanted beans in case of a vacant (zero tenancy) instance.

    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 net.sf.hibernate.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.
    Since:
    5.6
    See Also:
    SystemTenant
    • Constructor Detail

      • TenantGate

        protected TenantGate​(TenantRegistry tenantRegistry,
                             Class[] proxyInterfaces)
        Deprecated, for removal: This API element is subject to removal in a future version.
    • Method Detail

      • getTenantRegistry

        protected TenantRegistry getTenantRegistry()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since:
        7.0
      • getProxyInterfaces

        protected Class[] getProxyInterfaces()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Since:
        7.0
      • isPermitted

        public boolean isPermitted()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Returns:
        checks if the current thread is allowed to pass through the gate
      • open

        @Deprecated
        public static <T> Callable<T> open​(Callable<T> callback)
        Open all gates for the given closure on the current thread.

        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.

        Parameters:
        callback - the function allowed to pass through the gate
        Returns:
        the permitted function
      • close

        @Deprecated
        public static <T> Callable<T> close​(Callable<T> callback)
        Close all gates for the given closure on the current thread.

        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.

        Parameters:
        callback - the function allowed to pass through the gate
        Returns:
        the permitted function
      • createVacantDelegate

        protected T createVacantDelegate()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Returns the delegate to be used when the tenant is vacant. May be overriden by Spring using method-injection, but can be left as the default.
      • createTenantedDelegate

        protected abstract T createTenantedDelegate()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Returns the delegate to be used when the tenant is present. Generally overriden by Spring using method-injection.
      • getObject

        public final T getObject()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Specified by:
        getObject in interface org.springframework.beans.factory.FactoryBean<T>
      • getObjectType

        public final Class getObjectType()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Specified by:
        getObjectType in interface org.springframework.beans.factory.FactoryBean<T>
      • isSingleton

        public final boolean isSingleton()
        Deprecated, for removal: This API element is subject to removal in a future version.
        Specified by:
        isSingleton in interface org.springframework.beans.factory.FactoryBean<T>