Question 1
Match the following roles with their responsibilities by dragging the responsibilities in the empty boxes in front of the roles.
Choices
Roles (A-E):
A. The Bean Provider
B. The Application Assembler
C. The Deployer
D. The EJB Container Provider
E. The System Administrator
Responsibilities (1-5):
1. Ensures that all <env-entry-value> elements contain meaningful data.
2. Monitors the deployed enterprise beans applications at runtime.
3. Writes the primary key class for an entity bean.
4. Defines security roles in the deployment descriptor.
5. Implements the java:comp/env environment naming context.
Correct choice:
A-3; B-4; C-1; D-5; E-2
Explanation:
When developing an entity bean, the Bean Provider must provide the entity bean class and any dependent classes, the primary key class, as well as the entity bean (local and/or remote) home and component interfaces.
The Application Assembler can define one or more security roles in the deployment descriptor. Groups of methods are then mapped onto these security roles in order to define the security view of the application. It is worth noting that if the Application Assembler does not define security roles, this task will need to be performed by the Deployer.
The Bean Provider may fill in the environment entry value elements with some data. When the bean is assembled with other beans, the Application Assembler may modify or set those values in case the Bean Provider left them unassigned. However, the Deployer has the final say and may change the environment entry values in order to set them to meaningful values in the context of the deployment environment.
The EJB Container Provider must implement the java:comp/env naming context, and provide it to the enterprise beans at runtime, so that environment entries can be looked up in the bean instances.
Apart from being responsible for monitoring the deployed applications at runtime, the System Administrator must also configure the EJB container, set up security management, and integrate resource managers with the EJB container.
Please refer to sections 10.6.1, 20.2.3, 20.2.4, 21.3.1, and 25.5 of the EJB 2.0 specification for further details.
Question 2
Consider the following session bean home interface located through the Java Naming and Directory Interface (JNDI).
Context initialContext = new InitialContext();
ProcessPaymentHome ppHome = (ProcessPaymentHome)
initialContext.lookup("java:comp/env/ejb/pphome");
Which exceptions must be declared in the signatures of the methods contained in the ProcessPaymentHome interface?
Choices
A. RemoteException
B. FindException
C. Any application specific exception
D. CreateException
E. RuntimeException
Correct choice:
C; D
Explanation:
Choices C and D are the correct answers.
It is important to note that the object retrieved from JNDI is directly cast to the correct interface type without being narrowed first. This clearly indicates that we are dealing with the local client view of a session bean. This rules out choice A, as RemoteException must only be declared when dealing with remote client views.
Choice B is incorrect since even if the exception called were FinderException, the answer would still be incorrect, as only entity bean home interfaces define finder methods.
Choice C is correct since any application specific exceptions might be thrown from the methods declared in the home interface of a session bean.
Choice D is correct since session bean home interface have to declare at least one create method and the throws clause of create methods must include CreateException.
Choice E is incorrect since RuntimeException is an unchecked exception and it is not mandatory to declare such exceptions in the throws clause of the methods.
Please refer to sections 6.2.1 and 7.10 of the EJB 2.0 specification for further details.
Question 3
Consider the following code taken from some enterprise bean class (Assume all reference variables have been declared properly and the code has been compiled successfully):
EJBObject obj = ejbContext.getEJBObject();
Object pkey = obj.getPrimaryKey();
What type of bean may contain such code?
Choices
A. Message-driven bean
B. Stateless session bean
C. Entity bean
D. Stateful session bean
E. None of the above
Correct choice:
C
Explanation:
Choice C is the correct answer.
Primary keys only make sense for entity beans. As a result, the only possible answer is choice C.
Please refer to sections 9.9 and 9.10 of the EJB 2.0 specification for further details. |