Announcement Announcement Module
Collapse
No announcement yet.
DefaultAdvisorAutoProxyCreator Basics Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultAdvisorAutoProxyCreator Basics

    I have a basic question in setting DefaultAdvisorAutoProxyCreator in spring Application Context. I created methodInterceptor class to log some messages . If I use beanCreatorFactory and specify each object , it works fine. I want to apply methodInterceptor logging for all the objects defined in the xml. I did create an advisor and pointed to my methodinterceptor class. I am missing some basics here , for some reason it not working correctly. Here is my XML



    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <!-- Import Definitions -->
    <import resource="applicationContext-DB.xml"/>
    <import resource="applicationContext-Logger.xml"/>
    <!-- Bean Definitions -->
    <bean class="org.springframework.aop.framework.autoproxy .DefaultAdvisorAutoProxyCreator"/>

    <bean id="preEnrollmentExtract" class="org.springframework.scheduling.quartz.CronT riggerBean">
    <property name="jobDetail" ref="preEnrollmentExtractJobDetails"/>
    <property name="cronExpression" value="0 42 9 ? * MON-SAT"/>
    </bean>
    <bean id="preEnrollmentExtractJobDetails" class="org.springframework.scheduling.quartz.Metho dInvokingJobDetailFactoryBean" destroy-method="close">
    <property name="targetObject" ref="preEnrollmentProcessor"/>
    <property name="targetMethod" value="executePreEnrollmentPacketProcess"/>
    </bean>
    <bean id="quartzScheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean" destroy-method="close">
    <property name="schedulerName" value="jobScheduler"/>
    <property name="triggers">
    <list>
    <ref bean="preEnrollmentExtract"/>
    </list>
    </property>
    </bean>
    <bean id="harteHanksDAO" parent="user.txTemplate">
    <property name="proxyInterfaces">
    <list>
    <value>com.pearson.pdp.hartehanks.dataaccess.Harte HanksDAO</value>
    </list>
    </property>
    <property name="target">
    <bean class="com.pearson.pdp.hartehanks.dataaccess.Harte HanksDAOImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    </property>

    </bean>
    <bean id="preEnrollmentProcessor" class="org.springframework.aop.framework.ProxyFact oryBean" >
    <property name="target">
    <ref local="preEnrollmentProcessorTarget"/>
    </property>
    <property name="proxyInterfaces">
    <list>
    <value>com.pearson.pdp.hartehanks.dataaccess.Harte HanksDAO</value>
    </list>
    </property>
    <property name="proxyTargetClass">
    <value>true</value>
    </property>
    <property name="interceptorNames">
    <list>
    <value>logInterceptor</value>
    <value>global_debug</value>
    <value>global_performance</value>
    </list>
    </property>
    </bean>
    <bean id="preEnrollmentProcessorTarget" class="com.pearson.pdp.hartehanks.PreEnrollmentPac ketProcessScheduler">
    <property name="logger">
    <bean id="myLogger" parent="parent.logger">
    <constructor-arg index="0">
    <value>HarteHanksPreEnrollmentProcessor</value>
    </constructor-arg>
    <constructor-arg index="4">
    <value>FINEST</value>
    </constructor-arg>
    </bean>
    </property>
    <property name="extractProcessor">
    <bean class="com.pearson.pdp.hartehanks.file.PreEnrollme ntPacketExtractProcess">
    <property name="harteHanksDAO" ref="harteHanksDAO">
    </property>
    </bean>
    </property>

    </bean>
    <bean id="logInterceptor" class="com.pearson.pdp.logging.PDPAOPLogger">
    </bean>
    <bean id="global_debug" class="org.springframework.aop.interceptor.DebugIn terceptor">
    </bean>
    <bean id="global_performance" class="org.springframework.aop.interceptor.Perform anceMonitorInterceptor">
    </bean>

    <bean id="advisor" class="org.springframework.aop.support.RegexpMetho dPointcutAdvisor">
    <property name="advice">
    <ref bean="logInterceptor"/>
    </property>
    <property name="pattern">
    <value>HarteHanksDAO*</value>
    </property>
    </bean>

    </beans>

  • #2
    Seems to be the regex pattern you are using: HarteHanksDAO* that will not match any method from com.pearson.pdp.hartehanks.dataaccess.HarteHanksDA OImpl. Replace it with .*HarteHanksDAO.* that will match al he methods from that class.

    Comment


    • #3
      Thanks, let me try that.

      Comment

      Working...
      X