Package org.opennms.core.db
Class XADataSourceFactory
- java.lang.Object
-
- org.opennms.core.db.XADataSourceFactory
-
public abstract class XADataSourceFactory extends Object
This is the singleton class used to load the OpenNMS database configuration from the opennms-database.xml. This provides convenience methods to create database connections to the database configured in this default xml
Note: Users of this class should make sure the init() is called before calling any other method to ensure the config is loaded before accessing other convenience methods
- Author:
- Brian Weaver
-
-
Constructor Summary
Constructors Constructor Description XADataSourceFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close()
closestatic XADataSource
getInstance()
Return the singleton instance of this factory.static XADataSource
getInstance(String name)
getInstancestatic XADataSource
getXADataSource()
Return the datasource configured for the databasestatic XADataSource
getXADataSource(String dsName)
getDataSourcestatic void
init(String dsName)
initstatic void
setDataSourceConfigurationFactory(DataSourceConfigurationFactory factory)
static void
setInstance(String dsName, XADataSource singleton)
setInstancestatic void
setInstance(XADataSource ds)
setInstance
-
-
-
Method Detail
-
getInstance
public static XADataSource getInstance()
Return the singleton instance of this factory. This is the instance of the factory that was last created when the
init
orreload
method was invoked. The instance will not change unless areload
method is invoked.- Returns:
- The current factory instance.
- Throws:
IllegalStateException
- Thrown if the factory has not yet been initialized.
-
getInstance
public static XADataSource getInstance(String name)
getInstance
- Parameters:
name
- aString
object.- Returns:
- a
DataSource
object.
-
setInstance
public static void setInstance(XADataSource ds)
setInstance
- Parameters:
ds
- aDataSource
object.
-
setInstance
public static void setInstance(String dsName, XADataSource singleton)
setInstance
- Parameters:
dsName
- aString
object.singleton
- aDataSource
object.
-
getXADataSource
public static XADataSource getXADataSource()
Return the datasource configured for the database- Returns:
- the datasource configured for the database
-
getXADataSource
public static XADataSource getXADataSource(String dsName)
getDataSource
- Parameters:
dsName
- aString
object.- Returns:
- a
DataSource
object.
-
setDataSourceConfigurationFactory
public static void setDataSourceConfigurationFactory(DataSourceConfigurationFactory factory)
-
close
public static void close()
close
- Throws:
SQLException
- if any.
-
-