org.apache.commons.pool2

## Class BasePooledObjectFactory<T>

- java.lang.Object
- - org.apache.commons.pool2.BaseObject
  - - org.apache.commons.pool2.BasePooledObjectFactory<T>

- Type Parameters:
    `T` - Type of element managed in this factory.
  All Implemented Interfaces:
    PooledObjectFactory<T>

      public abstract class BasePooledObjectFactory<T>
      extends BaseObject
      implements PooledObjectFactory<T>

  A base implementation of `PoolableObjectFactory`.

  All operations defined here are essentially no-op's.

  This class is immutable, and therefore thread-safe

  Since:
    2.0
  See Also:
    `PooledObjectFactory`, `BaseKeyedPooledObjectFactory`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasePooledObjectFactory()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `activateObject(PooledObject<T> p)` No-op.
    `abstract T` | `create()` Creates an object instance, to be wrapped in a `PooledObject`.
    `void` | `destroyObject(PooledObject<T> p)` No-op.
    `PooledObject<T>` | `makeObject()` Creates an instance that can be served by the pool and wrap it in a `PooledObject` to be managed by the pool.
    `void` | `passivateObject(PooledObject<T> p)` No-op.
    `boolean` | `validateObject(PooledObject<T> p)` Always returns `true`.
    `abstract PooledObject<T>` | `wrap(T obj)` Wraps the provided instance with an implementation of `PooledObject`.

    - ### Methods inherited from class org.apache.commons.pool2.BaseObject

      `toString, toStringAppendFields`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.pool2.PooledObjectFactory

      `destroyObject`

- - ### Constructor Detail

    - #### BasePooledObjectFactory

          public BasePooledObjectFactory()

  - ### Method Detail

    - #### activateObject

          public void activateObject(PooledObject<T> p)
                              throws Exception

      No-op.
      Specified by:
        `activateObject` in interface `PooledObjectFactory<T>`
      Parameters:
        `p` - ignored
      Throws:
        `Exception` - if there is a problem activating `obj`, this exception may be swallowed by the pool.
      See Also:
        `PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)`

    - #### create

          public abstract T create()
                            throws Exception

      Creates an object instance, to be wrapped in a `PooledObject`.

      This method must support concurrent, multi-threaded activation.

      Returns:
        an instance to be served by the pool
      Throws:
        `Exception` - if there is a problem creating a new instance, this will be propagated to the code requesting an object.

    - #### destroyObject

          public void destroyObject(PooledObject<T> p)
                             throws Exception

      No-op.
      Specified by:
        `destroyObject` in interface `PooledObjectFactory<T>`
      Parameters:
        `p` - ignored
      Throws:
        `Exception` - should be avoided as it may be swallowed by the pool implementation.
      See Also:
        `PooledObjectFactory.validateObject(org.apache.commons.pool2.PooledObject<T>)`, `ObjectPool.invalidateObject(T)`

    - #### makeObject

          public PooledObject<T> makeObject()
                                     throws Exception

      Description copied from interface: `PooledObjectFactory`
      Creates an instance that can be served by the pool and wrap it in a `PooledObject` to be managed by the pool.
      Specified by:
        `makeObject` in interface `PooledObjectFactory<T>`
      Returns:
        a `PooledObject` wrapping an instance that can be served by the pool
      Throws:
        `Exception` - if there is a problem creating a new instance, this will be propagated to the code requesting an object.

    - #### passivateObject

          public void passivateObject(PooledObject<T> p)
                               throws Exception

      No-op.
      Specified by:
        `passivateObject` in interface `PooledObjectFactory<T>`
      Parameters:
        `p` - ignored
      Throws:
        `Exception` - if there is a problem passivating `obj`, this exception may be swallowed by the pool.
      See Also:
        `PooledObjectFactory.destroyObject(org.apache.commons.pool2.PooledObject<T>)`

    - #### validateObject

          public boolean validateObject(PooledObject<T> p)

      Always returns `true`.
      Specified by:
        `validateObject` in interface `PooledObjectFactory<T>`
      Parameters:
        `p` - ignored
      Returns:
        `true`

    - #### wrap

          public abstract PooledObject<T> wrap(T obj)

      Wraps the provided instance with an implementation of `PooledObject`.
      Parameters:
        `obj` - the instance to wrap
      Returns:
        The provided instance, wrapped by a `PooledObject`

Copyright © 2001–2021 The Apache Software Foundation. All rights reserved.