Search in sources :

Example 1 with SERVICE_REST_METADATA_RESOURCE_PATH

use of org.apache.dubbo.metadata.rest.RestMetadataConstants.SERVICE_REST_METADATA_RESOURCE_PATH in project dubbo by alibaba.

the class ServiceRestMetadataStorage method append.

public void append(Set<ServiceRestMetadata> serviceRestMetadata) throws IOException {
    storage.read(SERVICE_REST_METADATA_RESOURCE_PATH, reader -> {
        Gson gson = new Gson();
        return (List) gson.fromJson(reader, getParameterized(List.class, ServiceRestMetadata.class).getType());
    }).ifPresent(existedMetadata -> {
        // Add all existed ServiceRestMetadata
        serviceRestMetadata.addAll(existedMetadata);
    });
    write(serviceRestMetadata);
}
Also used : List(java.util.List) ServiceRestMetadata(org.apache.dubbo.metadata.rest.ServiceRestMetadata) ClassPathMetadataStorage(org.apache.dubbo.metadata.annotation.processing.ClassPathMetadataStorage) TypeToken.getParameterized(com.google.gson.reflect.TypeToken.getParameterized) Gson(com.google.gson.Gson) ProcessingEnvironment(javax.annotation.processing.ProcessingEnvironment) Set(java.util.Set) IOException(java.io.IOException) SERVICE_REST_METADATA_RESOURCE_PATH(org.apache.dubbo.metadata.rest.RestMetadataConstants.SERVICE_REST_METADATA_RESOURCE_PATH) Gson(com.google.gson.Gson)

Aggregations

Gson (com.google.gson.Gson)1 TypeToken.getParameterized (com.google.gson.reflect.TypeToken.getParameterized)1 IOException (java.io.IOException)1 List (java.util.List)1 Set (java.util.Set)1 ProcessingEnvironment (javax.annotation.processing.ProcessingEnvironment)1 ClassPathMetadataStorage (org.apache.dubbo.metadata.annotation.processing.ClassPathMetadataStorage)1 SERVICE_REST_METADATA_RESOURCE_PATH (org.apache.dubbo.metadata.rest.RestMetadataConstants.SERVICE_REST_METADATA_RESOURCE_PATH)1 ServiceRestMetadata (org.apache.dubbo.metadata.rest.ServiceRestMetadata)1