Document Information

Last modified:
2007/07/05 12:38 by thron7

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:
2007/07/05 12:38 by thron7

Account

Not logged in

 
 

Job Offers

To further improve qooxdoo we are seeking javascript developers. Read more...

Rich Ajax Platform (RAP)

RAP uses qooxdoo, Java and the Eclipse development model to build rich web applications. Read more...

qooxdoo Web Toolkit (QWT)

Similar to GWT this framework allows to create impressive qooxdoo applications just using Java. Read more...

Pustefix

Pustefix is a MVC-based web application framework using Java and XML/XSLT. Read more...

 
SourceForge.net Logo

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