• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

mock question about interceptor of EJB3.0

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic