About Question enthuware.oce-ejbd.v6.2.519 :
Moderator: admin
-
- Posts: 14
- Joined: Sat Jan 19, 2013 8:42 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
Here the return type of Business Method and Interceptor methods are different. Shouldn't it throw a Class cast exception at Runtime. Please explain.
-
- Site Admin
- Posts: 10045
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
No, the return type of the interceptor method is always Object as per Interceptor specification (Page 5).
HTH,
Paul.
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.Object <METHOD>(InvocationContext) throws Exception
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 124
- Joined: Wed Feb 12, 2014 2:44 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
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.
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.
-
- Site Admin
- Posts: 10045
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
Auto-boxing will take care of it.
If you like our products and services, please help us by posting your review here.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
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.
In this question, getBalance() and myAround should throw the same exceptions. But getBalance() throws NoAccountException while myAround throws Exception.
-
- Posts: 358
- Joined: Fri Nov 29, 2013 8:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
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.
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.
-
- Posts: 5
- Joined: Wed Dec 16, 2015 3:16 am
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.519 :
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
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
Who is online
Users browsing this forum: No registered users and 47 guests