Significance of "java:comp/env"

Each program has certain dependencies on the operating environment. The
classic example is the database. A driver is required to access the
database. Now since EJB is a component rather than a traditional program
that accesses the database, it is often advantageous not to hard-code the
driver name inside the ejb to get the connection. This abstracts the driver
from the ejb and the proper driver can be assigned to the ejb during
environment configuration or deployment process.

Secondly, since the EJB could be marketed as a component and could be
deployed by a number of users within their applications so a way must be
there that helps in the customization of the component according to the
particular users requirements.

In order to address these problems EJB framework has provided a standardized
way of achieving this. Each EJB is allowed to get these environment setting
through the JNDI interface and the initial naming context is standardized as
"java:comp/env" in order to avoid conflict with another naming contexts.
This particular naming context indicates that the name being looked up is an
environment name. The container hosting the EJB components is responsible
for actually providing the JNDI services and somehow provides the ejb with
its environment settings. Each environment setting has a scope that lasts
for a particular bean. Different beans can have the same environment names.
In fact a bean deployed multiple times is allowed to have different values
of the environment names.

This is what i have understood about the "java:comp/env". Please correct me
if i am wrong. Also, how the container actually does this is completely left
to the provider of the container.

Regards,
Ripan

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to