    [NAME]
    ALL.dao.class.aspect

    [TITLE]
    Aspect Class

    [DESCRIPTION]

    In Dao, a class decorator can be effectly used as an aspect for AOP, if decoration
    target patterns are specified for auto application. The target patterns are can be
    specified in the same way as the target patterns for class method decorators.

    The fields of such class will be automatically injected to normal classes selected
    according to the affix rules, and the decorators defined in such aspect class are
    automatically applied to the methods (selected according to the same affix rules) of the
    normal classes.

    To avoid unintentional application of aspects, a class can only be modified by aspects
    that are accessible at the definition point of the class. Furthermore, only aspects
    defined in the same file as the class or in the directly loaded file will be
    automatically applied.

       1  class @AspectForAnyClass for ~  # To be applied to any classes;
       2  {
       3      var injected = {}
       4
       5      # This is not a decorator!
       6      routine @AspectForAnyClass(){
       7          io.writeln( 'In @AspectForAnyClass():' );
       8          injected = { 1, 2, 3 }
       9      }
      10
      11      # This decorator will also be applied to the default constructors:
      12      routine @DecoratorForAnyMethod( meth(args) : routine ) for ~ {
      13          io.writeln( 'In @DecoratorForAnyMethod():', std.about(meth) )
      14          io.writeln( injected )
      15          return meth( args, ... )
      16      }
      17  }
      18
      19  # For classes with names prefixed with My:
      20  class @AspectForMyClasses for My~
      21  {
      22      routine @Method( meth(args) : routine ) for Method~ {
      23          io.writeln( 'In @AspectForMyClasses::@Method():', std.about(meth) )
      24          return meth( args, ... )
      25      }
      26  }
      27
      28  class MyClass
      29  {
      30      routine Method(){ io.writeln( 'MyClass::Method()' ) }
      31  }
      32
      33  k = MyClass()  # Invoke the default constructor of Klass;
      34  k.Method()