OracleJavaScript API Reference for Oracle ADF Faces

 

SUMMARY: FIELD | CONSTR | METHOD    DETAIL: FIELD | CONSTR | METHOD

oracle.adf.view.js.profiling
Class AdfProfiler

org.ecmascript.object.Object
   |
   +--oracle.adf.view.js.profiling.AdfProfiler

public class AdfProfiler
extends Object
This object is responsible for adding the instrumentation code to methods. It leverages the AdfCheckpoint class in order to perform timings and data collection. To get an instance, you must use the getInstance() method.


Since:
1.0

Field Summary

private static Number
_index
This is a counter for generating uids
private static String
_PROFILER_GROUP
The group id of all checkpoints added by the profiler class
private static String
_PROP_CLASS_ID
This is put as a property on instance objects so that we can maintain consistant methodIds.
private static String
_PROP_CLASSNAME
This is put as a property on every method that is registered and contains a flag as to whether this method was actually present on the object when it was instantiated
private static String
_PROP_REGISTERED
This is put as a property on every method that is registered and contains the method's name
private static String
_PROP_REGISTERED_CHECKPOINT
This is put as a property on every method that is registered and contains the method's checkpoint
private static String
_PROP_REGISTERED_INST_METHOD
This is put as a property on every method that is registered and contains the origional method
private static String
_PROP_REGISTERED_IS_PRESENT
This is put as a property on every method that is registered and contains a flag as to whether this method was actually present on the object when it was instantiated
private static String
_PROP_REGISTERED_METHOD_NAME
This is put as a property on every method that is registered and contains the method name
private static String
_PROP_REGISTERED_OBJECT
This is put as a property on every method that is registered and contains a reference to the containing object
private static RegExp
_REGEXP_FUNCTION
This regular expression is for retrieving the BODY of a function.
private static RegExp
_REGEXP_FUNCTION_NAME
This is the regular expression for retrieving the name of a function or object in the format of "function f(x)".
private static RegExp
_REGEXP_REGEXP
This regular expression is used to detect and parse a regular expression.
private static RegExp
_REGEXP_REPLACE_METHOD
This regular expression is for replacing the $methodname$ token in the body of the instrumentation function with another value.
private static AdfProfiler
_THE_INSTANCE
The reference to the profiler singleton.


Fields inherited from org.ecmascript.object.Object

constructor, prototype


Constructor Summary

public
AdfProfiler()
This object is responsible for adding the instrumentation code to methods.


Method Summary

private static Object
_getClassId(Object object)
Returns a unique class id.
private static Object
_getClassName(Object object)
Returns this objects class name or "[anonymous]" if the object name is anonymous.
public static Object
getInstance()
Returns the singleton instance of the AdfProfiler.
private static Object
_getMethodId(String methodName, Object object)
Returns a unique method id that is duplicatable based on the methodName and the given object.
private Object
__getRegisteredMethods()
Returns a list of instrumented methods by method id
private static Object
_hasOwnMethod(Object object, String methodName)
Returns true if the object has its own version of the method.
private static Object
_instrumenterFunction()
This is a "prototype" of the function that will be used for instrumentation.
private static Object
_instrumentFunction(String methodName, String methodId, Object object, Object checkpoint)
Instruments a function on the object and returns a reference to the new function.
private static Object
_isInstrumentable(Object object, Object property)
Returns true if this function is one which should be instrumented or not.
private static Object
_isInstrumented(Object method)
Returns true if this method is part of the instrumentation.
private static Object
_isPrototype(Object object, String classname)
Returns true if the given object is the prototype of its base class or false if it is either an instance or the class itself.
private static Object
_isWindow(Object object)
Returns true if the given object is the window object or false if it is not.
public Object
register(Object object, String methodName)
Deprecated: Please use registerMethod instead
public Object
registerFunction(String functionName)
Registers a javascript function with the AdfProfiler.
public Object
registerMethod(Object object, String methodName)
Registers a javascript method with the AdfProfiler.
public Object
startProfiling()
Starts recording profiling data for checkpoints registered by this AdfProfiler.
public Object
stopProfiling()
Stops recording profiling data for checkpoints registered by this AdfProfiler.
private static Object
_uninstrumentFunction(Object func)
Removes instrumentation from a method and reverts the method back to its origional state.
public Object
unregister(Object object, String methodName)
Deprecated: use unregisterMethod
public Object
unregisterAll()
Unregisters all of the registered functions
public Object
unregisterFunction(String functionName)
Unregisters functions that have been registered with the Javascript AdfProfiler.
public Object
unregisterMethod(Object object, String methodName)
Unregisters methods which have been registered with the Javascript AdfProfiler.


Field Detail


_index

private static Number _index

This is a counter for generating uids

_PROFILER_GROUP

private static String _PROFILER_GROUP

The group id of all checkpoints added by the profiler class

_PROP_CLASS_ID

private static String _PROP_CLASS_ID

This is put as a property on instance objects so that we can maintain consistant methodIds.

