A bean developer wants to write a stateless session bean class that implements the following
remote business interface:
@Remote
Public interface Foo {
Void bar () throws Exception;
Which bean class method is valid?
A.
@Asynchronous
public void bar () throws Exception { . . . }
B.
@Asynchronous
Future <void> bar () { . . .}
C.
void bar () throws Exception { . . . }
D.
public void bar () { . . . }
Explanation:
with EJB 3.1, you can use a simple session EJB with the @Asynchronous
annotation on the method which must be called asynchronously.
@Stateless
@Remote(HelloEjbAsynchronousRemote.class)
public class HelloEjbAsynchronous implements HelloEjbAsynchronousRemote {
@Asynchronous
@Override
public Future<String> ejbAsynchronousSayHello(String name){
If your method has a return value, your method has to return an AsyncResult object which is an
implementation of Future.
D
D
why D?
I think D is the correct one. The question is not telling the method should be async and since you are implementing an interface the method should be public that discard the option C
nfl shop cyber monday cheap wholesale jerseys nfl shop coupons
cheap jerseys Neww England Patriots Jersey wholesale mlb jerseys
D) because:
Asynchronous methods that returns void cannot throw exception. A) => incorrect
Future is changing the method signature. B) => incorrect
Interface methods should be only public. C) => incorrect