private Context createContext(final ContextModel contextModel) {
    final Bundle bundle = contextModel.getBundle();
    final BundleContext bundleContext = BundleUtils.getBundleContext(bundle);

    final Context context =
        m_server.addContext(
            contextModel.getContextParams(),
            getContextAttributes(bundleContext),
            contextModel.getContextName(),
            contextModel.getHttpContext(),
            contextModel.getAccessControllerContext(),
            contextModel.getContainerInitializers(),
            contextModel.getJettyWebXmlURL(),
            contextModel.getVirtualHosts(),
            contextModel.getConnectors(),
            m_server.getBasedir());

    context.setParentClassLoader(contextModel.getClassLoader());
    // TODO: is the context already configured?
    // TODO: how about security, classloader?
    // TODO: compare with JettyServerWrapper.addContext
    // TODO: what about the init parameters?
    /*
     * Do not start context here, but register it to be started lazily. This
     * ensures that all servlets, listeners, initializers etc. are
     * registered before the context is started.
     */
    ServletContextManager.addContext(
        context.getPath(), new TomcatServletContextWrapper(context, m_server.getHost()));

    final LifecycleState state = context.getState();
    if (state != LifecycleState.STARTED
        && state != LifecycleState.STARTING
        && state != LifecycleState.STARTING_PREP) {

      // if( !context.isStarted() && !context.isStarting() )
      // {
      LOG.debug("Registering ServletContext as service. ");
      final Dictionary<String, String> properties = new Hashtable<String, String>();
      properties.put("osgi.web.symbolicname", bundle.getSymbolicName());

      final Dictionary<String, String> headers = bundle.getHeaders();
      final String version = (String) headers.get(Constants.BUNDLE_VERSION);
      if (version != null && version.length() > 0) {
        properties.put("osgi.web.version", version);
      }

      String webContextPath = (String) headers.get(WEB_CONTEXT_PATH);
      final String webappContext = (String) headers.get("Webapp-Context");

      final ServletContext servletContext = context.getServletContext();

      // This is the default context, but shouldn't it be called default?
      // See PAXWEB-209
      if ("/".equalsIgnoreCase(context.getPath())
          && (webContextPath == null || webappContext == null)) {
        webContextPath = context.getPath();
      }

      // makes sure the servlet context contains a leading slash
      webContextPath = webContextPath != null ? webContextPath : webappContext;
      if (webContextPath != null && !webContextPath.startsWith("/")) {
        webContextPath = "/" + webContextPath;
      }

      if (webContextPath == null) {
        LOG.warn("osgi.web.contextpath couldn't be set, it's not configured");
      }

      properties.put("osgi.web.contextpath", webContextPath);

      servletContextService =
          bundleContext.registerService(ServletContext.class, servletContext, properties);
      LOG.debug("ServletContext registered as service. ");
    }
    m_contexts.put(contextModel.getHttpContext(), context);

    return context;
  }