_PROP_CLASSNAME

private static String _PROP_CLASSNAME

This is put as a property on every method that is registered and contains a flag as to whether this method was actually present on the object when it was instantiated

_PROP_REGISTERED

private static String _PROP_REGISTERED

This is put as a property on every method that is registered and contains the method's name

_PROP_REGISTERED_CHECKPOINT

private static String _PROP_REGISTERED_CHECKPOINT

This is put as a property on every method that is registered and contains the method's checkpoint

_PROP_REGISTERED_INST_METHOD

private static String _PROP_REGISTERED_INST_METHOD

This is put as a property on every method that is registered and contains the origional method

_PROP_REGISTERED_IS_PRESENT

private static String _PROP_REGISTERED_IS_PRESENT

This is put as a property on every method that is registered and contains a flag as to whether this method was actually present on the object when it was instantiated

_PROP_REGISTERED_METHOD_NAME

private static String _PROP_REGISTERED_METHOD_NAME

This is put as a property on every method that is registered and contains the method name

_PROP_REGISTERED_OBJECT

private static String _PROP_REGISTERED_OBJECT

This is put as a property on every method that is registered and contains a reference to the containing object

_REGEXP_FUNCTION

private static RegExp _REGEXP_FUNCTION

This regular expression is for retrieving the BODY of a function. It is used for retrieving the instrumentation function from the AdfProfiler.

_REGEXP_FUNCTION_NAME

private static RegExp _REGEXP_FUNCTION_NAME

This is the regular expression for retrieving the name of a function or object in the format of "function f(x)". Anonymous functions return a blank.

_REGEXP_REGEXP

private static RegExp _REGEXP_REGEXP

This regular expression is used to detect and parse a regular expression. It is used to determine if something is instrumentable or not because in Mozilla regular expressions are a function and bad things happen when we instrument regular expressions. Match[1] will be the regular expression and Match[2] will contain the flags (if any).

_REGEXP_REPLACE_METHOD

private static RegExp _REGEXP_REPLACE_METHOD

This regular expression is for replacing the $methodname$ token in the body of the instrumentation function with another value. It is multiline, global, and case-insensitive.

_THE_INSTANCE

private static AdfProfiler _THE_INSTANCE

The reference to the profiler singleton.

Constructor Detail


AdfProfiler

public AdfProfiler()

This object is responsible for adding the instrumentation code to methods. It leverages the AdfCheckpoint class in order to perform timings and data collection. To get an instance, you must use the getInstance() method.

Method Detail


_getClassId

private static Object _getClassId(Object object)

