Assume you would like to receive notification from the container as a stateless session bean transitions to
and from the ready state. Which of the following life cycle back annotations would you use? (Choose one.)
A developer wants to write a stateful session bean using the following interface as local business interface:
1. package acme;
2. public interface Bar {
3. public void bar ();
4. }
Assuming there is not an ejb-jar.xml file, which code can be inserted into Lines 4-6 below to define the bean
with the ejb name of BarBean?
1. package acme;
2. import javax.ejb.*;
3. import java.io.*;
4.
5.
6.
7. }
A developer creates a stateless session bean. This session bean needs data from a remote system.
Reading this data takes a long time. Assume that the data will NOT change during the life time of the bean
and that the information to connect to the remote system is defined in JNDI.
Which statement describes how to manage the data correctly?
Suppose an EJB named HelloWorldBean is deployed as a standalone ejb-jar. Assuming the
HelloWorldBean is implemented as follows:
Which HelloWorldBean methods are accessible by another EJB within the same ejb-jar?
Given the following stateless session bean:
How would you change the EJB to prevent multiple clients from simultaneously accessing the sayHello
method of a single bean instance?
A developer writes a Singleton bean that holds state for a single coordinate:
An update thread acquires an EJB reference to CoordinateBean and alternates between invoking
SetCoordinate (0, 0) and SetCoordinate (1, 1) in a loop.
At the same time, ten reader threads each acquire an EJB reference to CoordinateBean and invoke
getCoordinate () in a loop.
Which represents the set of all possible coordinate values [X, Y] returned to the reader threads?
A developer writes a Singleton bean that uses the java Persistence API within a business method:
Two different concurrently executing caller threads acquire an EJB reference to PersonBean and each
invoke the getPerson () method one time. How many distinct transaction are used to process the caller
invocations?
A developer writes three interceptor classes: AInt, BInt, and CInt. Each interceptor class defines an
AroundInvoke method called interceptor. In the ejb-jar.xml descriptor, CInt is declared as the default
interceptor.
FooBean is a stateless session bean with a local business interface Foo that declares a method Foo ():
10. @Stateless
11. @Interceptors(AInt.class)
12. public class FooBean Implements Foo {
13.
14. @Interceptors (BInt.class)
15. @ExcludeClassInterceptors
16. public void foo () {}
17. }
What is the interceptor order when the business method foo () is invoked?
An ejb-jar also contains three interceptor classes: AInt, BInt, CInt. Each interceptor class defines an
AroundInvoke method called intercept.
The ejb-jar also contains a stateless session bean FooBean with a local business interface Foo that
declares a method foo ():
10. @Stateless
11. @Intercaptors ({CInt.class, BInt.class})
12. public class FooBean implements Foo {
13.
14. public void foo () {}
15.
16. }
The ejb-jar contains a META-INF/ejb-jar.xml file with an section: com.acme.AInt FooBean
What is the interceptor order when the business methodfoo() is invoked?