Package de.hybris.platform.util
Class SingletonCreator
java.lang.Object
de.hybris.platform.util.SingletonCreator
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classabstract class used to for the Singleton creation.static classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voiddestroy()destroys this SingletonCreator instance this method will call the destroy() method of each SingletonCreator.Creator instance that was used when calling getSingleton() in reverse order to allow you to cleanup correctly<T> TgetSingleton(SingletonCreator.Creator<T> creator) returns a single instance created by the given Creator.<T> TgetSingleton(Class<T> clazz) returns a single instance of the specified class.<T> TgetSingletonIfExists(SingletonCreator.Creator<T> creator) boolean<T> TreplaceSingleton(SingletonCreator.Creator<T> creator)
-
Field Details
-
log
public static final org.apache.log4j.Logger log
-
-
Constructor Details
-
SingletonCreator
public SingletonCreator()creates a new SingletonCreator instance
-
-
Method Details
-
getSingleton
returns a single instance of the specified class. This is done by calling the newInstance() method on the class object. this method guarantees that only one instance is being created for this SingletonCreator instance. These instances will be cached and returned on subsequent calls of this method. Implementation note: This method implicitly creates a Creator instance and passes this to the getSingleton( Creator ) method. The key of this Creator instance (the getID() method) uses the full qualified class name (Class.getName()) to identify this singleton.- Parameters:
clazz- the Class for which the instance should be created- Returns:
- T the singleton instance
-
getSingleton
returns a single instance created by the given Creator. this method guarantees that only one instance is being created for this SingletonCreator instance. These instances will be cached in a Map keyed by the creator.getID() result are and returned on subsequent calls of this method.- Parameters:
creator- the Creator- Returns:
- T the singleton instance
-
replaceSingleton
-
getSingletonIfExists
-
destroy
public void destroy()destroys this SingletonCreator instance this method will call the destroy() method of each SingletonCreator.Creator instance that was used when calling getSingleton() in reverse order to allow you to cleanup correctly -
isDestroyed
public boolean isDestroyed() -
clear
public void clear()
-