*
* @param aRepository DAVRepository to be served by this server.
*/
public void addRepository(DAVRepository aRepository) {
// Gets the context associated to this repository.
ServletHttpContext servletContext =
(ServletHttpContext) server.getContext(aRepository.getHost(),
aRepository.getContext());
// Defines the servlet context attributes.
Map attributes = aRepository.getServletContextAttr();
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Map.Entry attribute = (Map.Entry) iter.next();
servletContext.setAttribute((String) attribute.getKey(),
attribute.getValue());
}
ServletHolder holder = null;
try {
// Defines the WebDAV servlet.
holder = servletContext.addServlet("DAVRepository", "/*", aRepository.getHandlingServlet().getName());
// Defines the servlet init parameters.
attributes = aRepository.getServletInitParam();
for (Iterator iter = attributes.entrySet().iterator(); iter.hasNext();) {
Map.Entry attribute = (Map.Entry) iter.next();
holder.setInitParameter((String) attribute.getKey(), (String) attribute.getValue());
}
servletContext.start();
} catch (Exception e) {
log.error(e);
throw new RuntimeException(e);
}
synchronized (repToServletHolder) {