Class MDRepositoryBean<T extends DataSourceAware>

All Implemented Interfaces:
Initializable, RegistrarBean, RegistrarBeanWithDefaultBeanClass, UnregisterAware
Direct Known Subclasses:

public abstract class MDRepositoryBean<T extends DataSourceAware> extends Object implements Initializable, UnregisterAware, RegistrarBeanWithDefaultBeanClass
Abstract class implementing bean to which should be used to create name aware repository pool. This class is responsible for creation of correct repository instances for every DataSource configured.
Created by andrzej on 15.03.2016.
  • Field Details

  • Constructor Details

    • MDRepositoryBean

      public MDRepositoryBean()
  • Method Details

    • getName

      public String getName()
      Returns name of a bean
      name of a bean
    • setDataSourceBean

      public void setDataSourceBean(DataSourceBean dataSourceBean)
    • registerIfNotExists

      public void registerIfNotExists(String name)
    • register

      public void register(Kernel kernel)
      Description copied from interface: RegistrarBean
      Method called when bean is being registered allowing developer to programatically register other beans.
      Specified by:
      register in interface RegistrarBean
      kernel - - instance from local scope
    • unregister

      public void unregister(Kernel kernel)
      Description copied from interface: RegistrarBean
      Method called while bean is being unregistered.
      Specified by:
      unregister in interface RegistrarBean
      kernel - - instance from local scope
    • initialize

      public void initialize()
      Description copied from interface: Initializable
      Method will be called, when bean will be created, configured and ready to use.
      Specified by:
      initialize in interface Initializable
    • beforeUnregister

      public void beforeUnregister()
      Description copied from interface: UnregisterAware
      Method called before bean unregister.
      Specified by:
      beforeUnregister in interface UnregisterAware
    • findClassForDataSource

      protected abstract Class<? extends T> findClassForDataSource(DataSource dataSource) throws DBInitException
      Method returns class implementing repository which supports data source instance provided in parameter.
      repository class
    • repositoriesStream

      protected Stream<T> repositoriesStream()
      Provides access to all available repository instances
      stream of repository instances
    • getRepositories

      protected Map<String,T> getRepositories()
      Provides access to unmodifiable map domain to repository instance
      map of domain to repository instance
    • getRepository

      protected T getRepository(String domain)
      Provides repository instance for passed domain name
      instance of repository
    • onDataSourceChange

      @HandleEvent protected void onDataSourceChange(DataSourceBean.DataSourceChangedEvent event)
    • initializeRepository

      protected void initializeRepository(String domain, T repo)
      Method called to initialized passed repository instance for passed domain.
      Should be empty if no custom initialization is required.
    • updateDataSourceAware

      protected void updateDataSourceAware(String domain, T newRepo, T oldRepo)
      Method called when repository instance for domain changes.
      domain - name of domain
      newRepo - new instance of repository
      oldRepo - old instance of repository