BT

Facilitating the spread of knowledge and innovation in professional software development

Contribute

Topics

Choose your language

InfoQ Homepage Guides Dynamic Proxies in Java Mini-Book

Dynamic Proxies in Java Mini-Book

Bookmarks

Of all the things that we could learn this month, why dynamic proxies?

Back in 1996, we could learn the entire Java ecosystem in a week with Bruce Eckel's "Thinking in Java".

Fast-forward to 2020 and the volume of information is overwhelming.

Java is still quite easy to learn, especially if we focus on the most essential tools. Start with the syntax, then object-orientation, flow control, collections and Java 8 streams. Design patterns hold everything together.

But there is more, much more.

To become a true Java Specialist, we need to also master the underpinnings of this great platform. How else can we develop systems that take advantage of the power of Java?

Dynamic proxies are such a tool. We can save thousands of lines of repetitive code with a single class. By taking a thorough look at how they work, we will recognize good use cases for them in our systems.

Dynamic proxies are not an everyday tool. They may come in handy only half a dozen times in our careers. But when they fit, they save us an incredible amount of effort. I once managed to replace over half a million code statements with a single dynamic proxy. Powerful stuff.

This book is for intermediate to advanced Java programmers who want to get to "guru" status. It is not suitable for beginners in Java.

We hope you enjoy this book as much as I enjoyed writing it for you!

Let the dynamic proxy games begin!

Free download

Before you download this book...

Is your test automation process being slowed down by unresolved failing tests? Need a solution for fixing intermittent errors fast? Record, Replay and Resolve Java application errors with LiveRecorder, from Undo.io.

Note: By checking the box you grant InfoQ permission to share your contact info with this sponsor.

Table of Contents:

  • Preface
    • Big win 
    • Infrastructure code 
    • But wait… 
    • What will we learn?
    • TL;DR? 
    • Java version 
    • Enjoy!
  • Design-Patterns Cousins 
    • Proxy pattern
    • Adapter pattern 
    • Decorator pattern
    • Composite pattern 
    • Chain-of-responsibility pattern
  • Handcrafted Proxies 
    • Lazy initialization with virtual proxy 
    • Calling remote methods with remote proxy 
    • Security with the protection proxy 
    • Cascaded proxies 
    • Implementing equals() in proxies 
  • Dynamic Proxy 
    • Proxy.newProxyInstance() 
    • InvocationHandler
    • Name of dynamic class 
    • Dissecting $Proxy. 
    • Turbo-boosting reflection methods 
    • Unwrapping the InvocationTargetException 
    • Casting. 
    • Virtual dynamic proxy 
    • Synchronized dynamic proxy 
    • EnhancedStream with dynamic proxies 
    • Restrictions with dynamic proxies 
    • Performance of dynamic proxies
  • Dynamic Decorator 
    • Decorator design pattern 
    • Using dynamic proxy to implement filter 
    • VTable 
    • ChainedInvocationHandler
  • Dynamic Object Adapter
    • Rapper wrappers 
    • A better ArrayList 
    • BetterCollection interface. 
    • Dynamic object adapter using dynamic proxies 
    • Restrictions of adapter 
    • Performance of dynamic-object-adapter method calls
  • Dynamic Composite 
    • Contact, Person, and DistributionList
    • Hacking dynamic proxy for composites
    • AppendableFlushableCloseable 
       
We need your feedback

How might we improve InfoQ for you

Thank you for being an InfoQ reader.

Each year, we seek feedback from our readers to help us improve InfoQ. Would you mind spending 2 minutes to share your feedback in our short survey? Your feedback will directly help us continually evolve how we support you.

Take the Survey

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.