Search in sources :

Example 1 with ApiManager

use of io.gravitee.gateway.handlers.api.manager.ApiManager in project gravitee-gateway by gravitee-io.

the class ApiDeployerStatement method evaluate.

@Override
public void evaluate() throws Throwable {
    URL home = ApiDeployerStatement.class.getResource("/gravitee-01/");
    System.setProperty("gravitee.home", URLDecoder.decode(home.getPath(), "UTF-8"));
    container = new Container();
    if (target instanceof PolicyRegister) {
        ((PolicyRegister) target).register(container.getApplicationContext().getBean(PolicyPluginManager.class));
    }
    container.start();
    Thread.sleep(1000);
    ApiManager apiManager = container.getApplicationContext().getBean(ApiManager.class);
    Api api = loadApi(target.getClass().getAnnotation(ApiDescriptor.class).value());
    try {
        apiManager.deploy(api);
        base.evaluate();
    } finally {
        apiManager.undeploy(api.getId());
        container.stop();
    }
}
Also used : ApiManager(io.gravitee.gateway.handlers.api.manager.ApiManager) Container(io.gravitee.gateway.standalone.Container) PolicyRegister(io.gravitee.gateway.standalone.policy.PolicyRegister) Api(io.gravitee.gateway.handlers.api.definition.Api) URL(java.net.URL) PolicyPluginManager(io.gravitee.plugin.policy.PolicyPluginManager)

Aggregations

Api (io.gravitee.gateway.handlers.api.definition.Api)1 ApiManager (io.gravitee.gateway.handlers.api.manager.ApiManager)1 Container (io.gravitee.gateway.standalone.Container)1 PolicyRegister (io.gravitee.gateway.standalone.policy.PolicyRegister)1 PolicyPluginManager (io.gravitee.plugin.policy.PolicyPluginManager)1 URL (java.net.URL)1