简体   繁体   English

关于btrace的代码是什么意思

[英]what's the mean of the code about btrace

In the following code: 在下面的代码中:

import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.annotations.*;
import org.jboss.deployment.DeploymentInfo; 

@BTrace public class Trace{
   @OnMethod(
      clazz="org.jboss.deployment.SARDeployer",
      method="parseDocument"
   )
   public static void traceExecute(DeploymentInfo di){
      printFields(di);
   }

   @OnMethod(
      clazz="java.net.URL",
      method="openConnection",
      location=@Location(Kind.RETURN)
   )
   public static void resolveEntity(@Self Object instance){
     String protocol = str(get(field("java.net.URL", "protocol"),instance));
     String file = str(get(field("java.net.URL", "file"),instance));
     if(startsWith(protocol,"http") && (endsWith(file,".xsd") || endsWith(file,".dtd"))){
        String authority = str(get(field("java.net.URL", "authority"),instance));
        String path = str(get(field("java.net.URL", "path"),instance));
        println("=====================================");
        print(protocol);
        print("://");
        print(authority);
        print(path);
        println(" not found!");
        println("who call:");
        jstack();
     }
   }
}

What does this mean: get(field("java.net.URL", "authority"),instance) ? 这是什么意思: get(field("java.net.URL", "authority"),instance)

Please refer me to the documentation. 请参考我的文档。

field("java.net.URL", "authority") will safely retrieve the field named authority from the class java.net.URL field("java.net.URL", "authority")将安全地从类java.net.URL中检索名为Authority的字段

get(field, instance) reflectively obtains the value of the given field in specified instance . get(field, instance)反射地获取指定instance中给定字段的值。

The Javadoc for BTraceUtils is a good starting point. BTraceUtilsJavadoc是一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM