use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class ProducerProviderManager method init.
public void init() throws Exception {
for (ProducerProvider provider : producerProviderList) {
provider.init();
}
Microservice microservice = RegistryUtils.getMicroservice();
MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta(microservice);
for (SchemaMeta schemaMeta : microserviceMeta.getSchemaMetas()) {
String content = SchemaUtils.swaggerToString(schemaMeta.getSwagger());
microservice.addSchema(schemaMeta.getSchemaId(), content);
}
}
use of org.apache.servicecomb.core.definition.MicroserviceMeta 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.MicroserviceMeta 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.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class TestDefinition method testMicroServiceMeta.
@Test
public void testMicroServiceMeta() {
MicroserviceMeta oMicroMeta = new MicroserviceMeta("app:micro1");
Assert.assertEquals(0, oMicroMeta.getSchemaMetas().size());
Assert.assertEquals(0, oMicroMeta.getOperations().size());
Assert.assertEquals("micro1", oMicroMeta.getShortName());
Assert.assertEquals("app:micro1", oMicroMeta.getName());
try {
oMicroMeta.putExtData("key1", new String("value1"));
Assert.assertNotEquals(null, oMicroMeta.getExtData("key1"));
} catch (Exception e) {
Assert.assertNotNull(e);
}
}
use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.
the class InvocationFactory method forConsumer.
/*
* 为tcc场景提供的快捷方式,consumer端使用
*/
public static Invocation forConsumer(ReferenceConfig referenceConfig, String operationQualifiedName, Object[] swaggerArguments) {
MicroserviceMeta microserviceMeta = referenceConfig.getMicroserviceMeta();
OperationMeta operationMeta = microserviceMeta.ensureFindOperation(operationQualifiedName);
return forConsumer(referenceConfig, operationMeta, swaggerArguments);
}
Aggregations