Package tigase.db.beans

## Class DataSourceBean

- java.lang.Object
- - tigase.db.beans.MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>
  - - tigase.db.beans.DataSourceBean

- All Implemented Interfaces:
    `RegistrarBean`, `RegistrarBeanWithDefaultBeanClass`, `ComponentStatisticsProvider`, `StatisticsProviderIfc`

      @Bean(name="dataSource",
            parent=Kernel.class,
            active=true,
            exportable=true)
      @ConfigType({DefaultMode,SessionManagerMode,ConnectionManagersMode,ComponentMode})
      public class DataSourceBean
      extends MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>
      implements ComponentStatisticsProvider

  This is main bean responsible for managing and initialization of data sources. Created by andrzej on 09.03.2016.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `DataSourceBean.DataSourceChangedEvent` | Event emitted by `DataSourceBean` using `EventBus` when instance of `DataSource` for some name changes.
    `static class` | `DataSourceBean.DataSourceMDConfigBean` |

  - ### Field Summary

    - ### Fields inherited from class tigase.db.beans.MDPoolBean

      `POOL_CLASS, POOL_SIZE, REPO_CLASS, REPO_URI`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DataSourceBean()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addRepo​(java.lang.String domain, DataSource repo)` | Add data source instance to the pool
    `protected java.util.concurrent.ScheduledFuture` | `addWatchdogTask​(java.lang.Runnable task, java.time.Duration frequency)` |
    `boolean` | `belongsTo​(java.lang.Class<? extends BasicComponent> component)` |
    `void` | `everyHour()` |
    `void` | `everyMinute()` |
    `void` | `everySecond()` |
    `java.lang.Class<? extends DataSourceBean.DataSourceMDConfigBean>` | `getConfigClass()` | Returns per domain configuration class
    `java.util.Set<java.lang.String>` | `getDataSourceNames()` | Retrieve list of all available data source names
    `java.lang.Class<?>` | `getDefaultBeanClass()` | Returns default class for all bean which are defined using configuration as subbeans of bean implementing this interface.
    `DataSource` | `getRepository​(java.lang.String name)` | Retrieves data source for provided name
    `void` | `getStatistics​(java.lang.String compName, StatisticsList list)` |
    `DataSource` | `removeRepo​(java.lang.String domain)` | Remove data source from the pool
    `protected void` | `removeWatchdogTask​(java.util.concurrent.ScheduledFuture scheduledFuture)` |
    `void` | `setDefault​(DataSource repo)` | Method called to set default repo instance.

    - ### Methods inherited from class tigase.db.beans.MDPoolBean

      `getDefaultAlias, getName, register, registerConfigBean, unregister`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DataSourceBean

          public DataSourceBean()

  - ### Method Detail

    - #### getRepository

          public DataSource getRepository​(java.lang.String name)

      Retrieves data source for provided name
      Parameters:
        `name` - of data source to retrieve
      Returns:
        instance of data source for name or default instance of data source

    - #### getConfigClass

          public java.lang.Class<? extends DataSourceBean.DataSourceMDConfigBean> getConfigClass()

      Description copied from class: `MDPoolBean`
      Returns per domain configuration class
      Specified by:
        `getConfigClass` in class `MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>`
      Returns:
        class

    - #### addRepo

          public void addRepo​(java.lang.String domain,
                              DataSource repo)

      Add data source instance to the pool
      Specified by:
        `addRepo` in class `MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>`
      Parameters:
        `domain` - name of data source
        `repo` - instance of data source

    - #### removeRepo

          public DataSource removeRepo​(java.lang.String domain)

      Remove data source from the pool
      Specified by:
        `removeRepo` in class `MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>`
      Parameters:
        `domain` - name of data source
      Returns:
        removed instance of data source

    - #### getDataSourceNames

          public java.util.Set<java.lang.String> getDataSourceNames()

      Retrieve list of all available data source names
      Returns:
        list of names

    - #### setDefault

          public void setDefault​(DataSource repo)

      Description copied from class: `MDPoolBean`
      Method called to set default repo instance.
      Specified by:
        `setDefault` in class `MDPoolBean<DataSource,​DataSourceBean.DataSourceMDConfigBean>`
      Parameters:
        `repo` - instance of repo

    - #### belongsTo

          public boolean belongsTo​(java.lang.Class<? extends BasicComponent> component)

      Specified by:
        `belongsTo` in interface `ComponentStatisticsProvider`

    - #### everyHour

          public void everyHour()

      Specified by:
        `everyHour` in interface `ComponentStatisticsProvider`

    - #### everyMinute

          public void everyMinute()

      Specified by:
        `everyMinute` in interface `ComponentStatisticsProvider`

    - #### everySecond

          public void everySecond()

      Specified by:
        `everySecond` in interface `ComponentStatisticsProvider`

    - #### getStatistics

          public void getStatistics​(java.lang.String compName,
                                    StatisticsList list)

      Specified by:
        `getStatistics` in interface `StatisticsProviderIfc`

    - #### getDefaultBeanClass

          public java.lang.Class<?> getDefaultBeanClass()

      Description copied from interface: `RegistrarBeanWithDefaultBeanClass`
      Returns default class for all bean which are defined using configuration as subbeans of bean implementing this interface. This allows users to have more convenient configuration file without the need to specify class for each of subbbeans if most of them will have the same class.
      Specified by:
        `getDefaultBeanClass` in interface `RegistrarBeanWithDefaultBeanClass`

    - #### addWatchdogTask

          protected java.util.concurrent.ScheduledFuture addWatchdogTask​(java.lang.Runnable task,
                                                                         java.time.Duration frequency)

    - #### removeWatchdogTask

          protected void removeWatchdogTask​(java.util.concurrent.ScheduledFuture scheduledFuture)