About Question enthuware.oce-ejbd.v6.2.364 :

Moderator: admin

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.364 :

Post by himaiMinh »

I think option 2 , changing the bean into a singleton bean is a correct choice if we consider these reasons:
1. by default, the concurrency management is container managed concurrency. So, we don't need to explicitly specify that.
2. by default, all the methods of a singleton bean has a @Lock(WRITE)

So, without doing anything, just change the bean into a singleton bean, will make the bean
thread safe?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.364 :

Post by admin »

Saying "change it to a singleton" is not same as saying "just add @Singleton" to the bean. If the question said the later, your argument would be correct. But in case of the former, it is ambiguous because it doesn't say anything about concurrency management type.
If you like our products and services, please help us by posting your review here.

Gerardo
Posts: 16
Joined: Tue Nov 08, 2016 9:39 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.364 :

Post by Gerardo »

Hi,

After seeing the example code now I have the following doubt:

What happens if I have the following modified code:

public interface SLRemote{
void process1();
void process2();
}

@Stateless
@Remote(SLRemote.class)
public class SLSBean {
public void process2() {
//valid code
}
//doesnt implement process1();
}

I know this will compile, but my doubt is:

¿Will this code deploy without errors?
¿Will I get an error when calling SLRemote.process2()?

Many Thanks in advance

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.oce-ejbd.v6.2.364 :

Post by admin »

1. This depends on the container. Ideally, the container should check that the bean does not define the method required by the remote interface and should fail to deploy.
2. Yes, if it deploys, you will get an exception at run time.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 38 guests