Page 1 of 1

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

Posted: Fri Jun 08, 2012 10:36 am
by ETS User
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?

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

Posted: Sat Jun 09, 2012 1:38 pm
by admin
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.

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

Posted: Sun Nov 11, 2012 8:09 am
by fjwalraven
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:
The client will get an exception when it calls doOne() as well as doTwo().
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.

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

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

Posted: Sun Nov 18, 2012 10:36 am
by admin
Thank you for your suggestion, Frits. It has now been updated.

-Paul.

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

Posted: Mon Jul 15, 2013 3:27 pm
by gurpreet_asrgndu
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()?

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

Posted: Mon Jul 15, 2013 7:42 pm
by admin
The client call can put the call to doOne in a try/catch and then call doTwo.

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

Posted: Sat Aug 24, 2013 2:14 am
by sanju.ait@gmail.com
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.

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

Posted: Sat Aug 24, 2013 2:30 am
by sanju.ait@gmail.com
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.

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

Posted: Sun Aug 25, 2013 10:05 am
by admin
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.

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

Posted: Tue Aug 27, 2013 9:24 am
by sanju.ait@gmail.com
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.

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

Posted: Tue Aug 27, 2013 9:45 am
by admin
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.
That is correct and that is what the explanation says as well:
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.
So I am not sure what is the issue.
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.
Where did you find this behavior description in the specification? I couldn't find it.

thank you,
Paul.