Results 1 to 3 of 3

Thread: Configuring proxing beans in Spring aop + cglib

  1. #1
    Join Date
    Dec 2012
    Posts
    2

    Default Configuring proxing beans in Spring aop + cglib

    We've got a Spring 3.1 web-application using spring-aop with cglib library.
    spring.xml:

    Code:
        <context:annotation-config/>
        <aop:aspectj-autoproxy proxy-target-class="true"/>
    That means that a proxy will be created using cglib for every bean.

    Now we need to use a db connection pool bean with com.mchange.v2.c3p0.ComboPooledDataSource:

    Code:
        <bean id="connectionPool" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
        <!-- here are some properties -->
        </bean>
    The problem is the ComboPooledDataSource class is marked as final. And cglib can't proxy final classes.

    How to mark "connectionPool" bean not to be proxied?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    By fixing your pointcuts, it shouldn't be proxied in the first place so find the pointcut that triggers proxy creation for this bean.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Dec 2012
    Posts
    2

    Default

    Quote Originally Posted by Marten Deinum View Post
    By fixing your pointcuts, it shouldn't be proxied in the first place so find the pointcut that triggers proxy creation for this bean.
    I confugured pointcuts with @annotation rule.
    I've got an annotation @Log and mark my beans with it.
    My AbstractDao bean uses connectionPool this way:
    Code:
    @Autowired
    private DataSource connectionPool;
    And AbstractDao is marked with @Log annotation.

    Pointcut looks this way:
    Code:
    @Pointcut("(@annotation(Log) || @target(Log)) && !@annotation(NotLog)")
    public void allLog() {
    }
    It seems to me that connectionPool isn't triggered by allLog pointcut... Or I'm mistaken?

Tags for this Thread

Posting Permissions

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