Skip to content

Conversation

@artembilan
Copy link
Member

Fixes #2695

To configure a proxyTargetClass=true we need declare a
PublisherAnnotationBeanPostProcessor bean manually, but that may cause
a confuse when @EnablePublisher is still present.
So, target service is proxied twice

  • Expose proxyTargetClass and order into the @EnablePublisher
    and <enable-publisher>
  • Refactor PublisherAnnotationBeanPostProcessor to extend an
    AbstractBeanFactoryAwareAdvisingPostProcessor to avoid AOP boilerplate
    code altogether
  • Add assertion into the PublisherAnnotationBeanPostProcessor to be
    sure that only one of its instance is present in the application context

Fixes spring-projects#2695

To configure a `proxyTargetClass=true` we need declare a
`PublisherAnnotationBeanPostProcessor` bean manually, but that may cause
a confuse when `@EnablePublisher` is still present.
So, target service is proxied twice

* Expose `proxyTargetClass` and `order` into the `@EnablePublisher`
and `<enable-publisher>`
* Refactor `PublisherAnnotationBeanPostProcessor` to extend an
`AbstractBeanFactoryAwareAdvisingPostProcessor` to avoid AOP boilerplate
code altogether
* Add assertion into the `PublisherAnnotationBeanPostProcessor` to be
sure that only one of its instance is present in the application context
Copy link
Contributor

@garyrussell garyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor polishings...

catch (NoUniqueBeanDefinitionException ex) {
throw new BeanCreationNotAllowedException(this.name,
"Only one 'PublisherAnnotationBeanPostProcessor' bean can be defined in the application context." +
" Consider do not use '@EnablePublisher' (or '<int:enable-publisher>') if you declare" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use '@EnablePublisher' (or '<int:enable-publisher>') if you declare a

----
====

Starting with version 5.1.3, the `<int:enable-publisher>` component, as well as `@EnablePublisher` annotation are supplied with the `proxy-target-class` and `order` attributes for tuning a `ProxyFactory` configuration.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as well as the @EnablePublisher ...

s/are supplied with the/have the/

for tuning the ProxyFactory

@garyrussell garyrussell merged commit 462dc98 into spring-projects:master Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can configure @EnablePublisher(proxyTargetClass=true)

2 participants