grpc优化
This commit is contained in:
@@ -11,13 +11,23 @@ import com.zyplayer.doc.grpc.controller.po.ColumnInfo;
|
|||||||
import com.zyplayer.doc.grpc.controller.po.GrpcDocInfo;
|
import com.zyplayer.doc.grpc.controller.po.GrpcDocInfo;
|
||||||
import com.zyplayer.doc.grpc.controller.po.GrpcServiceAndColumn;
|
import com.zyplayer.doc.grpc.controller.po.GrpcServiceAndColumn;
|
||||||
import com.zyplayer.doc.grpc.controller.po.MethodParam;
|
import com.zyplayer.doc.grpc.controller.po.MethodParam;
|
||||||
|
import com.zyplayer.doc.grpc.framework.config.DocGrpcContext;
|
||||||
|
import com.zyplayer.doc.grpc.framework.config.DocGrpcService;
|
||||||
import com.zyplayer.doc.grpc.framework.config.SpringContextUtil;
|
import com.zyplayer.doc.grpc.framework.config.SpringContextUtil;
|
||||||
import com.zyplayer.doc.grpc.framework.consts.Const;
|
import com.zyplayer.doc.grpc.framework.consts.Const;
|
||||||
import io.grpc.Channel;
|
import io.grpc.Channel;
|
||||||
|
import io.grpc.ManagedChannel;
|
||||||
|
import io.grpc.Metadata;
|
||||||
|
import io.grpc.netty.NettyChannelBuilder;
|
||||||
|
import io.grpc.stub.AbstractStub;
|
||||||
|
import io.grpc.stub.MetadataUtils;
|
||||||
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -37,8 +47,9 @@ import java.util.regex.Pattern;
|
|||||||
@RequestMapping("/zyplayer-doc-grpc")
|
@RequestMapping("/zyplayer-doc-grpc")
|
||||||
public class GrpcDocController {
|
public class GrpcDocController {
|
||||||
|
|
||||||
@Resource
|
@Autowired(required = false)
|
||||||
GrpcChannelFactory grpcChannelFactory;
|
DocGrpcContext docGrpcContext;
|
||||||
|
|
||||||
private static Map<String, ColumnInfo> allColumnsMap = new HashMap<>();
|
private static Map<String, ColumnInfo> allColumnsMap = new HashMap<>();
|
||||||
private static Map<String, Object> allBlockingStubMap = new HashMap<>();
|
private static Map<String, Object> allBlockingStubMap = new HashMap<>();
|
||||||
|
|
||||||
@@ -50,7 +61,7 @@ public class GrpcDocController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping("/service")
|
@RequestMapping("/service")
|
||||||
public DocResponseJson service() {
|
public DocResponseJson service() {
|
||||||
List<Object> grpcServiceList = SpringContextUtil.getBeanWithAnnotation(GrpcService.class);
|
List<Object> grpcServiceList = SpringContextUtil.getBeanWithAnnotation(DocGrpcService.class);
|
||||||
if (grpcServiceList == null || grpcServiceList.size() <= 0) {
|
if (grpcServiceList == null || grpcServiceList.size() <= 0) {
|
||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
}
|
}
|
||||||
@@ -80,12 +91,17 @@ public class GrpcDocController {
|
|||||||
* @since 2019年3月31日
|
* @since 2019年3月31日
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/execute")
|
@RequestMapping("/execute")
|
||||||
public DocResponseJson execute(String service, String params) throws Exception {
|
public DocResponseJson execute(String docService, String params) throws Exception {
|
||||||
List<GrpcDocInfo> grpcDocInfoList = this.getServiceInfoByJar(Class.forName(service));
|
List<GrpcDocInfo> grpcDocInfoList = this.getServiceInfoByJar(Class.forName(docService));
|
||||||
JSONObject executeResult = null;
|
JSONObject executeResult = null;
|
||||||
if (grpcDocInfoList != null && grpcDocInfoList.size() > 0) {
|
if (grpcDocInfoList != null && grpcDocInfoList.size() > 0) {
|
||||||
JSONObject paramMap = JSON.parseObject(params);
|
JSONObject paramMap = JSON.parseObject(params);
|
||||||
executeResult = this.executeFunction(grpcDocInfoList.get(0), paramMap);
|
try {
|
||||||
|
executeResult = this.executeFunction(grpcDocInfoList.get(0), paramMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return DocResponseJson.warn("执行方法失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return DocResponseJson.ok(executeResult);
|
return DocResponseJson.ok(executeResult);
|
||||||
}
|
}
|
||||||
@@ -119,6 +135,9 @@ public class GrpcDocController {
|
|||||||
if (newBuilder == null) {
|
if (newBuilder == null) {
|
||||||
throw new ConfirmException("参数组装失败");
|
throw new ConfirmException("参数组装失败");
|
||||||
}
|
}
|
||||||
|
if (docGrpcContext == null) {
|
||||||
|
throw new ConfirmException("注入grpc服务失败");
|
||||||
|
}
|
||||||
// 创建参数对象
|
// 创建参数对象
|
||||||
Method build = newBuilder.getClass().getMethod("build");
|
Method build = newBuilder.getClass().getMethod("build");
|
||||||
Object request = build.invoke(newBuilder);
|
Object request = build.invoke(newBuilder);
|
||||||
@@ -127,13 +146,24 @@ public class GrpcDocController {
|
|||||||
Object blockingStub = allBlockingStubMap.get(grpcDocInfo.getService());
|
Object blockingStub = allBlockingStubMap.get(grpcDocInfo.getService());
|
||||||
if (blockingStub == null) {
|
if (blockingStub == null) {
|
||||||
// 找到父类
|
// 找到父类
|
||||||
Class<?> serviceClass = Class.forName(grpcDocInfo.getService());
|
// Class<?> serviceClass = Class.forName(grpcDocInfo.getService());
|
||||||
String serviceSuperName = serviceClass.getSuperclass().getName();
|
// String serviceSuperName = serviceClass.getSuperclass().getName();
|
||||||
|
String serviceSuperName = grpcDocInfo.getService();
|
||||||
|
int index = serviceSuperName.lastIndexOf(".");
|
||||||
|
serviceSuperName = serviceSuperName.substring(0, index) + "$" + serviceSuperName.substring(index + 1);
|
||||||
String superClassName = serviceSuperName.substring(0, serviceSuperName.indexOf("$"));
|
String superClassName = serviceSuperName.substring(0, serviceSuperName.indexOf("$"));
|
||||||
// 注册
|
// 注册
|
||||||
Class<?> superClass = Class.forName(superClassName);
|
Class<?> superClass = Class.forName(superClassName);
|
||||||
Method newBlockingStubMethod = superClass.getMethod("newBlockingStub", Channel.class);
|
Method newBlockingStubMethod = superClass.getMethod("newBlockingStub", Channel.class);
|
||||||
blockingStub = newBlockingStubMethod.invoke(null, grpcChannelFactory.createChannel());
|
SslContext sslContext = docGrpcContext.getSslContext();
|
||||||
|
ManagedChannel channel = NettyChannelBuilder.forAddress(docGrpcContext.getHost(), docGrpcContext.getPort())
|
||||||
|
.sslContext(sslContext)
|
||||||
|
.build();
|
||||||
|
blockingStub = newBlockingStubMethod.invoke(null, channel);
|
||||||
|
Metadata metadata = docGrpcContext.getMetadata();
|
||||||
|
if (metadata != null) {
|
||||||
|
blockingStub = MetadataUtils.attachHeaders((AbstractStub) blockingStub, metadata);
|
||||||
|
}
|
||||||
allBlockingStubMap.put(grpcDocInfo.getService(), blockingStub);
|
allBlockingStubMap.put(grpcDocInfo.getService(), blockingStub);
|
||||||
}
|
}
|
||||||
Method sayHello = blockingStub.getClass().getMethod(grpcDocInfo.getMethod(), Class.forName(grpcDocInfo.getParamType()));
|
Method sayHello = blockingStub.getClass().getMethod(grpcDocInfo.getMethod(), Class.forName(grpcDocInfo.getParamType()));
|
||||||
@@ -250,7 +280,7 @@ public class GrpcDocController {
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
* @since 2019年3月31日
|
||||||
*/
|
*/
|
||||||
private List<MethodParam> getSetterFunction(Class clazz) {
|
private List<MethodParam> getSetterFunction(Class<?> clazz) {
|
||||||
List<MethodParam> result = new LinkedList<>();
|
List<MethodParam> result = new LinkedList<>();
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
StringBuilder nameSb = new StringBuilder();
|
StringBuilder nameSb = new StringBuilder();
|
||||||
@@ -306,7 +336,7 @@ public class GrpcDocController {
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
* @since 2019年3月31日
|
||||||
*/
|
*/
|
||||||
private List<ColumnInfo> findClassColumns(Class clazz) throws Exception {
|
private List<ColumnInfo> findClassColumns(Class<?> clazz) throws Exception {
|
||||||
Method getMoney = clazz.getMethod("newBuilder");
|
Method getMoney = clazz.getMethod("newBuilder");
|
||||||
Object newBuilder = getMoney.invoke(clazz);
|
Object newBuilder = getMoney.invoke(clazz);
|
||||||
|
|
||||||
@@ -331,7 +361,7 @@ public class GrpcDocController {
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
* @since 2019年3月31日
|
||||||
*/
|
*/
|
||||||
private List<GrpcDocInfo> getServiceInfoByJar(Class clazz) {
|
private List<GrpcDocInfo> getServiceInfoByJar(Class<?> clazz) {
|
||||||
List<GrpcDocInfo> providerList = new LinkedList<>();
|
List<GrpcDocInfo> providerList = new LinkedList<>();
|
||||||
try {
|
try {
|
||||||
Method[] methods = clazz.getDeclaredMethods();
|
Method[] methods = clazz.getDeclaredMethods();
|
||||||
@@ -353,13 +383,20 @@ public class GrpcDocController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GrpcDocInfo grpcDocInfo = new GrpcDocInfo();
|
GrpcDocInfo grpcDocInfo = new GrpcDocInfo();
|
||||||
|
DocGrpcService annotation = clazz.getAnnotation(DocGrpcService.class);
|
||||||
|
if (annotation != null) {
|
||||||
|
grpcDocInfo.setService(annotation.service());
|
||||||
|
} else {
|
||||||
|
grpcDocInfo.setService(clazz.getName());
|
||||||
|
}
|
||||||
|
grpcDocInfo.setDocService(clazz.getName());
|
||||||
grpcDocInfo.setMethod(methodName);
|
grpcDocInfo.setMethod(methodName);
|
||||||
grpcDocInfo.setService(clazz.getName());
|
|
||||||
grpcDocInfo.setParamType(paramType);
|
grpcDocInfo.setParamType(paramType);
|
||||||
grpcDocInfo.setResultType(resultType);
|
grpcDocInfo.setResultType(resultType);
|
||||||
providerList.add(grpcDocInfo);
|
providerList.add(grpcDocInfo);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return providerList;
|
return providerList;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ package com.zyplayer.doc.grpc.controller.po;
|
|||||||
public class GrpcDocInfo {
|
public class GrpcDocInfo {
|
||||||
private String method;
|
private String method;
|
||||||
private String service;
|
private String service;
|
||||||
|
private String docService;
|
||||||
private String explain;
|
private String explain;
|
||||||
private String result;
|
private String result;
|
||||||
private String paramType;
|
private String paramType;
|
||||||
@@ -70,4 +71,12 @@ public class GrpcDocInfo {
|
|||||||
public void setMethod(String method) {
|
public void setMethod(String method) {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDocService() {
|
||||||
|
return docService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDocService(String docService) {
|
||||||
|
this.docService = docService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.zyplayer.doc.grpc.framework.config;
|
||||||
|
|
||||||
|
import io.grpc.Metadata;
|
||||||
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
|
||||||
|
public interface DocGrpcContext {
|
||||||
|
|
||||||
|
SslContext getSslContext();
|
||||||
|
|
||||||
|
String getHost();
|
||||||
|
|
||||||
|
Metadata getMetadata();
|
||||||
|
|
||||||
|
Integer getPort();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.zyplayer.doc.grpc.framework.config;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* grpc服务的注解
|
||||||
|
*
|
||||||
|
* @author 暮光:城中城
|
||||||
|
* @since 2019年3月31日
|
||||||
|
*/
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Service
|
||||||
|
public @interface DocGrpcService {
|
||||||
|
|
||||||
|
String service() default "";
|
||||||
|
}
|
||||||
@@ -1,46 +1,45 @@
|
|||||||
package com.zyplayer.doc.grpc.framework.config;
|
//package com.zyplayer.doc.grpc.framework.config;
|
||||||
|
//
|
||||||
import com.nxest.grpc.client.*;
|
//import com.nxest.grpc.client.*;
|
||||||
import com.nxest.grpc.client.configure.GrpcClientProperties;
|
//import com.nxest.grpc.client.configure.GrpcClientProperties;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
//import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.context.annotation.Bean;
|
//import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//
|
||||||
import javax.annotation.Resource;
|
//import javax.annotation.Resource;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* grpc配置
|
// * grpc配置
|
||||||
*
|
// *
|
||||||
* @author 暮光:城中城
|
// * @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
// * @since 2019年3月31日
|
||||||
*/
|
// */
|
||||||
@Configuration
|
//@Configuration
|
||||||
@AutoConfigureAfter(GrpcServerConfiguration.class)
|
////@AutoConfigureAfter(GrpcServerConfiguration.class)
|
||||||
public class GrpcClientConfiguration {
|
//public class GrpcClientConfiguration {
|
||||||
|
//
|
||||||
@Resource
|
// @Resource
|
||||||
private GrpcProperties grpcProperties;
|
// private GrpcProperties grpcProperties;
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public GrpcClientProperties clientProperties() {
|
// public GrpcClientProperties clientProperties() {
|
||||||
return grpcProperties.getClient();
|
// return grpcProperties.getClient();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// @Bean
|
||||||
@Bean
|
// public GrpcChannelFactory channelFactory() {
|
||||||
public GrpcChannelFactory channelFactory() {
|
// return new AddressChannelFactory(clientProperties());
|
||||||
return new AddressChannelFactory(clientProperties());
|
// }
|
||||||
}
|
//
|
||||||
|
// @Bean
|
||||||
@Bean
|
// public GrpcClientInterceptorDiscoverer clientInterceptorDiscoverer() {
|
||||||
public GrpcClientInterceptorDiscoverer clientInterceptorDiscoverer() {
|
// return new AnnotationClientInterceptorDiscoverer();
|
||||||
return new AnnotationClientInterceptorDiscoverer();
|
// }
|
||||||
}
|
//
|
||||||
|
// @Bean
|
||||||
@Bean
|
// @ConditionalOnClass(GrpcClient.class)
|
||||||
@ConditionalOnClass(GrpcClient.class)
|
// public GrpcClientBeanPostProcessor grpcClientBeanPostProcessor() {
|
||||||
public GrpcClientBeanPostProcessor grpcClientBeanPostProcessor() {
|
// return new GrpcClientBeanPostProcessor(channelFactory(), clientInterceptorDiscoverer());
|
||||||
return new GrpcClientBeanPostProcessor(channelFactory(), clientInterceptorDiscoverer());
|
// }
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,34 +1,34 @@
|
|||||||
package com.zyplayer.doc.grpc.framework.config;
|
//package com.zyplayer.doc.grpc.framework.config;
|
||||||
|
//
|
||||||
import com.nxest.grpc.client.configure.GrpcClientProperties;
|
//import com.nxest.grpc.client.configure.GrpcClientProperties;
|
||||||
import com.nxest.grpc.server.configure.GrpcServerProperties;
|
//import com.nxest.grpc.server.configure.GrpcServerProperties;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
//import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
//import org.springframework.context.annotation.Configuration;
|
||||||
|
//
|
||||||
/**
|
///**
|
||||||
* grpc配置文件
|
// * grpc配置文件
|
||||||
*
|
// *
|
||||||
* @author 暮光:城中城
|
// * @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
// * @since 2019年3月31日
|
||||||
*/
|
// */
|
||||||
@Configuration
|
//@Configuration
|
||||||
@ConfigurationProperties(prefix = "grpc")
|
//@ConfigurationProperties(prefix = "grpc")
|
||||||
public class GrpcProperties {
|
//public class GrpcProperties {
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* Grpc server properties
|
// * Grpc server properties
|
||||||
*/
|
// */
|
||||||
private final GrpcServerProperties server = new GrpcServerProperties();
|
// private final GrpcServerProperties server = new GrpcServerProperties();
|
||||||
/**
|
// /**
|
||||||
* Grpc client properties
|
// * Grpc client properties
|
||||||
*/
|
// */
|
||||||
private final GrpcClientProperties client = new GrpcClientProperties();
|
// private final GrpcClientProperties client = new GrpcClientProperties();
|
||||||
|
//
|
||||||
public GrpcServerProperties getServer() {
|
// public GrpcServerProperties getServer() {
|
||||||
return server;
|
// return server;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public GrpcClientProperties getClient() {
|
// public GrpcClientProperties getClient() {
|
||||||
return client;
|
// return client;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -12,24 +12,24 @@ import javax.annotation.Resource;
|
|||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019年3月31日
|
* @since 2019年3月31日
|
||||||
*/
|
*/
|
||||||
@Configuration
|
//@Configuration
|
||||||
public class GrpcServerConfiguration {
|
//public class GrpcServerConfiguration {
|
||||||
|
//
|
||||||
@Resource
|
// @Resource
|
||||||
private GrpcProperties grpcProperties;
|
// private GrpcProperties grpcProperties;
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public GrpcServiceDiscoverer serviceDiscoverer() {
|
// public GrpcServiceDiscoverer serviceDiscoverer() {
|
||||||
return new AnnotationGrpcServiceDiscoverer();
|
// return new AnnotationGrpcServiceDiscoverer();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean
|
// @Bean
|
||||||
public GrpcServerFactory severFactory() {
|
// public GrpcServerFactory severFactory() {
|
||||||
return new NettyGrpcServerFactory(serviceDiscoverer(), grpcProperties.getServer());
|
// return new NettyGrpcServerFactory(serviceDiscoverer(), grpcProperties.getServer());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Bean(name = "grpcServer", initMethod = "start", destroyMethod = "destroy")
|
// @Bean(name = "grpcServer", initMethod = "start", destroyMethod = "destroy")
|
||||||
public GrpcServer serverRunner() {
|
// public GrpcServer serverRunner() {
|
||||||
return severFactory().createServer();
|
// return severFactory().createServer();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|||||||
@@ -312,11 +312,12 @@
|
|||||||
},
|
},
|
||||||
requestExecute() {
|
requestExecute() {
|
||||||
var fuc = app.grpcInfo.function;
|
var fuc = app.grpcInfo.function;
|
||||||
|
var docService = app.grpcInfo.docService;
|
||||||
var service = fuc.substring(0, fuc.lastIndexOf("."));
|
var service = fuc.substring(0, fuc.lastIndexOf("."));
|
||||||
var method = fuc.substring(fuc.lastIndexOf(".") + 1, fuc.length);
|
var method = fuc.substring(fuc.lastIndexOf(".") + 1, fuc.length);
|
||||||
var paramColumnRequest = JSON.stringify(JSON.parse(app.paramColumnRequest));
|
var paramColumnRequest = JSON.stringify(JSON.parse(app.paramColumnRequest));
|
||||||
var param = {
|
var param = {
|
||||||
service: service,
|
docService: docService,
|
||||||
method: method,
|
method: method,
|
||||||
params: paramColumnRequest,//JSON.stringify(params),
|
params: paramColumnRequest,//JSON.stringify(params),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ var Formatjson = {
|
|||||||
if (obj.length == 0) {
|
if (obj.length == 0) {
|
||||||
html += this.getRow(indent, "<span class='array-brace'>[ ]</span>" + comma, isPropertyContent);
|
html += this.getRow(indent, "<span class='array-brace'>[ ]</span>" + comma, isPropertyContent);
|
||||||
} else {
|
} else {
|
||||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
var clpsHtml = '<span><img class="option-img" src="webjars/doc-grpc/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||||
var annotation = '';
|
var annotation = '';
|
||||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
||||||
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
||||||
@@ -48,7 +48,7 @@ var Formatjson = {
|
|||||||
if (numProps == 0) {
|
if (numProps == 0) {
|
||||||
html += this.getRow(indent, "<span class='object-brace'>{ }</span>" + comma, isPropertyContent);
|
html += this.getRow(indent, "<span class='object-brace'>{ }</span>" + comma, isPropertyContent);
|
||||||
} else {
|
} else {
|
||||||
var clpsHtml = '<span><img class="option-img" src="webjars/doc-dubbo/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
var clpsHtml = '<span><img class="option-img" src="webjars/doc-grpc/img/expanded.png" onClick="Formatjson.expImgClicked(this);" /></span><span class="collapsible">';
|
||||||
var annotation = '';
|
var annotation = '';
|
||||||
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
if(showAnnotation && isNotEmpty(keyName) && isNotEmpty(this.annotationObject[keyName])) {
|
||||||
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
annotation = '<span class="annotation">// '+this.annotationObject[keyName]+'</span>';
|
||||||
@@ -80,10 +80,10 @@ var Formatjson = {
|
|||||||
var container = img.parentNode.nextSibling;
|
var container = img.parentNode.nextSibling;
|
||||||
if(!container) return;
|
if(!container) return;
|
||||||
var disp = "none";
|
var disp = "none";
|
||||||
var src = "webjars/doc-dubbo/img/collapsed.png";
|
var src = "webjars/doc-grpc/img/collapsed.png";
|
||||||
if(container.style.display == "none"){
|
if(container.style.display == "none"){
|
||||||
disp = "inline";
|
disp = "inline";
|
||||||
src = "webjars/doc-dubbo/img/expanded.png";
|
src = "webjars/doc-grpc/img/expanded.png";
|
||||||
}
|
}
|
||||||
container.style.display = disp;
|
container.style.display = disp;
|
||||||
img.src = src;
|
img.src = src;
|
||||||
|
|||||||
Reference in New Issue
Block a user