Tuesday, January 16, 2007

SCBCD - Enterprise Bean Environment

1)Which of the following statements regarding the resource manager connection factory reference deployment descriptor element are correct? [Select all correct answers]

1)Allows JMS destinations to be defined.
2)Allows relocation of a database without modifying the enterprise bean source code.
3)Enables the bean provider to use JNDI to lookup the home interface of an enterprise bean.
4)Allows the bean provider to reference configurable data that can be changed by a deployer without modifying the enterprise bean's source code.
5)Allows the bean provider to obtain database connections without requiring to specify the user credentials in the enterprise bean's source code.

2)Given an extract of an enterprise bean's deployment descriptor, which of the following code statements can be used to find the currency exchange rate between pound sterling and Japanese yen? [Select all correct answers]

...
<ejb-name>CurrencyConverter</ejb-name>
<ejb-class>com.ejbcertificate.CurrencyConverterBean</ejb-class>
...
<env-entry>
<description>
Currency exchange rate between pound sterling and Japanese yen
</description>
<env-entry-name>exchangeRate/japan</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>188.418</env-entry-value>
</env-entry>
...
Assume that the following variables have been declared:

Context initCtx= new InitialContext();
Context envCtx = initCtx.lookup("java:/comp/env");


1)(String)initCtx.lookup("java:/comp/env/exchangeRate/japan");
2)(String)envCtx.lookup("java:/comp/env/exchangeRate/japan");
3)(String)initCtx.lookup("exchangeRate/japan");
4)(String)envCtx.lookup("exchangeRate.japan");
5)
(String)envCtx.lookup("exchangeRate/japan");

3)Which of the following deployment descriptor elements allow the bean provider to refer to the homes of other enterprise beans? [Select all correct answers]

1)env-entry
2)env-ref
3)env-local-ref
4)ejb-ref
5)
ejb-local-ref

4)Which of the following responsibilities regarding EJB references belong to the application assembler? [Select all correct answers]

1)Declaring the EJB reference in the deployment descriptor.
2)Linking an EJB reference to a target enterprise bean.
3)Binding the homes of enterprise beans that exist in the target operational environment.
4)Ensuring that the target enterprise method is type-compatible with the declared EJB reference.
5)Ensuring that all the declared EJB references are bound to the home of enterprise beans.

5)Which of the following statements regarding an enterprise bean's environment JNDI naming are correct? [Select all correct answers]

1)java:comp/env is the JNDI name of an enterprise bean's environment.
2)An enterprise bean's configuration data cannot be declared in a subcontext of the enterprise bean's environment.
3)EJB references must be declared in the ejb subcontext of the enterprise bean's environment.
4)JDBC DataSource references must be declared in the jdbc subcontext of the enterprise bean's environment.
5)URL connection factories may be declared in java:comp/env.

6)Who is responsible for configuring resource managers in the EJB server environment?

1)Bean provider
2)Application assembler
3)Deployer
4)Container
5)System administrator

7)Which one of the following statements regarding an enterprise bean's environment is correct?

1)Multiple deployments of the same enterprise bean result in the same home.
2)Enterprise bean instances are permitted to modify the bean's environment at runtime.
3)Environment entries can be shared with different enterprise beans.
4)Only the same environment entry values can be set for an enterprise bean.
5)Each enterprise bean defines its own set of environment entries.

8)What are the purposes of the environment entry deployment descriptor element? [Select all correct answers]

1)Allows JMS destinations to be defined so that they can be bound to the target operational environment by the deployer.
2)Allows the password required by a database connection to be externally configured.
3)Describes the configuration details that the enterprise bean expects to be provided in its environment at runtime.
4)Allows configuration values used by an enterprise bean to be modified at deployment time without changing the enterprise bean's source code .
5)Avoids the use of property files as storage of configuration details, which is used by an enterprise bean.

9)Which one of the following is the container provider responsible for?

1)Linking an EJB reference to a target enterprise bean.
2)Binding the homes of enterprise beans that exist in the target operational environment.
3)Declaring the EJB reference in the deployment descriptor.
4)Providing tools that notify that there are unresolved EJB references.
5)Ensuring that the target enterprise method is type-compatible with the declared EJB reference

10)Which of the following statements regarding an enterprise bean's environment are correct? [Select all correct answers]

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)2,5

Answers 2 and 5 are correct. The bean provider uses the resource manager connection factory reference deployment descriptor element to define a logical name for a resource manager connection factory object. When a resource connection is required, the bean provider uses the defined logical name to perform a JNDI lookup to obtain the resource manager connection factory reference in the enterprise bean's code. A connection to the resource is obtained by calling the appropriate method on the factory reference.

