Class DefaultDataSourceFactory

    • Field Detail

      • PROPERTY_DATA_SOURCE_CLASS_NAME

        public static final java.lang.String PROPERTY_DATA_SOURCE_CLASS_NAME
        Property name for the DataSource Class.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultDataSourceFactory

        public DefaultDataSourceFactory()
    • Method Detail

      • createDataSource

        public static javax.sql.DataSource createDataSource​(java.lang.String propertiesFileName)
                                                     throws java.lang.Exception

        Convenience method to create a DataSource.

        This is typically used in testing.

        Parameters:
        propertiesFileName - Name of the Properties file on the class path.
        Returns:
        DataSource.
        Throws:
        java.lang.Exception - If fails to load the DataSource.
      • createDataSource

        public static javax.sql.DataSource createDataSource​(java.util.Properties properties)
                                                     throws java.lang.Exception

        Convenience method to create a DataSource.

        This is typically used in testing.

        Parameters:
        properties - Properties to configure the DataSource.
        Returns:
        DataSource.
        Throws:
        java.lang.Exception - If fails to load the DataSource.
      • loadProperties

        public static <S> void loadProperties​(S dataSource,
                                              SourceContext context)
                                       throws java.lang.Exception
        Loads the properties onto the DataSource.
        Type Parameters:
        S - DataSource type.
        Parameters:
        dataSource - DataSource.
        context - SourceContext.
        Throws:
        java.lang.Exception - If fails to load properties.
      • createDataSource

        public javax.sql.DataSource createDataSource​(SourceContext context)
                                              throws java.lang.Exception
        Description copied from interface: DataSourceFactory
        Creates the DataSource.
        Specified by:
        createDataSource in interface DataSourceFactory
        Parameters:
        context - SourceContext to configure the DataSource.
        Returns:
        DataSource.
        Throws:
        java.lang.Exception - If fails to create the DataSource.