Top Spring AOP Interview Questions

Top Frequently Asked Spring AOP Interview Questions

What is AOP ?

AOP is nothing but Aspect Oriented Programming.As In OOP, the key unit of modularity is the class, whereas in AOP the unit of modularity is the aspect.Using AOP we can modularize the cross cutting concern like Logging, Security, Transaction.

What is Advice ?

It is a block of code that is executed on selected join Point.

What is Aspect ?

It is a module that contains Pointcuts and Advice.

What is Weaving ?

It is a technique by which we connect Aspect with main code.

How to enable Aspectj ? In java configuration we need to add @EnableAspectJAutoProxy annotation as shown below.

@Configuration
@EnableAspectJAutoProxy
public class AppConfig {
}

While in XML we need to add following tag

<aop:aspectj-autoproxy/>

What are the two proxy created by Spring ?

  • JDK Proxy
  • CGLib Proxy

What are the different Advice Spring support ?

  • Before
  • After
  • Around
  • After returning
  • After throwing

Mention few cross cutting concern ?

  • Logging
  • Security
  • Transaction

What are the limitations of Spring AOP ?

  • Can only advise non-private methods
  • Aspect can be applied only on Spring beans
  • Limitations of weaving with proxies

What is Pointcut ?

It is an expression that selects one or more join points.

How to declare Pointcuts In Spring Aop ?


@Pointcut("execution(public void save())")

public void save(){}

What is a named pointcut ?

A named pointcut can be declared inside an <aop:config> element, enabling the pointcut definition to be shared across several aspects and advisors.


<aop:config>
    <aop:pointcut id="businessService" expression="execution(* com.xyz.myapp.service.*.*(..))"/>
</aop:config>


How do you externalize pointcuts? What is the advantage of doing this ?

Externalize the pointcut to a named pointcut. Avoid to writing complex pointcut expression across the application.

What is a ProceedingJoinPoint ?

An around advice is a special advice that can control when is executed. This is true for around advices only, so they require an argument of type ProceedingJoinPoint, whereas other advices just use a plain JoinPoint. ProceedingJoinPoint is used as an argument of the methods which hints for before, after, after throwing and around. ProceedingJoinPoint has the methods like getKind, getTarget, proceed etc.




Visit Others Links

Interview Questions Top Elasticsearch Interview Question
Top Kubernetes Interview Question
Top HTTP Interview Question
Top PouchDB Interview Question
Top Pivotal Cloud Foundry (pcf) Interview Question
Top Apache Camel Interview Question
Top Docker Interview Question
Top Gradle Interview Question
Top Generics Interview Questions In Java
Java 9 Interview Questions
Top Maven Interview Question
Top RabbitMQ Interview Question
Top Spring Batch Interview Question
Top Spring Boot Interview Question
Top Tika Interview Question
Top Kotlin Interview Question
Top OpenShift Interview Question
Top Polymer Interview Question
Top WebGL Interview Question
Top Continuous Integration Interview Question
Top Spring Cloud Interview Question
Top JOGL Interview Question
Top JFreeChart Interview Question
Java MultiThreading Interview Question
Top Spring ROO Interview Question
Top Seaborn Interview Question
Top TestRail Interview Question
Top LolCode Interview Question
Top Spring Transaction Management Interview Question
Top DynamoDB Interview Question
Top PySpark Interview Question
Top SaltStack Interview Question
Top Spring AOP Interview Question
© 2019 PreparationForInterview.com