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 »

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: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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 »

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: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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 »

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 »

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 »

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 26 guests