Aspects Oriented Programming(AOP) with Spring
Aspects Oriented Programming(AOP) with Spring
Aspect-Oriented Programming (AOP) complements Object-Oriented Programming (OOP) by providing another way of thinking about program structure.
Aspect Oriented Programming Core Concepts
a modularization of a concern that cuts across multiple classes. Transaction management is a good example of a crosscutting concern in enterprise Java applications.
AOP Advice Types
Based on the execution strategy of advices, they are some following types.
Spring AOP capabilities and goals
Spring AOP is implemented in pure Java. There is no need for a special compilation process.
AOP Proxies
Spring AOP defaults to using standard JDK dynamic proxies for AOP proxies. This enables any interface (or set of interfaces) to be proxied.
AOP Implementations
AOP implementations are provided by several ways.
XML Schema Based AOP with Spring
In this chapter we will see that Implementation of AOP based on XML Schema. Before using the AOP
Declaring an aspect
Using the schema support, an aspect is simply a regular Java object defined as a bean in your Spring application context.
Declaring a pointcut
A named pointcut can be declared inside an element, enabling the pointcut definition to be shared across several aspects and advisors.
Declaring advices
There are five types of Advices as follows
After returning advice
After returning advice runs when a matched method execution completes normally.
After throwing advice
After throwing advice executes when a matched method execution exits by throwing an exception.
After (finally) advice in Spring
After (finally) advice runs however a matched method execution exits. It is declared using the after element
Around advice
The final kind of advice is around advice. Around advice runs \"around\" a matched method execution.
XML Schema Based AOP Example
In this section we provide complete Example of XML Schema Based AOP in Spring.
@AspectJ Based AOP with Spring
In this section we provide @AspectJ Based AOP with Spring in detail.
Declaring an aspect
In this section we provide to declare an Aspect.
Declaring a pointcut
A pointcut helps in determining the join points (ie methods) of interest to be executed with different advices.
Declaring advices
Advice is associated with a pointcut expression, and runs before, after, or around method executions matched by the pointcut.
After returning advice
After returning advice runs when a matched method execution returns normally.
After throwing advice
After throwing advice runs when a matched method execution exits by throwing an exception.
After (finally) advice in Spring
After (finally) advice runs however a matched method execution exits. It is declared using the @After annotation.
Around advice
Around advice runs \"around\" a matched method execution. It has the opportunity to do work both before and after the method executes,
@AspectJ Based AOP Example
To understand the concepts related to @AspectJ based AOP, let us write an example which will implement few of the advices.

Spring Framework

Basic of Spring Framework

Spring with IDE

Spring IoC Containers

Bean in spring framework

Aspects Oriented Programming(AOP) with Spring

Dependency Injection in Spring

DAO support in Spring

Data access with JDBC

Object Relational Mapping (ORM) Data Access

Spring Expression Language (SpEL)

Spring Transaction Management

Object XML Mappers(OXM) Frameworks

Spring Web MVC Framework

Remoting and web services using Spring

Spring Web Services

web services using jax-ws in Spring

JMS (Java Message Service)

Spring with JMS Integration Example

JMX(Java Management Extension)

Java Mail with Spring

Example of Sending mail in Spring

Enterprise JavaBeans (EJB) integration with spring

Spring With Struts 2 Integration