Making use of the RDBMS extension mechanism

An extension mechanism is part of the RDBMS feature so that you add new connection pools in a more flexible and easy way.

Previous RDBMS code already dealt with the possibility of multiple pools. This JDBC file contains the following type attribute that was used to switch between pools:
<jdbc type="simple">
    <driver>com.ibm.db2.jcc.DB2Driver</driver>
    <url>jdbc:db2://<host>:<port>/<DB></url>

This code handled the switch as static, however.

Improvements in the form of an extension mechanism now allow for better switching. This mechanism also lets you contribute your own pool(s) if desired. This code example shows how this is done:
IJdbcResourceFactory jdbcFactory = null;
List<Object> providers = ExtensionManager.findServices
(null,IFileJdbcPoolProvider.class,"com.ibm.xsp.extlib.jdbc.datasource.IFileJdbcPoolProvider");

The following information provides the name of the class where the code sample was taken from. You can look this up directly in the Extension Library source.

Class: AbstractFileJdbcProvider

Method: loadJDBCConnection

Code Snippet:
AccessController.doPrivileged(new PrivilegedAction<Void>() {
                public Void run() {
                    // Read the providers
                    m_providers = ExtensionManager.findServices(null,IFileJdbcPoolProvider.class,
                    "com.ibm.xsp.extlib.jdbc.datasource.IFileJdbcPoolProvider");
                    return null;
                }
            });
Each provider is added to the list using the normal extension mechanism. This example shows a scenario using 2 providers:
<extension point="com.ibm.commons.Extension">
         <service type="com.ibm.xsp.extlib.jdbc.datasource.IFileJdbcPoolProvider" 
class="com.ibm.xsp.extlib.jdbc.datasource.dbcp.NSFFileJdbcDBCPProvider" />
   </extension>
   <extension point="com.ibm.commons.Extension">
         <service type="com.ibm.xsp.extlib.jdbc.datasource.IFileJdbcPoolProvider" 
class="com.ibm.xsp.extlib.jdbc.datasource.xpages.NSFFileJdbcXPCPProvider" />
   </extension>

The code was taken from com.ibm.xsp.exlibx.relational/plugin.xml and can be found directly in the Extension Library source.