org.apache.commons.dbcp2.datasources

## Class SharedPoolDataSourceFactory

- java.lang.Object
- - org.apache.commons.dbcp2.datasources.SharedPoolDataSourceFactory

- All Implemented Interfaces:
    ObjectFactory

      public class SharedPoolDataSourceFactory
      extends Object

  A JNDI ObjectFactory which creates `SharedPoolDataSource`s
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SharedPoolDataSourceFactory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `closeAll()` Closes all pools associated with this class.
    `protected static Object` | `deserialize(byte[] data)` Deserializes the provided byte array to create an object.
    `protected InstanceKeyDataSource` | `getNewInstance(Reference ref)` Creates an instance of the subclass and sets any properties contained in the Reference.
    `Object` | `getObjectInstance(Object refObj, Name name, Context context, Hashtable<?,?> env)` Implements ObjectFactory to create an instance of SharedPoolDataSource or PerUserPoolDataSource
    `protected boolean` | `isCorrectClass(String className)`

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

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

- - ### Constructor Detail

    - #### SharedPoolDataSourceFactory

          public SharedPoolDataSourceFactory()

  - ### Method Detail

    - #### isCorrectClass

          protected boolean isCorrectClass(String className)

      Parameters:
        `className` - The class name to test.
      Returns:
        true if and only if className is the value returned from getClass().getName().toString()

    - #### getNewInstance

          protected InstanceKeyDataSource getNewInstance(Reference ref)

      Creates an instance of the subclass and sets any properties contained in the Reference.
      Parameters:
        `ref` - The properties to be set on the created DataSource
      Returns:
        A configured DataSource of the appropriate type.

    - #### closeAll

          public static void closeAll()
                               throws Exception

      Closes all pools associated with this class.
      Throws:
        `Exception` - a `ListException` containing all exceptions thrown by `InstanceKeyDataSource.close()`
      Since:
        2.4.0 throws a `ListException` instead of, in 2.3.0 and before, the first exception thrown by `InstanceKeyDataSource.close()`.
      See Also:
        `InstanceKeyDataSource.close()`, `ListException`

    - #### getObjectInstance

          public Object getObjectInstance(Object refObj,
                                          Name name,
                                          Context context,
                                          Hashtable<?,?> env)
                                   throws IOException,
                                          ClassNotFoundException

      Implements ObjectFactory to create an instance of SharedPoolDataSource or PerUserPoolDataSource
      Specified by:
        `getObjectInstance` in interface `ObjectFactory`
      Throws:
        `IOException`
        `ClassNotFoundException`

    - #### deserialize

          protected static final Object deserialize(byte[] data)
                                             throws IOException,
                                                    ClassNotFoundException

      Deserializes the provided byte array to create an object.
      Parameters:
        `data` - Data to deserialize to create the configuration parameter.
      Returns:
        The Object created by deserializing the data.
      Throws:
        `ClassNotFoundException` - If a class cannot be found during the deserialization of a configuration parameter.
        `IOException` - If an I/O error occurs during the deserialization of a configuration parameter.

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