Announcement Announcement Module
Collapse
No announcement yet.
Configuring proxing beans in Spring aop + cglib Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    By fixing your pointcuts, it shouldn't be proxied in the first place so find the pointcut that triggers proxy creation for this bean.

    Comment


    • #3
      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?

      Comment

      Working...
      X