Browse Java Design Patterns & Enterprise Application Architecture

Types of Proxies in Java

Distinguish virtual, protection, and remote proxies in Java so the access concern is explicit instead of buried in a generic wrapper.

Java proxies usually fall into three practical categories.

    flowchart TD
	    A["Proxy"] --> B["Virtual proxy"]
	    A --> C["Protection proxy"]
	    A --> D["Remote proxy"]
	    B --> E["Delay expensive creation or loading"]
	    C --> F["Authorize or deny access"]
	    D --> G["Represent a remote service locally"]

Virtual Proxy

Use it when the real object is expensive and should only be created when needed.

Examples:

  • lazy image or document loading
  • expensive repository initialization
  • deferred connection setup

Protection Proxy

Use it when callers should see the same contract but not all have the same access rights.

Examples:

  • role-based access to documents
  • write restrictions around administrative operations
  • tenant-aware access checks

Remote Proxy

Use it when the real object lives on another machine or process and the local code should interact with a stand-in.

Examples:

  • RPC or HTTP client wrappers
  • generated service stubs
  • client-side proxies for distributed APIs

Review Rule

Name the proxy by its access concern. If you cannot say what the proxy is controlling, it is probably just an undisciplined wrapper.

Revised on Thursday, April 23, 2026