Class DataSourceConverter

  • public class DataSourceConverter
    extends Object
    A DataSource is a representation of an database pool bound to JNDI. This converter will take a property and convert it to a DataSource and visa versa.
    • Constructor Detail

      • DataSourceConverter

        public DataSourceConverter()
    • Method Detail

      • fromPropertyString

        public DataSource fromPropertyString​(String datasourceInformation)
        Construct a DataSource from a single String. Note that database driver properties can be nested as long as they are semicolon delimited Example: CreateDatabase=create;DatabaseName=TEST.
        datasourceInformation - A string, really a list of properties, representing a datasource
        DataSource representing the string
        See Also:
      • toPropertyString

        public String toPropertyString​(DataSource data)
        Get a string representation of this datasource.
        data - DataSource to serialize into a string.
        a string representation
      • toProperties

        public Properties toProperties​(DataSource data)
        Get a properties object containing all of the members of this datasource object. Note that driver properties will be nested and delimited by a semicolon.
        data - DataSource to serialize into properties.
        a properties object corresponding to this datasource
      • getConnectionPropertiesAsASemicolonDelimitedString

        public String getConnectionPropertiesAsASemicolonDelimitedString​(DataSource data)
        tests to see if the value is null before attempting to join the database properties on a semicolon.
        data - DataSource to parse connection properties from.
        property string delimited by semicolon, or null, if they cannot be parsed because the input properties weren't set or empty
      • convertToResource

        public Resource convertToResource​(DataSource ds,
                                          String resourceType,
                                          String driverParameter)
        This method converts the DataSource to a Resource.
        ds - DataSource to convert to a resource.
        resourceType - the type of the Resource to convert to. ex. javax.sql.DataSource
        driverParameter - the name of the parameter to store driverClass.
        a Resource representing the assignable fields of the DataSource.