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(value={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 and 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 and Description
    `DataSourceBean()`

  - ### Method Summary

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

      Specified by:
        `getStatistics` in interface `StatisticsProviderIfc`

    - #### getDefaultBeanClass

          public 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 ScheduledFuture addWatchdogTask(Runnable task,
                                                    Duration frequency)

    - #### removeWatchdogTask

          protected void removeWatchdogTask(ScheduledFuture scheduledFuture)

Copyright © 2004–2020 "Tigase, Inc.". All rights reserved.