Class sap.ui.base.ObjectPoolModule: sap/ui/base/ObjectPool
Manages a pool of objects all of the same type; the type has to be specified at pool construction time.
Maintains a list of free objects of the given type. If sap.ui.base.ObjectPool.prototype.borrowObject is called, an existing free object is taken from the pool and the init
method is called on this object.
When no longer needed, any borrowed object should be returned to the pool by calling returnObject. At that point in time, the reset method is called on the object and the object is added to the list of free objects.
See sap.ui.base.Poolable for a description of the contract for poolable objects.
Example:
this.oEventPool = new sap.ui.base.ObjectPool(sap.ui.base.Event); var oEvent = this.oEventPool.borrowObject(iEventId, mParameters);
Constructor Summary
new sap.ui.base.ObjectPool(oObjectClass)Creates an ObjectPool instance based on the given oObjectClass.
Method Summary
sap.ui.base.ObjectPool.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.base.ObjectPool with name
sClassName
and enriches it with the information contained in oClassInfo
.Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.base.ObjectPool(oObjectClass)
Creates an ObjectPool instance based on the given oObjectClass.<br/> If there is a free pooled instance, returns that one, otherwise creates a new one.<br/> In order to be maintained by the ObjectPool, oObjectClass must implement methods described in the class description.
Parameters:
{function} | oObjectClass | constructor for the class of objects that this pool should manage |
Method Detail
sap.ui.base.ObjectPool.extend(sClassName, oClassInfo?, FNMetaImpl?): function
Creates a new subclass of class sap.ui.base.ObjectPool with name
sClassName
and enriches it with the information contained in oClassInfo
. oClassInfo
might contain the same kind of information as described in sap.ui.base.Object.extend.
Parameters:
{string} | sClassName | Name of the class being created |
{object} | oClassInfo? | Object literal with information about the class |
{function} | FNMetaImpl? | Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata |
Returns:
{function} | Created class / constructor function |
sap.ui.base.ObjectPool.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.base.ObjectPool.
Returns:
{sap.ui.base.Metadata} | Metadata object describing this class |
borrowObject(any?): object
Borrows a free object from the pool. Any arguments to this method are forwarded to the init method of the borrowed object.
Parameters:
{any} | any? | optional initialization parameters for the borrowed object |
Returns:
{object} | the borrowed object of the same type that has been specified for this pool |