Aspect Oriented Programming in Java
Hello, I am working on java and currently searching for the introduction to AOP (Aspect Oriented Programming) with the Spring framework. If you are having any kind of information about it, then please help me to achieve it. I will be thankful to you. I have search this related to it, but on internet I have got some information, but it is not useful for me. So, please provide some details about it.
Re: Aspect Oriented Programming in Java
The aspect-oriented programming because it provides a programming paradigm and new concepts, developed a very specific jargon which makes no understanding of its concepts are ultimately simple but powerful.
- aspect : A module defining the grafts and their activation points,
- graft : A program to be activated at a certain point of execution of the system, specified by a junction point,
- action point, Breaking, court : Place where the software is inserted a graft by the aspect weaver,
- junction, Implementation : Location in the flow of execution of the system, where it is valid to insert a graft. To clarify the connection it is not possible, for example, to insert a graft in the middle of a function code. By cons we can do before, around, instead of or after the function call.
Re: Aspect Oriented Programming in Java
Take the example of a simple business class "test" which contains the method "hello ()" and returns a String. So we will see how to change the Spring configuration in order to track each call and each output of the method hello (). The idea is to intercept input / output method "hello ()" and the logger with an external class "MonLogger".
Code:
public class test
{
public String hello (String msg)
{
String s = "Hello" + msg;
System.out.println (s);
return s;
}
}
Re: Aspect Oriented Programming in Java
Aspect Oriented Programming (AOP) has been around for a long time but recently has begun to get more attention from the Microsoft .NET development community. As with any new adoption of technology, there tends to be many misconceptions of the technology and how to use it. AOP is no exception to this. To bring light to AOP, this article and the following code sample will demonstrate a practical application of AOP and some common problems that AOP can address. Taking an application that consumes a Web service, we will be extending functionality of the objects that the Web service returns by applying new aspects to them using an AOP framework. These aspects will provide for this functionality independent of the object model generated off the WSDL.
Re: Aspect Oriented Programming in Java
Different types of advice are present in the AOP as below:
- Before advice: Executed before the join point.
- After returning advice: Executed after the join point (If the intercepted method is executed normally - no return exception).
- After throwing advice: Executed if the intercepted method returns an exception.
- After (finally) advice: Executed output of the join point (normal execution of the method or output exception).
- Around advice: It includes the execution of the intercepted method. This is the most powerful advices. It allows to configure the behavior before and after method execution.
Re: Aspect Oriented Programming in Java
If you are using the AOP then it is having the benefits below:
- Increased Maintenance : The technical modules in the form of appearance can be maintained more easily because of its detachment from its use,
- Improved reuse : Any module can be reused without worrying about its environment and independently the business or application domain. Each module implements functionality specific technique, we need not worry about future developments: new features can be implemented in new modules interact with the system through aspects.
- Productivity gain : The programmer is concerned only the aspect of implementation is concerned, This simplifies work and increases the parallelism of development.
- Improved code quality : Simplifying code entails the programming aspect allows make it more readable and thus better quality.