About Question enthuware.oce-ejbd.v6.2.434 :
Moderator: admin
About Question enthuware.oce-ejbd.v6.2.434 :
How can doTwo() be called when it says "So the timer creation will fail and the container will discard the instance." when doOne() is called?
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
Client's call to a method and the actual invocation of the method on the bean instance are disconnected. Therefore, the client call call whatever method is exposed by the interface. It may or may not succeed.
HTH,
Paul.
HTH,
Paul.
-
- Posts: 429
- Joined: Tue Jul 24, 2012 2:43 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
In the question it is stated that:
"Given that a client calls doOne() and then doTwo(), which of the following statements are correct?"
The answer:
So I suggest changing the answer
The client will get an exception when it calls doOne() as well as doTwo().
into
The client will receive an exception from both methods (doOne() and doTwo()).
Regards,
Frits
"Given that a client calls doOne() and then doTwo(), which of the following statements are correct?"
The answer:
can be misunderstood as it is not clear whether the client gets an exception when it calls doOne() in combination with doTwo() or that you get an exception from both methods.The client will get an exception when it calls doOne() as well as doTwo().
So I suggest changing the answer
The client will get an exception when it calls doOne() as well as doTwo().
into
The client will receive an exception from both methods (doOne() and doTwo()).
Regards,
Frits
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
Thank you for your suggestion, Frits. It has now been updated.
-Paul.
-Paul.
-
- Posts: 55
- Joined: Thu Jan 03, 2013 7:51 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
still not clear about the explanation given to the orginal poster. if the timer creation is failed and the bean instance is discarded how can client call doTwo()?
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
The client call can put the call to doOne in a try/catch and then call doTwo.
-
- Posts: 38
- Joined: Fri Aug 16, 2013 11:37 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
doOne won't throw any exception in this case, tried it.
Also doTwo will print "1" if called within 10 seconds of doOne.
After 10 seconds of of doOne, runtime exception will be thrown because container won't find any timeout method declared in the bean, than only bean instance will be discarded. So if doTwo will be called after 10 seconds of doOnc invocation, will throw exception stating that no ejb found.
Also doTwo will print "1" if called within 10 seconds of doOne.
After 10 seconds of of doOne, runtime exception will be thrown because container won't find any timeout method declared in the bean, than only bean instance will be discarded. So if doTwo will be called after 10 seconds of doOnc invocation, will throw exception stating that no ejb found.
-
- Posts: 38
- Joined: Fri Aug 16, 2013 11:37 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
Based on above comment explanation.
//LINE 20 in method doTwo() will print 1................... Will be true if called within 10 seconds
//LINE 20 in method doTwo() will print 0................... Will never be called, if called after 10 sec, no ejb will be found.
The print out by //LINE 20 in method doTwo() cannot be predicted with the given information. ... Very True
The client will get an exception when it calls doOne() but not when it calls doTwo(). ... doOne will not throw exception, doTwo will throw exception if called after 10 seconds.
Seems like a messed up question.
//LINE 20 in method doTwo() will print 1................... Will be true if called within 10 seconds
//LINE 20 in method doTwo() will print 0................... Will never be called, if called after 10 sec, no ejb will be found.
The print out by //LINE 20 in method doTwo() cannot be predicted with the given information. ... Very True
The client will get an exception when it calls doOne() but not when it calls doTwo(). ... doOne will not throw exception, doTwo will throw exception if called after 10 seconds.
Seems like a messed up question.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
1. As per the specification, a bean that does not implement TimedObject, it cannot create a timer. So if the exception is not thrown by a container in such a case, then the container is not compliant.
2. This is a stateless bean so it is possible that two calls from a client may even go to a different instances. So even if one instance is discarded, the container will create another instance to service the second call.
HTH,
Paul.
2. This is a stateless bean so it is possible that two calls from a client may even go to a different instances. So even if one instance is discarded, the container will create another instance to service the second call.
HTH,
Paul.
-
- Posts: 38
- Joined: Fri Aug 16, 2013 11:37 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
1. As per the specification, a bean that does not implement TimedObject, it cannot create a timer. So if the exception is not thrown by a container in such a case, then the container is not compliant.
REPLY : Its not necessary to implement TimedObject to create timer, method annotated with @Timeout will be suffice.
2. This is a stateless bean so it is possible that two calls from a client may even go to a different instances. So even if one instance is discarded, the container will create another instance to service the second call.
REPLY : Since there is no timeout method in the bean, for every bean if doOne method is called on that bean, that bean will be discarded after 10 second in absence of timeout method.
REPLY : Its not necessary to implement TimedObject to create timer, method annotated with @Timeout will be suffice.
2. This is a stateless bean so it is possible that two calls from a client may even go to a different instances. So even if one instance is discarded, the container will create another instance to service the second call.
REPLY : Since there is no timeout method in the bean, for every bean if doOne method is called on that bean, that bean will be discarded after 10 second in absence of timeout method.
-
- Site Admin
- Posts: 10386
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.434 :
That is correct and that is what the explanation says as well:sanju.ait@gmail.com wrote:1. As per the specification, a bean that does not implement TimedObject, it cannot create a timer. So if the exception is not thrown by a container in such a case, then the container is not compliant.
REPLY : Its not necessary to implement TimedObject to create timer, method annotated with @Timeout will be suffice.
So I am not sure what is the issue.Because the bean does not implement javax.ejb.TimedObject and it does not contain @Timeout method either. So the timer creation will fail and the container will discard the instance.
Where did you find this behavior description in the specification? I couldn't find it.sanju.ait@gmail.com wrote: 2. This is a stateless bean so it is possible that two calls from a client may even go to a different instances. So even if one instance is discarded, the container will create another instance to service the second call.
REPLY : Since there is no timeout method in the bean, for every bean if doOne method is called on that bean, that bean will be discarded after 10 second in absence of timeout method.
thank you,
Paul.
Who is online
Users browsing this forum: No registered users and 7 guests