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.  

0 comments:

Post a Comment

Ads 468x60px

.

Ads

.

Featured Posts

Popular Posts

Like Us On FaceBook

Total Pageviews

Online Members

Live Traffic