Announcement Announcement Module
Collapse
No announcement yet.
Problem with AOP pointcut for before advice Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with AOP pointcut for before advice

    Hi All,

    I am a newbee to the Spring Framework and am confused with the AOP concepts.

    I want to intercept a method call with before advice , and hence i have configured the following entry in application_context.xml file

    Defined an Advice as followes:

    <bean id="serviceAuthorizationAdvice"
    class="com.sp.cms.core.advice.ServiceAuthorization Advice">
    <property name="objContext" ref="userContext" />
    </bean>

    <aop:advisor id="methodServiceAuthorizationAdvisor"
    pointcut="execution(* com.sp.cms.ce.command.SmartworkCommandHandlerImpl. *(..))"
    advice-ref="serviceAuthorizationAdvice" />



    SmartworkCommandHandlerImpl class gets called from 2 different beans:

    Bean 1:

    <bean id="baseBO" abstract="true"
    class="com.sp.cms.core.biz.BaseBO">
    <property name="commandHandler"
    ref="smartworkCommandHandlerImpl" />
    </bean>

    Bean 2:
    <bean id="referDataMajorRegionHandler"
    class="com.sp.cms.ce.refdata.impl.handler.Referenc eDataMajorRegionHandler">
    <property name="commandHandler">
    <ref local="smartworkCommandHandlerImpl" />
    </property>

    </bean>

    ---------------------
    ref Bean for smartworkCommandHandlerImpl

    <bean id="smartworkCommandHandlerImpl" scope="prototype"
    cass="com.sp.cms.ce.command.SmartworkCommandHandle rImpl" />

    On Execution Before advice is invoked successfully from Bean 2 , but when i am trying to invoke from Bean 1 it is not getting invoked.

    I have created a new bean Id
    <bean id="smartworkCommandHandlerImplService" scope="prototype"
    cass="com.sp.cms.ce.command.SmartworkCommandHandle rImpl" />

    and mapped this to bean 1 as follows and it started working as expected.

    <bean id="baseBO" abstract="true"
    class="com.sp.cms.core.biz.BaseBO">
    <property name="commandHandler"
    ref="smartworkCommandHandlerImplService" />
    </bean>

    I am confused as to why it is working when i have defined a new beanid for the same class and changed the reference.

    Please help me on solving this confusion as i know it is not a correct solution by duplicating the bean ids.

    Appreciate support on this.

    Thanks,
    rani.
Working...
X