Which bean class method is valid?

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 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.



Leave a Reply 7

Your email address will not be published. Required fields are marked *


Leo

Leo

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

Delilah

Delilah

nfl shop cyber monday cheap wholesale jerseys nfl shop coupons

Pasquale

Pasquale

cheap jerseys Neww England Patriots Jersey wholesale mlb jerseys

Andrei

Andrei

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