Results 1 to 4 of 4

Thread: How to autoproxy a bean by its related package ?

  1. #1
    Join Date
    Feb 2006
    Posts
    7

    Default 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. #2
    Join Date
    Mar 2007
    Posts
    515

    Default

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

  3. #3
    Join Date
    Feb 2006
    Posts
    7

    Default

    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

  4. #4
    Join Date
    Mar 2007
    Posts
    515

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •