Enterprise Information Portal APIs

com.ibm.mm.beans
Class CMBObjectManagement

java.lang.Object
  |
  +--com.ibm.mm.beans.CMBObjectManagement
All Implemented Interfaces:
java.io.Serializable

public class CMBObjectManagement
extends java.lang.Object
implements java.io.Serializable

The CMBObjectManagement class can be used to efficiently allocate and free instances of CMBItem and CMBObject. Pools of free CMBItem and CMBObject objects are maintained. Using CMBObjectManagement to allocate CMBItem and CMBObject is more efficient than performing new's because the objects will be reused from the pools rather than freed to Java garbage collection.

Further optimizations are made in the case of CMBItem. If an instance of CMBItem already exists with the same pidstring as requested, that object will be returned rather than creating a new instance.

CMBObjectManagement is used internally by other non-visual beans. In particular, CMBSearchResults uses CMBObjectManagement to allocate CMBItems for items in the list of search results, and frees all items when the list of results is cleared. This means that the lifetime of CMBItems obtained from CMBSearchResults is only during the time the items are part of the list of results.

CMBObjectManagement is constructed by CMBConnection and is available using CMBConnection.getObjectManagement(). Object management is initially disabled. Use CMBObjectManagement.setEnabled(true) to enable object management.

Note that CMBObjectManagement has affinity to a CMBConnection. This means that, like CMBConnection, an instance of CMBObjectManagement can only be used by a single thread. If it is used by multiple threads, synchronization must be performed in the application to insure that only a single thread is using CMBObjectManagment at any point in time.

Since:
7.1
See Also:
CMBConnection, CMBSearchResults, Serialized Form

Method Summary
 CMBItem createItem()
          Creates an instance of CMBItem, or reuses a freed instance from the pool.
 CMBItem createItem(java.lang.String pidString)
          Creates an instance of CMBItem for the specified pid string.
 CMBObject createObject()
          Creates an instance of CMBObject, or reuses a freed instance from the pool.
 int getItemPoolSize()
          Returns the maximum size of the CMBItem free pool.
 int getObjectPoolSize()
          Returns the maximum size of the CMBObject free pool.
 boolean isEnabled()
          Returns true if object management is enabled.
 void releaseItem(CMBItem item)
          Release an instance of CMBItem tht is no longer being used.
 void releaseObject(CMBObject obj)
          Release an instance of CMBObject that is no longer being used.
 void setEnabled(boolean managementEnabled)
          Sets the enablement of object management.
 void setItemPoolSize(int itemPoolSize)
          Sets the maximum size of the CMBItem free pool.
 void setObjectPoolSize(int objectPoolSize)
          Sets the maximum size of the CMBObject free pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEnabled

public boolean isEnabled()
Returns true if object management is enabled. When object management is disabled, new objects will always be created. When object management is enabled, new objects will be created only when needed, otherwise previously freed objects will be reused.

Initially, object management is disabled.


setEnabled

public void setEnabled(boolean managementEnabled)
Sets the enablement of object management.

getItemPoolSize

public int getItemPoolSize()
Returns the maximum size of the CMBItem free pool. Initially, this is 100.

setItemPoolSize

public void setItemPoolSize(int itemPoolSize)
Sets the maximum size of the CMBItem free pool.

getObjectPoolSize

public int getObjectPoolSize()
Returns the maximum size of the CMBObject free pool. Initially, this is 100.

setObjectPoolSize

public void setObjectPoolSize(int objectPoolSize)
Sets the maximum size of the CMBObject free pool.

createObject

public CMBObject createObject()
Creates an instance of CMBObject, or reuses a freed instance from the pool.

createItem

public CMBItem createItem()
Creates an instance of CMBItem, or reuses a freed instance from the pool.

createItem

public CMBItem createItem(java.lang.String pidString)
Creates an instance of CMBItem for the specified pid string. If an instance already exists with that pid, the existing instance is returned.

releaseObject

public void releaseObject(CMBObject obj)
Release an instance of CMBObject that is no longer being used. Note: You must be sure that the instance is not being used. It will be cleared and will no longer be valid after calling this method.

releaseItem

public void releaseItem(CMBItem item)
Release an instance of CMBItem tht is no longer being used. Note: You must be sure tht the instance is not being used. It will be cleared and will no longer be valid after calling this method.

EIP JavaBeans

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.