• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Traditional objects live in a single JVM—if you want to call a method on an object running on a different server, you can’t just use object.method(). Network programming is complex: you need sockets, serialization, protocol handling, and error recovery.

Core Idea

A distributed object is a Java object running on a remote server, but it can be accessed as if it were local. The EJB container (via RMI-IIOP) handles all network complexity—the client calls methods on a proxy, and the container forwards the call to the actual object on the server.

How It Works

  1. Server side: The EJB object (proxy) is registered with the naming service (JNDI)
  2. Client lookup: Client uses JNDI to find the home object reference
  3. Proxy creation: Home object creates an EJB object (proxy) for the client
  4. Method invocation: Client calls methods on the proxy; proxy forwards via network to the actual bean
  5. Result return: Bean’s response travels back through proxy to client

Visual Explanation

DistributedObjects cluster_client Client JVM cluster_server Server JVM (Container) C Client Code Proxy EJB Object (Proxy) C->Proxy 1. hello() Proxy->C 5. Return Home Home Object (Factory) Proxy->Home 2. Network call (RMI-IIOP) Bean Enterprise Bean (Actual Object) Home->Bean 3. Delegate Bean->Proxy 4. Result

Key Properties

  • Objects can be accessed across network boundaries (different machines, different JVMs)
  • Location transparency: Client doesn’t know or care where the object physically lives
  • RMI-IIOP protocol: Standard wire protocol for EJB distributed objects
  • Proxy pattern: Client never talks directly to the bean—always through EJB object

Connections

Edge Cases & Gotchas

  • Network failures: Remote exceptions (RemoteException) can occur—not present with local objects
  • Serialization overhead: Parameters must be serializable for network transfer
  • Latency: Network calls are 100-1000x slower than in-process calls
  • Stateless beans preferred for distributed access: No client-specific state to transfer