Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I just started reading about spring , and a book mentioned "Spring AOP is a Proxy based framework" . What is meant by "Proxy based" framework.

share|improve this question
    
It's a reference to a proxy design pattern. –  Yuriy Zubarev Mar 19 '11 at 7:15
add comment

2 Answers

up vote 5 down vote accepted

The framework is using the java.lang.reflect.Proxy to do the work

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 Proxy class.

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).

share|improve this answer
add comment

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:

Proxy objects can assist in building a flexible application architecture because it allows functionality to be transparently added to code without modifying it. For example, a class could be proxied to add logging or security checking without making the code aware this functionality has been added.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.