Search in sources :

Example 1 with ApplicationDeploymentContributor

use of org.apache.knox.gateway.deploy.impl.ApplicationDeploymentContributor in project knox by apache.

the class DeploymentFactory method selectContextApplications.

private static Map<String, ServiceDeploymentContributor> selectContextApplications(GatewayConfig config, Topology topology) {
    Map<String, ServiceDeploymentContributor> contributors = new HashMap<>();
    if (topology != null) {
        for (Application application : topology.getApplications()) {
            String name = application.getName();
            if (name == null || name.isEmpty()) {
                throw new DeploymentException("Topologies cannot contain an application without a name.");
            }
            ApplicationDeploymentContributor contributor = new ApplicationDeploymentContributor(config, application);
            List<String> urls = application.getUrls();
            if (urls == null || urls.isEmpty()) {
                urls = new ArrayList<String>(1);
                urls.add("/" + name);
            }
            for (String url : urls) {
                if (url == null || url.isEmpty() || url.equals("/")) {
                    if (!topology.getServices().isEmpty()) {
                        throw new DeploymentException(String.format("Topologies with services cannot contain an application (%s) with a root url.", name));
                    }
                }
                contributors.put(url, contributor);
            }
        }
    }
    return contributors;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Application(org.apache.knox.gateway.topology.Application) ApplicationDeploymentContributor(org.apache.knox.gateway.deploy.impl.ApplicationDeploymentContributor)

Aggregations

HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ApplicationDeploymentContributor (org.apache.knox.gateway.deploy.impl.ApplicationDeploymentContributor)1 Application (org.apache.knox.gateway.topology.Application)1