SShortSingh.
Back to feed

How Spring Uses JDK and CGLIB Proxies to Power Transactions and Caching

0
·2 views

Spring annotations like @Transactional and @Cacheable work by inserting a proxy object between the caller and the actual bean, adding behaviour without modifying the original code. This proxy pattern mirrors a classic design where a wrapper class implements the same interface as the real object, forwarding calls while injecting extra logic. Spring builds these proxies automatically at runtime using one of two mechanisms: JDK dynamic proxies, which work via Java's built-in Proxy API and require an interface, or CGLIB proxies, which subclass the target class directly and work without interfaces. The choice between them affects how Spring-managed concerns like transactions, caching, security, and async execution are applied across an application. Understanding how proxies are constructed helps developers avoid common pitfalls, such as self-invocation bypassing proxy logic or final classes breaking CGLIB subclassing.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Microsoft Copilot Tools Lose Momentum as Pricing and Pivots Deter Adoption

Microsoft launched three developer-focused AI tools — Code Apps, Cowork, and the new Copilot Studio — that initially generated strong enthusiasm for their productivity potential. However, adoption has since been hampered by incomplete rollouts, with Code Apps' citizen-developer interface still in preview nearly a year after launch, and Cowork shifting to a costly pay-as-you-go model. New Copilot Studio also began charging for development while removing free access for Microsoft 365 Copilot users, a move significant enough that Microsoft appears to be retaining the older version rather than replacing it. Critics argue these pricing shifts enforce a 'prove ROI before trying' mindset that stifles innovation and discourages citizen developers. The broader Copilot strategy has also faced criticism for fragmented rollouts and repeated architectural pivots, leaving the platform's early reputation weakened despite recent improvements.

0
ProgrammingDEV Community ·

Building a browser-only media converter with FFmpeg.wasm: deadlocks, limits and workarounds

A developer built BrowsersKit, a fully client-side media conversion tool using FFmpeg.wasm, to eliminate server uploads and protect user file privacy. The project encountered serious technical hurdles, including thread pool deadlocks in FFmpeg.wasm's multithreaded build that silently hung roughly one in ten heavy jobs with no error output. A watchdog mechanism was eventually shipped to detect and recover from these freezes. The 32-bit WebAssembly heap imposed a 2 GB memory ceiling, requiring a workaround using WORKERFS to handle larger files. Additionally, the developer chose to serve VP8 video instead of VP9 despite user requests, citing codec reliability issues within the browser environment.

0
ProgrammingDEV Community ·

How to Diagnose VPN DNS Issues by Identifying the Layer Causing the Problem

When DNS behaves unexpectedly, the VPN is often blamed, but multiple layers — including the OS, browser, router, app cache, and VPN profile — can each influence how a lookup is resolved. A structured diagnostic approach involves first identifying where the problem appears, such as whether it affects one browser, one device, or all devices on a network. Comparing behavior across browsers, devices, and VPN states — while changing only one variable at a time — helps isolate the responsible layer without disrupting a working setup. DNS caching means recent changes may not appear immediately, making a device restart or a timed retest a valid early step. Precisely describing the symptom, including when it started and under what conditions it occurs, is key to making the problem actionable.

0
ProgrammingDEV Community ·

PostgreSQL XID Wraparound: How a Math Limit Can Halt Your Database

PostgreSQL uses a 32-bit Transaction ID (XID) system with roughly 4.2 billion available IDs, treating them as a circular ring to manage data visibility under its MVCC concurrency model. When old rows are not periodically 'frozen,' their transaction IDs can mathematically shift into the future, making valid data invisible to queries. To prevent data corruption, PostgreSQL forcefully blocks all new write operations once the counter comes within 11 million transactions of wraparound. Autovacuum normally handles row freezing in the background, but it can be silently stalled by abandoned replication slots, orphaned prepared transactions, or long-running uncommitted queries. Monitoring the datfrozenxid age and ensuring Autovacuum runs without blockers are the primary safeguards against this type of outage.