This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.
SpringAOP is Proxy based AOP. In other words it's Spring implementation of Java Dynamic Proxy API. With CGLIB Proxies it became even more flexible by allowing you to intercept methods on the classes that do not implement any interfaces. But with all the benefits of elegant OO approach to AOP paradigm it also has some limitations. One of them is limitations on the pointcuts supported by the Spring AOP. Keep in mind Spring AOP was never in the business of competing with byte-code-injection style of AOP represented by AspectJ and JBossAOP.
Now, back to your question. Could you use Spring AOP on the class to which you have no source code? The answer is yes, regardless of which AOP technique (byte code injection or dynamic proxies) you are using. The only limitations would be standard JDK packages (you can not weave/inject anything into them), but you can write "call" pointcuts to intercept calls to them.
So unless you have more specific question about what exactly you are trying to do, the answer is within Spring Application Context you can use Spring AOP or AspectJ to intercept calls to commons-beanutils methods.
Basically we use struts 1.x and struts uses Apache commons beanutils internally for getting/setting properties on Forms. All of the get/sets go through a class in Apache beanutils called PropertyUtilsBean. This class is in the Apache Commons beanutils JAR.
We would like to intercept calls to PropertyUtilsBean.getProperty(bean, propName) and before it is called:
a) if the bean is an "instanceof" a particular class, call a method on on of our classes instead of entering the getProperty() method
b) if the bean is NOT an "instanceof" this particular class, simply continue execution of the getProperty() method.
I've double checked everything and it all looks ok. I think the difference here is that I never fetch the "bean" via spring. This PropertyUtilsBean class simply lives in the commons jar and is called as low-level Struts code executes. Maybe it isn't working for me because the PropertyUtilsBean is not directly managed by spring and created within it but instead is just being used by another library? (struts)
I've double checked everything and it all looks ok. I think the difference here is that I never fetch the "bean" via spring. This PropertyUtilsBean class simply lives in the commons jar and is called as low-level Struts code executes.
That's correct. That's why you need to use AspectJ bytecode weaving to apply aspects to code not managed by Spring.