//	@SuppressWarnings("unchecked")
  private void addServletToWebXml(IProgressMonitor monitor) {

    monitor = Util.getNonNullMonitor(monitor);

    try {

      monitor.beginTask("", 1);

      WebapplicationFactory factory = WebapplicationFactory.eINSTANCE;

      Servlet servlet = factory.createServlet();
      servlet.setServletName(getTypeName());

      ServletType servletType = factory.createServletType();
      servletType.setClassName(
          getPackageFragment().getElementName() + '.' + getTypeName() + "Impl");
      servlet.setWebType(servletType);

      IVirtualComponent component = ComponentCore.createComponent(Util.getProject(projectText));
      WebArtifactEdit artifactEdit = WebArtifactEdit.getWebArtifactEditForWrite(component);
      WebApp webApp = (WebApp) artifactEdit.getContentModelRoot();
      webApp.getServlets().add(servlet);

      ServletMapping mapping = WebapplicationFactory.eINSTANCE.createServletMapping();
      mapping.setServlet(servlet);
      mapping.setName(servlet.getServletName());
      mapping.setUrlPattern("/" + serviceUri);
      webApp.getServletMappings().add(mapping);

      artifactEdit.saveIfNecessary(monitor);

      artifactEdit.dispose();

    } finally {
      monitor.done();
    }
  }
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected void initializeValues() {
    List<ServletMapping> servletMappings = new ArrayList<ServletMapping>();
    if (webAppObj != null) {
      servletInfoGroup.lstJAXRSServletURLPatterns.removeAll();
      // set defaults- in the rare case we do not find the servlet we will create another servlet
      // entry
      String servletName = JAXRSUtils.JAXRS_DEFAULT_SERVLET_NAME;
      String servletClass = JAXRSUtils.JAXRS_SERVLET_CLASS;
      // get id ofthe library provider being used
      LibraryInstallDelegate installDelegate = super.getLibraryInstallDelegate();
      ILibraryProvider libraryProvider = installDelegate.getLibraryProvider();
      String id = "";
      if (libraryProvider != null) id = libraryProvider.getId();
      if (JAXRSJEEUtils.isWebApp25orHigher(webAppObj)) {
        WebApp webApp = (WebApp) webAppObj;
        Servlet servlet = JAXRSJEEUtils.findJAXRSServlet(webApp, id);
        if (servlet != null) {
          servletMappings = webApp.getServletMappings();
          servletName = (servlet.getServletName() == null) ? servletName : servlet.getServletName();
          servletClass =
              (servlet.getServletClass() == null) ? servletClass : servlet.getServletClass();
        } else {
          // we did not find the servlet entry, set default value
          servletInfoGroup.lstJAXRSServletURLPatterns.add(JAXRSUtils.JAXRS_DEFAULT_URL_MAPPING);
        }
      } else {
        // 2.3 or 2.4 web app
        org.eclipse.jst.j2ee.webapplication.WebApp webApp =
            (org.eclipse.jst.j2ee.webapplication.WebApp) webAppObj;
        org.eclipse.jst.j2ee.webapplication.Servlet servlet =
            JAXRSJ2EEUtils.findJAXRSServlet(webApp, id);
        if (servlet != null) {
          this.j2eeServlet = servlet;
          servletMappings = webApp.getServletMappings();
          servletName = (servlet.getServletName() == null) ? servletName : servlet.getServletName();
          if (servlet.getServletClass() != null) {
            servletClass =
                (servlet.getServletClass().getQualifiedName() == null)
                    ? servletClass
                    : servlet.getServletClass().getQualifiedName();
          }
        } else {
          // we did not find the servlet entry, set default value
          servletInfoGroup.lstJAXRSServletURLPatterns.add(JAXRSUtils.JAXRS_DEFAULT_URL_MAPPING);
        }
      }
      servletInfoGroup.txtJAXRSServletName.setText(servletName);
      servletInfoGroup.txtJAXRSServletClassName.setText(servletClass);
      // Find the servletMapping that corresponds to the servletName
      if (JAXRSJEEUtils.isWebApp25orHigher(webAppObj)) {

        for (Iterator<ServletMapping> i = servletMappings.iterator(); i.hasNext(); ) {
          Object o = i.next();
          if (o instanceof ServletMapping) {
            // init the servletMapping
            ServletMapping next = (ServletMapping) o;
            if (servletName.equals(next.getServletName())) {
              for (Iterator p = next.getUrlPatterns().iterator(); p.hasNext(); ) {
                UrlPatternType pattern = (UrlPatternType) p.next();
                servletInfoGroup.lstJAXRSServletURLPatterns.add(pattern.getValue());
              }
            }
          }
        }
      } else {
        for (Iterator<ServletMapping> i = servletMappings.iterator(); i.hasNext(); ) {
          Object o = i.next();
          if (o instanceof org.eclipse.jst.j2ee.webapplication.ServletMapping) {
            // init the servletMapping
            org.eclipse.jst.j2ee.webapplication.ServletMapping next =
                (org.eclipse.jst.j2ee.webapplication.ServletMapping) o;
            org.eclipse.jst.j2ee.webapplication.Servlet aServlet = next.getServlet();
            // the servlet mapping may not have an associated servlet since the user could have
            // modified the file
            if (aServlet != null && servletName.equals(aServlet.getServletName())) {
              this.j2eeServletMapping = next;
              String pattern = next.getUrlPattern();
              servletInfoGroup.lstJAXRSServletURLPatterns.add(new String(pattern));
            }
          }
        }
      }
    }
  }