Generic Pool

The Generic Pool service enables the service invokers to share certain objects (classes and services), making them reusable. This reuse reduces the average time to execute client operations or business processes, and also reduces garbage collection, since the system does not destroy the reusable objects after use. The Generic Pool service is available in the application logic layer and Java(TM) clients. In the application logic layer, the service invoker for a Generic Pool is a business process or a Single Action EJB, while in Java clients it's a client operation.

The Generic Pool service supports the sharing by managing a pool of Poolable classes, all of which implement the Poolable interface. A service invoker requests a Poolable object from the pool. The service invoker gets the Poolable, uses it, and then releases it back to the pool so that it is available for other invokers. In the application logic layer, the toolkit provides a Cache Cleaning Process to release timeout Poolable objects automatically.

In the application logic layer, the Generic Pool service stores the Poolable objects in a Java Hashtable object, while in Java clients, 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 Hashtable or 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 service invokers for a given period of time. That is, if a service invoker 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.

In the application logic layer there is a mechanism for orphan Poolable instance cleanup. You can specify a time length that if an assigned Poolable instance has been inactive for that long, the Generic Pool will release this Poolable instance from its invoker automatically. Therefore if the service invoker forgets to release the Poolable instance after the transaction finishes, the Generic Pool will still free the Poolable after a specified period to avoid the no-Poolable-instance-available error.

If a service invoker requests a service, there are no free entries available, and automatic growth is not turned on, the Generic Pool returns null, which means the request is rejected. An application must be prepared for this possibility.

In Java clients, 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. Note that the Generic Pool in the application logic layer do not support this function. In the application logic layer, you can only manage the size of the pool through the Generic Pool definition file.

In the client, the following services implement the Poolable interface and therefore can be instantiated using the Generic Pool:

In the application logic layer, the following services implement the Poolable interface for the service objects, and their corresponding service requesters extend the PooledServiceRequester class; therefore these services can be instantiated using the Generic Pool: