Dynamic Proxies in Java LIVE - June 2020
From the 8-12 June 2020, we are running our Dynamic Proxies in Java Course LIVE.
Abstract
Don't repeat yourself. The mantra of the effective Java programmer. However, often we need to create similar looking classes for slightly different interfaces in Java. In some cases this can amount to thousands of lines of code. In this course, we learn how to use dynamic proxies to create classes dynamically. We show how thousands of lines of similar looking code is transformed into a few dozen, using the techniques in this course. We study four different variants of this pattern: dynamic proxy, dynamic object adapter, dynamic filter and dynamic composite. The course has hands-on exercises for each pattern that are carefully thought out to maximize learning. The course is based on a book, a PDF of which is included in the course handouts.
What you'll learn - and how you can apply it
- Introduction to some of the related patterns: proxy, adapter, decorator and filter
- How to write proxies by hand
- How to create dynamic proxies
- How the adapter, decorator and composite can be created dynamically
- How the Java Platform Module System (JPMS) interacts with dynamic proxies
- How to match between methods in different classes quickly and efficiently
- In one of our exercise, we will build a complete JDBC driver that we can use for measuring how long each database operation takes
How do these LIVE classes work?
We have two sessions per day with the same content (but most likely, different student questions). The early session is scheduled at a good time for Europe/APAC from 10am-12pm London time (that is 11am-1pm Berlin, 2:30-4:30pm Bangalore, and 7-9pm Sydney). The later session is at a time more convenient for America/Europe from 9-11am Los Angeles time (that is 12-2pm New York, 5-7pm London, 6-8pm Berlin, 9:30-11:30pm Bangalore).
Some sessions can be shorter than 2 hours, and some may be a bit longer. We try our best to keep it below 2 hours. It all depends on how many questions we get. Each session ends with exercises that you should try to complete before the next session. We begin the sessions with walkthroughs and questions from the previous day. Recordings of each day become available within a couple of hours after completion to help you review and prepare for the next day.
Once you enrol in this course, you are automatically signed up for the webinar. Our system will send you login details. These are personal to you so please do not share them (otherwise you might lose access to the course).
Schedule
Day 1
0: Welcome
- Welcome to the course and overview of what dynamic proxies are and why we should care about them
1: Design Patterns Cousins
- Brief overview of design patterns we will use in the course: Proxy, Adapter, Decorator, Composite, and Chain of Responsibility
2: Handcrafted Proxies
- Different types of proxies: Virtual Proxy, Remote Proxy, Protection proxy
- Cascaded Proxies
- equals() in proxies
Exercises for day 1 to complete before day 2
- Exercise/activity description: We will create a JDBC driver by hand for monitoring how long database calls take.
Day 2
Exercise walkthrough
- We will walk through the exercises from day 1 and do a quick revision
3: Dynamic Proxies
- Proxy.newProxyInstance()
- LoggingInvocationHandler
- Dissecting a Dynamic Proxy
- Recasted Exceptions
- Proxies Facade
- Virtual Dynamic Proxy
- Synchronized Dynamic Proxy
- Cascading Dynamic Proxies
- EnhancedStream
- Dynamic Proxy Restrictions
- Performance
Exercises for day 2 to complete before day 3
- Exercise/activity description: We will now change our JDBC driver to use dynamic proxies, thus reducing the amount of code by 30x
Day 3
Exercise walkthrough
- We will walk through the exercises from day 2 and do a quick revision
4: Dynamic Decorator
- Filtering for Immutability
- FilterHandler
- VTable
- ChainedInvocationHandler
5: Dynamic Object Adapter
- Better Collections
- Dynamic Object Adapter Restrictions
- Performance
Exercises for day 3 to complete before day 4
- Decorator: Filtering Queue to remove unwanted methods
- Adapter: Fun exercise involving singers and rappers, writing own ChainedInvocationHandler
Day 4
Exercise walkthrough
- We will walk through the exercises from day 3 and do a quick revision
6: Dynamic Composite
- Mailing List
- CompositeHandler
- TeeAppendables
- AppendableFlushableCloseable
- Composing Appendable Dynamically
Exercises for day 4 to complete before day 5
- Exercise/activity description: Fun exercise combining the visitor with composite
Day 5
Exercise walkthrough
- We will walk through the exercises from day 4 and do a quick revision
7: Conclusion
- Course wrap-up and next steps
Preparation
- This training is for intermediate to advanced Java programmers
- It is recommended to do the Java Design Patterns Deep Dive LIVE Class prior to this class
- Students should download and install the exercises found in the Resources chapter of the course material
Recommended Reading
Your Instructor
Heinz Kabutz is the author of The Java Specialists’ Newsletter, a publication enjoyed by tens of thousands of Java experts in over 150 countries. He has been a Java Champion since 2005.
Course Curriculum
-
StartSession 1 (AM) Introduction, Design Patterns Cousins, Hand-crafted Proxies (110:24)
-
StartSession 1 (PM) Introduction, Design Patterns Cousins, Hand-crafted Proxies (103:41)
-
StartSession 2 (AM) Dynamic Proxies (110:43)
-
StartSession 2 (PM) Dynamic Proxies (109:02)
-
StartSession 3 (AM) Dynamic Filter, Dynamic Object Adapter (113:17)
-
StartSession 3 (PM) Dynamic Filter, Dynamic Object Adapter (100:32)
-
StartSession 4 (AM) Composite (101:07)
-
StartSession 4 (PM) Composite (99:02)
-
StartSession 5 (AM) Conclusion (59:30)
-
StartSession 5 (PM) Conclusion (36:05)