Following are task done by the Proxy Object when we calls the business logic on the proxy object.

1.  First proxy checks whether the Business logic( methods ) to be invoked is available with the target class object or proxy interface specified by the developer in the Spring Configuration while configuring the proxy for the target class. 

2. If it found either with the target class or the proxy interface, collects the data configured in the List of InterceptorName wile configuring the ProxyFactoryBean in the XML document.

Note : List of InterceptorName contains list of Advice class object. 

3. Proxy checks for the list of Advice class object in the List of InterceptorName, to invoke the methods defined in the Advice class by getting its Object form the list.  


Note: Normally 3 method are invoked sequentially i.e,
a) before()             --> First called defined in one of the Advice class.
b) afterReturning() --> Called after before() defined in another class.
c) afterThrowing    --> Called only when exception thrown by the . 


4. All the methods are called sequentially by their respective Target Objects , present in the Spring Container. 

Note : Respective methods will be called on the basis of Advice class implementing following Interfaces. 

a) MethodBeforeAdvice  ( has before() )
b) AfterReturningAdvice  ( has afterReturning() )
c) ThrowAdvice              ( has afterThrowing() )


5. If the Business Logic executes and returns control successfully then proxy checks for any Interceptor(Advice) which has to be applied after executing successfully. 

6. If not executed successfully that means exception will be thrown and then afterThrowing() will be executed. 


7. Proxy checks for the Advice class implementing ThrowAdvice interface to class the overridden afterThrowing() method. 

Important points 

1. before () method is present in the MethodBeforeAdvice interface , so need to override in our Advice class and always will be called before executing any business logic. 

2. afterReturning() method is present in the AfterReturningAdvice interface, so need to override in our Advice class and always will be executed if business logic executes successfully. 

3. afterThrowing() method is present in the ThrowAdvice interface, so need to override in our Advice class and always will be executed only if business logic fails to executes and throws exception.  

Related Posts:

  • Invoking Business Logic with the Proxy Object Following are task done by the Proxy Object when we calls the business logic on the proxy object. 1.  First proxy checks whether the Business logic( methods ) to be invoked is available with the target class object … Read More
  • Spring AOP Terminology There are some important terms in Spring AOP which we need to know about. All total there are 8 terms which are as follows : 1. Aspect 2. Advice 3. JoinPoint 4. PointCut 5. Advisor 6. Target 7. Proxy 8. Weaving A… Read More
  • Spring AOP : Introduction AOP is termed as Aspect Oriented Programming. Spring AOP is a concept which overcomes the limitations with the simple OOPs concepts. It is a new kind of programming technique which gives the facility to add the functionalit… Read More
  • AOP using Spring API This is the very first technique to implement Spring AOP using Spring API. Later they introduces Annotation and XML schema concept which itself uses Spring API but with Annotation/ XML schema approach.  Using ProxyFa… Read More

0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

201978

Online Members

Live Traffic