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?
About Question enthuware.oce-ejbd.v6.2.364 :
Moderator: admin
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
-
- Site Admin
- Posts: 10043
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.364 :
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.
-
- Posts: 16
- Joined: Tue Nov 08, 2016 9:39 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.364 :
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
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
-
- Site Admin
- Posts: 10043
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.364 :
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.
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.
Who is online
Users browsing this forum: No registered users and 19 guests