Returns a unique class id. If the object passed in is a function, the the classname is returned by itself. If the object is a prototype of a class then className.prototype will be returned. If the object is an instance of the class then className.[INSTANCE###] will be returned where instance is a unique number signifying this instance. In the last case, a property will be added to the object allowing us to keep the same ID throughout multiple calls to registered functions.

Parameters:
object  -  the object to get the class id for
Return:
Object - the class id

_getClassName

private static Object _getClassName(Object object)

Returns this objects class name or "[anonymous]" if the object name is anonymous.

Parameters:
object  -  the object to get the name of
Return:
Object - a String representation of this object

getInstance

public static Object getInstance()

Returns the singleton instance of the AdfProfiler. Use this instead of the constructor.

Return:
Object - an instace of the ProflerClass

_getMethodId

private static Object _getMethodId(String methodName,
                                   Object object)

Returns a unique method id that is duplicatable based on the methodName and the given object. The format of this method Id is "classID.methodName".

Parameters:
methodName  -  the name of the method
object    
Return:
Object - a methodId

__getRegisteredMethods

private Object __getRegisteredMethods()

Returns a list of instrumented methods by method id

Return:
Object - a String contining a list of registered methodIds

_hasOwnMethod

private static Object _hasOwnMethod(Object object,
                                    String methodName)

Returns true if the object has its own version of the method. If the object is the window object, this method will always return true.

Parameters:
object  -  the object which contains the property
methodName  -  the method to test
Return:
Object - true if this object has its own version of the method

_instrumenterFunction

private static Object _instrumenterFunction()

This is a "prototype" of the function that will be used for instrumentation. It will replace the origional method and will set up and use the checkpoint. The $methodName$ key will be replaced with the method name when it is retrieved. This will never be executed directly.

Return:
Object

_instrumentFunction

private static Object _instrumentFunction(String methodName,
                                          String methodId,
                                          Object object,
                                          Object checkpoint)

Instruments a function on the object and returns a reference to the new function.

Parameters:
methodName  -  the name of the method to instrument
methodId  -  the id of this instrumented method
object  -  the object containing this method
checkpoint    
Return:
Object - a reference to the new function

_isInstrumentable

private static Object _isInstrumentable(Object object,
                                        Object property)

Returns true if this function is one which should be instrumented or not. It judges this on a number of criteria. First, it will return false if the variable is not a function. Second, it will return false if the variable is a function that has already been instrumented. Third it will return false if the variable is a constructor. Bad things happen when constructors are automatically instrumented, ESPECIALLY in the Rich Client. Finally it will return false if the function is a Regular Expression. They show up as functions in Mozilla (in IE they are objects) and bad things happen when you instrument them.

Parameters:
object  -  the object that contains the property
property  -  the name of the property to test
Return:
Object - null true if this variable is able to be instrumented.

_isInstrumented

private static Object _isInstrumented(Object method)

Returns true if this method is part of the instrumentation. This will check if a method is either an INSTRUMENTER or an INSTRUMENTEE.

Parameters:
method  -  the method to test
Return:
Object - true if this method is either already instrumented or is part of the instrumentation framework

_isPrototype

private static Object _isPrototype(Object object,
                                   String classname)

Returns true if the given object is the prototype of its base class or false if it is either an instance or the class itself.

Parameters:
object  -  the object to test
classname  -  an optional parameter containing the classname. This parameter is provided for performance and prevents us from having to recalculate the classname for the object.
Return:
Object - true of this object is a prototype of its parent class.

_isWindow

private static Object _isWindow(Object object)

Returns true if the given object is the window object or false if it is not.

Parameters:
object  -  the object to test
Return:
Object - true if this object is the window object

register

public Object register(Object object,
                       String methodName)

Registers a javascript method with the AdfProfiler. The profiler will replace this method with a proxy which will, in turn, execute the origional method. If methodName is null then every function on the object will be instrumented.

Deprecated: Please use registerMethod instead
Parameters:
object  -  the object which contains this method
methodName  -  the name of the method that needs to be instrumented
Return:
Object
Throws:
Error if asserts are enabled and if object is null or the method does not exist in the object

registerFunction

public Object registerFunction(String functionName)

Registers a javascript function with the AdfProfiler. The profiler will replace this function with a proxy which will, in turn, execute the origional function. This method assumes that the function defined by functionName is accessible from the window object. If it is not then use the registerMethod function and supply the base object.

Parameters:
functionName  -  the name of the function that needs to be instrumented
Return:
Object
Throws:
Error if asserts are enabled and if the functionName is null

registerMethod

public Object registerMethod(Object object,
                             String methodName)

Registers a javascript method with the AdfProfiler. The profiler will replace this method with a proxy which will, in turn, execute the origional method. If methodName is null then every function on the object will be instrumented.

Parameters:
object  -  the object which contains this method
methodName  -  the name of the method that needs to be instrumented
Return:
Object
Throws:
Error if asserts are enabled and if object is null or the method does not exist in the object

startProfiling

public Object startProfiling()

Starts recording profiling data for checkpoints registered by this AdfProfiler. Manual AdfCheckpoints are not effected by this. Essentially this sets a checkpoint override using AdfCheckpoint.setCheckpointOverride(String, String, Boolean) for the profilers group to true.

Return:
Object

stopProfiling

public Object stopProfiling()

Stops recording profiling data for checkpoints registered by this AdfProfiler. Manual AdfCheckpoints are not effected by this. Essentially this sets a checkpoint override using AdfCheckpoint.setCheckpointOverride(String, String, Boolean) for the profilers group to false.

Return:
Object

_uninstrumentFunction

private static Object _uninstrumentFunction(Object func)

Removes instrumentation from a method and reverts the method back to its origional state.

Parameters:
func    
Return:
Object

unregister

public Object unregister(Object object,
                         String methodName)

Unregisters methods which have been registered with the Javascript AdfProfiler. The profiler will undo changes made to the object by the Register method. It is important to note that collected data for this method will NOT be removed nor will the checkpoint. If the method name is null then every registered method on the object will be unregistered.

Deprecated: use unregisterMethod
Parameters:
object  -  the object that contains the instrumented method
methodName  -  the name of the method to remove
Return:
Object
Throws:
Error if asserts are enabled and if object is null

unregisterAll

public Object unregisterAll()

Unregisters all of the registered functions

Return:
Object

unregisterFunction

public Object unregisterFunction(String functionName)

Unregisters functions that have been registered with the Javascript AdfProfiler. The profiler will undo changes made to the object by registerFunction. It is important to note that collected data for this function will NOT be removed nor will the checkpoint.

Parameters:
functionName  -  the name od the function to unregister from the profiler.
Return:
Object
Throws:
Error if asserts are enabled and if the functionName is null

unregisterMethod

public Object unregisterMethod(Object object,
                               String methodName)

Unregisters methods which have been registered with the Javascript AdfProfiler. The profiler will undo changes made to the object by the Register method. It is important to note that collected data for this method will NOT be removed nor will the checkpoint. If the method name is null then every registered method on the object will be unregistered.

Parameters:
object  -  the object that contains the instrumented method
methodName  -  the name of the method to remove
Return:
Object
Throws:
Error if asserts are enabled and if object is null

SUMMARY: FIELD | CONSTR | METHOD    DETAIL: FIELD | CONSTR | METHOD

 

Generated on 2011.04.27 02:28 UTC
Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.