Hello Friends, This is a question that I found in ejbcertificate.com:
Which of the following statements regarding an enterprise bean's environment are correct? 1. The container provides the tools that allow the deployer to create and manage the enterprise bean's environment. 2. Enterprise bean instances can modify the values of the environment entries at runtime. 3. The deployer sets and modifies the values of the environment entries by editing the enterprise bean's deployment descriptor. 4. Enterprise bean instances obtain the values of the environment entries from the enterprise bean's deployment descriptor. 5. Enterprise bean instances use the JNDI interfaces to obtain the values of the environment entries.
Answers 1 and 5 are correct.
Answer 2 is incorrect because enterprise bean instances can only read the values of the environment entries at runtime and are not able to modify them. Answers 3 and 4 are incorrect because the deployment descriptor is used to define only the environment entries, as opposed to the values that the enterprise bean expects to be provided at runtime.
It says Answers 3 & 4 are incorrect because the values of environment entries are not provided by DDs and the <env-entry>'s only describe the environment entries. But in the <env-entry> element there is a <env-entry-value> that specifies the value. What is this element for? If the deployer sets the value of an environment entry then isn't he modifying the value in the DD and isn't the bean picking up that value from the DD?
The default values for environment entries can be specified in the deployment descriptor by either the bean provider or the assembler using that <env-entry-value> tag that you mentioned. I think 3 is incorrect because the deployer is supposed to use the container-provided tools to alter these values, rather than edit the deployment descriptor directly. I think 4 is incorrect because the bean obtains the values through JNDI. Now, usually (or at least often) JNDI gets the values from the DD, but the bean doesn't ... not directly. Both of these points seems to be splitting hairs, IMHO.
Hello Greg, Yep what you said is exactly what I thought. The deployer might be using tools but I guess once the bean is deployed it is the container that provides the value as set by the deployer and it might not be necessarily being picked up from the DD. The DD might be having something like a default value.
Now, usually (or at least often) JNDI gets the values from the DD, but the bean doesn't ... not directly. Both of these points seems to be splitting hairs, IMHO.
It's not splitting hairs. On deployment the JNDI names of resource environment names that are declared in the deployment descriptor are bound to objects in the JNDI tree. These names are relative to the java:comp/env context. In order to access the environment entries, it's necessary to obtain the InitialContext and do a lookup based on the name. In other words, the bean can obtain its environment entries only via JNDI.
JNDI is fundamentally important to EJB. You don't need to know all of it, but an understanding of what's required for the exam is necessary.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop