Class DataSourceFactory


  • public abstract class DataSourceFactory
    extends java.lang.Object

    This is the singleton class used to load the OpenNMS database configuration from the opennms-datasources.xml. This provides convenience methods to create database connections to the database configured in this default XML.

    Author:
    Brian Weaver
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void close()
      close
      static javax.sql.DataSource getInstance()
      Return the singleton instance of this factory.
      static javax.sql.DataSource getInstance​(java.lang.String name)
      getInstance
      static void init()
      Deprecated.
      This function is no longer necessary for DataSourceFactory initialization
      static void init​(java.lang.String dsName)
      init
      static void setDataSourceConfigurationFactory​(DataSourceConfigurationFactory factory)  
      static void setInstance​(java.lang.String dsName, javax.sql.DataSource ds)
      setInstance
      static void setInstance​(javax.sql.DataSource ds)
      setInstance
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DataSourceFactory

        public DataSourceFactory()
    • Method Detail

      • init

        public static void init()
                         throws java.io.IOException,
                                java.lang.ClassNotFoundException,
                                java.beans.PropertyVetoException,
                                java.sql.SQLException
        Deprecated.
        This function is no longer necessary for DataSourceFactory initialization
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
        java.beans.PropertyVetoException
        java.sql.SQLException
      • init

        public static void init​(java.lang.String dsName)

        init

        Parameters:
        dsName - a String object.
      • getInstance

        public static javax.sql.DataSource 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:
        java.lang.IllegalStateException - Thrown if the factory has not yet been initialized.
      • getInstance

        public static javax.sql.DataSource getInstance​(java.lang.String name)

        getInstance

        Parameters:
        name - a String object.
        Returns:
        a DataSource object.
      • setInstance

        public static void setInstance​(javax.sql.DataSource ds)

        setInstance

        Parameters:
        ds - a DataSource object.
      • setInstance

        public static void setInstance​(java.lang.String dsName,
                                       javax.sql.DataSource ds)

        setInstance

        Parameters:
        dsName - a String object.
        ds - a DataSource object.
      • close

        public static void close()

        close

        Throws:
        java.sql.SQLException - if any.