• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

mock question about interceptor of EJB3.0

 
Sam Sunamin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is the mock question about interceptor, I am not sure about the questions, please help me.



[ August 29, 2007: Message edited by: Sam Sunamin ]
[ September 07, 2007: Message edited by: Sam Sunamin ]
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client will always receives a return value of "intercpted".
The methos testzero is not invoked.

I don't know what's the good answer because the answer D is:
D - The client receives a return value of "intercepted".
and the return of the method Intercept is "intercpted".

I hope it's a copy error and the exam don't test on it.

Beno�t
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the interceptor method will never be invoked because the method signature is wrong:

According MZ Notes:


AroundInvoke methods have the following signature:

Object <METHOD>(InvocationContext) throws Exception


The exception throw is missing.

Please confirm if this is correct,
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The testzero method is not invoked because the interceptor method does not contain the ctx.proceed(); statement. Due to this reason, the next method in the chain, that is testzero business method is never invoked.

Thanks
 
Benoît de Chateauvieux
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Camilo,

When I test the following code in my OC4J



it returns


So I think that the interceptor method is invoked even if there's no throw Exception.
But I know that, in some points, OC4J doesn't follow the EJB specifications.

Thanks
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

The interceptor method can throw Exception. That is can can throw any checked Exception and run-time Exception. Also, If the interceptor method can throw only the Exception which are defined in the business method.

This mean that the interceptor method can be without throws clause, if the exceptions are handles internally in the method.

Your example is running perfectly. I think OC4J container is Java EE compliant with some extra facilities.

Thanks
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright Beno�t and Narendra ,,, thanks for clarifying.

Regards,
 
Sam Sunamin
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer for this is D, return intercepted.

Now, I know why.

Since the overrided interceptor can swallow the exception and it has no ctx.proceed() called.

Best regards.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic