The Generic Pool service enables multiple application operations to share certain objects (classes and services), making them reusable. This reuse reduces the average time to execute any operation and also reduces the "garbage collection" work, since the system does not destroy the reusable objects after use. The Generic Pool is similar to the Communications Pool (see Communications Pool) except that it is not limited to supporting communication services. Also, the elements of the Generic Pool are always identical.
The Generic Pool service supports the sharing by managing a pool of Poolable classes, all of which implement the Poolable interface. An application requests a Poolable object from the pool. The application operation gets the Poolable, uses it, and then releases it back to the pool so that it is available for other operations.
The Generic Pool service stores the Poolable objects in a Java Vector object. When the system initializes this service, it instantiates each pool object (defined in the service file if the Poolable object is a service) and calls the initialize method for each one. The service file (dsesrvce.xml) defines the size of the pool at initialization and, consequently, how many elements the system instantiates in the Vector.
The service definition also defines whether the pool size increases or decreases automatically. With automatic resizing, a process increases or decreases the pool size according to the maximum number of concurrent requests served since the previous occurrence of the process. As a result, this process adjusts the pool size according to the needs of the executing operations for a given period of time. That is, if an operation requests a specific Poolable and it is not in the pool, the Generic Pool creates an instance of the Poolable and adds it to the pool.
If an application requests a service, there are no free entries available, and automatic growth is not turned on, the Generic Pool will return null. An application must be prepared for this possibility.
You can add or remove elements from the pool at any time after initialization, by using insert and remove methods. These methods can be used even when the pool has been defined to grow automatically. In this case, it is valid to insert or remove elements that do not match the element specifications in the pool definition.
The following are the services that implement the Poolable interface and therefore can be instantiated using the Generic Pool: