Class 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 Detail

      • XADataSourceFactory

        public XADataSourceFactory()
    • Method Detail

      • init

        public static void init​(String dsName)

        init

        Parameters:
        dsName - a String object.
      • 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 or reload method was invoked. The instance will not change unless a reload method is invoked.

        Returns:
        The current factory instance.
        Throws:
        IllegalStateException - Thrown if the factory has not yet been initialized.
      • setInstance

        public static void setInstance​(XADataSource ds)

        setInstance

        Parameters:
        ds - a DataSource object.
      • setInstance

        public static void setInstance​(String dsName,
                                       XADataSource singleton)

        setInstance

        Parameters:
        dsName - a String object.
        singleton - a DataSource object.
      • getXADataSource

        public static XADataSource getXADataSource()
        Return the datasource configured for the database
        Returns:
        the datasource configured for the database
      • close

        public static void close()

        close

        Throws:
        SQLException - if any.