<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Proxies on Sven Ruppert</title><link>https://svenruppert.com/tags/proxies/</link><description>Sven Ruppert — Java Veteran, Speaker, Trainer &amp; Bushcrafter. Articles, talks, workshops and videos on Core Java, Cybersecurity, Vaadin and Developer Relations.</description><generator>Hugo</generator><language>en</language><managingEditor>sven.ruppert@gmail.com (Sven Ruppert)</managingEditor><webMaster>sven.ruppert@gmail.com (Sven Ruppert)</webMaster><copyright>© 2026 Sven Ruppert</copyright><atom:link href="https://svenruppert.com/tags/proxies/index.xml" rel="self" type="application/rss+xml"/><image><url>https://svenruppert.com/img/sven-ruppert.jpg</url><title>Sven Ruppert</title><link>https://svenruppert.com/tags/proxies/</link></image><lastBuildDate>Sat, 02 May 2015 00:00:00 +0000</lastBuildDate><item><title>ProxyBuilder</title><link>https://svenruppert.com/projects/proxybuilder/</link><pubDate>Sat, 02 May 2015 00:00:00 +0000</pubDate><author>sven.ruppert@gmail.com (Sven Ruppert)</author><dc:creator>Sven Ruppert</dc:creator><guid isPermaLink="true">https://svenruppert.com/projects/proxybuilder/</guid><description>Runtime proxy builders and annotation processors for Java — pre/post actions, security rules, metrics and virtual proxies, all via a fluent API or compile-time code generation.</description><content:encoded>&lt;![CDATA[<p>A Java library for<strong>runtime proxies</strong> and<strong>compile-time generated static
proxies</strong>. It started in 2015 as an internal AOP-style utility and has
quietly stayed useful ever since — currently tracking JDK 26 and Maven 4.</p><h2 id="two-ways-to-wrap-a-method-call">Two ways to wrap a method call</h2><h3 id="runtime--dynamicproxybuilder">Runtime —<code>DynamicProxyBuilder</code></h3><p>A fluent API around JDK dynamic proxies:</p><div class="code-wrap"><div class="code-wrap__bar"><span class="code-wrap__lang">java</span><button type="button" class="code-wrap__copy" aria-label="Copy code">Copy</button></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">Service</span><span class="w"/><span class="n">proxy</span><span class="w"/><span class="o">=</span><span class="w"/><span class="n">DynamicProxyBuilder</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">createBuilder</span><span class="p">(</span><span class="n">Service</span><span class="p">.</span><span class="na">class</span><span class="p">,</span><span class="w"/><span class="k">new</span><span class="w"/><span class="n">ServiceImpl</span><span class="p">())</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">addIPreAction</span><span class="p">((</span><span class="n">original</span><span class="p">,</span><span class="w"/><span class="n">method</span><span class="p">,</span><span class="w"/><span class="n">args</span><span class="p">)</span><span class="w"/><span class="o">-&gt;</span><span class="w"/><span class="p">{</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="c1">// before every invocation</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">})</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">addIPostAction</span><span class="p">((</span><span class="n">original</span><span class="p">,</span><span class="w"/><span class="n">method</span><span class="p">,</span><span class="w"/><span class="n">args</span><span class="p">)</span><span class="w"/><span class="o">-&gt;</span><span class="w"/><span class="p">{</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="c1">// after every invocation</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">})</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">addSecurityRule</span><span class="p">(()</span><span class="w"/><span class="o">-&gt;</span><span class="w"/><span class="n">currentUserCanCall</span><span class="p">())</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">addMetrics</span><span class="p">()</span><span class="w"/></span></span><span class="line"><span class="cl"><span class="w"/><span class="p">.</span><span class="na">build</span><span class="p">();</span></span></span></code></pre></div></div><p>You get<strong>pre/post hooks</strong>,<strong>security gates</strong>,<strong>logging</strong>,<strong>Dropwizard
metrics</strong> and<strong>virtual proxy strategies</strong> without writing a single<code>InvocationHandler</code>.</p><h3 id="compile-time--annotation-processor">Compile-time — annotation processor</h3><p>Annotate your interface, the processor emits a static proxy class at
build time. Zero reflection at runtime, full type-safety, JIT-friendly.
You get the proxy behaviour with the performance characteristics of
hand-written code.</p><div class="code-wrap"><div class="code-wrap__bar"><span class="code-wrap__lang">xml</span><button type="button" class="code-wrap__copy" aria-label="Copy code">Copy</button></div><div class="highlight"><pre tabindex="0" class="chroma"><code class="language-xml" data-lang="xml"><span class="line"><span class="cl"><span class="nt">&lt;plugin&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;artifactId&gt;</span>maven-compiler-plugin<span class="nt">&lt;/artifactId&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;configuration&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;annotationProcessorPaths&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;path&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;groupId&gt;</span>com.svenruppert<span class="nt">&lt;/groupId&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;artifactId&gt;</span>proxybuilder<span class="nt">&lt;/artifactId&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;version&gt;</span>00.11.01<span class="nt">&lt;/version&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;/path&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;/annotationProcessorPaths&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;/configuration&gt;</span></span></span><span class="line"><span class="cl"><span class="nt">&lt;/plugin&gt;</span></span></span></code></pre></div></div><h2 id="when-to-reach-for-it">When to reach for it</h2><p>✅<strong>Security wrappers</strong> — declarative &ldquo;is the current user allowed to call
this method&rdquo; without an AOP framework
✅<strong>Method-level metrics</strong> — counter / timer / histogram per method call
without modifying the implementation
✅<strong>Lazy initialisation</strong> — virtual proxies that defer construction until
first use
✅<strong>Tracing / debugging</strong> — pre/post hooks for ad-hoc instrumentation</p><p>❌ When you&rsquo;re already in a Spring or Quarkus stack — use their AOP layers
❌ When you need cross-cutting concerns across non-interface classes — JDK
proxies only wrap interfaces</p><h2 id="modules">Modules</h2><ul><li><code>proxybuilder-annotations</code> — annotations-only JAR (tiny, on consumer compile path)</li><li><code>proxybuilder</code> — implementation: runtime utilities + annotation processor</li><li><code>proxybuilder-testusage</code> — runnable usage examples and integration tests</li></ul><p>License is<strong>EUPL-1.2</strong>. Maven coordinates on the<a href="https://proxy.svenruppert.com">project site</a>.</p>
]]></content:encoded></item></channel></rss>