Document Information

Last modified:
2011/02/22 12:31 (external edit)

This is documentation for qooxdoo 0.7.x only. You might be interested in consulting the latest docs.

An Aspect Template Class

Here is a code template which you may copy to your application namespace and adapt it to implement aspects in your qooxdoo application. For a far more advanced sample look at qx.dev.Profile.

/**
 * AspectTemplate.js -- template class to use qooxdoo aspects
 *
 * This is a minimal class template to show how to deploy aspects in qooxdoo
 * applications. For more information on the aspect infrastructure see the API
 * documentation for qx.core.Aspect.
 *
 * You should copy this template to your application namespace and adapt it to
 * your needs. See the comments in the code for further hints.
 *
 * To enable the use of your aspect class, some extra arguments have to be
 * passed to qooxdoo's generator, e.g. through a Makefile variable like so:
 *
 * APPLICATION_ADDITIONAL_SOURCE_OPTIONS = --add-require \
 *   qx.Class:your.namespace.YourAspectClass --use-variant=qx.aspects:on \
 *   --use-setting=qx.enableAspect:true
 *
 */
 
/* ************************************************************************
 
#require(qx.core.Aspect)
#ignore(auto-require)
 
************************************************************************ */
 
/** Adapt the name of the class */
qx.Class.define("your.namespace.YourAspectClass", {
 
  /** The class definition may only contain a 'statics' and a 'defer' member */
  statics :
  {
 
    __counter : 0,  // Static vars are possible
 
    /**
     * This function will be called before each function call.
     *
     * @param fullname {String} Full name of the function including the class name.
     * @param fcn {Function} Wrapped function.
     * @param type {String} The type of the wrapped function (static, member, ...)
     * @param args {Arguments} The arguments passed to the wrapped function.
     */
    atEnter: function(fullName, fcn, type, args) 
    {
      console.log("Entering "+fullName);  // Adapt this to your needs
    },
 
 
    /**
     * This function will be called after each function call.
     *
     * @param fullname {String} Full name of the function including the class name.
     * @param fcn {Function} Wrapped function.
     * @param type {String} The type of the wrapped function (static, member, ...)
     * @param args {Arguments} The arguments passed to the wrapped function.
     * @param returnValue {var} return value of the wrapped function.
     */
    atExit: function(fullName, fcn, type, args, returnValue) 
    {
      console.log("Leaving "+fullName);  // Adapt this to your needs
    }
 
  },
 
 
  defer : function(statics)
  {
    /**
     * Registering your static functions with the aspect registry. For more
     * information see the API documentation for qx.core.Aspect.
     *
     * @param position {String} Where to inject the aspect ("before" or "after").
     * @param type {String} Which types to wrap (“member”, “static”, “constructor”, 
     *                       “destructor”, “property” or ”*”).
     * @param name {RegExp} Name(pattern) of the functions to wrap.
     * @param fcn {Function} Function from this class to be called.
     */
    qx.core.Aspect.addAdvice("before", "*", "your.namespace.*", statics.atEnter);
    qx.core.Aspect.addAdvice("after",  "*", "your.namespace.*", statics.atExit);
  }
 
});

Information

Last modified:
2011/02/22 12:31 (external edit)

Account

 
 
A book on qooxdoo RIAs, authored  by community members
JS Tutorial, JavaScript Tutorial, JavaScript Guide, Learn JavaScript JS, How To Learn JS, Learning JavaScript
 

Bad Behavior has blocked 0 potential spam attempts in the last 7 days.