Class JdbcProvider

  • All Implemented Interfaces:
    IDataSourceKeeper, org.osgi.service.cm.ManagedService

    public class JdbcProvider
    extends Object
    implements org.osgi.service.cm.ManagedService, IDataSourceKeeper

    Export DataSource instances as OSGi services with the given properties.

    This bundle reads in configuration properties from the configuration PID org.clazzes.jdbc.provider following the convention datasource.<name>.<propname>, where designates the name of the datasource as published under the datasource.name OSGi service property.

    <propname> designates a property of BasicDataSource to be set for the published datasource instance.

    The following properties are supported:

    PropertyBasicDataSource docRemarks
    url BasicDataSource.setUrl(String)
    username{@link BasicDataSource#setUsername(String)
    password{@link BasicDataSource#setPassword(String)
    driverClassName{@link BasicDataSource#setDriverClassName(String) The driver class is resolved from the class loader of the jdbc-provider bundle. This allows for putting JDBC driver on the boot classloader of the OSGi container or creating fragment bundles, which supply JDBC drivers to the jdbc-provider bundle. For MySQL, MSSQL, PostgreSql and Oracle JDBC.URLs the driver class name is automatically deduced from url.
    validationQueryBasicDataSource.setValidationQuery(String)
    testOnBorrowBasicDataSource.setTestOnBorrow(boolean) If unspecified, this property is set to true, if validationQuery has been specified.
    testOnReturnBasicDataSource.setTestOnReturn(boolean)
    testWhileIdleBasicDataSource.setTestWhileIdle(boolean)
    defaultCatalogBasicDataSource.setDefaultCatalog(String)Needed, if your driver supports catalogs.
    defaultAutoCommitBasicDataSource#setDefaultAutoCommit(boolean)
    defaultTransactionIsolationBasicDataSource.setDefaultTransactionIsolation(int)
    defaultReadOnlyBasicDataSource#setDefaultReadOnly(boolean)
    initialSizeBasicDataSource.setInitialSize(int)
    minIdleBasicDataSource.setMinIdle(int)
    minEvictableIdleTimeMillisBasicDataSource.setMinEvictableIdleTimeMillis(long)
    maxActiveBasicDataSource#setMaxActive(int)
    maxIdleBasicDataSource.setMaxIdle(int)
    maxWaitBasicDataSource#setMaxWait(long)
    maxOpenPreparedStatementBasicDataSource.setMaxOpenPreparedStatements(int)
    timeBetweenEvictionRunsMillisBasicDataSource.setTimeBetweenEvictionRunsMillis(long)
    connectionInitSqlsBasicDataSource.setConnectionInitSqls(java.util.Collection)The String property is split at semicolon characters and passed as a list of strings.
    connectionPropertiesBasicDataSource.setConnectionProperties(String)
    poolPreparedStatementsBasicDataSource.setPoolPreparedStatements(boolean)
    accessToUnderlyingConnectionAllowedBasicDataSource.setAccessToUnderlyingConnectionAllowed(boolean)
    removeAbandonedBasicDataSource#setRemoveAbandoned(boolean)
    removeAbandonedTimeoutBasicDataSource.setRemoveAbandonedTimeout(int)
    healthTags Comma-separated health check tags. If set, the datasource is registered as a felix health check. The tag jdbc will be added, if not specified in the given list.
    healthQuery SQL query to perform as health check. The query mus return one row an one column.
    healthInterval See hc.async.intervalInSec Interval in seconds at which to perform health checks. If not specified, 60 seconds are used.
    healthKeepNonOkResultsStickyForSec See hc.keepNonOkResultsStickyForSec Interval in seconds to keep negtive health check results. If not specified, negative results will not be kept longer then healthInterval seconds.

    • Constructor Detail

      • JdbcProvider

        public JdbcProvider()
    • Method Detail

      • updated

        public void updated​(Dictionary properties)
                     throws org.osgi.service.cm.ConfigurationException
        Specified by:
        updated in interface org.osgi.service.cm.ManagedService
        Throws:
        org.osgi.service.cm.ConfigurationException
      • init

        public void init()
                  throws IOException
        An init-method for blueprint in order to create an empty configuration.
        Throws:
        IOException
      • shutdown

        public void shutdown()
        A destroy-method for blueprint in order to shut down all datasources.
      • setBundle

        public void setBundle​(org.osgi.framework.Bundle bundle)
        Parameters:
        bundle - The bundle to set, which is used to export DataSource OSGi services.
      • restartDataSource

        public boolean restartDataSource​(String name)
                                  throws org.osgi.service.cm.ConfigurationException
        Description copied from interface: IDataSourceKeeper
        Restart and possibly re-export the given datasource as an OSGi service.
        Specified by:
        restartDataSource in interface IDataSourceKeeper
        Parameters:
        name - The name of the datasource to restart.
        Throws:
        org.osgi.service.cm.ConfigurationException
      • setConfigurationAdmin

        public void setConfigurationAdmin​(org.osgi.service.cm.ConfigurationAdmin configurationAdmin)
      • setOneTimeScheduler

        public void setOneTimeScheduler​(org.clazzes.util.sched.IOneTimeScheduler oneTimeScheduler)