特点
脚本语言
即动态语言,和其他脚本语言一样,无需编译即可直接运行,而C#、C++和Java等需要通过编译然后才能运行。Ruby减少了开发者的开发流程。
The HttpClient is library which is support by apache. It can post or get data from specific webservice and represents only the most basic contract for HTTP request execution.
We explain how to use this library with a example. In this example, we are going to use it to access the google tranlated API. Translating some text from specific language to other language. And this example using the Spring framework and Maven tool to build.
In this article, we introduce how to use AOP
with the @AspectJ
Annotation. If we want to use this Annotation. we should include below code in the XML schema-based configuration file.
1 | <aop:aspectj-autoproxy/> |
And also you need to add these libraries to your project, aspectjrt.jar, aspectjweaver.jar, aspectj.jar and aopalliance.jar.
Previously, we created AOP with Spring framework via implementing interface of spring AOP. And now we can use XML Schema to achieve it. We need to add below AspectJ libraries to our project. So downloading and adding them to the CLASSPATH of application, and also we can use the maven to build our application.
If we want to intercept methods with dynamic pointcut, we need to override matches and getClassFilter methods of DynamicMethodMatcher abstract class. The dynamic pointcut can verify the arguments of the method at runtime. This is a difference with static pointcut.
Let’s first to see the three very technical terms as below.
What is Pointcut
of Spring AOP? let’s describe it. A Pointcut
defines what Advice
s are required at what Join Point
s. In fact all business logic methods of the class are not required all services, that means each business logic method might require different service even some methods don’t require. So Pointcut can informs IOC container that what business methods of a class needs what type of services.
In this type of Advice. This service executed when the logic method throws exceptions. To create Throws Advice, we should implement the interface called ThrowsAdvice
.
ThrowsAdvice
is provided by org.springframework.aop.* package. But it has not any method we need to override.
In this blog, let us talk about Around Advice
. There are some few points about it.
Around Advice
is combination of Before Advice
and After Advice
.Around Advice
we can implement both before and after services.Around Advice
is not given by spring framework, it is from Open Source implementation called AOP
alliance.Around Advice
can be used by any framework which supports AOP
. Around Advice
can access the return value of business method and it can modify the value and it can return a different value back to the client, as return type is Object, but in the After Advice
its not possible right, as its return type is void.