code: public void addServletModel(final ServletModel model) throws NamespaceException, ServletException {
  		servletLock.writeLock().lock();
  		try {
              associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
              for (String virtualHost:resolveVirtualHosts(model)) {
                  if (servlets.get(virtualHost) == null) {
                      servlets.put(virtualHost, new HashSet<>());
                  }
                  if (model.getServlet() != null && servlets.get(virtualHost).contains(model.getServlet())) {
                          throw new ServletException("servlet already registered with a different alias");
                  }
                  if (model.getAlias() != null) {
                          final String alias = getFullPath(model.getContextModel(), model.getAlias());
                          if (aliasMapping.get(virtualHost) == null) {
                              aliasMapping.put(virtualHost, new HashMap<>());
                          }
                          if (aliasMapping.get(virtualHost).containsKey(alias)) {
                                  throw new NamespaceException("alias: '" + alias + "' is already in use in this or another context");
                          }
                          aliasMapping.get(virtualHost).put(alias, model);
                  }
                  if (model.getServlet() != null) {
                          servlets.get(virtualHost).add(model.getServlet());
                  }
                  for (String urlPattern : model.getUrlPatterns()) {
                          if (servletUrlPatterns.get(virtualHost) == null) {
                              servletUrlPatterns.put(virtualHost, new HashMap<>());
                          }
                          servletUrlPatterns.get(virtualHost).put(getFullPath(model.getContextModel(), urlPattern),
                                          new UrlPattern(getFullPath(model.getContextModel(), urlPattern), model));
                  }
              }
  		} finally {
  			servletLock.writeLock().unlock();
  		}
  	}
docs: Registers a servlet model.
  
  @param model servlet model to register
  @throws ServletException   - If servlet is already registered
  @throws NamespaceException - If servlet alias is already registered