You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/09/24 06:16:56 UTC

[GitHub] [skywalking-java] VictorZeng commented on a change in pull request #35: Add Fastjson plugin

VictorZeng commented on a change in pull request #35:
URL: https://github.com/apache/skywalking-java/pull/35#discussion_r715343862



##########
File path: apm-sniffer/optional-plugins/fastjson-1.2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/fastjson/define/FastjsonInstrumentation.java
##########
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.fastjson.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.StaticMethodsInterceptPoint;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassStaticMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.apache.skywalking.apm.agent.core.plugin.match.MultiClassNameMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+
+/**
+ * Fastjson A fast JSON parser/generator for Java (It's the most popular
+ * json parsing library in China from Alibaba inc).
+ * <p>
+ * JSON provides a "one stop" solution for json parser/generator solution
+ * basic requirements.
+ * <p>
+ * json2x: JSON#parse()/JSON#parseArray()/JSON#parseObject()/JSON#toJavaObject()
+ * x2json: JSON#toJSON()/JSON#toJSONBytes()/JSON#toJSONString()/JSON#writeJSONString()
+ */
+public class FastjsonInstrumentation extends ClassStaticMethodsEnhancePluginDefine {
+
+    public static final String ENHANCE_CLASS = "com.alibaba.fastjson.JSON";
+
+    public enum Enhance {
+
+        PARSE_ARRAY("parseArray", "org.apache.skywalking.apm.plugin.fastjson.ParseArrayInterceptor"),
+        PARSE("parse", "org.apache.skywalking.apm.plugin.fastjson.ParseInterceptor"),
+        PARSE_OBJECT("parseObject", "org.apache.skywalking.apm.plugin.fastjson.ParseObjectInterceptor"),
+        TO_JAVA_OBJECT("toJavaObject", "org.apache.skywalking.apm.plugin.fastjson.ToJavaObjectInterceptor"),
+        TO_JSON_BYTES("toJSONBytes", "org.apache.skywalking.apm.plugin.fastjson.ToJsonBytesInterceptor"),
+        TO_JSON("toJSON", "org.apache.skywalking.apm.plugin.fastjson.ToJsonInterceptor"),
+        TO_JSON_STRING("toJSONString", "org.apache.skywalking.apm.plugin.fastjson.ToJsonStringInterceptor"),
+        WRITE_JSON_STRING("writeJSONString", "org.apache.skywalking.apm.plugin.fastjson.WriteJsonStringInterceptor");
+
+        private String enhanceMethod, interceptorClass;
+
+        Enhance(String enhanceMethod, String interceptorClass) {
+            this.enhanceMethod = enhanceMethod;
+            this.interceptorClass = interceptorClass;
+        }
+    }

Review comment:
       bo build a Map<String, String>? key is interceptorClass , value is interceptorClass.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org