Spring Tutorial Home

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

Spring Home

Java Resources

Community

Site

Creating After Advice


The after retruning advise is also same as the all the advices which we have discussed so far. All the steps for creating the after advise is same as what we have seen in the previous examples. The only difference is in the <aop:config> settings where <aop:after>

is used  to  descibe the after advice. The only difference in after and after returning advice is that after retruning advice is not executed if any exception occurs but on the other hand after advice will always gets executed  whether the exception occrs or not. That is why after advice are also known as after finally advice.



 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