Menu

AOP and Replacing args

Help
eRom
2005-01-13
2013-04-17
  • eRom

    eRom - 2005-01-13

    Hi,

    I ant to build an Aspect for checking input parameters for all methods thats use String type input parameter.
    The method can continue if only the input parameter is not null or undefined and string.length>0.

    So I decide to write an new Aspect.
    But How can i overwriting the args parameters when i do my : joinPoint.proceed(args) ?

    There is an exemple of my Aspect Method :
    private function checkStringAdvice(joinPoint:JoinPoint, args:FunctionArguments) {
            var s:String = args[0];
            if(s != undefined && s.length >0) {
                joinPoint.proceed(args);
            }else {
                joinPoint.proceed(["a base string"]); //Not work !!
            }
        }

    thanks for help ;)
    @+

     
    • Simon Wacker

      Simon Wacker - 2005-01-17

      joinPoint.proceed(["a base string"]); should work trouble-free in case you did all the rest the right way.

       
    • eRom

      eRom - 2005-01-17

      Okay, indeed all works well ;)

      But we have to set the TYPE_AROUND mode for Addvice interception....otherwise it doesn't work...
      In TYPE_BEFORE = the old value is passed
      in TYPE_AFTER = undefined value is passed...

      So great, thanks a lot ;)

      If I understand your mail, I must use the mailing list (as2lib-updates) rather than the sf forum, for quick technical support ? Okay I do..

      Thank you and cheer for this formidable project ;)

      eRom

       
    • Simon Wacker

      Simon Wacker - 2005-01-17

      Yep, JoinPoint proceed can only be used with Around Advices.
      The Before Advice executes the method itself, as well as the After Advice.

       

Log in to post a comment.