Package de.hybris.platform.core
Class Registry
java.lang.Object
de.hybris.platform.core.Registry
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classprotected static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TenantInternal note: currently called via reflection from JUnitTestRunner to assure that "ant yunit" will workstatic TenantactivateMasterTenant(de.hybris.platform.core.Registry.REPLACE replace) Deprecated, for removal: This API element is subject to removal in a future version.static TenantDeprecated, for removal: This API element is subject to removal in a future version.since ages - useactivateMasterTenant(),setCurrentTenant(Tenant)orsetCurrentTenantByID(String)insteadstatic Tenantstatic voidprotected static booleanstatic voiddestroy(boolean all) static voidCan be called to ensure new Singletons are created and all startup()-Hookins are called again.static org.springframework.context.ApplicationContextTries to retrieve web implementation of theApplicationContextfrom the currentServletContextor from http sessionWebSessionFunctions.getCurrentHttpSession()if it fails it fall backs to core application spring context seegetCoreApplicationContext().static final Collection<String>static final intReturns the cluster ID assigned to this platform instance.static org.springframework.context.ApplicationContextMethod returns an instance ofApplicationContextcontext.static <T extends Tenant>
TReturns the tenant currently associated with the callers thread.protected static Exceptionprotected static Tenantstatic <T extends Tenant>
TReturns the tenant currently associated with the callers thread orNULLif no tenant had been activated.static org.springframework.context.ApplicationContextDeprecated, for removal: This API element is subject to removal in a future version.since 5.0 usegetCoreApplicationContext()insteadstatic MasterTenantstatic <T> TgetNonTenantSingleton(SingletonCreator.Creator<T> creator) static PersistenceManagerstatic intDeprecated, for removal: This API element is subject to removal in a future version.since ages - useisStandaloneMode()insteadstatic javax.servlet.ServletContextReturns servlet context if invoked in webcontextstatic <T> TgetSingleton(SingletonCreator.Creator<T> creator) static <T> TgetSingleton(Class<T> clazz) static org.springframework.context.ApplicationContextThis method returns a global 'super' spring context.static SlaveTenantreturns a slave tenant instance if exist otherwise throwsIllegalStateException.static Map<String,SlaveTenant> returns immutable map of slave tenant configurationstatic <T extends Tenant>
TgetTenantByID(String id) Return the tenant by its ID or NULL if no tenant was found.static List<TenantListener>Gets all listeners registered for getting tenant notifications.static booleanTells whether the callers thread is already associated with a tenant.static booleanisCurrentTenant(Tenant tenant) Tells whether the callers thread is associated with the given tenant.static booleanstatic booleanstatic voidregisterTenantListener(TenantListener listener) Registers aTenantListenerwhich will be then notified on tenant start up / shut down.static <T> TreplaceSingleton(SingletonCreator.Creator<T> creator) static <T> TrunAsTenant(Tenant tenant, Callable<T> callable) Runs a given Callable within the given tenant.static voidsetCurrentTenant(Tenant tenant) Activates the given tenant as current tenant for the callers thread.static voidsetCurrentTenantByID(String tenantID) protected static voidsetCurrentTenantInternal(Tenant tenant) static voidsetPreferredClusterID(int clusterid) Deprecated, for removal: This API element is subject to removal in a future version.since ages - UseactivateStandaloneMode()insteadstatic voidstartup()This method starts up the Registry.static voidunregisterTenantListener(TenantListener listener) Unregisters aTenantListenerfor not be notified on tenant start up / shut down anymore.static voidDe-activates the currently active tenant for the callers thread.
-
Field Details
-
SYSTEM_PROPERTY_FAILSAFE_ACTIVE
- See Also:
-
FAILSAVE_NOTENANTACTIVE
public static final boolean FAILSAVE_NOTENANTACTIVE
-
-
Constructor Details
-
Registry
public Registry()
-
-
Method Details
-
getSlaveTenants
returns immutable map of slave tenant configuration -
getSlaveJunitTenant
returns a slave tenant instance if exist otherwise throwsIllegalStateException. -
destroyAndForceStartup
public static void destroyAndForceStartup()Can be called to ensure new Singletons are created and all startup()-Hookins are called again. This is normally done at system startup (in Registry.static{}) and before a new system database initialization is made -
getCurrentTenantActivationTrace
-
setCurrentTenantInternal
-
getCurrentTenantInternal
-
destroy
public static void destroy(boolean all) -
startup
public static void startup()This method starts up the Registry. If the Registry is already started, it returns immediately. It is usually safe to call this method from several places to ensure the Registry is correctly started. (e.g. in Item(), Manager() ) Note that if system shutdown is in progress (RedeployUtilities.isShutdownInProgress()), this method returns immediately without doing anything. -
getNonTenantSingleton
-
getSingleton
-
getSingleton
-
replaceSingleton
-
runAsTenant
Runs a given Callable within the given tenant. The previously active tenant (if one is set) is deactivated before and activated afterward execution. If the same tenant was active, it stays active. If none was active before there will be no tenant active afterwards.- Throws:
Exception
-
setCurrentTenant
Activates the given tenant as current tenant for the callers thread. -
activateMasterTenantAndFailIfAlreadySet
@Deprecated(since="ages", forRemoval=true) public static Tenant activateMasterTenantAndFailIfAlreadySet()Deprecated, for removal: This API element is subject to removal in a future version.since ages - useactivateMasterTenant(),setCurrentTenant(Tenant)orsetCurrentTenantByID(String)insteadActivates the master tenant.- Returns:
- the previous tenant
- Throws:
IllegalStateException- if the current tenant is already set
-
activateMasterTenant
Internal note: currently called via reflection from JUnitTestRunner to assure that "ant yunit" will work- Returns:
- the previous tenant
-
activateMasterTenantForInit
-
activateMasterTenant
@Deprecated(since="ages", forRemoval=true) public static Tenant activateMasterTenant(de.hybris.platform.core.Registry.REPLACE replace) Deprecated, for removal: This API element is subject to removal in a future version.since ages - useactivateMasterTenant(),setCurrentTenant(Tenant)orsetCurrentTenantByID(String)instead -
assureTenantStarted
-
setCurrentTenantByID
-
unsetCurrentTenant
public static void unsetCurrentTenant()De-activates the currently active tenant for the callers thread. In case no tenant had been active this method has no effect. -
hasCurrentTenant
public static boolean hasCurrentTenant()Tells whether the callers thread is already associated with a tenant. -
isCurrentTenant
Tells whether the callers thread is associated with the given tenant. -
getCurrentTenantNoFallback
Returns the tenant currently associated with the callers thread orNULLif no tenant had been activated.- See Also:
-
isCurrentTenantStarted
public static boolean isCurrentTenantStarted() -
getCurrentTenant
Returns the tenant currently associated with the callers thread. This may be anySlaveTenantor (as default) theMasterTenant.Please note that depending upon the setting of
activate.tenant.fallbackthis method will automatically activate the master tenant if no current tenant could be found!- Throws:
IllegalStateException- in case no tenant has been activated and fallback mode is not switched on (system property 'activate.tenant.fallback')- See Also:
-
getTenantByID
Return the tenant by its ID or NULL if no tenant was found. -
getPersistenceManager
-
getMasterTenant
-
getClusterID
public static final int getClusterID()Returns the cluster ID assigned to this platform instance. -
getClusterGroups
-
setPreferredClusterID
Deprecated, for removal: This API element is subject to removal in a future version.since ages - UseactivateStandaloneMode()insteadset the preferred clusternode. note that this setting will be ignored if the registry is already initialized (e.g. if running on tomcat). it can be useful if running as a standalone application to ensure a different clusternode- Parameters:
clusterid- the preferred clusternode (0-15). if set to -1, the preferral is cleared.
-
getPreferredClusterID
Deprecated, for removal: This API element is subject to removal in a future version.since ages - useisStandaloneMode()instead -
activateStandaloneMode
public static void activateStandaloneMode() -
isStandaloneMode
public static boolean isStandaloneMode() -
getGlobalApplicationContext
@Deprecated(since="5.0", forRemoval=true) public static org.springframework.context.ApplicationContext getGlobalApplicationContext()Deprecated, for removal: This API element is subject to removal in a future version.since 5.0 usegetCoreApplicationContext()instead- See Also:
-
getApplicationContext
public static org.springframework.context.ApplicationContext getApplicationContext()Tries to retrieve web implementation of theApplicationContextfrom the currentServletContextor from http sessionWebSessionFunctions.getCurrentHttpSession()if it fails it fall backs to core application spring context seegetCoreApplicationContext().- Returns:
- current application context
-
getServletContextIfExists
public static javax.servlet.ServletContext getServletContextIfExists()Returns servlet context if invoked in webcontext- Returns:
- servlet context if available, otherwise null
-
getCoreApplicationContext
public static org.springframework.context.ApplicationContext getCoreApplicationContext()Method returns an instance ofApplicationContextcontext.- If current thread 'has a tenant'. This context consists of merged of every available extension beans
definition(s) (its core part spring definitions) specific for the tenant. The bean definitions can be provided using
properties as :
${extname}.application-context = ...The context also has as a parent global 'super' context @see
getSingletonGlobalApplicationContext(). - Otherwise it returns a empty context which in most case will cause application to fail.
- Returns:
- current global application context
- If current thread 'has a tenant'. This context consists of merged of every available extension beans
definition(s) (its core part spring definitions) specific for the tenant. The bean definitions can be provided using
properties as :
-
getSingletonGlobalApplicationContext
public static org.springframework.context.ApplicationContext getSingletonGlobalApplicationContext()This method returns a global 'super' spring context. This context is not tenant aware. It contains a beans defined in spring configuration defined in properties as :${extname}.global-application-context = ...Warning In most cases this context won't contain a business logic beans only those infrastructure ones which needs to stay in memory longer than tenant lifecycle. -
registerTenantListener
Registers aTenantListenerwhich will be then notified on tenant start up / shut down.- Parameters:
listener- the listener to register for notifications- Since:
- 3.1-u1
-
unregisterTenantListener
Unregisters aTenantListenerfor not be notified on tenant start up / shut down anymore.- Parameters:
listener- the listener to unregister for notifications- Since:
- 3.1-u1
-
getTenantListeners
Gets all listeners registered for getting tenant notifications.- Returns:
- Unmodifiable list of all registered listeners
- Since:
- 3.1-u1
-
activateMasterTenant(),setCurrentTenant(Tenant)orsetCurrentTenantByID(String)instead