The Target probe object

The Target object is a specification of the classes and methods to which the probe should be applied. The default is to apply the probe to all instrumented classes and methods.

The Target object is optional. When no Target is specified, the probe will be applied to all instrumented classes and methods.

The Target object lets you specify patterns to match against the package name, class name, and method name, plus the method's signature, of each method the instrumentation engine sees. The patterns can contain wildcards, where "*" will match zero or more characters. If a Target’s wildcard patterns match a method’s package, class, name and signature, the type property determines whether the method is instrumented (include) or not (exclude).

The Target object includes the following properties:
typeRequired. The type property determines whether or not a probe is applied to a target method. Specify include to apply the probe to classes and methods that match the wildcard patterns, exclude to exclude them.
packageSpecify a wildcard pattern to match against the package portion of class names. For example: java.util* will match every class in the java.util package and its subpackages.
classSpecify a wildcard pattern to match against class names.
methodSpecify a wildcard pattern to match against method names.
signatureSpecify a wildcard pattern to match against a method’s signature - that is, the string representing the method's arguments and return type. This is in the Java internal format for method signatures. For example: (Ljava/lang/Object;)D is the signature of a method that takes an Object as a parameter and returns a double. This wildcard pattern can be used to distinguish among overloaded methods.

Notes:

  • The package, class, method, and signature properties are optional. When a property is not specified, the default value is "*".
  • Package and class names specified in a Target object are also checked against the package and class names of any interfaces that a class implements. For example, java.util.HashMap implements the interface java.util.Map. If a probe targets the package java.util, the class name Map, and the method name size, the probe will be applied to java.util.HashMap.size(), and any other class that implements the Map interface.
  • Pattern matching does not consider inheritance relationships: if class Derived extends class Base, and a probe targets Base.run(), the probe will not automatically be applied to Derived.run().
  • Callsite probes match target patterns and rules against the package, class, name and signature of a called method. The matching is done against the called method as it was known at compile time; that is, against the statically-known class and method names, not the actual methods that will be called due to inheritance and virtual functions. If the call is done through an interface reference, the interface name must match.
  • A probe can have multiple Target objects containing successive targeting rules. To target only the methods you specify, add a final Target object that specifies class=* method=* signature=* type=exclude after the Target object for the methods you want to target.
Example
<target
  type="include"
  package="com.example"
  class="*Proxy"
  method="Get*"
/>

Contained by
The Probe object

Copyright IBM Corporation and others 2000, 2003.