via Spring AOP Example | Examples Java Code Geeks.
With this tutorial we shall show you how to use Aspect Oriented Programming in Spring Framework. AOP is used in the Spring Framework to provide declarative enterprise services, especially as a replacement for EJB declarative services. It is also used to allow users to implement custom aspects, complementing their use of OOP with AOP.
We will demonstrate how to create and apply some central AOP concepts. In short we will create all types of advices, we will use a pointcut and an advisor over an advice and we will check on some special features of Spring in interceptors and proxy beans.
Our preferred development environment is Eclipse. We are using Eclipse Juno (4.2) version, along with Maven Integration plugin version 3.1.0. You can download Eclipse from here and Maven Plugin for Eclipse from here. The installation of Maven plugin for Eclipse is out of the scope of this tutorial and will not be discussed. We are also using Spring version 3.2.3 and the JDK 7_u_21.
via Create your own AOP in Java | Java Code Geeks.
As you know AOP is one of the best features provided by Spring framework which provides utmost flexibility while achieving cross cutting concerns. Have you thought of how AOP works in Spring ? Sometimes this is the question asked in case of senior level technical interview. Sometimes this question becomes more significant when it comes to only core java. Recently one of my friend went to attend the interview and he faced an embarrassing question about how to use AOP only in core java without using Spring and related libraries. In this article I will provide you an outline about how to create your own AOP only in core java of course with certain limitations. This is not a comparative study between Spring AOP and Java AOP. However you can achieve AOP in java to certain extent using proper design patterns.
All of you know AOP and how to use it using Spring framework , this article will give you an insight into a way to achieve AOP in java without using Spring. For your information Spring uses both JDK proxy as well as CGlib to provide AOP implementation. JDK dynamic proxy provides a flexible approach to hook a method and to perform certain operation with certain limitations. The limitation is that there should be an interface and there should be an implementation for that interface. Nothing is clear as of now. Let us take an example. We have a Calculator through which we want to perform some mathematical operations. Let us consider for division of a number by another number. Now question is somebody has already provided an implementation for the division operation in the core framework, is it possible to highjack in the method to perform additional validation/s ? Yes it is. To achieve this I provide below the code snippet for this simple case. The basic abstract code is given below.
Memoization is a method-level caching technique for speeding-up consecutive invocations.
This post will demonstrate how you can achieve request-level repeatable reads for any data source, using Spring AOP only.