org.datanucleus.store.rdbms.adapter
Class RDBMSAdapterFactory

java.lang.Object
  extended by org.datanucleus.store.rdbms.adapter.RDBMSAdapterFactory

public class RDBMSAdapterFactory
extends java.lang.Object

Factory of RDBMS datastore adapters. Acts as a registry of adapters to RDBMS that can be selected for use. Uses a singleton pattern, and the factory can be accessed using the getInstance() method.

Autodetection

Provides a level of autodetection of the adapter to use for a particular RDBMS. It uses the DatabaseMetaData to extract the "product name" and matches this against a series of "adapter aliases" that we define internally or that can be contributed by plugins that extend the org.datanucleus.store_datastoreadapter extension point. These extension can define a priority, so if multiple adapter match for the given database connection the one with the highest priority is chosen.

Specification of adapter class

You can call getDatastoreAdapter(ClassLoaderResolver, Connection, String, PluginManager) passing the adapter class name directly if you know which you want to use. This allows for user-defined database adapters.


Constructor Summary
protected RDBMSAdapterFactory()
          Protected constructor to prevent outside instantiation
 
Method Summary
protected  java.lang.Class getAdapterClass(org.datanucleus.plugin.PluginManager pluginMgr, java.lang.String adapterClassName, java.lang.String productName, org.datanucleus.ClassLoaderResolver clr)
          Accessor for the adapter class for a specified datastore product.
 org.datanucleus.store.mapped.DatastoreAdapter getDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, java.sql.Connection conn, java.lang.String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr)
          Accessor for an adapter, given a Connection to the datastore.
static RDBMSAdapterFactory getInstance()
          Accessor for the RDBMSAdapterFactory.
protected  org.datanucleus.store.mapped.DatastoreAdapter getNewDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, java.sql.DatabaseMetaData metadata, java.lang.String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr)
          Accessor for the adapter for a specified datastore product.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RDBMSAdapterFactory

protected RDBMSAdapterFactory()
Protected constructor to prevent outside instantiation

Method Detail

getInstance

public static RDBMSAdapterFactory getInstance()
Accessor for the RDBMSAdapterFactory.

Returns:
The manager of type information

getDatastoreAdapter

public org.datanucleus.store.mapped.DatastoreAdapter getDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr,
                                                                         java.sql.Connection conn,
                                                                         java.lang.String adapterClassName,
                                                                         org.datanucleus.plugin.PluginManager pluginMgr)
                                                                  throws java.sql.SQLException
Accessor for an adapter, given a Connection to the datastore.

Parameters:
clr - ClassLoader resolver for resolving the adapter class
conn - The Connection
adapterClassName - Name of the class of the database adapter to use
pluginMgr - the Plug-in manager
Returns:
The database adapter for this connection.
Throws:
java.sql.SQLException - Thrown if a DB error occurs.

getNewDatastoreAdapter

protected org.datanucleus.store.mapped.DatastoreAdapter getNewDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr,
                                                                               java.sql.DatabaseMetaData metadata,
                                                                               java.lang.String adapterClassName,
                                                                               org.datanucleus.plugin.PluginManager pluginMgr)
Accessor for the adapter for a specified datastore product.

Parameters:
clr - ClassLoader resolver for resolving the adapter class
metadata - Database MetaData for the RDBMS
adapterClassName - Name of the class of the database adapter (null implies use autodetect)
pluginMgr - the Plug-in manager
Returns:
Instance of the database adapter

getAdapterClass

protected java.lang.Class getAdapterClass(org.datanucleus.plugin.PluginManager pluginMgr,
                                          java.lang.String adapterClassName,
                                          java.lang.String productName,
                                          org.datanucleus.ClassLoaderResolver clr)
Accessor for the adapter class for a specified datastore product.

Parameters:
pluginMgr - the Plug-in manager
adapterClassName - Name of the class of the database adapter (null implies use autodetect)
productName - the database product name
clr - ClassLoader resolver for resolving the adapter class
Returns:
the adapater class


Copyright © 2009. All Rights Reserved.