예제 #1
0
  @Override
  public String getArgumentAdditions(TestServerConfiguration config) {
    StringBuilder buf = new StringBuilder(100);

    buf.append(" -dd \""); // $NON-NLS-1$
    List<DDFile> ddFiles =
        DeploymentDescriptorFinder.findDeploymentDescriptors(config.getProject());
    buf.append(DeploymentDescriptorFinder.toArgumentString(ddFiles));

    buf.append("\" -ddd \""); // $NON-NLS-1$
    String defaultDDName = DeploymentDescriptorFinder.getDefaultDDName(config.getProject());
    buf.append(defaultDDName);

    String orderedDDNames = DeploymentDescriptorFinder.toOrderedArgumentString(ddFiles);
    buf.append("\" -odd \""); // $NON-NLS-1$
    buf.append(orderedDDNames);
    buf.append("\""); // $NON-NLS-1$

    synchronized (syncObj) {
      currentDDFiles.put(config, ddFiles);
      currentDefaultDDName.put(config, defaultDDName);
      currentDDNameOrder.put(config, orderedDDNames);
    }

    return buf.toString();
  }
예제 #2
0
  public synchronized void updateDDSettingsOnServer(TestServerConfiguration config) {
    String oldDDNameOrder;
    String oldDefaultDD;
    List<DDFile> oldDDs;

    synchronized (syncObj) {
      oldDefaultDD = currentDefaultDDName.get(config);
      oldDDNameOrder = currentDDNameOrder.get(config);
      oldDDs = currentDDFiles.get(config);
    }

    String defaultDD = DeploymentDescriptorFinder.getDefaultDDName(config.getProject());
    boolean defaultDDChanged = !oldDefaultDD.equals(defaultDD);

    // Iterate through, keep track of those that are no longer in the list, those that were already
    // in the list but have
    // changed, and those that are new to the list. Updates are treated as additions, and the server
    // will handle it appropriately.
    List<DDFile> newDDFiles =
        DeploymentDescriptorFinder.findDeploymentDescriptors(config.getProject());
    List<DDFile> addedOrChangedDDFiles = new ArrayList<DDFile>();
    List<DDFile> copyOfCurrentDDFiles = new ArrayList<DDFile>(oldDDs);
    for (DDFile next : newDDFiles) {
      int size = copyOfCurrentDDFiles.size();
      DDFile old = null;
      for (int i = 0; i < size; i++) {
        if (next.name.equals(copyOfCurrentDDFiles.get(i).name)) {
          old = copyOfCurrentDDFiles.remove(i);
          break;
        }
      }
      if (old == null || !old.equals(next)) {
        addedOrChangedDDFiles.add(next);
      }
    }

    String newDDNameOrder = DeploymentDescriptorFinder.toOrderedArgumentString(newDDFiles);
    boolean ddOrderChanged = !oldDDNameOrder.equals(newDDNameOrder);

    if (defaultDDChanged
        || ddOrderChanged
        || addedOrChangedDDFiles.size() > 0
        || copyOfCurrentDDFiles.size() > 0) {
      String addedDDArg = DeploymentDescriptorFinder.toArgumentString(addedOrChangedDDFiles);
      String removedDDArg =
          DeploymentDescriptorFinder.toArgumentString(
              copyOfCurrentDDFiles); // leftovers get removed

      StringBuilder args =
          new StringBuilder(
              addedDDArg.length()
                  + newDDNameOrder.length()
                  + removedDDArg.length()
                  + defaultDD.length()
                  + 50);
      if (addedDDArg.length() > 0) {
        if (args.length() > 0) {
          args.append('&');
        }
        args.append(ConfigServlet.ARG_DD_ADDED);
        args.append('=');
        args.append(addedDDArg);
      }
      if (removedDDArg.length() > 0) {
        if (args.length() > 0) {
          args.append('&');
        }
        args.append(ConfigServlet.ARG_DD_REMOVED);
        args.append('=');
        args.append(removedDDArg);
      }
      if (defaultDDChanged) {
        if (args.length() > 0) {
          args.append('&');
        }
        args.append(ConfigServlet.ARG_DEFAULT_DD);
        args.append('=');
        try {
          args.append(URLEncoder.encode(defaultDD, "UTF-8")); // $NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
          // Shouldn't happen.
          args.append(defaultDD);
        }
      }
      if (ddOrderChanged) {
        if (args.length() > 0) {
          args.append('&');
        }
        args.append(ConfigServlet.ARG_ORDERED_DDS);
        args.append('=');
        try {
          args.append(URLEncoder.encode(newDDNameOrder, "UTF-8")); // $NON-NLS-1$
        } catch (UnsupportedEncodingException e) {
          // Shouldn't happen.
          args.append(newDDNameOrder);
        }
      }

      try {
        int status = config.invokeServlet(ConfigServlet.SERVLET_PATH, args.toString());
        if (status != 200) {
          TestServerPlugin.getDefault().log(NLS.bind(Messages.ConfigServletBadStatus, status));
        }
      } catch (IOException e) {
        TestServerPlugin.getDefault().log(e);
      }
    }

    synchronized (syncObj) {
      currentDDNameOrder.put(config, newDDNameOrder);
      currentDDFiles.put(config, newDDFiles);
      currentDefaultDDName.put(config, defaultDD);
    }
  }
예제 #3
0
  @Override
  public String[] getClasspathAdditions(TestServerConfiguration config) {
    List<String> entries = new ArrayList<String>(2);
    String entry =
        ClasspathUtil.getClasspathEntry("org.eclipse.edt.ide.deployment.core"); // $NON-NLS-1$
    if (entry != null) {
      entries.add(entry);
    }

    entry =
        ClasspathUtil.getClasspathEntry("org.eclipse.edt.ide.deployment.services"); // $NON-NLS-1$
    if (entry != null) {
      entries.add(entry);
    }

    entry = ClasspathUtil.getClasspathEntry("org.eclipse.edt.runtime.java"); // $NON-NLS-1$
    if (entry != null) {
      entries.add(entry);
    }

    entry = ClasspathUtil.getClasspathEntry("com.ibm.icu"); // $NON-NLS-1$
    if (entry != null) {
      entries.add(entry);
    }

    DDUtil.addJDBCJars(
        config.getProject(), new HashSet<IProject>(), new HashSet<IResource>(), entries);

    // Add a Tomcat runtime if one's available, so that JNDI can use connection pooling.
    IRuntime bestTomcat = null;
    for (IRuntime rt : ServerUtil.getRuntimes(null, null)) {
      if (rt.getRuntimeType().getName().toLowerCase().contains("tomcat")) { // $NON-NLS-1$
        if (bestTomcat == null) {
          bestTomcat = rt;
        } else if (bestTomcat
                .getRuntimeType()
                .getVersion()
                .compareTo(rt.getRuntimeType().getVersion())
            < 0) {
          bestTomcat = rt;
        }
      }
    }

    if (bestTomcat != null) {
      RuntimeClasspathProviderWrapper rcpw =
          JavaServerPlugin.findRuntimeClasspathProvider(bestTomcat.getRuntimeType());
      if (rcpw != null) {
        entries.add(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><runtimeClasspathEntry containerPath=\"" //$NON-NLS-1$
                + RuntimeClasspathContainer.SERVER_CONTAINER
                + "/"
                + rcpw.getId()
                + "/"
                + bestTomcat.getId() // $NON-NLS-1$ //$NON-NLS-2$
                + "\" path=\"3\" type=\"4\"/>"); //$NON-NLS-1$
      }
    }

    return entries.toArray(new String[entries.size()]);
  }