Previous Topic: Add a Class for TrackingNext Topic: Excluding from Interception and Virtualization


Adding a Method to Intercept

You can add a method for the DevTest Java Agent to intercept by adding the intercept directive to the rules.xml file of the agent.

The intercept directive has the following format:

<intercept class="class_name" method="method_name" signature="signature"/>

The intercept directive can be placed within the group element or the agent element of the rules.xml file.

The format of the signature is described in Signature Specification.

Class hierarchies are considered. Assume that class B extends class A, and both classes define method M. If you intercept method M of class A, then method M of class B is also captured.

By default, CA Continuous Application Insight does not capture getter and setter methods. To add a getter or setter method, include the delay attribute with the value set to true.

 

Examples

The following example adds the setName() method of the com.itko.examples.entity.Account class. The method takes in a java.lang.String object as an argument. The method returns void.

<intercept class="com.itko.examples.entity.Account" method="setName" signature="(Ljava/lang/String;)V" delay="true"/>

The following example adds the getTransactions() method of the com.itko.examples.entity.Account class. The method takes in no arguments. The method returns a java.util.Collection object.

<intercept class="com.itko.examples.entity.Account" method="getTransactions" signature="()Ljava/util/Collection;" delay="true"/>

The following example adds the getRequestTypes() method of the com.itko.examples.airline.ws.jaxws.Request class. The method takes in no arguments. The method returns an array of java.lang.String objects.

<intercept class="com.itko.examples.airline.ws.jaxws.Request" method="getRequestTypes" signature="()[Ljava/lang/String;" delay="true"/>