The deployer uses the resource reference deployment descriptor element to bind the reference to an actual resource manager connection factory in the target environment. If the location of a database is modified, the deployer can simply rebind the associated resource manager connection factory without modifying the enterprise bean's source code. The bean provider can also specify whether the principle associated with a resource manager needs to be supplied by the deployer thus allowing the bean provider to obtain database connections without having to specify the user credentials in the enterprise bean's source code.

Answer 1 is incorrect because the resource environment reference deployment descriptor element must be used when referencing an administered object associated with resources such as JMS destinations. Answer 3 is incorrect because the EJB reference deployment descriptor element must be used to enable the bean provider to lookup the home interface of an enterprise bean. Answer 4 is incorrect because the environment entry deployment descriptor element must be used to allow the bean provider to reference configurable data.



2)1,5

Answers 1 and 5 are correct. The exchange rate between pound sterling and Japanese yen is stored in the exchangeRate subcontext of the enterprise bean's environment. The JNDI name of this environment entry is java:/comp/env/exchangeRate/japan and can therefore be accessed using either the full JNDI name from the initial context or using the exchangeRate/japan JNDI name from the enterprise bean's environment context.

Answer 2 is incorrect. The full JNDI name cannot be used from the enterprise bean's environment context. Answer 3 is incorrect because the JNDI name used to lookup the exchange rate from the initial context must include the enterprise bean's environment name. Answer 4 is incorrect because the '.' symbol cannot be used to partition the subcontexts.



3)4,5

Answers 4 and 5 are correct. The ejb-ref element allows the bean provider to refer to enterprise beans that are accessed through its remote home and ejb-local-ref to refer to enterprise beans that are accessed through its local home.

Answer 1 is incorrect because the env-entry element should only be used to reference configurable data that allow customisation of an enterprise bean without changing the bean's source code. Answers 2 and 3 are incorrect because no such elements are permitted in the deployment descriptor.



4)2,4

Answers 2 and 4 are correct. Ensuring that the target enterprise method is type-compatible with the declared EJB reference are the responsibilities of both the application assembler and the deployer.

Answer 1 is incorrect because it is the responsibility of the bean provider. Answers 3 and 5 are incorrect because they are the responsibilities of the deployer.



5)1,5

Answers 1 and 5 are correct.

Answer 2 is incorrect because there are no restrictions imposed by the EJB specification regarding the organisation of the configuration data that an enterprise bean needs. The configuration data can be declared at the root of the env context or in the subcontexts within the enterprise bean's environment. If fact, the same rules apply for references to other enterprise beans, JDBC DataSource references, JMS connection factories, JavaMail connection factories and URL connection factories. Although the J2EE specification provides guidelines regarding how they should be organised in the subcontexts, it is not mandatory that the guidelines are followed. Therefore answers 3 and 4 are also incorrect.



6)5
Answer 5 is correct. The system administrator is responsible for adding, removing and configuring resource managers in the EJB environment.

7)5

Answer 5 is correct.

Answer 1 is incorrect. If an enterprise bean is deployed more that once in the same container, each bean will get a distinct home. Answer 2 is incorrect because enterprise bean instances can only read the values of the environment entries at runtime; the bean instances are not able to modify them. Answer 3 is incorrect because environment entries cannot be shared with different enterprise beans. Answer 4 is incorrect because different environment entry values can be set for an enterprise bean if the bean is deployed multiple times in the same container.



8)3,4,5

Answers 3, 4 and 5 are correct. The bean provider declares in the deployment descriptor the configuration details that the enterprise bean expects to be provided in its environment at runtime. The tools provided by the container presents the configuration details expected, for the application assembler or deployer to set or modify. The process allows configuration values to be changed without requiring any access or modification of the enterprise bean's source code. Answer 5 is correct because the use of the environment entry deployment descriptor element provides a standard process for externalising configuration details used by enterprise beans. This avoids the necessity of using property files to store configuration details. Note that accessing files from an enterprise bean is of course prohibited by the EJB specification.

Answer 1 is incorrect. The bean provider should use the resource environment reference deployment descriptor element when referencing an administered object associated with resources such as JMS destinations. Answer 2 is incorrect. The bean provider should use the resource manager connection factory reference deployment descriptor element to define factories for creating connections to a resource manager. The child res-auth element is used to define whether the deployer is responsible for supplying the credentials used by the connection.



9)4

Answer 4 is correct.

Answer 1 is incorrect because it is the responsibility of the application assembler. Answer 2 is incorrect because it the responsibility of the deployer. Answer 3 is incorrect because it is the responsibility of the bean provider. Answer 5 is incorrect because ensuring that the target enterprise method is type-compatible with the declared EJB reference are the responsibilities of both the application assembler and the deployer.



10)1,5

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.



No comments: