Skip to content
btpka3 edited this page Oct 11, 2018 · 5 revisions

watch

Display the details of specified class and method .

Example

Watch paramters , return value/exception.

ga?> watch -f com.your.XxxApi yyyMthod "{params, returnObj, throwExp}" -x 3
  • -f : watch after method invocation, if not specified, returnObj and throwExp will be null.
  • "{params, returnObj, throwExp}" : It's a ONGL Collection Construction expression. When expression contains space, expression must be quoted. This example can also be written in {params,returnObj,throwExp} (without space and double quote).
  • -x 3 : Display nested object at most 3 level. It's very useful for complex/nested/combined objects/collections.

Help

ga?>help watch
+---------+----------------------------------------------------------------------------------+
|   USAGE | -[bfesx:En:] class-pattern method-pattern express condition-express              |
|         | Display the details of specified class and method                                |
+---------+----------------------------------------------------------------------------------+
| OPTIONS |              [b] | Watch before invocation                                       |
|         | -----------------+-------------------------------------------------------------- |
|         |              [f] | Watch after invocation                                        |
|         | -----------------+-------------------------------------------------------------- |
|         |              [e] | Watch after throw exception                                   |
|         | -----------------+-------------------------------------------------------------- |
|         |              [s] | Watch after successful invocation                             |
|         | -----------------+-------------------------------------------------------------- |
|         |             [x:] | Expand level of object (0 by default)                         |
|         | -----------------+-------------------------------------------------------------- |
|         |              [E] | Enable regular expression to match (wildcard matching by def  |
|         |                  | ault)                                                         |
|         | -----------------+-------------------------------------------------------------- |
|         |             [n:] | Threshold of execution times                                  |
|         | -----------------+-------------------------------------------------------------- |
|         |    class-pattern | Path and classname of Pattern Matching                        |
|         | -----------------+-------------------------------------------------------------- |
|         |   method-pattern | Method of Pattern Matching                                    |
|         | -----------------+-------------------------------------------------------------- |
|         |          express | express, write by OGNL.                                       |
|         |                  |                                                               |
|         |                  | FOR EXAMPLE    params[0]                                      |
|         |                  |     params[0]+params[1]                                       |
|         |                  |     returnObj                                                 |
|         |                  |     throwExp                                                  |
|         |                  |     target                                                    |
|         |                  |     clazz                                                     |
|         |                  |     method                                                    |
|         |                  |                                                               |
|         |                  | THE STRUCTURE                                                 |
|         |                  |           target : the object                                 |
|         |                  |            clazz : the object's class                         |
|         |                  |           method : the constructor or method                  |
|         |                  |     params[0..n] : the parameters of method                   |
|         |                  |        returnObj : the returned object of method              |
|         |                  |         throwExp : the throw exception of method              |
|         |                  |         isReturn : the method ended by return                 |
|         |                  |          isThrow : the method ended by throwing exception     |
|         | -----------------+-------------------------------------------------------------- |
|         |  condition-expre | Conditional expression by OGNL                                |
|         |               ss |                                                               |
|         |                  | FOR EXAMPLE                                                   |
|         |                  |      TRUE : 1==1                                              |
|         |                  |      TRUE : true                                              |
|         |                  |     FALSE : false                                             |
|         |                  |      TRUE : params.length>=0                                  |
|         |                  |     FALSE : 1==2                                              |
|         |                  |                                                               |
|         |                  | THE STRUCTURE                                                 |
|         |                  |           target : the object                                 |
|         |                  |            clazz : the object's class                         |
|         |                  |           method : the constructor or method                  |
|         |                  |     params[0..n] : the parameters of method                   |
|         |                  |        returnObj : the returned object of method              |
|         |                  |         throwExp : the throw exception of method              |
|         |                  |         isReturn : the method ended by return                 |
|         |                  |          isThrow : the method ended by throwing exception     |
+---------+----------------------------------------------------------------------------------+
| EXAMPLE | watch -Eb org\.apache\.commons\.lang\.StringUtils isBlank params[0]              |
|         | watch -b org.apache.commons.lang.StringUtils isBlank params[0]                   |
|         | watch -f org.apache.commons.lang.StringUtils isBlank returnObj                   |
|         | watch -bf *StringUtils isBlank params[0]                                         |
|         | watch *StringUtils isBlank params[0]                                             |
|         | watch *StringUtils isBlank params[0] 'params[0].length==1'                       |
|         | watch *StringUtils isBlank params[0] '#cost>100'                                 |
+---------+----------------------------------------------------------------------------------+
Clone this wiki locally