I just started reading about spring , and a book mentioned "Spring AOP is a Proxy based framework" . What is meant by "Proxy based" framework.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
The framework is using the
In general Aspect Oriented Programming (AOP) in Java is implemented by means of instrumenting the target objects in some manner. There are many ways to do this but a common approach is to use the
This provides a facility to create a new object at runtime based on a given interface. You can then adjust the behaviour of the proxy to include extra features, such as logging or security boilerplate code, before handing control over to the original object.
An alternative approach, is to use subclassing. The proxy extends the original class and weaves the aspect before handing back to the super class. This fails if your class has final methods that need proxying.
You can read more about it in the Java reference here: http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.html
Alternatively, take a look at Spring in Action (pp 124).
As Gary Rowe says: some implementations of Aspect Oriented Programming generally rely on the imposition of a layer between the object and the rest of the system. This layer is usually called a proxy or a dynamic proxy.
From the Castle Project site: