Examples

Working code from the proxybuilder-testusage module, pinned to release 00.10.00.

This section shows complete, runnable Java code drawn from the proxybuilder-testusage module of the proxybuilder repository.

Every code block on these pages is the real source — no hand-written snippets, no glossed-over corners. The blocks are pinned to the 00.10.00 release tag, so what you see is what is in the published artefact.

How this works

  • Code blocks are sourced from files in proxybuilder-testusage, frozen at the tag listed in each block’s footer.
  • “View on GitHub” links open the source at the same tag — permalinks, never broken.
  • To run an example yourself, clone the proxybuilder repository, check out the tag, and execute the listed Maven command.

Categories

  • Quickstart — minimal copy-paste material to get going.
  • Runtime — using DynamicProxyBuilder to wrap interfaces at runtime with pre-actions, security rules, metrics and more.
  • Compile-time — generating proxies via annotations (Phase B).
  • Adapters@StaticObjectAdapter and @DynamicObjectAdapterBuilder patterns (Phase B).
  • Edge cases — multi-level interfaces, cross-package, inner classes (Phase B).

Phase A scope. Three examples are live below. The wider catalogue is queued for the next iteration, once marker comments land in the proxybuilder test sources and the extraction script is wired up.

In this section

  • Add a pre-action

    Run a callback before every method invocation on a runtime proxy.

  • Add metrics at runtime

    Record method timings on a runtime proxy through Dropwizard Metrics and read them back.

  • Wrap an interface

    The minimum viable runtime proxy — give the builder an interface and an implementation, get a proxy back.