getLogger().info("Script Engines: " + w.toString());
}*/
for (Configuration.Server serverConf : config.getServers()) {
getContext().getLogger().info(serverConf.getProtocol().getName()+" listening on " + serverConf.getAddress() + ":" + serverConf.getPort());
Server server = getServers().add(serverConf.getProtocol(), serverConf.getAddress().equals("*") ? null : serverConf.getAddress(), serverConf.getPort());
if (serverConf.getProtocol().isConfidential()) {
if (config.getKeyStorePath() != null) {
server.getContext().getParameters().add("keystorePath", config.getKeyStorePath().getAbsolutePath());
server.getContext().getParameters().add("keystorePassword", config.getKeyStorePassword());
server.getContext().getParameters().add("keyPassword", config.getKeyStorePassword());
}
}
Map<String, ConfiguredHost> confHosts = ifaceHosts.get(serverConf.getKey());
if (confHosts == null) {
confHosts = new TreeMap<String, ConfiguredHost>();
ifaceHosts.put(serverConf.getKey(), confHosts);
}
// Configure static hosts
for (String name : serverConf.getHosts().keySet()) {
final Configuration.Host host = serverConf.getHosts().get(name);
if (confHosts.get(host.getName()) != null) {
getLogger().warning("Ignoring duplicate host name " + host.getName());
} else {
Context hostContext = getContext().createChildContext();
ConfiguredHost confHost = new ConfiguredHost(hostContext, getInternalRouter(), serverConf, host, new Date(), true);
confHosts.put(host.getName(), confHost);
if (host.getLinks().get("autoconf") != null) {
hasStaticAutoConf = true;
}
getHosts().add(confHost.getVirtualHost());
}
}
// Configure autoconf
List<Link> autoFeeds = serverConf.getLinks().get("autoconf");
if (autoFeeds != null) {
for (Link link : autoFeeds) {
addAutoConfiguration(serverConf, link);
}
}
}
this.getDefaultHost().attach(new Restlet() {
public void handle(Request request, Response response) {
response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
}
});
// Add the clients
for (Protocol client : config.getClients()) {
getClients().add(client);
}
for (Server server : getServers()) {
try {
server.start();
} catch (Exception ex) {
getLogger().log(Level.SEVERE,"Cannot start server.",ex);
}
}