Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.jst.server.preview.adapter/src')
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/IMemento.java67
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java52
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties44
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/PreviewPlugin.java55
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ProgressUtil.java69
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Trace.java73
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/XMLMemento.java140
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PingThread.java133
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchConfigurationDelegate.java130
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchableAdapterDelegate.java53
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java151
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java50
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServer.java175
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServerBehaviour.java277
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewSourcePathComputerDelegate.java90
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewStartup.java77
-rw-r--r--plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ui/PreviewLaunchConfigurationTabGroup.java42
17 files changed, 0 insertions, 1678 deletions
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/IMemento.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/IMemento.java
deleted file mode 100644
index 9e6a2d662..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/IMemento.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-/**
- * Interface to a memento used for saving the important state of an object
- * in a form that can be persisted in the file system.
- * <p>
- * Mementos were designed with the following requirements in mind:
- * <ol>
- * <li>Certain objects need to be saved and restored across platform sessions.
- * </li>
- * <li>When an object is restored, an appropriate class for an object might not
- * be available. It must be possible to skip an object in this case.</li>
- * <li>When an object is restored, the appropriate class for the object may be
- * different from the one when the object was originally saved. If so, the
- * new class should still be able to read the old form of the data.</li>
- * </ol>
- * </p>
- * <p>
- * Mementos meet these requirements by providing support for storing a
- * mapping of arbitrary string keys to primitive values, and by allowing
- * mementos to have other mementos as children (arranged into a tree).
- * A robust external storage format based on XML is used.
- * </p><p>
- * The key for an attribute may be any alpha numeric value. However, the
- * value of <code>TAG_ID</code> is reserved for internal use.
- * </p><p>
- * This interface is not intended to be implemented by clients.
- * </p>
- */
-public interface IMemento {
- /**
- * Creates a new child of this memento with the given type.
- * <p>
- * The <code>getChild</code> and <code>getChildren</code> methods
- * are used to retrieve children of a given type.
- * </p>
- *
- * @param type the type
- * @return a new child memento
- */
- public IMemento createChild(String type);
-
- /**
- * Sets the value of the given key to the given integer.
- *
- * @param key the key
- * @param value the value
- */
- public void putInteger(String key, int value);
-
- /**
- * Sets the value of the given key to the given string.
- *
- * @param key the key
- * @param value the value
- */
- public void putString(String key, String value);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java
deleted file mode 100644
index 300a8f465..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-
-import org.eclipse.osgi.util.NLS;
-/**
- * Translated messages.
- */
-public class Messages extends NLS {
- public static String errorLocation;
- public static String errorJRE;
- public static String classpathContainerDescription;
- public static String classpathContainer;
- public static String classpathContainerUnbound;
-
- public static String copyingTask;
- public static String deletingTask;
- public static String errorCopyingFile;
- public static String errorCreatingZipFile;
- public static String errorDelete;
- public static String errorRename;
- public static String errorReading;
- public static String updateClasspathContainers;
- public static String errorNoRuntime;
- public static String errorFacet;
- public static String errorDeleting;
- public static String errorNotADirectory;
- public static String errorMkdir;
-
- public static String artifactServlet;
- public static String artifactEJB;
- public static String artifactJNDI;
- public static String artifactCactusTest;
-
- public static String canModifyModules;
- public static String errorNoProfiler;
- public static String errorPublish;
- public static String httpPort;
- public static String errorPortInUse;
-
- static {
- NLS.initializeMessages(PreviewPlugin.PLUGIN_ID + ".internal.Messages", Messages.class);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties
deleted file mode 100644
index 76c6ce48b..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Messages.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-###############################################################################
-# Copyright (c) 2004, 2007 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-classpathContainerDescription=Server Library
-classpathContainer={0} [{1}]
-classpathContainerUnbound={0} [{1}] (unbound)
-
-errorLocation=Invalid location.
-errorJRE=Invalid JRE.
-
-copyingTask=Copying from {0} to {1}
-deletingTask=Deleting {0}
-errorCopyingFile=Error copying file {0}: {1}
-errorCreatingZipFile=Error creating zip file {0}: {1}
-errorDelete=Could not delete previous copy, which may be locked by another process.
-errorRename=Could not replace with temp file {0}.
-errorReading=Error reading file {0}
-errorNoRuntime=Cannot verify facets because there is no runtime associated with the server.
-errorFacet=Project facet {0} version {1} is not supported.
-errorDeleting=Could not delete {0}. May be locked by another process.
-errorNotADirectory=Could not delete {0} since it is not a directory.
-errorMkdir=Could not create directory {0}.
-
-updateClasspathContainers=Updating classpath container for {0}
-
-artifactServlet=Servlet {0}
-artifactEJB=EJB {0}
-artifactJNDI=JNDI {0}
-artifactCactusTest=Cactus test {0}
-
-canModifyModules=Web module can be added to the server.
-errorNoProfiler=Could not launch in profiling mode because no profilers are configured.
-errorPublish=An error occured during publishing.
-httpPort=HTTP Port
-errorPortInUse=Port {0} required by {1} is already in use. The server may already be running in another process, or a system process may be using the port. \
- To start this server you will need to stop the other process or change the port number(s). \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/PreviewPlugin.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/PreviewPlugin.java
deleted file mode 100644
index 6020f2c3c..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/PreviewPlugin.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-
-import org.eclipse.core.runtime.*;
-/**
- * The main preview server tools plugin class.
- */
-public class PreviewPlugin extends Plugin {
- /**
- * Java server plugin id
- */
- public static final String PLUGIN_ID = "org.eclipse.jst.server.preview.adapter";
-
- // singleton instance of this class
- private static PreviewPlugin singleton;
-
- /**
- * Create the PreviewPlugin.
- */
- public PreviewPlugin() {
- super();
- singleton = this;
- }
-
- /**
- * Returns the singleton instance of this plugin.
- *
- * @return a singleton instance
- */
- public static PreviewPlugin getInstance() {
- return singleton;
- }
-
- /**
- * Convenience method for logging.
- *
- * @param status a status
- */
- private static void log(IStatus status) {
- getInstance().getLog().log(status);
- }
-
- public static void logWarning(String msg) {
- log(new Status(IStatus.WARNING, PLUGIN_ID, IStatus.OK, msg, null));
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ProgressUtil.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ProgressUtil.java
deleted file mode 100644
index e42adf2bd..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ProgressUtil.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-
-import org.eclipse.core.runtime.*;
-/**
- * Progress Monitor utility.
- */
-public class ProgressUtil {
- /**
- * ProgressUtil constructor comment.
- */
- private ProgressUtil() {
- super();
- }
-
- /**
- * Return a valid progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getMonitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- /**
- * Return a sub-progress monitor with the given amount on the
- * current progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @param ticks int
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
-
- /**
- * Return a sub-progress monitor with the given amount on the
- * current progress monitor.
- *
- * @param monitor org.eclipse.core.runtime.IProgressMonitor
- * @param ticks a number of ticks
- * @param style a style
- * @return org.eclipse.core.runtime.IProgressMonitor
- */
- public static IProgressMonitor getSubMonitorFor(IProgressMonitor monitor, int ticks, int style) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks, style);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Trace.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Trace.java
deleted file mode 100644
index 29b7081c1..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/Trace.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-/**
- * Helper class to route trace output.
- */
-public class Trace {
- /**
- * Config tracing
- */
- public static final byte CONFIG = 0;
- /**
- * Warning tracing
- */
- public static final byte WARNING = 1;
- /**
- * Severe tracing
- */
- public static final byte SEVERE = 2;
- /**
- * Finest tracing
- */
- public static final byte FINEST = 3;
-
- public static final byte PUBLISHING = 4;
-
- /**
- * Trace constructor comment.
- */
- private Trace() {
- super();
- }
-
- /**
- * Trace the given text.
- *
- * @param level trace level
- * @param s String
- */
- public static void trace(byte level, String s) {
- Trace.trace(level, s, null);
- }
-
- /**
- * Trace the given message and exception.
- *
- * @param level trace level
- * @param s String
- * @param t Throwable
- */
- public static void trace(byte level, String s, Throwable t) {
- if (level == SEVERE)
- PreviewPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, s, t));
-
- if (!PreviewPlugin.getInstance().isDebugging())
- return;
-
- System.out.println(PreviewPlugin.PLUGIN_ID + " " + s);
- if (t != null)
- t.printStackTrace();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/XMLMemento.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/XMLMemento.java
deleted file mode 100644
index 61a932b26..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/XMLMemento.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal;
-
-import java.io.*;
-
-import org.w3c.dom.*;
-
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-/**
- * A Memento is a class independent container for persistence
- * info. It is a reflection of 3 storage requirements.
- *
- * 1) We need the ability to persist an object and restore it.
- * 2) The class for an object may be absent. If so we would
- * like to skip the object and keep reading.
- * 3) The class for an object may change. If so the new class
- * should be able to read the old persistence info.
- *
- * We could ask the objects to serialize themselves into an
- * ObjectOutputStream, DataOutputStream, or Hashtable. However
- * all of these approaches fail to meet the second requirement.
- *
- * Memento supports binary persistance with a version ID.
- */
-public final class XMLMemento implements IMemento {
- private Document factory;
- private Element element;
-
- /**
- * Answer a memento for the document and element. For simplicity
- * you should use createReadRoot and createWriteRoot to create the initial
- * mementos on a document.
- */
- private XMLMemento(Document doc, Element el) {
- factory = doc;
- element = el;
- }
-
- /**
- * @see IMemento#createChild(String)
- */
- public IMemento createChild(String type) {
- Element child = factory.createElement(type);
- element.appendChild(child);
- return new XMLMemento(factory, child);
- }
-
- /**
- * Answer a root memento for writing a document.
- *
- * @param type a type
- * @return a memento
- */
- public static XMLMemento createWriteRoot(String type) {
- Document document;
- try {
- document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- Element element = document.createElement(type);
- document.appendChild(element);
- return new XMLMemento(document, element);
- } catch (ParserConfigurationException e) {
- throw new Error(e);
- }
- }
-
- /*
- * @see IMemento
- */
- public void putInteger(String key, int n) {
- element.setAttribute(key, String.valueOf(n));
- }
-
- /*
- * @see IMemento
- */
- public void putString(String key, String value) {
- if (value == null)
- return;
- element.setAttribute(key, value);
- }
-
- /**
- * Save this Memento to a Writer.
- *
- * @param os an output stream
- * @throws IOException if anything goes wrong
- */
- private void save(OutputStream os) throws IOException {
- Result result = new StreamResult(os);
- Source source = new DOMSource(factory);
- try {
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xalan}indent-amount", "2");
- transformer.transform(source, result);
- } catch (Exception e) {
- throw (IOException) (new IOException().initCause(e));
- }
- }
-
- /**
- * Saves the memento to the given file.
- *
- * @param filename java.lang.String
- * @exception java.io.IOException
- */
- public void saveToFile(String filename) throws IOException {
- FileOutputStream w = null;
- try {
- w = new FileOutputStream(filename);
- save(w);
- } catch (IOException e) {
- throw e;
- } catch (Exception e) {
- throw new IOException(e.getLocalizedMessage());
- } finally {
- if (w != null) {
- try {
- w.close();
- } catch (Exception e) {
- // ignore
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PingThread.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PingThread.java
deleted file mode 100644
index 1d5461cbe..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PingThread.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.io.FileNotFoundException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.internal.ServerType;
-/**
- * Thread used to ping server to test when it is started.
- */
-public class PingThread {
- // delay before pinging starts
- private static final int PING_DELAY = 2000;
-
- // delay between pings
- private static final int PING_INTERVAL = 250;
-
- // maximum number of pings before giving up
- private int maxPings;
-
- private boolean stop = false;
- private String url;
- private IServer server;
- private PreviewServerBehaviour behaviour;
-
- /**
- * Create a new PingThread.
- *
- * @param server
- * @param url
- * @param behaviour
- */
- public PingThread(IServer server, String url, PreviewServerBehaviour behaviour) {
- super();
- this.server = server;
- this.url = url;
- this.behaviour = behaviour;
- this.maxPings = guessMaxPings();
- Thread t = new Thread("Preview Ping Thread") {
- public void run() {
- ping();
- }
- };
- t.setDaemon(true);
- t.start();
- }
-
- private int guessMaxPings() {
- int startTimeout = ((ServerType) server.getServerType()).getStartTimeout();
- if (startTimeout > 0)
- return startTimeout / PING_INTERVAL;
- return -1;
- }
-
- /**
- * Ping the server until it is started. Then set the server state to
- * STATE_STARTED.
- */
- protected void ping() {
- int count = 0;
- try {
- Thread.sleep(PING_DELAY);
- } catch (Exception e) {
- // ignore
- }
- while (!stop) {
- try {
- if (count == maxPings) {
- try {
- server.stop(false);
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: could not stop server");
- }
- stop = true;
- break;
- }
- count++;
-
- Trace.trace(Trace.FINEST, "Ping: pinging " + count);
- URL pingUrl = new URL(url);
- URLConnection conn = pingUrl.openConnection();
- ((HttpURLConnection)conn).getResponseCode();
-
- // ping worked - server is up
- if (!stop) {
- Trace.trace(Trace.FINEST, "Ping: success");
- Thread.sleep(200);
- behaviour.setServerStarted();
- }
- stop = true;
- } catch (FileNotFoundException fe) {
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- // ignore
- }
- behaviour.setServerStarted();
- stop = true;
- } catch (Exception e) {
- Trace.trace(Trace.FINEST, "Ping: failed");
- // pinging failed
- if (!stop) {
- try {
- Thread.sleep(PING_INTERVAL);
- } catch (InterruptedException e2) {
- // ignore
- }
- }
- }
- }
- }
-
- /**
- * Tell the pinging to stop.
- */
- public void stop() {
- Trace.trace(Trace.FINEST, "Ping: stopping");
- stop = true;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchConfigurationDelegate.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchConfigurationDelegate.java
deleted file mode 100644
index 94d050a7c..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchConfigurationDelegate.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.io.File;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jdt.launching.*;
-import org.eclipse.jst.server.core.ServerProfilerDelegate;
-import org.eclipse.jst.server.preview.adapter.internal.PreviewPlugin;
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.osgi.framework.Bundle;
-/**
- *
- */
-public class PreviewLaunchConfigurationDelegate extends AbstractJavaLaunchConfigurationDelegate {
- private static final String[] REQUIRED_BUNDLE_IDS = new String[] {
- "org.apache.commons.logging",
- "org.apache.commons.el",
- "javax.servlet",
- "javax.servlet.jsp",
- "org.apache.jasper",
- "org.mortbay.jetty",
- "org.eclipse.wst.server.preview"
- };
-
- private static final String MAIN_CLASS = "org.eclipse.wst.server.preview.internal.PreviewStarter";
-
- public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
- IServer server = ServerUtil.getServer(configuration);
- if (server == null) {
- Trace.trace(Trace.FINEST, "Launch configuration could not find server");
- // throw CoreException();
- return;
- }
-
- PreviewServerBehaviour previewServer = (PreviewServerBehaviour) server.loadAdapter(PreviewServerBehaviour.class, null);
-
- int size = REQUIRED_BUNDLE_IDS.length;
- String[] jars = new String[size];
- for (int i = 0; i < size; i++) {
- Bundle b = Platform.getBundle(REQUIRED_BUNDLE_IDS[i]);
- IPath path = null;
- if (b != null)
- path = PreviewRuntime.getJarredPluginPath(b);
- if (path == null)
- throw new CoreException(new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, "Could not find required bundle " + REQUIRED_BUNDLE_IDS[i]));
- jars[i] = path.toOSString();
- }
-
- if (new File(jars[6] + "bin").exists())
- jars[6] = jars[6] + "bin";
-
- IVMInstall vm = verifyVMInstall(configuration);
-
- IVMRunner runner = vm.getVMRunner(mode);
- if (runner == null)
- runner = vm.getVMRunner(ILaunchManager.RUN_MODE);
-
- File workingDir = verifyWorkingDirectory(configuration);
- String workingDirName = null;
- if (workingDir != null)
- workingDirName = workingDir.getAbsolutePath();
-
- // Program & VM args
- String pgmArgs = "\"" + previewServer.getTempDirectory().append("preview.xml").toOSString() + "\"";
- //getProgramArguments(configuration);
- String vmArgs = getVMArguments(configuration);
- String[] envp = getEnvironment(configuration);
-
- ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs);
-
- // VM-specific attributes
- Map vmAttributesMap = getVMSpecificAttributesMap(configuration);
-
- // Classpath
- String[] classpath2 = getClasspath(configuration);
- String[] classpath = new String[classpath2.length + REQUIRED_BUNDLE_IDS.length];
- System.arraycopy(jars, 0, classpath, 0, REQUIRED_BUNDLE_IDS.length);
- System.arraycopy(classpath2, 0, classpath, REQUIRED_BUNDLE_IDS.length, classpath2.length);
-
- // Create VM config
- VMRunnerConfiguration runConfig = new VMRunnerConfiguration(MAIN_CLASS, classpath);
- runConfig.setProgramArguments(execArgs.getProgramArgumentsArray());
- runConfig.setVMArguments(execArgs.getVMArgumentsArray());
- runConfig.setWorkingDirectory(workingDirName);
- runConfig.setEnvironment(envp);
- runConfig.setVMSpecificAttributesMap(vmAttributesMap);
-
- // Bootpath
- String[] bootpath = getBootpath(configuration);
- if (bootpath != null && bootpath.length > 0)
- runConfig.setBootClassPath(bootpath);
-
- setDefaultSourceLocator(launch, configuration);
-
- // Launch the configuration
- previewServer.setupLaunch(launch, mode, monitor);
-
- if (ILaunchManager.PROFILE_MODE.equals(mode))
- ServerProfilerDelegate.configureProfiling(launch, vm, runConfig, monitor);
-
- try {
- runner.run(runConfig, launch, monitor);
- previewServer.addProcessListener(launch.getProcesses()[0]);
- } catch (Exception e) {
- // ignore - process failed
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchableAdapterDelegate.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchableAdapterDelegate.java
deleted file mode 100644
index c074d8cc4..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewLaunchableAdapterDelegate.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-import org.eclipse.wst.server.core.IModuleArtifact;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.model.LaunchableAdapterDelegate;
-import org.eclipse.wst.server.core.util.HttpLaunchable;
-import org.eclipse.wst.server.core.util.WebResource;
-
-public class PreviewLaunchableAdapterDelegate extends LaunchableAdapterDelegate {
- /*
- * @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact)
- */
- public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException {
- if (server == null || moduleArtifact == null)
- return null;
-
- PreviewServer server2 = (PreviewServer) server.loadAdapter(PreviewServer.class, null);
- if (server2 == null)
- return null;
-
- try {
- URL url = server2.getModuleRootURL(moduleArtifact.getModule());
-
- if (moduleArtifact instanceof WebResource) {
- WebResource resource = (WebResource) moduleArtifact;
- String path = resource.getPath().toString();
-
- if (path.startsWith("/"))
- path = path.substring(1);
- url = new URL(url.toExternalForm() + "/" + path);
- }
- return new HttpLaunchable(url);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error in launchable adapter", e);
- }
-
- return null;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java
deleted file mode 100644
index 04c0b24fd..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntime.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.jdt.launching.IVMInstall;
-import org.eclipse.jdt.launching.IVMInstallType;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.jst.server.core.IJavaRuntimeWorkingCopy;
-import org.eclipse.jst.server.preview.adapter.internal.Messages;
-import org.eclipse.jst.server.preview.adapter.internal.PreviewPlugin;
-import org.eclipse.wst.server.core.model.RuntimeDelegate;
-import org.osgi.framework.Bundle;
-/**
- * J2EE preview runtime.
- */
-public class PreviewRuntime extends RuntimeDelegate implements IJavaRuntimeWorkingCopy {
- public static final String ID = "org.eclipse.jst.server.preview.runtime";
-
- protected static final String PROP_VM_INSTALL_TYPE_ID = "vm-install-type-id";
- protected static final String PROP_VM_INSTALL_ID = "vm-install-id";
-
- /**
- * Create a new preview runtime.
- */
- public PreviewRuntime() {
- // do nothing
- }
-
- /**
- * Returns the path that corresponds to the specified bundle.
- *
- * @return a path
- */
- protected static Path getPluginPath(Bundle bundle) {
- try {
- URL installURL = bundle.getEntry("/");
- URL localURL = FileLocator.toFileURL(installURL);
- return new Path(localURL.getFile());
- } catch (IOException ioe) {
- return null;
- }
- }
-
- protected static IPath getJarredPluginPath(Bundle bundle) {
- Path runtimeLibFullPath = null;
- String jarPluginLocation = bundle.getLocation().substring(7);
-
- // handle case where jars are installed outside of eclipse installation
- Path jarPluginPath = new Path(jarPluginLocation);
- if (jarPluginPath.isAbsolute())
- runtimeLibFullPath = jarPluginPath;
- // handle normal case where all plugins under eclipse install
- else {
- int ind = jarPluginLocation.lastIndexOf(":");
- if (ind > 0)
- jarPluginLocation = jarPluginLocation.substring(ind+1);
-
- String installPath = Platform.getInstallLocation().getURL().getPath();
- runtimeLibFullPath = new Path(installPath+"/"+jarPluginLocation);
- }
- return runtimeLibFullPath;
- }
-
- protected String getVMInstallTypeId() {
- return getAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null);
- }
-
- protected String getVMInstallId() {
- return getAttribute(PROP_VM_INSTALL_ID, (String)null);
- }
-
- /**
- * @see RuntimeDelegate#setDefaults(IProgressMonitor)
- */
- public void setDefaults(IProgressMonitor monitor) {
- getRuntimeWorkingCopy().setLocation(new Path(""));
- }
-
- /**
- * Returns <code>true</code> if the runtime is using the default JRE.
- *
- * @return <code>true</code> if the runtime is using the default JRE,
- * and <code>false</code> otherwise
- */
- public boolean isUsingDefaultJRE() {
- return getVMInstallTypeId() == null;
- }
-
- public IVMInstall getVMInstall() {
- if (getVMInstallTypeId() == null)
- return JavaRuntime.getDefaultVMInstall();
- try {
- IVMInstallType vmInstallType = JavaRuntime.getVMInstallType(getVMInstallTypeId());
- IVMInstall[] vmInstalls = vmInstallType.getVMInstalls();
- int size = vmInstalls.length;
- String id = getVMInstallId();
- for (int i = 0; i < size; i++) {
- if (id.equals(vmInstalls[i].getId()))
- return vmInstalls[i];
- }
- } catch (Exception e) {
- // ignore
- }
- return null;
- }
-
- /**
- * @see RuntimeDelegate#validate()
- */
- public IStatus validate() {
- IStatus status = super.validate();
- if (!status.isOK())
- return status;
-
- if (getVMInstall() == null)
- return new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, 0, Messages.errorJRE, null);
-
- return Status.OK_STATUS;
- }
-
- public void setVMInstall(IVMInstall vmInstall) {
- if (vmInstall == null) {
- setVMInstall(null, null);
- } else
- setVMInstall(vmInstall.getVMInstallType().getId(), vmInstall.getId());
- }
-
- protected void setVMInstall(String typeId, String id) {
- if (typeId == null)
- setAttribute(PROP_VM_INSTALL_TYPE_ID, (String)null);
- else
- setAttribute(PROP_VM_INSTALL_TYPE_ID, typeId);
-
- if (id == null)
- setAttribute(PROP_VM_INSTALL_ID, (String)null);
- else
- setAttribute(PROP_VM_INSTALL_ID, id);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java
deleted file mode 100644
index b3ea20df3..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewRuntimeClasspathProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jst.server.core.RuntimeClasspathProviderDelegate;
-
-import org.eclipse.wst.server.core.IRuntime;
-import org.osgi.framework.Bundle;
-/**
- *
- */
-public class PreviewRuntimeClasspathProvider extends RuntimeClasspathProviderDelegate {
- private static final String[] REQUIRED_BUNDLE_IDS = new String[] {
- "javax.servlet",
- "javax.servlet.jsp"
- };
-
- /** (non-Javadoc)
- * @see RuntimeClasspathProviderDelegate#resolveClasspathContainer(IProject, IRuntime)
- */
- public IClasspathEntry[] resolveClasspathContainer(IProject project, IRuntime runtime) {
- List<IClasspathEntry> list = new ArrayList<IClasspathEntry>();
-
- int size = REQUIRED_BUNDLE_IDS.length;
- for (int i = 0; i < size; i++) {
- Bundle b = Platform.getBundle(REQUIRED_BUNDLE_IDS[i]);
- IPath path = PreviewRuntime.getJarredPluginPath(b);
- if (path != null)
- list.add(JavaCore.newLibraryEntry(path, null, null));
- }
-
- return list.toArray(new IClasspathEntry[list.size()]);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServer.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServer.java
deleted file mode 100644
index 2da1b7dc7..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.net.URL;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.preview.adapter.internal.Messages;
-import org.eclipse.jst.server.preview.adapter.internal.PreviewPlugin;
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.model.IURLProvider;
-import org.eclipse.wst.server.core.model.ServerDelegate;
-import org.eclipse.wst.server.core.util.IStaticWeb;
-/**
- * J2EE preview server.
- */
-public class PreviewServer extends ServerDelegate implements IURLProvider {
- public static final String ID = "org.eclipse.jst.server.preview.server";
-
- public static final String PROPERTY_PORT = "port";
-
- /**
- * PreviewServer.
- */
- public PreviewServer() {
- super();
- }
-
- protected void initialize() {
- // do nothing
- }
-
- public PreviewRuntime getPreviewRuntime() {
- if (getServer().getRuntime() == null)
- return null;
-
- return (PreviewRuntime) getServer().getRuntime().loadAdapter(PreviewRuntime.class, null);
- }
-
- /**
- * Return the root URL of this module.
- *
- * @param module a module
- * @return java.net.URL
- */
- public URL getModuleRootURL(IModule module) {
- try {
- String base = "http://localhost";
-
- int port = getPort();
- URL url = null;
- if (port == 80)
- url = new URL(base + "/");
- else
- url = new URL(base + ":" + port + "/");
-
- String type = module.getModuleType().getId();
- if ("wst.web".equals(type)) {
- IStaticWeb staticWeb = (IStaticWeb) module.loadAdapter(IStaticWeb.class, null);
- return new URL(url, staticWeb.getContextRoot());
- } else if ("jst.web".equals(type)) {
- IWebModule webModule = (IWebModule) module.loadAdapter(IWebModule.class, null);
- return new URL(url, webModule.getContextRoot());
- }
- return url;
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Could not get root URL", e);
- return null;
- }
- }
-
- /*
- * Returns the child module(s) of this module.
- */
- public IModule[] getChildModules(IModule[] module) {
- return new IModule[0];
- }
-
- /*
- * Returns the root module(s) of this module.
- */
- public IModule[] getRootModules(IModule module) throws CoreException {
- return new IModule[] { module };
- }
-
- /**
- * Returns true if the given project is supported by this server, and false
- * otherwise.
- *
- * @param add modules
- * @param remove modules
- * @return the status
- */
- public IStatus canModifyModules(IModule[] add, IModule[] remove) {
- return new Status(IStatus.OK, PreviewPlugin.PLUGIN_ID, 0, Messages.canModifyModules, null);
- }
-
- public ServerPort[] getServerPorts() {
- int port = getPort();
- ServerPort[] ports = { new ServerPort("http", Messages.httpPort, port, "http") };
- return ports;
- }
-
- public int getPort() {
- return getAttribute(PreviewServer.PROPERTY_PORT, 8080);
- }
-
- public void setPort(int port) {
- setAttribute(PreviewServer.PROPERTY_PORT, port);
- }
-
- public static IServer createPreviewServer(String serverName) {
- try {
- NullProgressMonitor monitor = new NullProgressMonitor();
- IRuntimeType runtimeType = ServerCore.findRuntimeType(PreviewRuntime.ID);
- IRuntimeWorkingCopy runtimeCopy = runtimeType.createRuntime(PreviewRuntime.ID, monitor);
- IRuntime runtime = runtimeCopy.save(true, monitor);
-
- IServerType serverType = ServerCore.findServerType(ID);
- IServerWorkingCopy workingCopy = serverType.createServer(ID, null, runtime, monitor);
- workingCopy.setName(serverName);
- workingCopy.setHost("localhost");
- return workingCopy.save(true, monitor);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error creating server", e);
- }
-
- return null;
- }
-
- public static IServer findPreviewServer(String id) {
- IServer[] servers = ServerCore.getServers();
- for (int i = 0; i < servers.length; i++) {
- if (servers[i].getId().equals(id)) {
- return servers[i];
- }
- }
- return null;
- }
-
- public void modifyModules(IModule[] add, IModule[] remove, IProgressMonitor monitor) throws CoreException {
- // do nothing
- }
-
- /**
- * Return a string representation of this object.
- *
- * @return java.lang.String
- */
- public String toString() {
- return "PreviewServer";
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServerBehaviour.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServerBehaviour.java
deleted file mode 100644
index f785e5ee7..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewServerBehaviour.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.io.IOException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugEvent;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IDebugEventSetListener;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.IProcess;
-import org.eclipse.jst.server.core.IWebModule;
-import org.eclipse.jst.server.preview.adapter.internal.IMemento;
-import org.eclipse.jst.server.preview.adapter.internal.Messages;
-import org.eclipse.jst.server.preview.adapter.internal.PreviewPlugin;
-import org.eclipse.jst.server.preview.adapter.internal.ProgressUtil;
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-import org.eclipse.jst.server.preview.adapter.internal.XMLMemento;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerPort;
-import org.eclipse.wst.server.core.model.IModuleResource;
-import org.eclipse.wst.server.core.model.IModuleResourceDelta;
-import org.eclipse.wst.server.core.model.ServerBehaviourDelegate;
-import org.eclipse.wst.server.core.util.IStaticWeb;
-import org.eclipse.wst.server.core.util.PublishUtil;
-import org.eclipse.wst.server.core.util.SocketUtil;
-/**
- * Generic Http server.
- */
-public class PreviewServerBehaviour extends ServerBehaviourDelegate {
- // the thread used to ping the server to check for startup
- protected transient PingThread ping = null;
- protected transient IDebugEventSetListener processListener;
-
- /**
- * PreviewServer.
- */
- public PreviewServerBehaviour() {
- super();
- }
-
- public void initialize(IProgressMonitor monitor) {
- // do nothing
- }
-
- public PreviewRuntime getPreviewRuntime() {
- if (getServer().getRuntime() == null)
- return null;
-
- return (PreviewRuntime) getServer().getRuntime().loadAdapter(PreviewRuntime.class, null);
- }
-
- public PreviewServer getPreviewServer() {
- return (PreviewServer) getServer().getAdapter(PreviewServer.class);
- }
-
- /**
- * Returns the runtime base path for relative paths in the server
- * configuration.
- *
- * @return the base path
- */
- public IPath getRuntimeBaseDirectory() {
- return getServer().getRuntime().getLocation();
- }
-
- /**
- * Setup for starting the server.
- *
- * @param launch ILaunch
- * @param launchMode String
- * @param monitor IProgressMonitor
- * @throws CoreException if anything goes wrong
- */
- protected void setupLaunch(ILaunch launch, String launchMode, IProgressMonitor monitor) throws CoreException {
- // check that ports are free
- ServerPort[] ports = getPreviewServer().getServerPorts();
- int port = ports[0].getPort();
-
- if (SocketUtil.isPortInUse(port, 5))
- throw new CoreException(new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorPortInUse, new String[] {port + "", getServer().getName()}), null));
-
- // generate preview config file
- XMLMemento memento = XMLMemento.createWriteRoot("server");
- memento.putInteger("port", port);
-
- IModule[] modules = getServer().getModules();
- int size = modules.length;
- for (int i = 0; i < size; i++) {
- IMemento mod = memento.createChild("module");
- mod.putString("name", modules[i].getName());
- String type = modules[i].getModuleType().getId();
- if ("wst.web".equals(type)) {
- IStaticWeb staticWeb = (IStaticWeb) modules[i].loadAdapter(IStaticWeb.class, null);
- if (staticWeb != null)
- mod.putString("context", staticWeb.getContextRoot());
- mod.putString("type", "static");
- } else if ("jst.web".equals(type)) {
- IWebModule webModule = (IWebModule) modules[i].loadAdapter(IWebModule.class, null);
- if (webModule != null)
- mod.putString("context", webModule.getContextRoot());
- mod.putString("type", "j2ee");
- }
- mod.putString("path", getModulePublishDirectory(modules[i]).toPortableString());
- }
- try {
- memento.saveToFile(getTempDirectory().append("preview.xml").toOSString());
- } catch (IOException e) {
- Trace.trace(Trace.SEVERE, "Could not write preview config", e);
- throw new CoreException(new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, 0, "Could not write preview configuration", null));
- }
-
- setServerRestartState(false);
- setServerState(IServer.STATE_STARTING);
- setMode(launchMode);
-
- // ping server to check for startup
- try {
- String url = "http://localhost";
- if (port != 80)
- url += ":" + port;
- ping = new PingThread(getServer(), url, this);
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Can't ping for Tomcat startup.");
- }
- }
-
- protected void addProcessListener(final IProcess newProcess) {
- if (processListener != null || newProcess == null)
- return;
-
- processListener = new IDebugEventSetListener() {
- public void handleDebugEvents(DebugEvent[] events) {
- if (events != null) {
- int size = events.length;
- for (int i = 0; i < size; i++) {
- if (newProcess != null && newProcess.equals(events[i].getSource()) && events[i].getKind() == DebugEvent.TERMINATE) {
- stop(true);
- }
- }
- }
- }
- };
- DebugPlugin.getDefault().addDebugEventListener(processListener);
- }
-
- protected void setServerStarted() {
- setServerState(IServer.STATE_STARTED);
- }
-
- protected void publishServer(int kind, IProgressMonitor monitor) throws CoreException {
- monitor = ProgressUtil.getMonitorFor(monitor);
- monitor.done();
-
- setServerPublishState(IServer.PUBLISH_STATE_NONE);
- }
-
- /*
- * Publishes the given module to the server.
- */
- protected void publishModule(int kind, int deltaKind, IModule[] moduleTree, IProgressMonitor monitor) throws CoreException {
- IModule module = moduleTree[moduleTree.length - 1];
- IPath to = getModulePublishDirectory(module);
-
- if (kind == IServer.PUBLISH_CLEAN || deltaKind == ServerBehaviourDelegate.REMOVED) {
- IStatus[] status = PublishUtil.deleteDirectory(to.toFile(), monitor);
- throwException(status);
- }
-
- IModuleResource[] res = getResources(moduleTree);
- IStatus[] status = PublishUtil.publishSmart(res, to, monitor);
- throwException(status);
-
- setModulePublishState(moduleTree, IServer.PUBLISH_STATE_NONE);
- }
-
- /**
- * Utility method to throw a CoreException based on the contents of a list of
- * error and warning status.
- *
- * @param status a List containing error and warning IStatus
- * @throws CoreException
- */
- private static void throwException(IStatus[] status) throws CoreException {
- if (status == null || status.length == 0)
- return;
-
- if (status.length == 1)
- throw new CoreException(status[0]);
-
- String message = Messages.errorPublish;
- MultiStatus status2 = new MultiStatus(PreviewPlugin.PLUGIN_ID, 0, status, message, null);
- throw new CoreException(status2);
- }
-
- public void restart(String launchMode) throws CoreException {
- setServerState(IServer.STATE_STOPPED);
- setServerState(IServer.STATE_STARTED);
- }
-
- /**
- * Cleanly shuts down and terminates the server.
- *
- * @param force <code>true</code> to kill the server
- */
- public void stop(boolean force) {
- int state = getServer().getServerState();
- if (state == IServer.STATE_STOPPED)
- return;
-
- setServerState(IServer.STATE_STOPPING);
-
- if (ping != null) {
- ping.stop();
- ping = null;
- }
-
- if (processListener != null) {
- DebugPlugin.getDefault().removeDebugEventListener(processListener);
- processListener = null;
- }
-
- try {
- Trace.trace(Trace.FINEST, "Killing the process");
- ILaunch launch = getServer().getLaunch();
- if (launch != null)
- launch.terminate();
- } catch (Exception e) {
- Trace.trace(Trace.SEVERE, "Error killing the process", e);
- }
-
- setServerState(IServer.STATE_STOPPED);
- }
-
- protected IPath getTempDirectory() {
- return super.getTempDirectory();
- }
-
- /**
- * Returns the module's publish path.
- *
- * @param module a module
- * @return the publish directory for the module
- */
- protected IPath getModulePublishDirectory(IModule module) {
- return getTempDirectory().append(module.getName());
- }
-
- /**
- * Return a string representation of this object.
- *
- * @return java.lang.String
- */
- public String toString() {
- return "PreviewServer";
- }
-
- protected IModuleResourceDelta[] getPublishedResourceDelta(IModule[] module) {
- return super.getPublishedResourceDelta(module);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewSourcePathComputerDelegate.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewSourcePathComputerDelegate.java
deleted file mode 100644
index d346e906c..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewSourcePathComputerDelegate.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- **********************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.sourcelookup.ISourceContainer;
-import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
-import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
-import org.eclipse.jdt.launching.JavaRuntime;
-import org.eclipse.wst.server.core.IModule;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.ServerUtil;
-/**
- *
- */
-public class PreviewSourcePathComputerDelegate implements ISourcePathComputerDelegate {
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
- */
- public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- List<IRuntimeClasspathEntry> classpaths = new ArrayList<IRuntimeClasspathEntry>();
- classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedSourceLookupPath(configuration)));
- List<ISourceContainer> sourcefolderList = new ArrayList<ISourceContainer>();
-
- IServer server = ServerUtil.getServer(configuration);
- if (server != null) {
- List<IJavaProject> list = new ArrayList<IJavaProject>();
- IModule[] modules = server.getModules();
- for (int i = 0; i < modules.length; i++) {
- IProject project = modules[i].getProject();
- if (project != null) {
- IFolder moduleFolder = project.getFolder(modules[i].getName());
- if (moduleFolder.exists()) {
- sourcefolderList.add(new FolderSourceContainer(moduleFolder, true));
- }
-
- try {
- if (project.hasNature(JavaCore.NATURE_ID)) {
- IJavaProject javaProject = (IJavaProject) project.getNature(JavaCore.NATURE_ID);
- if (!list.contains(javaProject))
- list.add(javaProject);
- }
- } catch (Exception e) {
- // ignore
- }
- }
- }
- int size = list.size();
- IJavaProject[] projects = new IJavaProject[size];
- list.toArray(projects);
-
- for (int i = 0; i < size; i++)
- classpaths.addAll(Arrays.asList(JavaRuntime.computeUnresolvedRuntimeClasspath(projects[i])));
- }
-
- IRuntimeClasspathEntry[] entries = new IRuntimeClasspathEntry[classpaths.size()];
- classpaths.toArray(entries);
-
- IRuntimeClasspathEntry[] resolved = JavaRuntime.resolveSourceLookupPath(entries, configuration);
- ISourceContainer[] sourceContainers = JavaRuntime.getSourceContainers(resolved);
-
- if (!sourcefolderList.isEmpty()) {
- ISourceContainer[] combinedSourceContainers = new ISourceContainer[sourceContainers.length + sourcefolderList.size()];
- sourcefolderList.toArray(combinedSourceContainers);
- System.arraycopy(sourceContainers, 0, combinedSourceContainers, sourcefolderList.size(), sourceContainers.length);
- sourceContainers = combinedSourceContainers;
- }
-
- return sourceContainers;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewStartup.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewStartup.java
deleted file mode 100644
index 2f9970c8a..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/core/PreviewStartup.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jst.server.preview.adapter.internal.Trace;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.IServer;
-import org.eclipse.wst.server.core.IServerType;
-import org.eclipse.wst.server.core.IServerWorkingCopy;
-import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.IStartup;
-
-public class PreviewStartup implements IStartup {
- private static final String ID = "xyz";
-
- public void startup() {
- // create runtime
- IRuntime[] runtimes = ServerCore.getRuntimes();
- IRuntime runtime = null;
-
- int size = runtimes.length;
- for (int i = 0; i < size; i++) {
- if (runtimes[i].getRuntimeType() != null && PreviewRuntime.ID.equals(runtimes[i].getRuntimeType().getId())) {
- if (ID.equals(runtimes[i].getId()))
- runtime = runtimes[i];
- }
- }
-
- if (runtime == null) {
- try {
- IRuntimeType runtimeType = ServerCore.findRuntimeType(PreviewRuntime.ID);
- IRuntimeWorkingCopy wc = runtimeType.createRuntime(ID, null);
- wc.setName("My Preview");
- wc.setReadOnly(true);
- runtime = wc.save(true, null);
- } catch (CoreException ce) {
- Trace.trace(Trace.WARNING, "Could not create default preview runtime");
- }
- }
-
- // create server
- IServer[] servers = ServerCore.getServers();
-
- boolean found = false;
- size = servers.length;
- for (int i = 0; i < size; i++) {
- if (servers[i].getServerType() != null && PreviewServer.ID.equals(servers[i].getServerType().getId())) {
- if (ID.equals(servers[i].getId()))
- found = true;
- }
- }
-
- if (!found) {
- try {
- IServerType serverType = ServerCore.findServerType(PreviewServer.ID);
- IServerWorkingCopy wc = serverType.createServer(ID, null, runtime, null);
- wc.setName("My preview");
- wc.setHost("localhost");
- wc.setReadOnly(true);
- wc.save(true, null);
- } catch (CoreException ce) {
- Trace.trace(Trace.WARNING, "Could not create default preview server");
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ui/PreviewLaunchConfigurationTabGroup.java b/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ui/PreviewLaunchConfigurationTabGroup.java
deleted file mode 100644
index bf3730d5a..000000000
--- a/plugins/org.eclipse.jst.server.preview.adapter/src/org/eclipse/jst/server/preview/adapter/internal/ui/PreviewLaunchConfigurationTabGroup.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.server.preview.adapter.internal.ui;
-
-import org.eclipse.debug.ui.*;
-import org.eclipse.debug.ui.sourcelookup.SourceLookupTab;
-import org.eclipse.jdt.debug.ui.launchConfigurations.JavaArgumentsTab;
-import org.eclipse.jdt.debug.ui.launchConfigurations.JavaClasspathTab;
-
-import org.eclipse.wst.server.ui.ServerLaunchConfigurationTab;
-/**
- * A debug tab group for launching Tomcat.
- */
-public class PreviewLaunchConfigurationTabGroup extends AbstractLaunchConfigurationTabGroup {
- /*
- * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog, String)
- */
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[6];
- tabs[0] = new ServerLaunchConfigurationTab(new String[] { "org.eclipse.jst.server.preview" });
- tabs[0].setLaunchConfigurationDialog(dialog);
- tabs[1] = new JavaArgumentsTab();
- tabs[1].setLaunchConfigurationDialog(dialog);
- tabs[2] = new JavaClasspathTab();
- tabs[2].setLaunchConfigurationDialog(dialog);
- tabs[3] = new SourceLookupTab();
- tabs[3].setLaunchConfigurationDialog(dialog);
- tabs[4] = new EnvironmentTab();
- tabs[4].setLaunchConfigurationDialog(dialog);
- tabs[5] = new CommonTab();
- tabs[5].setLaunchConfigurationDialog(dialog);
- setTabs(tabs);
- }
-} \ No newline at end of file

Back to the top