Package: org.grails.transaction

## [Java] Class ChainedTransactionManagerPostProcessor

- org.grails.transaction.ChainedTransactionManagerPostProcessor

- All Implemented Interfaces and Traits:
    org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.core.Ordered

      public class ChainedTransactionManagerPostProcessor
      extends java.lang.Object

  A org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor for using the "Best Effort 1 Phase Commit" (BE1PC) in Grails applications when there are multiple data sources. When the context contains multiple transactionManager beans, the bean with the name "transactionManager" will be renamed to "$primaryTransactionManager" and a new ChainedTransactionManager bean will be added with the name "transactionManager". All transactionManager beans will be registered in the ChainedTransactionManager bean. The post processor checks if the previous transactionManager bean is an instance of org.springframework.transaction.jta.JtaTransactionManager. In that case it will not do anything since it's assumed that JTA/XA is handling transactions spanning multiple datasources. For performance reasons an additional dataSource can be marked as non-transactional by adding a property 'transactional = false' in it's dataSource configuration. This will leave the dataSource out of the transactions initiated by Grails transactions. This is the default behaviour in Grails versions before Grails 2.3.6 .

  Authors:
    Lari Hotari
  Since:
    2.3.6

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static java.lang.String` | `DATA_SOURCES_PREFIX` |
    `static java.lang.String` | `DATA_SOURCES_SETTING` |
    `static java.lang.String` | `DATA_SOURCE_SETTING` |

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `java.lang.String` | `beanNameBlacklistPattern`
    `java.lang.String` | `beanNameInternalBlacklistPattern`
    `java.lang.String` | `beanNameWhitelistPattern`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ChainedTransactionManagerPostProcessor (Config config)`
    `ChainedTransactionManagerPostProcessor (Config config, java.lang.String whitelistPattern, java.lang.String blacklistPattern)`
    `ChainedTransactionManagerPostProcessor ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected org.springframework.beans.factory.config.BeanDefinition` | `addChainedTransactionManager(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `protected int` | `countChainableTransactionManagerBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `protected org.springframework.beans.factory.support.ManagedList<org.springframework.beans.factory.config.RuntimeBeanReference>` | `createTransactionManagerBeanReferences(org.springframework.beans.factory.config.BeanDefinition chainedTransactionManagerBeanDefinition)`
    `` | `java.lang.String` | `getBeanNameBlacklistPattern()`
    `` | `java.lang.String` | `getBeanNameInternalBlacklistPattern()`
    `` | `java.lang.String` | `getBeanNameWhitelistPattern()`
    `` | `int` | `getOrder()`
    `` | `protected static java.lang.String[]` | `getTransactionManagerBeanNames(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `protected boolean` | `hasJtaOrChainedTransactionManager(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `protected boolean` | `isNotTransactional(java.lang.String suffix)`
    `` | `protected boolean` | `isValidTransactionManagerBeanDefinition(java.lang.String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)`
    `` | `void` | `postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `void` | `postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)`
    `` | `protected void` | `registerAdditionalTransactionManagers(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.beans.factory.config.BeanDefinition chainedTransactionManagerBeanDefinition, org.springframework.beans.factory.support.ManagedList<org.springframework.beans.factory.config.RuntimeBeanReference> transactionManagerRefs)`
    `` | `protected java.lang.String` | `resolveDataSourceSuffix(java.lang.String transactionManagerBeanName)`
    `` | `protected java.lang.Class<?>` | `resolveTransactionManagerClass(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)`
    `` | `void` | `setBeanNameBlacklistPattern(java.lang.String beanNameBlacklistPattern)`
    `` | `void` | `setBeanNameInternalBlacklistPattern(java.lang.String beanNameInternalBlacklistPattern)`
    `` | `void` | `setBeanNameWhitelistPattern(java.lang.String beanNameWhitelistPattern)`
    `` | `void` | `setConfig(Config config)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Field Detail

    - #### public static final java.lang.String DATA_SOURCES_PREFIX

    - #### public static final java.lang.String DATA_SOURCES_SETTING

    - #### public static final java.lang.String DATA_SOURCE_SETTING

  - ### Property Detail

    - #### java.lang.String beanNameBlacklistPattern

    - #### java.lang.String beanNameInternalBlacklistPattern

    - #### java.lang.String beanNameWhitelistPattern

  - ### Constructor Detail

    - #### public ChainedTransactionManagerPostProcessor(Config config)

    - #### public ChainedTransactionManagerPostProcessor(Config config, java.lang.String whitelistPattern, java.lang.String blacklistPattern)

    - #### public ChainedTransactionManagerPostProcessor()

  - ### Method Detail

    - #### protected org.springframework.beans.factory.config.BeanDefinition addChainedTransactionManager(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### protected int countChainableTransactionManagerBeans(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### protected org.springframework.beans.factory.support.ManagedList<org.springframework.beans.factory.config.RuntimeBeanReference> createTransactionManagerBeanReferences(org.springframework.beans.factory.config.BeanDefinition chainedTransactionManagerBeanDefinition)

    - #### public java.lang.String getBeanNameBlacklistPattern()

    - #### public java.lang.String getBeanNameInternalBlacklistPattern()

    - #### public java.lang.String getBeanNameWhitelistPattern()

    - #### @java.lang.Override public int getOrder()

    - #### protected static java.lang.String[] getTransactionManagerBeanNames(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### protected boolean hasJtaOrChainedTransactionManager(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### protected boolean isNotTransactional(java.lang.String suffix)

    - #### protected boolean isValidTransactionManagerBeanDefinition(java.lang.String beanName, org.springframework.beans.factory.config.BeanDefinition beanDefinition)

    - #### @java.lang.Override public void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### @java.lang.Override public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)

    - #### protected void registerAdditionalTransactionManagers(org.springframework.beans.factory.support.BeanDefinitionRegistry registry, org.springframework.beans.factory.config.BeanDefinition chainedTransactionManagerBeanDefinition, org.springframework.beans.factory.support.ManagedList<org.springframework.beans.factory.config.RuntimeBeanReference> transactionManagerRefs)

    - #### protected java.lang.String resolveDataSourceSuffix(java.lang.String transactionManagerBeanName)

    - #### protected java.lang.Class<?> resolveTransactionManagerClass(org.springframework.beans.factory.support.BeanDefinitionRegistry registry)

    - #### public void setBeanNameBlacklistPattern(java.lang.String beanNameBlacklistPattern)

    - #### public void setBeanNameInternalBlacklistPattern(java.lang.String beanNameInternalBlacklistPattern)

    - #### public void setBeanNameWhitelistPattern(java.lang.String beanNameWhitelistPattern)

    - #### public void setConfig(Config config)