Spring Tutorial Home

  • Managing Database Transactions
  • Remoting in Spring
  • Working with the Web Layer

Spring Home

Java Resources

Community

Site

Creating After Returning Advice

text zoom

Creating After Returning Advice


The after retruning advise is also same as the before advise. All the steps for creating the after returning advise is same as what we have seen in the previous examples. The only difference is in the <aop:config> settins where the point 1 is changed with the point 2 and then the advise becomes the after advise.


 



  1. <aop:before pointcut-ref="beforeMethodExecution" method="beforeMethod" />

  2. <aop:after-returning pointcut-ref="beforeMethodExecution" method="beforeMethod" />



 Output:- Now if we run the main class then the following output will get printed on console.


Sep 19, 2008 2:01:38 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh

INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@133f1d7: display name [org.springframework.context.support.ClassPathXmlApplicationContext@133f1d7]; startup date [Fri Sep 19 14:01:38 IST 2008]; root of context hierarchy

Sep 19, 2008 2:01:39 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions

INFO: Loading XML bean definitions from class path resource [com/visualbuilder/aop/beans.xml]

Sep 19, 2008 2:01:39 PM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory

INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@133f1d7]: org.springframework.beans.factory.support.DefaultListableBeanFactory@2bb514

Sep 19, 2008 2:01:39 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons

INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@2bb514: defining beans [service,advice,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.aop.aspectj.AspectJPointcutAdvisor#0,beforeMethodExecution]; root of factory hierarchy


This is the Test Advice Method for Name visualbuilder

The method is advised.


 

                    

Copyright © 2010 VisualBuilder. All rights reserved