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

The Problem

How do you model business processes and workflow logic in a server-side Java application that can be managed by a container and participate in transactions?

Core Idea

A session bean is a server-side component that represents work being performed for client code. It implements business logic, rules, algorithms, and workflow. Session beans are business process objects—not persistent data objects.

How It Works

  • Client code accesses session beans through the EJB container
  • The container intercepts all calls, providing middleware services (security, transactions, concurrency)
  • Session beans are non-persistent—they exist only in memory during a client session
  • When the client disconnects, the session bean can be destroyed
  • Session beans do not survive server or machine crashes

Key Properties

  • Non-persistent (in-memory only)
  • Short-lived (lifetime of client session)
  • Not shared between multiple clients
  • Can perform database operations but are not themselves persistent
  • Two subtypes: stateful and stateless

Edge Cases & Gotchas

  • Session beans cannot survive application server crashes
  • If client times out, container may destroy the session bean
  • Do not rely on ejbRemove() for critical cleanup—it may never be called if container crashes