final ContainerMapper containerMapper = new ContainerMapper(grizzlyService, this);
containerMapper.setMapper(mapper);
containerMapper.setDefaultHost(http.getDefaultVirtualServer());
containerMapper.configureMapper();
VirtualServer vs = null;
String webAppRootPath = null;
final Collection<VirtualServer> list = grizzlyService.getHabitat().getAllServices(VirtualServer.class);
final String vsName = http.getDefaultVirtualServer();
for (final VirtualServer virtualServer : list) {
if (virtualServer.getId().equals(vsName)) {
vs = virtualServer;
webAppRootPath = vs.getDocroot();
if (!grizzlyService.hasMapperUpdateListener() && vs.getProperty() != null
&& !vs.getProperty().isEmpty()) {
for (final Property p : vs.getProperty()) {
final String propertyName = p.getName();
if (propertyName.startsWith("alternatedocroot")) {
String value = p.getValue();
String[] mapping = value.split(" ");
if (mapping.length != 2) {
logger.log(Level.WARNING, "Invalid alternate_docroot {0}", value);
continue;
}
String docBase = mapping[1].substring("dir=".length());
String urlPattern = mapping[0].substring("from=".length());
final StaticHttpHandler staticResourceService =
new StaticHttpHandler(docBase);
List<String> al = toArray(vs.getHosts(), ";");
al.add(http.getDefaultVirtualServer());
containerMapper.register(urlPattern, al, staticResourceService, null);
}
}
}