use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class SchemaLoader method registerSchema.
public SchemaMeta registerSchema(MicroserviceMeta microserviceMeta, String schemaId, Swagger swagger) {
String microserviceName = microserviceMeta.getName();
LOGGER.info("register schema {}/{}/{}", microserviceMeta.getAppId(), microserviceName, schemaId);
SchemaMeta schemaMeta = new SchemaMeta(swagger, microserviceMeta, schemaId);
List<Handler> producerHandlerChain = ProducerHandlerManager.INSTANCE.getOrCreate(microserviceName);
schemaMeta.setProviderHandlerChain(producerHandlerChain);
List<Handler> consumerHandlerChain = ConsumerHandlerManager.INSTANCE.getOrCreate(microserviceName);
schemaMeta.setConsumerHandlerChain(consumerHandlerChain);
microserviceMeta.regSchemaMeta(schemaMeta);
putSelfBasePathIfAbsent(microserviceName, swagger.getBasePath());
return schemaMeta;
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class AbstractSchemaFactory method getOrCreateSchema.
// 因为aop的存在,schemaInstance的class不一定等于schemaClass
protected SchemaMeta getOrCreateSchema(CONTEXT context) {
MicroserviceMeta microserviceMeta = context.getMicroserviceMeta();
SchemaMeta schemaMeta = microserviceMeta.findSchemaMeta(context.getSchemaId());
if (schemaMeta == null) {
schemaMeta = createSchema(context);
}
context.setSchemaMeta(schemaMeta);
return schemaMeta;
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class ProducerSchemaFactory method getOrCreateProducerSchema.
// 只会在启动流程中调用
public SchemaMeta getOrCreateProducerSchema(String microserviceName, String schemaId, Class<?> producerClass, Object producerInstance) {
MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta(microserviceName);
ProducerSchemaContext context = new ProducerSchemaContext();
context.setMicroserviceMeta(microserviceMeta);
context.setSchemaId(schemaId);
context.setProviderClass(producerClass);
context.setProducerInstance(producerInstance);
SchemaMeta schemaMeta = getOrCreateSchema(context);
SwaggerProducer producer = swaggerEnv.createProducer(producerInstance, schemaMeta.getSwagger());
Executor reactiveExecutor = BeanUtils.getBean(ExecutorManager.EXECUTOR_REACTIVE);
for (OperationMeta operationMeta : schemaMeta.getOperations()) {
SwaggerProducerOperation producerOperation = producer.findOperation(operationMeta.getOperationId());
operationMeta.putExtData(Const.PRODUCER_OPERATION, producerOperation);
if (CompletableFuture.class.equals(producerOperation.getProducerMethod().getReturnType())) {
operationMeta.setExecutor(ExecutorManager.findExecutor(operationMeta, reactiveExecutor));
}
}
return schemaMeta;
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class InvokerUtils method syncInvoke.
public static Object syncInvoke(String microserviceName, String microserviceVersion, String transport, String schemaId, String operationName, Object[] args) {
ReferenceConfig referenceConfig = ReferenceConfigUtils.getForInvoke(microserviceName, microserviceVersion, transport);
SchemaMeta schemaMeta = referenceConfig.getMicroserviceMeta().ensureFindSchemaMeta(schemaId);
Invocation invocation = InvocationFactory.forConsumer(referenceConfig, schemaMeta, operationName, args);
return syncInvoke(invocation);
}
use of org.apache.servicecomb.core.definition.SchemaMeta in project incubator-servicecomb-java-chassis by apache.
the class TestServicePathManager method setup.
@Before
public void setup() {
BeanUtils.setContext(applicationContext);
MicroserviceMeta mm = new MicroserviceMeta("app:ms");
Swagger swagger = UnitTestSwaggerUtils.generateSwagger(TestServicePathManagerSchemaImpl.class).getSwagger();
Map<String, Path> paths = swagger.getPaths();
swagger.setBasePath("");
Path path = paths.remove("/static1");
paths.put("/root/rest/static1", path);
path = paths.remove("/dynamic1");
paths.put("/dynamic1/{id}", path);
path = paths.remove("/dynamic2");
paths.put("/dynamic2/{id}", path);
SchemaMeta schemaMeta = new SchemaMeta(swagger, mm, "sid");
spm = new ServicePathManager(mm);
spm.addSchema(schemaMeta);
spm.sortPath();
}
Aggregations