May 15 2015

Spring AOP Interview Questions

Spring AOP Interview Questions

What is a Concern?

Concern refers to part of the program divided based on the functionality. Concerns are of two types core and crosscutting. The concern that represents the core functionality is called as primary concerns. The concern which represents the secondary requirement is called crosscutting concerns. For example, Logging, transaction management, security etc.

What is Spring AOP?

Spring Aspect Oriented Programming (AOP) is a programming methodology that allows us to build core concerns and crosscutting concerns separately and provides dynamic way of introducing the crosscutting before, after or around the core concerns. The key unit of modularity in AOP is aspect.

What do you mean by join point?

Join point is a point during the execution of the method or handling of an exception. Spring supports only the method execution join point

What do you mean by advice? What are the different types of advices in AOP?

Advice is an action to perform by an aspect at a join point (method).The following are the different types of advices in Spring AOP

  • Before Advice – runs before a method
  • After returning – runs after a method normal execution
  • After throwing – runs when a method terminates throwing an exception
  • Around – runs around the joint point. It is a combination of all the above three advices.

What is an aspect?

The combination of advice and pointcut is called as aspect.

What do you mean by pointcut?

A pointcut indicates which method should be intercepted (advice is to be applied) by matching the method name or regular expression.

What is the target object?

Objects which are advised by aspects are called target objects.

What is AOP proxy?

AOP is a proxy based framework, it builds dynamic proxy objects to intercept the requests to the target objet method and invoke the advices which are applicable for the method call. Spring by default uses Java Standard editions dynamic proxies and it can also use CBLIB proxies.

What is weaving?

Weaving is a process of linking aspects with other application types or objects to create an advised object (combining individual concerns into a single system).Weaving can be done at compile time, load time, or at runtime.

How to enable @AspectJ support?

If you are using xml configuration file include <aop:aspectj-autoproxy/>


<aop:aspectj-autoproxy/>

If you are using configuration class add @EnableAspectJAutoProxy annotation


@Configuration
@EnableAspectJAutoProxy
public class ConfigurationClass{

}

Related Articles : Spring articles


Copyright © 2014. All rights reserved.

Posted May 15, 2015 by answersz in category Interview Questions

Leave a Comment

Your email address will not be published. Required fields are marked *

*