Class DatastoreAdapterFactory
- java.lang.Object
-
- org.datanucleus.store.rdbms.adapter.DatastoreAdapterFactory
-
public class DatastoreAdapterFactory extends 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 theorg.datanucleus.store.rdbms.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 callgetDatastoreAdapter(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
Constructors Modifier Constructor Description protected
DatastoreAdapterFactory()
Protected constructor to prevent outside instantiation
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class
getAdapterClass(org.datanucleus.plugin.PluginManager pluginMgr, String adapterClassName, String productName, org.datanucleus.ClassLoaderResolver clr)
Accessor for the adapter class for a specified datastore product.DatastoreAdapter
getDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, Connection conn, String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr)
Accessor for an adapter, given a Connection to the datastore.static DatastoreAdapterFactory
getInstance()
Accessor for the RDBMSAdapterFactory.protected DatastoreAdapter
getNewDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, DatabaseMetaData metadata, String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr)
Accessor for the adapter for a specified datastore product.
-
-
-
Method Detail
-
getInstance
public static DatastoreAdapterFactory getInstance()
Accessor for the RDBMSAdapterFactory.- Returns:
- The manager of type information
-
getDatastoreAdapter
public DatastoreAdapter getDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, Connection conn, String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr) throws SQLException
Accessor for an adapter, given a Connection to the datastore.- Parameters:
clr
- ClassLoader resolver for resolving the adapter classconn
- The ConnectionadapterClassName
- Name of the class of the database adapter to usepluginMgr
- the Plug-in manager- Returns:
- The database adapter for this connection.
- Throws:
SQLException
- Thrown if a DB error occurs.
-
getNewDatastoreAdapter
protected DatastoreAdapter getNewDatastoreAdapter(org.datanucleus.ClassLoaderResolver clr, DatabaseMetaData metadata, String adapterClassName, org.datanucleus.plugin.PluginManager pluginMgr)
Accessor for the adapter for a specified datastore product.- Parameters:
clr
- ClassLoader resolver for resolving the adapter classmetadata
- Database MetaData for the RDBMSadapterClassName
- 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 Class getAdapterClass(org.datanucleus.plugin.PluginManager pluginMgr, String adapterClassName, String productName, org.datanucleus.ClassLoaderResolver clr)
Accessor for the adapter class for a specified datastore product.- Parameters:
pluginMgr
- the Plug-in manageradapterClassName
- Name of the class of the database adapter (null implies use autodetect)productName
- the database product nameclr
- ClassLoader resolver for resolving the adapter class- Returns:
- the adapter class
-
-