Results 1 to 3 of 3

Thread: How to make MethodBeforeAdvice completely exit?

  1. #1
    Join Date
    Jan 2005
    Posts
    23

    Default How to make MethodBeforeAdvice completely exit?

    Hi,

    Here is my situation.

    I want a particular set of methods on a variety of objects to first perform a check. If that check is passed, these methods should execute normally. If the check fails, method execution should not commence at all and we should just return to the caller.

    This seems like a prime candidate for BeforeAdvice/MethodBeforeAdvice, except for one thing -- after execution of BeforeAdvice, the advised method would execute regardless of whether or not the check is passed.

    I suppose I could have the BeforeAdvice throw an exception if the check fails, but this seems kind of like a hack to me. Plus, I'd rather not throw exceptions needlessly since they consume more stack space than what would be required if I could just get the MethodBeforeAdvice to cause the exiting of the advised method entirely.

  2. #2
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    Why not just use an around advise?

  3. #3
    Join Date
    Jan 2005
    Posts
    23

    Default

    yeah, of course.

    Use MethodInterceptor and do the check inside there. IF the check fails, just return null instead of returning the return value given by invocation.proceed().

    Thanks for pointing that out.

Similar Threads

  1. Easiest Way to Make a Form Read-Only?
    By cyboc in forum Swing
    Replies: 21
    Last Post: Nov 13th, 2006, 11:05 AM
  2. Exit action from view state
    By pglezen in forum Web Flow
    Replies: 5
    Last Post: Oct 7th, 2005, 02:23 PM
  3. Replies: 0
    Last Post: Jun 6th, 2005, 01:30 PM
  4. Replies: 3
    Last Post: Dec 9th, 2004, 07:43 PM
  5. How to make domain model objects observables ?
    By baptiste in forum Architecture
    Replies: 1
    Last Post: Nov 15th, 2004, 08:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •