Package com.helger.web.scope.singleton
Class AbstractGlobalWebSingleton
- java.lang.Object
-
- com.helger.scope.singleton.AbstractSingleton
-
- com.helger.web.scope.singleton.AbstractGlobalWebSingleton
-
- All Implemented Interfaces:
com.helger.scope.IScopeDestructionAware,IWebSingleton
- Direct Known Subclasses:
GlobalDiskFileItemFactory
public abstract class AbstractGlobalWebSingleton extends com.helger.scope.singleton.AbstractSingleton implements IWebSingleton
This is the base class for singleton objects that reside in the global scope. The global scope is identical for web scope and non-web scope applications.- Author:
- Philip Helger
- See Also:
EWebScope.GLOBAL
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGlobalWebSingleton()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.helger.commons.collection.impl.ICommonsList<AbstractGlobalWebSingleton>getAllGlobalSingletons()Get all singleton objects registered in the current global web scope.static <T extends AbstractGlobalWebSingleton>
TgetGlobalSingleton(Class<T> aClass)Get the singleton object in the current global web scope, using the passed class.static <T extends AbstractGlobalWebSingleton>
TgetGlobalSingletonIfInstantiated(Class<T> aClass)Get the singleton object if it is already instantiated inside the current global web scope ornullif it is not instantiated.static booleanisGlobalSingletonInstantiated(Class<? extends AbstractGlobalWebSingleton> aClass)Check if a singleton is already instantiated inside the current global web scope-
Methods inherited from class com.helger.scope.singleton.AbstractSingleton
getAllSingletons, getSingleton, getSingletonIfInstantiated, getSingletonScopeKey, isDestroyed, isInDestruction, isInInstantiation, isInPreDestruction, isInstantiated, isSingletonInstantiated, isUsableObject, onAfterInstantiation, onBeforeDestroy, onBeforeScopeDestruction, onDestroy, onScopeDestruction, readAbstractSingletonFields, setDestroyed, setInDestruction, setInInstantiation, setInPreDestruction, setInstantiated, toString, writeAbstractSingletonFields
-
-
-
-
Method Detail
-
getGlobalSingleton
@Nonnull public static final <T extends AbstractGlobalWebSingleton> T getGlobalSingleton(@Nonnull Class<T> aClass)
Get the singleton object in the current global web scope, using the passed class. If the singleton is not yet instantiated, a new instance is created.- Type Parameters:
T- The type to be returned- Parameters:
aClass- The class to be used. May not benull. The class must be public as needs to have a public no-argument constructor.- Returns:
- The singleton object and never
null.
-
getGlobalSingletonIfInstantiated
@Nullable public static final <T extends AbstractGlobalWebSingleton> T getGlobalSingletonIfInstantiated(@Nonnull Class<T> aClass)
Get the singleton object if it is already instantiated inside the current global web scope ornullif it is not instantiated.- Type Parameters:
T- The type to be returned- Parameters:
aClass- The class to be checked. May not benull.- Returns:
- The singleton for the specified class is already instantiated,
nullotherwise.
-
isGlobalSingletonInstantiated
public static final boolean isGlobalSingletonInstantiated(@Nonnull Class<? extends AbstractGlobalWebSingleton> aClass)
Check if a singleton is already instantiated inside the current global web scope- Parameters:
aClass- The class to be checked. May not benull.- Returns:
trueif the singleton for the specified class is already instantiated,falseotherwise.
-
getAllGlobalSingletons
@Nonnull public static final com.helger.commons.collection.impl.ICommonsList<AbstractGlobalWebSingleton> getAllGlobalSingletons()
Get all singleton objects registered in the current global web scope.- Returns:
- A non-
nulllist with all instances of this class in the current global web scope.
-
-