Announcement Announcement Module
Collapse
No announcement yet.
Help! Cannot get advice to "fire" Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help! Cannot get advice to "fire"

    Here's the setup servlet-context.xml:

    Code:
    <bean id="breakInjector" class="ks.rah.avik2.web.form.support.AddHtmlBreakInterceptor"/>
    	
    	<bean id="breakInjectorTarget" class="ks.rah.avik2.logic.LogicFacadeImpl">
    		<property name="sessionFactory"><ref bean="sessionFactory"/></property>
    	</bean>
    	
    	<!-- Interceptor to inject <br>-tags into output -->
    	<bean id="breakInjectorPointcut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
    		<property name="advice"><ref local="breakInjector"/></property>
    		<property name="patterns">
    			<list>
    				<value>.*</value>
    			</list>
    		</property>
    	</bean>
    	
    	<bean id="debugInterceptor" class="org.springframework.aop.interceptor.DebugInterceptor">
    	</bean>
    	
    	<bean id="breakInjectorProxy" class="org.springframework.aop.framework.ProxyFactoryBean">		
    		<property name="proxyInterfaces"><value>ks.rah.avik2.logic.LogicFacade</value></property>
    		<property name="target"><ref bean="logic"/></property>
    		<property name="interceptorNames">
    			<list>
    				<value>breakInjector</value>
    				<value>debugInterceptor</value>
    			</list>		
    		</property>
    	</bean>
    The logicImpl (in applicationContext-hibernate)

    Code:
    <bean id="logicImpl" class="ks.rah.avik2.logic.LogicFacadeImpl">
    		<property name="sessionFactory"><ref local="sessionFactory"/></property>
    		<property name="userDao"><ref local="userDao"/></property>
    		<property name="eventDao"><ref local="eventDao"/></property>
    		<property name="posDao"><ref local="positionDao"/></property>
    		<property name="deptDao"><ref local="departmentDao"/></property>
    		<property name="locDao"><ref local="locationDao"/></property>
    		<property name="uiDao"><ref local="uiDao"/></property>
    		<property name="funcDao"><ref local="funcDao"/></property>
    		<property name="tentryDao"><ref local="tentryDao"/></property>
    	</bean>
    Relevant method of interceptor:

    Code:
    public class AddHtmlBreakInterceptor implements MethodInterceptor &#123;
    	
    	public static Logger log = Logger.getLogger&#40;"AddHtmlBreakInterceptor"&#41;;
    	
    	public Object invoke&#40;MethodInvocation invocation&#41; throws Throwable&#123;
    		log.debug&#40;"AddHtmlBreakInterceptor invoked"&#41;;
    		System.out.println&#40;"Holy smoke!"&#41;;
    		return invocation.proceed&#40;&#41;;
    	
    	&#125;
    No traces from log or System.out. No 'Holy smoke!'. Zip. Zero.

    I thought that '.*' meant any method/pattern.

    Help please.

  • #2
    Correction

    'logic' should be 'logicImpl'
    It still doesn't work.

    Comment


    • #3
      What bean do you access from your client code? breakInjectorProxy?

      Comment


      • #4
        I access the 'logicImpl' (listed as 'logic' in the first post) which is the main business facade implementation. Hence the

        Code:
        AddHtmlBreakInterceptor
        should fire every time the app hits the database, so there should be a lot of traces. It isn't, of course, invoked directly, but indirectly through a lot of MVC webcontrollers.

        Comment


        • #5
          You should be using breakInjectorProxy.
          HTH

          Comment


          • #6
            You should be using breakInjectorProxy.
            OK....
            I don't understand.
            Isn't the "target" property of the ProxyFactoryBean meant to hide the application from the need to explicitly fetch the ProxyFactoryBean?

            But it works. I apparently have been able to miss this little detail.

            I suggest a minor adjustment to the part of Spring docs that says:
            The "person" bean definition above can be used in place of a Person implementation, as follows:

            Person person = (Person) factory.getBean("person");
            to

            In order to be able to use AOP functionality the "person" bean definition above MUST be used in place of a Person implementation, as follows:

            Person person = (Person) factory.getBean("person");
            Anyway, thanks for your help and patience.

            Comment

            Working...
            X