The previous sections demonstrated how to subclass ResourcePool
to create the type of resource object to be managed by your pool. The ResourcePool
class provides a shortcut that lets you create resource objects without subclassing ResourcePool
. You can use this shortcut if your resource object fits the following criteria:
The resource object has a public constructor that takes no arguments.
The resource object requires no special initialization beyond the constructor.
The resource object requires no special cleanup operations to be performed when the resource object is destroyed.
If your resource object fits these criteria, you can use the base ResourcePool
class without defining a subclass. To do this, specify an extra property called resourceClassName
. This property should define the full class name of the resource object. For example:
resourceClassName=atg.resources.ReallyExpensiveObject
Now, whenever the resource pool requires a new object, it calls:
new atg.resources.ReallyExpensiveObject()
When the resource is no longer needed, the resource pool simply discards the object without calling any special notification methods.