Search in sources :

Example 1 with ProtoMapperFactory

use of org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory in project incubator-servicecomb-java-chassis by apache.

the class ScopedProtobufSchemaManager method getOrCreateProtoMapper.

/**
 * get the ProtoMapper from Swagger
 */
public ProtoMapper getOrCreateProtoMapper(SchemaMeta schemaMeta) {
    return mapperCache.computeIfAbsent(schemaMeta.getSchemaId(), key -> {
        Swagger swagger = schemaMeta.getSwagger();
        SwaggerToProtoGenerator generator = new SwaggerToProtoGenerator(schemaMeta.getMicroserviceQualifiedName(), swagger);
        Proto proto = generator.convert();
        ProtoMapperFactory protoMapperFactory = new ProtoMapperFactory();
        return protoMapperFactory.create(proto);
    });
}
Also used : ProtoMapperFactory(org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory) Proto(io.protostuff.compiler.model.Proto) SwaggerToProtoGenerator(org.apache.servicecomb.codec.protobuf.internal.converter.SwaggerToProtoGenerator) Swagger(io.swagger.models.Swagger)

Example 2 with ProtoMapperFactory

use of org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory in project java-chassis by ServiceComb.

the class ScopedProtobufSchemaManager method getOrCreateProtoMapper.

/**
 * get the ProtoMapper from Swagger
 */
public ProtoMapper getOrCreateProtoMapper(SchemaMeta schemaMeta) {
    return mapperCache.computeIfAbsent(schemaMeta.getSchemaId(), key -> {
        Swagger swagger = schemaMeta.getSwagger();
        SwaggerToProtoGenerator generator = new SwaggerToProtoGenerator(schemaMeta.getMicroserviceQualifiedName(), swagger);
        Proto proto = generator.convert();
        ProtoMapperFactory protoMapperFactory = new ProtoMapperFactory();
        return protoMapperFactory.create(proto);
    });
}
Also used : ProtoMapperFactory(org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory) Proto(io.protostuff.compiler.model.Proto) SwaggerToProtoGenerator(org.apache.servicecomb.codec.protobuf.internal.converter.SwaggerToProtoGenerator) Swagger(io.swagger.models.Swagger)

Aggregations

Proto (io.protostuff.compiler.model.Proto)2 Swagger (io.swagger.models.Swagger)2 SwaggerToProtoGenerator (org.apache.servicecomb.codec.protobuf.internal.converter.SwaggerToProtoGenerator)2 ProtoMapperFactory (org.apache.servicecomb.foundation.protobuf.ProtoMapperFactory)2