Search in sources :

Example 16 with MicroserviceMeta

use of org.apache.servicecomb.core.definition.MicroserviceMeta 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();
}
Also used : Path(io.swagger.models.Path) Swagger(io.swagger.models.Swagger) SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) Before(org.junit.Before)

Example 17 with MicroserviceMeta

use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.

the class SchemaListenerManager method notifySchemaListener.

public void notifySchemaListener(MicroserviceMeta... microserviceMetas) {
    List<SchemaMeta> schemaMetaList = new ArrayList<>();
    for (MicroserviceMeta microserviceMeta : microserviceMetas) {
        schemaMetaList.addAll(microserviceMeta.getSchemaMetas());
    }
    notifySchemaListener(schemaMetaList.toArray(new SchemaMeta[schemaMetaList.size()]));
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) ArrayList(java.util.ArrayList) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta)

Example 18 with MicroserviceMeta

use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.

the class MockUtil method mockRequestMeta.

public void mockRequestMeta() {
    new MockUp<RequestMeta>() {

        @Mock
        public OperationMeta getOperationMeta() throws Exception {
            OperationMeta om = new OperationMeta();
            om.init(new SchemaMeta(null, new MicroserviceMeta("test"), null), this.getClass().getMethods()[0], "path", "get", null);
            return om;
        }
    };
}
Also used : SchemaMeta(org.apache.servicecomb.core.definition.SchemaMeta) MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) MockUp(mockit.MockUp) OperationMeta(org.apache.servicecomb.core.definition.OperationMeta) RestOperationMeta(org.apache.servicecomb.common.rest.definition.RestOperationMeta)

Example 19 with MicroserviceMeta

use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.

the class RestEngineSchemaListener method onBootEvent.

@Override
public void onBootEvent(BootEvent event) {
    if (!event.getEventType().equals(EventType.BEFORE_REGISTRY)) {
        return;
    }
    MicroserviceMeta microserviceMeta = microserviceMetaManager.getOrCreateMicroserviceMeta(RegistryUtils.getMicroservice());
    ServicePathManager servicePathManager = ServicePathManager.getServicePathManager(microserviceMeta);
    if (servicePathManager != null) {
        servicePathManager.buildProducerPaths();
    }
}
Also used : MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta) ServicePathManager(org.apache.servicecomb.common.rest.locator.ServicePathManager)

Example 20 with MicroserviceMeta

use of org.apache.servicecomb.core.definition.MicroserviceMeta in project incubator-servicecomb-java-chassis by apache.

the class RestProducerInvocation method findRestOperation.

protected void findRestOperation() {
    String targetMicroserviceName = requestEx.getHeader(Const.TARGET_MICROSERVICE);
    if (targetMicroserviceName == null) {
        // for compatible
        targetMicroserviceName = RegistryUtils.getMicroservice().getServiceName();
    }
    MicroserviceMeta selfMicroserviceMeta = CseContext.getInstance().getMicroserviceMetaManager().ensureFindValue(targetMicroserviceName);
    findRestOperation(selfMicroserviceMeta);
}
Also used : MicroserviceMeta(org.apache.servicecomb.core.definition.MicroserviceMeta)

Aggregations

MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)20 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)10 ServicePathManager (org.apache.servicecomb.common.rest.locator.ServicePathManager)5 OperationMeta (org.apache.servicecomb.core.definition.OperationMeta)5 Swagger (io.swagger.models.Swagger)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RestOperationMeta (org.apache.servicecomb.common.rest.definition.RestOperationMeta)2 Path (io.swagger.models.Path)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 Executor (java.util.concurrent.Executor)1 Mock (mockit.Mock)1 MockUp (mockit.MockUp)1 OperationLocator (org.apache.servicecomb.common.rest.locator.OperationLocator)1 ProducerProvider (org.apache.servicecomb.core.ProducerProvider)1 MicroserviceVersionMeta (org.apache.servicecomb.core.definition.MicroserviceVersionMeta)1 ConsumerSchemaFactory (org.apache.servicecomb.core.definition.schema.ConsumerSchemaFactory)1 ReferenceConfig (org.apache.servicecomb.core.provider.consumer.ReferenceConfig)1