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

Moderator: admin

Post Reply
PMiglani
Posts: 14
Joined: Sat Jan 19, 2013 8:42 am
Contact:

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

Post by PMiglani » Sun Dec 15, 2013 3:50 pm

Here the return type of Business Method and Interceptor methods are different. Shouldn't it throw a Class cast exception at Runtime. Please explain.

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

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

Post by admin » Sun Dec 15, 2013 11:59 pm

No, the return type of the interceptor method is always Object as per Interceptor specification (Page 5).
Object <METHOD>(InvocationContext) throws Exception
RTE will occur only if, at run time, the actual type of the object returned by the interceptor method cannot be cast to the return type of the business method.

HTH,
Paul.
If you like our products and services, please help us by posting your review here.

ramy6_1
Posts: 124
Joined: Wed Feb 12, 2014 2:44 am
Contact:

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

Post by ramy6_1 » Wed Dec 10, 2014 6:56 am

Hello ,

getBalance return double , but myAround returns new Double(1.1).
It should be class cast exception for casting double primitive type to Double wrapper type.

Please explain.

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

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

Post by admin » Wed Dec 10, 2014 7:33 am

Auto-boxing will take care of it.
If you like our products and services, please help us by posting your review here.

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

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

Post by himaiMinh » Sun Jun 14, 2015 6:43 pm

But according to the spec, "AroundInvoke methods are allowed to throw runtime or any checked exception that the business method allows within its throws clauses."

In this question, getBalance() and myAround should throw the same exceptions. But getBalance() throws NoAccountException while myAround throws Exception.

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

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

Post by himaiMinh » Sun Jun 14, 2015 7:07 pm

Let me answer my own question.
myAround is allowed to throw NoAccountException inside the method , even though both interceptor method and the business method declare different exceptions in the throw clauses.

peter.varga
Posts: 5
Joined: Wed Dec 16, 2015 3:16 am
Contact:

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

Post by peter.varga » Fri Apr 15, 2016 8:01 am

I was wondering why the first option ("This is an invalid implementation of an interceptor") is not correct, while the interceptor class is not annotated with @Interceptor.

In the specification I did not found anything regarding to this problem. Finally I found it in the separate Interceptor specification:

"The @Interceptor annotation may be used to explicitly designate a class as an interceptor class. Support for this annotation is not required."

I hope it helps other candidates :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest