Search in sources :

Example 1 with BaseLocationApplicationContext

use of com.predic8.membrane.core.config.spring.BaseLocationApplicationContext in project service-proxy by membrane.

the class SimpleApiConfig method setUrl.

/**
 * @description the url to the configuration file
 * @default api.yaml
 */
@MCAttribute
public void setUrl(String url) {
    this.url = url;
    if (context != null) {
        if (amc == null) {
            String workingDir = ((BaseLocationApplicationContext) context).getBaseLocation();
            amc = new ApiManagementConfiguration(workingDir, this.url);
        } else {
            amc.setLocation(this.url);
        }
    }
}
Also used : ApiManagementConfiguration(com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration) BaseLocationApplicationContext(com.predic8.membrane.core.config.spring.BaseLocationApplicationContext) MCAttribute(com.predic8.membrane.annot.MCAttribute)

Example 2 with BaseLocationApplicationContext

use of com.predic8.membrane.core.config.spring.BaseLocationApplicationContext in project service-proxy by membrane.

the class EtcdRegistryApiConfig method initAmc.

public void initAmc() {
    String workingDir = ((BaseLocationApplicationContext) context).getBaseLocation();
    String etcdUrlForAmc = null;
    URL u = null;
    try {
        u = new URL(getUrl());
    } catch (MalformedURLException e) {
        try {
            u = new URL("http://" + getUrl());
        } catch (MalformedURLException ignored) {
        }
    }
    if (u == null) {
        log.error("Url malformed: " + getUrl());
    }
    etcdUrlForAmc = "etcd://" + u.getHost() + ":" + u.getPort();
    amc = new ApiManagementConfiguration(workingDir, etcdUrlForAmc, membraneId);
}
Also used : MalformedURLException(java.net.MalformedURLException) ApiManagementConfiguration(com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration) BaseLocationApplicationContext(com.predic8.membrane.core.config.spring.BaseLocationApplicationContext) URL(java.net.URL)

Aggregations

BaseLocationApplicationContext (com.predic8.membrane.core.config.spring.BaseLocationApplicationContext)2 ApiManagementConfiguration (com.predic8.membrane.core.interceptor.apimanagement.ApiManagementConfiguration)2 MCAttribute (com.predic8.membrane.annot.MCAttribute)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1