Announcement Announcement Module
Collapse
No announcement yet.
aop:config and factory-bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • aop:config and factory-bean

    I am trying to use some aop and at the same time i create bean with the factory -bean definition.

    I define my aop configuration


    Code:
    <aop:config>
            <aop:aspect ref="ilInterceptor">
                <aop:pointcut id="ilService"
                    expression="@target(com.my.package.common.stereotype.ILService)" />
                <aop:around pointcut-ref="ilService" method="invokeMethod" />
            </aop:aspect>
        </aop:config>
    
    
        <context:annotation-config />
        <context:component-scan base-package="com.my.package.common" />
    Than I define a bean with the factory bean method.
    Code:
    <bean id="cacheAdministrator"
            class="com.opensymphony.oscache.general.GeneralCacheAdministrator"
            destroy-method="destroy" />
    
        <bean id="cache" factory-bean="cacheAdministrator"
            factory-method="getCache" />
    I go this error
    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cache' defined in class path resource [capi-beans.xml]: No matching factory method found: factory bean 'cacheAdministrator'; factory method 'getCache'
        at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:396)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:871)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:785)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:437)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:404)
        at java.security.AccessController.doPrivileged(AccessController.java:193)

    Its look like the aop:config create a proxy around all bean define. is there a way to avoid this ?


    Thanks Francis

  • #2
    Try the following:

    Change:

    Code:
    @target(com.my.package.common.stereotype.ILService)
    to

    Code:
    execution(* (@com.my.package.common.stereotype.ILService *).*(..))
    This would be more efficient anyway.

    -Ramnivas

    Comment


    • #3
      tks for the answer.

      I am still new with the aspectJ language expression.

      Comment

      Working...
      X