use of org.apache.knox.gateway.service.definition.ServiceDefinition in project knox by apache.
the class DefaultTopologyService method getServiceTestURLs.
public Map<String, List<String>> getServiceTestURLs(Topology t, GatewayConfig config) {
File tFile = null;
Map<String, List<String>> urls = new HashMap<>();
if (topologiesDirectory.isDirectory() && topologiesDirectory.canRead()) {
for (File f : listFiles(topologiesDirectory)) {
if (FilenameUtils.removeExtension(f.getName()).equals(t.getName())) {
tFile = f;
}
}
}
Set<ServiceDefinition> defs;
if (tFile != null) {
defs = ServiceDefinitionsLoader.getServiceDefinitions(new File(config.getGatewayServicesDir()));
for (ServiceDefinition def : defs) {
urls.put(def.getRole(), def.getTestURLs());
}
}
return urls;
}
use of org.apache.knox.gateway.service.definition.ServiceDefinition in project knox by apache.
the class DefaultServiceDefinitionRegistry method init.
@Override
public void init(GatewayConfig config, Map<String, String> options) throws ServiceLifecycleException {
String stacks = config.getGatewayServicesDir();
File stacksDir = new File(stacks);
Set<ServiceDefinition> serviceDefinitions = ServiceDefinitionsLoader.getServiceDefinitions(stacksDir);
for (ServiceDefinition serviceDefinition : serviceDefinitions) {
List<Route> routes = serviceDefinition.getRoutes();
for (Route route : routes) {
try {
Template template = Parser.parseTemplate(route.getPath());
addServiceDefEntry(template, serviceDefinition);
} catch (URISyntaxException e) {
LOG.failedToParsePath(route.getPath(), e);
}
}
}
}
Aggregations