Simple aspect oriented programming for TIBCO General Interface™.
Advice can be added before, after, and around any call to an instance method of a GI class.
Note that only the exact class and subclasses loaded after a pointcut is defined are affected.
Note that only instance methods and not static methods can define pointcuts.
The second argument to the before, after, and around methods is the advice function, examples of which are
provided here:
jsx3.AOP.pc("myPointcut", {classes:"jsx3.xml.Document", methods:"load"});
jsx3.AOP.before("myPointcut", function(strURL, intTimeout) {
jsx3.log("load() called on " + this + " with URL " + strURL + ".");
});
jsx3.AOP.after("myPointcut", function(rv, strURL, intTimeout) {
jsx3.log("load() called on " + this + " with URL " + strURL + " returned " + rv + ".");
});
jsx3.AOP.around("myPointcut", function(aop, strURL, intTimeout) {
var t1 = new Date().getTime();
var rv = aop.proceed(strURL, intTimeout);
var tTotal = new Date().getTime() - t1;
jsx3.log("load() called on " + this + " with URL " + strURL + " took " + tTotal + " ms and returned " + rv + ".");
return rv;
});
Note that after advice receives the method return value as the first method parameter. Note also that around
advice must manage the AOP chain by calling
proceed() on the first method parameter and by returning
the return value of this call.
Parameters:
strPName – the pointcut name.
fctAdvice – the advice function.
bRemove – if true, remove this advice.
Parameters:
strPName – the pointcut name.
fctAdvice – the advice function.
bRemove – if true, remove this advice.
Parameters:
strPName – the pointcut name.
fctAdvice – the advice function.
bRemove – if true, remove this advice.
Creates a new pointcut. The supported conditions are as follows:
- classes {String|Function|jsx3.Class|Array<String|Function|jsx3.Class>}:
the classes for which to look for methods.
- methods {String|Array<String>}: the names of the methods for which to add pointcuts. Any name can be a
regular expression with "*" expanded to
\w+.
- type: {String|Function|jsx3.Class}: the pointcut will only affect objects that are
instanceOf(type).
Parameters:
strName – the name of the pointcut to create.
objConditions – the pointcut conditions.
Removes a pointcut.
Parameters:
strName – the name of the pointcut to remove.
Copyright © 2001-2008, TIBCO Software Inc.