Search in sources :

Example 56 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class UrlPathAccessItem method appendClientFormattedItem.

@Override
public void appendClientFormattedItem(InvocationFinishEvent finishEvent, StringBuilder builder) {
    OperationMeta operationMeta = finishEvent.getInvocation().getOperationMeta();
    SchemaMeta schemaMeta = finishEvent.getInvocation().getSchemaMeta();
    if (operationMeta != null && schemaMeta != null && schemaMeta.getSwagger() != null) {
        builder.append(schemaMeta.getSwagger().getBasePath()).append(operationMeta.getOperationPath());
        return;
    }
    RestClientRequestImpl restRequestImpl = (RestClientRequestImpl) finishEvent.getInvocation().getHandlerContext().get(RestConst.INVOCATION_HANDLER_REQUESTCLIENT);
    if (null == restRequestImpl || null == restRequestImpl.getRequest() || StringUtils.isEmpty(restRequestImpl.getRequest().path())) {
        builder.append(EMPTY_RESULT);
        return;
    }
    builder.append(restRequestImpl.getRequest().path());
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) RestClientRequestImpl(org.apache.servicecomb.common.rest.codec.param.RestClientRequestImpl) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta)

Example 57 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class InvokerUtils method createInvocation.

private static Invocation createInvocation(String microserviceName, String microserviceVersion, String transport, String schemaId, String operationId, Map<String, Object> swaggerArguments, Type responseType) {
    MicroserviceReferenceConfig microserviceReferenceConfig = SCBEngine.getInstance().createMicroserviceReferenceConfig(microserviceName, microserviceVersion);
    MicroserviceMeta microserviceMeta = microserviceReferenceConfig.getLatestMicroserviceMeta();
    SchemaMeta schemaMeta = microserviceMeta.ensureFindSchemaMeta(schemaId);
    OperationMeta operationMeta = schemaMeta.ensureFindOperation(operationId);
    ReferenceConfig referenceConfig = microserviceReferenceConfig.createReferenceConfig(transport, operationMeta);
    InvocationRuntimeType invocationRuntimeType = operationMeta.buildBaseConsumerRuntimeType();
    invocationRuntimeType.setSuccessResponseType(responseType);
    return InvocationFactory.forConsumer(referenceConfig, operationMeta, invocationRuntimeType, swaggerArguments);
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) InvocationRuntimeType(org.apache.servicecomb.core.definition.InvocationRuntimeType) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta)

Example 58 with SchemaMeta

use of org.apache.servicecomb.core.definition.SchemaMeta in project java-chassis by ServiceComb.

the class TestSchemaMetaCodecRestTemplate method setUp.

@Before
public void setUp() {
    ProtobufManager.clear();
    new Expectations() {

        {
            providerMicroserviceMeta.getMicroserviceName();
            result = "test";
            providerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
            result = null;
            consumerMicroserviceMeta.getMicroserviceName();
            result = "test";
            consumerMicroserviceMeta.getExtData(ProtobufManager.EXT_ID);
            result = null;
        }
    };
    SpringmvcSwaggerGenerator swaggerGenerator = new SpringmvcSwaggerGenerator(ProtoSchema.class);
    Swagger swagger = swaggerGenerator.generate();
    SwaggerEnvironment swaggerEnvironment = new SwaggerEnvironment();
    providerSchemaMeta = new SchemaMeta(providerMicroserviceMeta, "ProtoSchema", swagger);
    SwaggerProducer swaggerProducer = swaggerEnvironment.createProducer(new ProtoSchema(), swagger);
    for (SwaggerProducerOperation producerOperation : swaggerProducer.getAllOperations()) {
        OperationMeta operationMeta = providerSchemaMeta.ensureFindOperation(producerOperation.getOperationId());
        operationMeta.setSwaggerProducerOperation(producerOperation);
    }
    consumerSchemaMeta = new SchemaMeta(consumerMicroserviceMeta, "ProtoSchema", swagger);
}
Also used : Expectations(mockit.Expectations) ProtoSchema(org.apache.servicecomb.codec.protobuf.internal.converter.model.ProtoSchema) SwaggerProducer(org.apache.servicecomb.swagger.engine.SwaggerProducer) Swagger(io.swagger.models.Swagger) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) SwaggerProducerOperation(org.apache.servicecomb.swagger.engine.SwaggerProducerOperation) SwaggerEnvironment(org.apache.servicecomb.swagger.engine.SwaggerEnvironment) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) SpringmvcSwaggerGenerator(org.apache.servicecomb.swagger.generator.springmvc.SpringmvcSwaggerGenerator) Before(org.junit.Before)

Aggregations

SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)58 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)28 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)25 Test (org.junit.Test)24 Invocation (org.apache.servicecomb.core.Invocation)13 Swagger (io.swagger.models.Swagger)9 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)6 Executor (java.util.concurrent.Executor)5 InvocationRuntimeType (org.apache.servicecomb.core.definition.InvocationRuntimeType)5 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)5 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)5 SwaggerProducerOperation (org.apache.servicecomb.swagger.engine.SwaggerProducerOperation)5 MockUp (mockit.MockUp)4 NonSwaggerInvocation (org.apache.servicecomb.core.NonSwaggerInvocation)4 Transport (org.apache.servicecomb.core.Transport)4 TransportManager (org.apache.servicecomb.core.transport.TransportManager)4 InstanceCacheManager (org.apache.servicecomb.registry.cache.InstanceCacheManager)4 DiscoveryTreeNode (org.apache.servicecomb.registry.discovery.DiscoveryTreeNode)4 ServiceRegistry (org.apache.servicecomb.serviceregistry.ServiceRegistry)4