public static synchronized List<String> getServerInstanceIds(FileObject suiteDir) {

    if (suiteDir == null) {
      return null;
    }
    Path suitePath = Paths.get(suiteDir.getPath());
    Deployment d = Deployment.getDefault();

    if (d == null || d.getServerInstanceIDs() == null) {
      return null;
    }
    List<String> result = new ArrayList<>();
    for (String uri : d.getServerInstanceIDs()) {
      InstanceProperties ip = InstanceProperties.getInstanceProperties(uri);

      String foundSuiteLocation = SuiteUtil.getSuiteProjectLocation(ip);
      if (foundSuiteLocation == null || !new File(foundSuiteLocation).exists()) {
        // May be not a native plugin server
        continue;
      }
      Project foundSuite =
          BaseUtil.getOwnerProject(FileUtil.toFileObject(new File(foundSuiteLocation)));

      if (foundSuite == null) {
        continue;
      }
      Path p = Paths.get(foundSuiteLocation);

      if (suitePath.equals(p)) {
        result.add(uri);
      }
    }
    return result;
  }
  private void onDeploy() {
    if (isCompleteImmediately()) {
      return;
    }

    List<Pair<BaseTargetModuleID, BaseTargetModuleID>> modules =
        getManager().getInitialDeployedModulesOld();
    Project wp =
        BaseUtil.getOwnerProject(
            FileUtil.toFileObject(new File(getTargetModuleID().getProjectDir())));

    int i = 0;
    for (Pair<BaseTargetModuleID, BaseTargetModuleID> pair : modules) {
      if (pair.first().getContextPath().equals(getTargetModuleID().getContextPath())) {
        modules.set(i, Pair.of(getTargetModuleID(), (BaseTargetModuleID) null));
        return;
      }
      i++;
    }
    i = 0;
    for (Pair<BaseTargetModuleID, BaseTargetModuleID> pair : modules) {
      if (pair.first().getProjectDir().equals(getTargetModuleID().getProjectDir())) {
        modules.set(i, Pair.of(getTargetModuleID(), (BaseTargetModuleID) null));
        return;
      }
      i++;
    }

    modules.add(Pair.of(getTargetModuleID(), (BaseTargetModuleID) null));
    //      }
  }
  public static Project getServerSuiteProject(String uri) {

    InstanceProperties ip = InstanceProperties.getInstanceProperties(uri);
    String suiteLocation;
    if (ip != null) {
      suiteLocation = SuiteUtil.getSuiteProjectLocation(ip);
    } else {
      // extract from url
      String s = SuiteConstants.SUITE_URL_ID; // ":server:suite:project:";
      int i = uri.indexOf(s);
      suiteLocation = uri.substring(i + s.length());
      Path path = Paths.get(suiteLocation);
      suiteLocation = path.getParent().toString().replace("\\", "/");
    }
    if (suiteLocation == null || !new File(suiteLocation).exists()) {
      // May be not a native plugin server
      return null;
    }
    return BaseUtil.getOwnerProject(FileUtil.toFileObject(new File(suiteLocation)));
  }
    public ContextAction(final Lookup webapplookup) {

      webProject = webapplookup.lookup(Project.class);
      J2eeModuleProvider p = BaseUtil.getJ2eeModuleProvider(webProject);
      String id = "";
      if (p != null) {
        id = p.getServerInstanceID();
      }
      if (p != null
          && id.startsWith("jettystandalone:deploy:server")
          && p.getInstanceProperties() != null) {
        File file = new File(BaseUtil.getServerLocation(p.getInstanceProperties()));
        FileObject fo = FileUtil.toFileObject(file);
        serverProject = BaseUtil.getOwnerProject(fo);
      } else {
        serverProject = null;
      }

      boolean enabled = serverProject == null ? false : true;

      if (enabled) {

        File f =
            Paths.get(serverProject.getProjectDirectory().getPath(), Utils.jettyBase(serverProject))
                .toFile();
        String jsfListener = JettyConfig.getInstance(serverProject).getJsfListener();
        // BaseUtil.out("@@@@@@@@@@@@@@@@@ AddListenerAction listener=" + jsfListener);
        String jsfModule = JettyConfig.getInstance(serverProject).getJSFModuleName();

        enabled = jsfModule != null && !DDHelper.hasJsfListener(serverProject, webProject);
        setEnabled(enabled);

        String s = isEnabled() ? "(" + jsfModule + ") " : "";
        putValue(NAME, "Add Listener " + s + " to web.xml ");
      }

      putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true);
    }