//	@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();
    }
  }
  private Collection getWSServiceRefsFromSelection() {

    IStructuredSelection initSel = getInitialSelection();
    if (initSel != null && initSel.size() == 1) {
      Object obj = initSel.getFirstElement();
      ServiceRef serviceRef = null;
      if (obj instanceof ServiceRef) {
        // Client ServiceRef
        serviceRef = (ServiceRef) obj;
        serviceRefName_ = serviceRef.getServiceRefName();
        project_ = ProjectUtilities.getProject(serviceRef);
      } else if (obj instanceof WebServiceNavigatorGroupType) {
        WebServiceNavigatorGroupType wsngt = (WebServiceNavigatorGroupType) obj;
        serviceRef = wsngt.getServiceRef();
        serviceRefName_ = serviceRef.getServiceRefName();
        project_ = ProjectUtilities.getProject(serviceRef);
      } else if (obj instanceof IFile) {
        Resource res = WorkbenchResourceHelperBase.getResource((IFile) obj, true);
        Collection serviceRefs = null;
        if (res instanceof WebServicesResource) {
          // webservicesclient.xml for J2EE 1.3
          WebServicesResource wsRes = (WebServicesResource) res;
          serviceRefs = wsRes.getWebServicesClient().getServiceRefs();
          if (!serviceRefs.isEmpty()) {
            ServiceRef ref = (ServiceRef) ((List) serviceRefs).get(0);
            serviceRefName_ = ref.getServiceRefName();
            project_ = ProjectUtilities.getProject(ref);
            return serviceRefs;
          }
          return null;
        } else {
          if (res instanceof WebAppResource) {
            // web.xml for J2EE 1.4
            WebAppResource webAppRes = (WebAppResource) res;
            serviceRefs = webAppRes.getWebApp().getServiceRefs();
          } else if (res instanceof EJBResource) {
            EJBResource ejbRes = (EJBResource) res;
            serviceRefs = webServicesManager_.getServiceRefs(ejbRes.getEJBJar());
          } else if (res instanceof ApplicationClientResource) {
            ApplicationClientResource appClientRes = (ApplicationClientResource) res;
            serviceRefs =
                webServicesManager_.getServiceRefs(
                    appClientRes
                        .getApplicationClient()); // appClientRes.getApplicationClient().getServiceRefs();
          }
          if (serviceRefs != null && serviceRefs.size() > 0) {
            ServiceRef ref = (ServiceRef) ((List) serviceRefs).get(0);
            serviceRefName_ = ref.getServiceRefName();
            project_ = ProjectUtilities.getProject(ref);
          }
          return serviceRefs;
        }
      }

      // This section is for obtaining all the serviceRefs from the project, given that the initial
      // selection
      // was from the J2EE view (ServiceRef or WebServiceNavigatorGroupType), it will select the
      // right serviceRef
      if (project_ == null) {
        project_ = getProject();
      }
      if (project_ == null) {
        return null;
      }

      if (J2EEUtils.isWebComponent(project_)) {
        WebArtifactEdit webEdit = null;
        try {
          IVirtualComponent vc = ComponentCore.createComponent(project_);
          webEdit = WebArtifactEdit.getWebArtifactEditForRead(vc);
          if (webEdit != null) {
            WebApp webApp = (WebApp) webEdit.getDeploymentDescriptorRoot();
            if (webApp != null) {
              return webServicesManager_.getServiceRefs(webApp);
            }
          }
        } finally {
          if (webEdit != null) webEdit.dispose();
        }
      } else if (J2EEUtils.isEJBComponent(project_)) {

        IVirtualComponent vc = ComponentCore.createComponent(project_);
        EJBJar ejbJar = EJBArtifactEditUtilities.getEJBJar(vc);
        if (ejbJar != null) {
          return webServicesManager_.getServiceRefs(ejbJar);
        }
      } else if (J2EEUtils.isAppClientComponent(project_)) {
        IVirtualComponent vc = ComponentCore.createComponent(project_);
        AppClientArtifactEdit appEdit = null;
        try {
          appEdit = AppClientArtifactEdit.getAppClientArtifactEditForRead(vc);
          if (appEdit != null) {
            ApplicationClient appClient = appEdit.getApplicationClient();
            if (appClient != null) {
              return webServicesManager_.getServiceRefs(appClient);
            }
          }
        } finally {
          if (appEdit != null) {
            appEdit.dispose();
          }
        }
      }
    }
    return null;
  }