gavlyukovskiy/spring-boot-data-source-decorator

proxyDataSourceDecorator bean should be overridable

janput opened this issue · 3 comments

Currently the bean is created without @ConditionalOnMissingBean which only allows for creating an additional bean with a different name. This has as a result that queries will be logged twice because all decorated datasources will be decorated twice.
Also I propose to make the constructor of ProxyDataSourceDecorator protected so it can be called from subclasses to make overriding the behaviour easier. Because right now it is package private so unable to call the super constructor.

The reason there is no @ConditionalOnMissingBean on proxyDataSourceDecorator bean is that it's not supposed to be pluggable. Why do you want to use your own bean there?

To solve the issue #75 because the naming of the decorated datasource doens't work. If you have multiple datasources they all get the same name dataSource

DataSourceNameResolver is @ConditionalOnMissingBean so you can provide your own to be used for decoration.
I will take a look at your other issue, but passing bean name there, as you suggested, is not an option as it would change the interface.