Announcement Announcement Module
Collapse
No announcement yet.
How to autoproxy a bean by its related package ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to autoproxy a bean by its related package ?

    Hi all,
    To manage transactions in my app, I've declared a txManager, associated with a BeanNameAutoProxyCreator
    Currently, I've this configuration :
    Code:
    	<bean id="txBeanNameProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    		<property name="beanNames">
    			<list>
    				<value>*-manager</value>
    			</list>
    		</property>
    		<property name="interceptorNames">
    			<list>
    				<value>txInterceptor</value>
    			</list>
    		</property>
    	</bean>
    The problem is :
    • All beans names terminated by "-manager" are autoproxied
    • When a bean needs transactions support, I must give it a name terminated by "-manager"
    My question is : is there any possibilities to autoproxy by package name instead of bean name. For example, by indicating that all classes (and their associated beans) in the package "com.mypackage.manager" must be autoproxied ?

    Thx for your response

  • #2
    Why don't you try with pointcuts ?
    For example:
    Code:
    execution(*com.xyz.service.*.*(..))
    All methods in a certain package.

    Comment


    • #3
      Thanks for your response, I'll try this
      However, I was looking for a solution which does not use pointcuts but some class like BeanNameAutoProxyCreator

      Comment


      • #4
        I think you can play with DefaultAdvisorAutoProxyCreator and create your own logic for auto-proxying.

        Comment

        Working...
        X