• ↑↓ to navigate
  • ↵ to open
  • ⟶ to select
  • ⌘ ⌥ ↵ to open in a panel
  • ←→ to navigate
  • esc to dismiss
⌘ '
keyboard shortcuts

The Problem

When the EJB container creates a new entity bean instance for the pool, how does the bean gain access to container services and environment information?

Core Idea

setEntityContext() is called by the container when a new entity bean instance is created. It provides the bean with its EntityContext, enabling access to container services like JNDI lookups and security information.

How It Works

  • Container instantiates a new entity bean class
  • Container calls setEntityContext(EntityContext ctx) on the instance
  • Bean stores the context in a member variable for later use
  • Bean can now query environment info via JNDI (DataSource, etc.)
  • Bean enters the pool—no specific data associated yet

Key Properties

  • Called exactly once when the bean instance is created
  • Bean can retrieve resources and environment data here
  • Context should be stored for use in lifecycle callbacks
  • Bean is now in the pool but has no specific data

Visual Explanation

setEntityContext__ A Setentitycontext() Input B Setentitycontext() Core Mechanism A->B triggers C Setentitycontext() Output B->C produces

Semantic Network

semantic_setEntityContext__ THIS Setentitycontext() REL1 Related Concept THIS--REL1 related REL2 Builds Into THIS--REL2 builds into

Connections

Edge Cases & Gotchas

  • Do NOT perform database operations here
  • Do NOT assume the bean is associated with any data