Class AbstractTenant

    • Constructor Detail

      • AbstractTenant

        protected AbstractTenant​(java.lang.String tenantID)
    • Method Detail

      • getTenantSpecificExtensionNames

        public abstract java.util.List<java.lang.String> getTenantSpecificExtensionNames()
        Specified by:
        getTenantSpecificExtensionNames in interface Tenant
      • shutDown

        public abstract void shutDown()
      • getCurrentTenant

        public static Tenant getCurrentTenant()
      • setSystemInit

        public void setSystemInit​(java.lang.Boolean state)
      • getTenantRestartMarker

        public long getTenantRestartMarker()
        Returns:
        a time stamp marker when current tenant was created/restarted for the last time. If no restart occurred points to creation time.
      • doInitialize

        protected void doInitialize()
      • relaseAdministrationLockIfNeeded

        protected void relaseAdministrationLockIfNeeded​(HybrisDataSource masterDataSource)
        Tries to release administration lock if lock was acquired by this getClusterID() node.
      • initializeCache

        protected void initializeCache​(HybrisDataSource masterDataSource)
      • readParameters

        public MSSQLServerTransactionParameters readParameters​(javax.sql.DataSource dataSource)
        Checks READ_COMMITTED_SNAPSHOT and ALLOW_SNAPSHOT_ISOLATION parameters for MS SQL Server
      • assureTypeSystemStructureIsUpToDate

        protected void assureTypeSystemStructureIsUpToDate()
      • doShutDown

        public final void doShutDown()
      • executeInitsIfNecessary

        protected final void executeInitsIfNecessary()
        Performs calling Init.Init() for all registered init instances and also performs TenantListener.afterTenantStartUp(Tenant) notification.

        Both is working in a thread-safe non-blocking mode now.

      • cannotAccess

        protected final boolean cannotAccess()
      • getStateInfo

        protected java.lang.String getStateInfo()
      • getTenantID

        public java.lang.String getTenantID()
        Specified by:
        getTenantID in interface Tenant
      • setTenantID

        public void setTenantID​(java.lang.String id)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • cancelForceMasterMode

        public void cancelForceMasterMode()
        Be careful! This method is intended for internal testing. Generally it's not recommended to cancel forceMaster mode since this would bear the danger of seeing stale data due to switching to slave data source is possible again.
      • createDataSourceFactory

        protected DataSourceFactory createDataSourceFactory​(java.lang.String className)
      • getAllAlternativeDataSources

        protected java.util.Collection<HybrisDataSource> getAllAlternativeDataSources​(boolean asMaster)
      • getAllAlterntiveDataSourceIDs

        protected java.util.Set<java.lang.String> getAllAlterntiveDataSourceIDs​(boolean asMaster)
      • activateSlaveDataSource

        public void activateSlaveDataSource​(java.lang.String id)
        Description copied from interface: DataSourceProvider
        Switches to a specified (by the id) slave data source for the current thread. If the current data source is already a slave one this has no effect. Use as follows:
         Tenant t = Registry.getCurrentTenant();
         try
         {
                t.activateSlaveDataSource("your_slave_id");
                // ... business logic ...
         }
         finally
         {
                t.deactivateSlaveSource();
         }
         
        Specified by:
        activateSlaveDataSource in interface DataSourceProvider
        Parameters:
        id - the id string of the slave data source
        See Also:
        DataSourceProvider.deactivateAlternativeDataSource()
      • activateAlternativeDataSource

        protected void activateAlternativeDataSource​(java.lang.String id,
                                                     boolean asMaster)
      • activateAlternativeMasterDataSource

        public void activateAlternativeMasterDataSource​(java.lang.String id)
        Description copied from interface: DataSourceProvider
        Switches to a specified (by the id) master data source for the current thread. Use as follows:
         Tenant t = Registry.getCurrentTenant();
         try
         {
                t.activateMasterDataSource("your_slave_id");
                // ... business logic ...
         }
         finally
         {
                t.deactivateSlaveSource();
         }
         
        Specified by:
        activateAlternativeMasterDataSource in interface DataSourceProvider
        Parameters:
        id - the id string of the slave data source
        See Also:
        DataSourceProvider.deactivateAlternativeDataSource()
      • createDefaultThreadPool

        public static ThreadPool createDefaultThreadPool​(java.lang.String tenantID,
                                                         int poolSize)
      • createAlternativeDataSource

        protected HybrisDataSource createAlternativeDataSource​(DataSourceFactory factory,
                                                               java.lang.String id,
                                                               java.util.Map<java.lang.String,​java.lang.String> params,
                                                               boolean readOnly)
      • mergeSlaveDataSourceParameter

        protected java.util.Map<java.lang.String,​java.lang.String> mergeSlaveDataSourceParameter​(java.lang.String dsID,
                                                                                                       java.util.Map<java.lang.String,​java.lang.String> tenantSettings,
                                                                                                       java.lang.String... keys)
      • extractCustomDBParams

        public static java.util.Map<java.lang.String,​java.lang.String> extractCustomDBParams​(ConfigIntf cfg)
      • extractCustomDBParams

        public static java.util.Map<java.lang.String,​java.lang.String> extractCustomDBParams​(ConfigIntf cfg,
                                                                                                   boolean stripPrefix)
      • extractCustomDBParams

        public static java.util.Map<java.lang.String,​java.lang.String> extractCustomDBParams​(java.util.Map<java.lang.String,​java.lang.String> map)
      • extractCustomDBParams

        public static java.util.Map<java.lang.String,​java.lang.String> extractCustomDBParams​(java.util.Map<java.lang.String,​java.lang.String> map,
                                                                                                   boolean stripPrefix)
      • createCache

        protected Cache createCache()
      • isClusteringEnabled

        public boolean isClusteringEnabled()
        checks if clustermode is enabled
        Returns:
        'true' ONLY IF the correspondig property is set to 'true' AND the installed licence file supports this feature, too
        Since:
        4.0.3
      • getClusterID

        @Deprecated
        public int getClusterID()
        Deprecated.
        since ages - UseRegistry.getClusterID() instead. The cluster ID is a global setting and therefore not strictly depending on the current tenant.
      • getDynamicClusterNodeID

        public long getDynamicClusterNodeID()
      • setActiveSessionForCurrentThread

        public void setActiveSessionForCurrentThread​(JaloSession session)
      • assertTenant

        protected void assertTenant​(JaloSession session)
      • getActiveSessionContextList

        public java.util.List<SessionContext> getActiveSessionContextList()
      • cannotConnect

        public boolean cannotConnect()
      • connectionHasBeenBroken

        public boolean connectionHasBeenBroken()
      • clearConnectionHasBeenBroken

        public void clearConnectionHasBeenBroken()
      • writeReplace

        public java.lang.Object writeReplace()
                                      throws java.io.ObjectStreamException
        Throws:
        java.io.ObjectStreamException
      • isStarting

        public final boolean isStarting()
      • isStopping

        public final boolean isStopping()
      • isNotifiyingListeners

        public final boolean isNotifiyingListeners()
      • createAndRegisterBackgroundThread

        public java.lang.Thread createAndRegisterBackgroundThread​(java.lang.Runnable payload,
                                                                  java.util.concurrent.ThreadFactory factory)
        Specified by:
        createAndRegisterBackgroundThread in interface Tenant
      • backgroundThreadStarted

        protected void backgroundThreadStarted​(java.lang.Thread thread,
                                               java.lang.Runnable payload)
      • backgroundThreadFinished

        protected void backgroundThreadFinished​(java.lang.Thread thread,
                                                java.lang.Runnable payload)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object