Java Dynamic Proxies: One Step from Aspect-oriented Programming
Learn how to implement application concerns such as logging and remote error handling across classes using dynamic proxies. Along the way, you'll find out what dynamic proxies and aspect-oriented programming (AOP) have in common.
by Lara D'Abreo
July 9, 2004
ynamic proxies are a nifty, often overlooked feature of the Java language. Introduced in J2SE 1.3, they allow you to intercept method calls so you can interpose additional behavior between a class caller and its "callee". From the caller's perspective, a proxy is no different from the real class that it encapsulates—it presents the same interfaces and follows all the rules and conventions expected of the real class.
For savvy programmers, proxies present a unique timesaving opportunity. Why spend effort inserting and maintaining such common code as debugging and logging when you can just centralize it and put in a proxy instead? Logging, retry semantics, performance metrics, performance optimizations, test stubs, and caching are examples of application concerns that cut across class implementations regardless of design and business function.
It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com. Already a member?
To become a member of DevX.com create your Member Profile by completing the form below. Membership is free!