Inheritance Proxies
An object that is non-final can be proxied by another class that extends it.
For example, in order to log every method call on an ArrayList, you could
create a ProxyList class that extends ArrayList and overrides every
method with a delegated call to super(). Each overridden method provides
a join point that can be surrounded by logging code.
This proxy could be passed to any method that accepts a List or an
ArrayList
. However, one limitation of inheritance proxies is that final classes
and final methods cannot be proxied.
Runtime Weaving vs Binary Weaving
Weaving is the process of linking aspects and objects together. Proxy objects are
examples of runtime weaving, which can be accomplished through pure coding
patterns. Binary weaving injects aspects directly into bytecode. Binary weaving
can take place at compile-time with a custom compiler or at load-time with
a custom class loader. Binary weaving has none of the limitations of interface
or inheritance proxies, but it usually requires the help of a dedicated library.
AspectJ
AspectJ is a widely used AOP framework with support for compile-time
weaving, load-time weaving, and post-compile weaving for external classes.
AspectJ is often used in conjunction with the Spring framework, which provides
additional support for aspects as well as runtime weaving.
Questions
What is the difference between a core concern and a cross-cutting concern?
What is aspect-oriented programming?
What is the difference between an interface proxy and an inheritance proxy?
What is the difference between runtime weaving and binary weaving?
What is the AspectJ library?
|