Search in sources :

Example 1 with MethodMetadata

use of org.apache.dubbo.admin.model.domain.MethodMetadata in project incubator-dubbo-ops by apache.

the class ServiceTestV3Util method generateMethodMeta.

public static MethodMetadata generateMethodMeta(FullServiceDefinition serviceDefinition, MethodDefinition methodDefinition) {
    MethodMetadata methodMetadata = new MethodMetadata();
    String[] parameterTypes = methodDefinition.getParameterTypes();
    String returnType = methodDefinition.getReturnType();
    String signature = methodDefinition.getName() + "~" + String.join(";", parameterTypes);
    methodMetadata.setSignature(signature);
    methodMetadata.setReturnType(returnType);
    List<Object> parameters = generateParameterTypes(parameterTypes, serviceDefinition);
    methodMetadata.setParameterTypes(parameters);
    return methodMetadata;
}
Also used : MethodMetadata(org.apache.dubbo.admin.model.domain.MethodMetadata)

Example 2 with MethodMetadata

use of org.apache.dubbo.admin.model.domain.MethodMetadata in project incubator-dubbo-ops by apache.

the class ServiceTestController method methodDetail.

@RequestMapping(value = "/method", method = RequestMethod.GET)
public MethodMetadata methodDetail(@PathVariable String env, @RequestParam String application, @RequestParam String service, @RequestParam String method) {
    Map<String, String> info = ConvertUtil.serviceName2Map(service);
    MetadataIdentifier identifier = new MetadataIdentifier(info.get(Constants.INTERFACE_KEY), info.get(Constants.VERSION_KEY), info.get(Constants.GROUP_KEY), Constants.PROVIDER_SIDE, application);
    String metadata = providerService.getProviderMetaData(identifier);
    MethodMetadata methodMetadata = null;
    if (metadata != null) {
        Gson gson = new Gson();
        String release = providerService.findVersionInApplication(application);
        if (release.startsWith("2.")) {
            org.apache.dubbo.admin.model.domain.FullServiceDefinition serviceDefinition = gson.fromJson(metadata, org.apache.dubbo.admin.model.domain.FullServiceDefinition.class);
            List<org.apache.dubbo.admin.model.domain.MethodDefinition> methods = serviceDefinition.getMethods();
            if (methods != null) {
                for (org.apache.dubbo.admin.model.domain.MethodDefinition m : methods) {
                    if (ServiceTestUtil.sameMethod(m, method)) {
                        methodMetadata = ServiceTestUtil.generateMethodMeta(serviceDefinition, m);
                        break;
                    }
                }
            }
        } else {
            FullServiceDefinition serviceDefinition = gson.fromJson(metadata, FullServiceDefinition.class);
            List<MethodDefinition> methods = serviceDefinition.getMethods();
            if (methods != null) {
                for (MethodDefinition m : methods) {
                    if (ServiceTestV3Util.sameMethod(m, method)) {
                        methodMetadata = ServiceTestV3Util.generateMethodMeta(serviceDefinition, m);
                        break;
                    }
                }
            }
        }
    }
    return methodMetadata;
}
Also used : Gson(com.google.gson.Gson) MetadataIdentifier(org.apache.dubbo.metadata.report.identifier.MetadataIdentifier) FullServiceDefinition(org.apache.dubbo.metadata.definition.model.FullServiceDefinition) MethodDefinition(org.apache.dubbo.metadata.definition.model.MethodDefinition) MethodMetadata(org.apache.dubbo.admin.model.domain.MethodMetadata) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with MethodMetadata

use of org.apache.dubbo.admin.model.domain.MethodMetadata in project incubator-dubbo-ops by apache.

the class ServiceTestUtil method generateMethodMeta.

public static MethodMetadata generateMethodMeta(FullServiceDefinition serviceDefinition, MethodDefinition methodDefinition) {
    MethodMetadata methodMetadata = new MethodMetadata();
    String[] parameterTypes = methodDefinition.getParameterTypes();
    String returnType = methodDefinition.getReturnType();
    String signature = methodDefinition.getName() + "~" + String.join(";", parameterTypes);
    methodMetadata.setSignature(signature);
    methodMetadata.setReturnType(returnType);
    List<Object> parameters = generateParameterTypes(parameterTypes, serviceDefinition);
    methodMetadata.setParameterTypes(parameters);
    return methodMetadata;
}
Also used : MethodMetadata(org.apache.dubbo.admin.model.domain.MethodMetadata)

Aggregations

MethodMetadata (org.apache.dubbo.admin.model.domain.MethodMetadata)3 Gson (com.google.gson.Gson)1 FullServiceDefinition (org.apache.dubbo.metadata.definition.model.FullServiceDefinition)1 MethodDefinition (org.apache.dubbo.metadata.definition.model.MethodDefinition)1 MetadataIdentifier (org.apache.dubbo.metadata.report.identifier.MetadataIdentifier)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1