Announcement Announcement Module
Collapse
No announcement yet.
TransactionProxyFactoryBean for non-singleton Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • TransactionProxyFactoryBean for non-singleton

    The Javadoc for org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean says,

    “This class is intended to cover the typical case of declarative transaction demarcation: namely, wrapping a (singleton) target object with a transactional proxy, proxying all the interfaces that the target implements.”
    (emphasis added).

    I can't quite get my arms around why this is only possible with singleton classes. Is this truly the case? Or is the singleton just a recommendation and I have other problems?

    - Justin Makeig

  • #2
    Justin, the comment is correct. (Of course the reference to "singleton" means a Spring singleton-scoped bean, not a GoF Singleton, but I'm sure you're aware of that.)

    TransactionProxyFactoryBean's pre and post interceptors lists are lists of bean references, rather than bean names (like ProxyFactoryBean's interceptorNames list). While this is a bit more intuitive and appropriate for common use, it means that you can't control whether or not an independent instance of each Advisor should be used for distinct proxies, and hence you don't have the full control that ProxyFactoryBean gives you over the shared/non-shared nature of both the target and all Advisors.

    Comment

    Working...
    X