The Default JNDI Context
Environment variables have undergone a fairly
[a-z]adical change. Environment properties in
EJB 1.0 are a powerful mechanism for modifying the behavior of a
component without changing the component’s code. In EJB 1.0,
the environment properties are accessible to the bean through the
EJBContext.getEnvironment()
method, are set by the
bean developer, and can be modified by the deployer. In EJB 1.0, the
environment variables might, for example, be used to set a maximum
withdraw amount for an account bean, as in the following code:
// EJB 1.0 public class AccountBean implements javax.ejb.EntityBean { public EntityContext context; public void withdraw(double amount) throws MaximumLimitException { try { Properties environment = context.getEnvironment(); String value = environment.getProperty("withdraw_limit"); Double limit = new Double(value); if ( amount > limit.doubleValue()) { throw new MaximumLimitException(); else { // continue processing } } } }
EJB 1.1 changes the environment properties from the
java.util.Properties
class, used in EJB 1.0, to a
set of JNDI entries that exist in a name space called the
environment naming context. All deployed beans
in EJB 1.1 have an environment naming context (default JNDI context)
that can be accessed using the JNDI API. This default JNDI context
provides a set of immutable JNDI entries specific to each type of
bean. The default JNDI context provides the bean with access to
environment variables which can be of type String ...
Get Enterprise JavaBeans, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.