diff options
Diffstat (limited to 'plugins/org.eclipse.wst.server.http.core/src/org')
15 files changed, 0 insertions, 1227 deletions
diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpCorePlugin.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpCorePlugin.java deleted file mode 100644 index 127768561..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpCorePlugin.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.wst.server.http.core.internal; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; -/** - * The HTTP server core plugin. - */ -public class HttpCorePlugin extends Plugin { - public static final String PLUGIN_ID = "org.eclipse.wst.server.http.core"; - - private static HttpCorePlugin plugin; - - /** - * The constructor - */ - public HttpCorePlugin() { - plugin = this; - } - - /** - * Returns the singleton instance of this plugin. - * - * @return an instance - */ - public static HttpCorePlugin getInstance() { - return plugin; - } - - /** - * Return the install location preference. - * - * @param id a runtime type id - * @return the install location - */ - public static String getPreference(String id) { - return getInstance().getPluginPreferences().getString(id); - } - - /** - * Set the install location preference. - * - * @param id the runtimt type id - * @param value the location - */ - public static void setPreference(String id, String value) { - getInstance().getPluginPreferences().setValue(id, value); - getInstance().savePluginPreferences(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpLaunchableAdapterDelegate.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpLaunchableAdapterDelegate.java deleted file mode 100644 index 6ab83f8fc..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpLaunchableAdapterDelegate.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.wst.server.http.core.internal; - -import java.net.URL; - -import org.eclipse.core.runtime.CoreException; -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 HttpLaunchableAdapterDelegate extends LaunchableAdapterDelegate { - /* - * @see LaunchableAdapterDelegate#getLaunchable(IServer, IModuleArtifact) - */ - public Object getLaunchable(IServer server, IModuleArtifact moduleArtifact) throws CoreException { - if (server == null || moduleArtifact == null) - return null; - - HttpServer server2 = (HttpServer) server.loadAdapter(HttpServer.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.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntime.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntime.java deleted file mode 100644 index 542bb1f57..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntime.java +++ /dev/null @@ -1,38 +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.wst.server.http.core.internal; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.server.core.model.RuntimeDelegate; -/** - * - */ -public class HttpRuntime extends RuntimeDelegate { - public static final String ID = "org.eclipse.wst.server.http.runtime"; - - public HttpRuntime() { - // do nothing - } - - public IStatus validate() { - return Status.OK_STATUS; - } - - /* - * @see RuntimeDelegate#setDefaults(IProgressMonitor) - */ - public void setDefaults(IProgressMonitor monitor) { - getRuntimeWorkingCopy().setLocation(new Path("")); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntimeLocator.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntimeLocator.java deleted file mode 100644 index c32545670..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpRuntimeLocator.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.wst.server.http.core.internal; - -import java.io.File; -import java.io.FileFilter; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.wst.server.core.IRuntimeType; -import org.eclipse.wst.server.core.IRuntimeWorkingCopy; -import org.eclipse.wst.server.core.ServerCore; -import org.eclipse.wst.server.core.model.RuntimeLocatorDelegate; -/** - * - */ -public class HttpRuntimeLocator extends RuntimeLocatorDelegate { - protected static final String[] runtimeTypes = new String[] { HttpRuntime.ID }; - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.server.core.model.IRuntimeFactoryDelegate#getKnownRuntimes() - */ - public void searchForRuntimes(IPath path, IRuntimeSearchListener listener, - IProgressMonitor monitor) { - searchForRuntimes2(path, listener, monitor); - } - - protected static void searchForRuntimes2(IPath path, IRuntimeSearchListener listener, - IProgressMonitor monitor) { - File[] files = null; - if (path != null) { - File f = path.toFile(); - if (f.exists()) - files = f.listFiles(); - else - return; - } else - files = File.listRoots(); - - if (files != null) { - int size = files.length; - int work = 100 / size; - int workLeft = 100 - (work * size); - for (File file : files) { - if (monitor.isCanceled()) - return; - if (file != null && file.isDirectory()) - searchDir(listener, file, 4, monitor); - monitor.worked(work); - } - monitor.worked(workLeft); - } else - monitor.worked(100); - } - - protected static void searchDir(IRuntimeSearchListener listener, File dir, int depth, IProgressMonitor monitor) { - if ("htdocs".equals(dir.getName())) { - IRuntimeWorkingCopy runtime = getRuntimeFromDir(dir.getParentFile(), monitor); - if (runtime != null) { - listener.runtimeFound(runtime); - return; - } - } - - if (depth == 0) - return; - - File[] files = dir.listFiles(new FileFilter() { - public boolean accept(File file) { - return file.isDirectory(); - } - }); - if (files != null) { - for (File file : files) { - if (monitor.isCanceled()) - return; - searchDir(listener, file, depth - 1, monitor); - } - } - } - - protected static IRuntimeWorkingCopy getRuntimeFromDir(File dir, IProgressMonitor monitor) { - for (String rt : runtimeTypes) { - try { - IRuntimeType runtimeType = ServerCore.findRuntimeType(rt); - String absolutePath = dir.getAbsolutePath(); - String id = absolutePath.replace(File.separatorChar, '_').replace(':', '-'); - IRuntimeWorkingCopy runtime = runtimeType.createRuntime(id, monitor); - runtime.setName(dir.getName()); - runtime.setLocation(new Path(absolutePath).append("htdocs")); - IStatus status = runtime.validate(monitor); - if (status == null || status.getSeverity() != IStatus.ERROR) - return runtime; - - Trace.trace(Trace.FINER, "False runtime found at " + dir.getAbsolutePath() - + ": " + status.getMessage()); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Could not find runtime", e); - } - } - return null; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServer.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServer.java deleted file mode 100644 index 3a51982eb..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServer.java +++ /dev/null @@ -1,272 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2008 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.wst.server.http.core.internal; - -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.Status; -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; -/** - * Generic HTTP server. - */ -public class HttpServer extends ServerDelegate implements IURLProvider { - public static final String PROPERTY_URL_PREFIX = "urlPrefix"; - public static final String PROPERTY_PORT = "port"; - public static final String PROPERTY_IS_PUBLISHING = "isPublishing"; - - public static final String ID = "org.eclipse.wst.server.http.server"; - - /** - * HttpServer. - */ - public HttpServer() { - super(); - } - - protected void initialize() { - // do nothing - } - - /* - * @see RuntimeDelegate#setDefaults(IProgressMonitor) - */ - public void setDefaults(IProgressMonitor monitor) { - setPort(80); - setURLPrefix(""); - setPublishing(true); - } - - public HttpRuntime getHttpRuntime() { - if (getServer().getRuntime() == null) - return null; - - return (HttpRuntime) getServer().getRuntime().loadAdapter(HttpRuntime.class, null); - } - - /*public void importRuntimeConfiguration(IRuntime arg0, IProgressMonitor arg1) throws CoreException { - if (getHttpRuntime() != null) { - if (!getHttpRuntime().publishToDirectory()) { - setAttribute("auto-publish-setting", 1); - } else { - setAttribute("auto-publish-setting", 2); - setAttribute("auto-publish-time", 1); - } - //setPublishDirectory(getHttpRuntime().getPublishLocation()); - } - }*/ - - public boolean dontPublish() { - return getAttribute("auto-publish-setting", "2").equals("1"); - } - - // public void setDocumentRoot(String docRoot) { - // setAttribute(HttpServer.DOCUMENT_ROOT, docRoot); - // } - - // public String getDocumentRoot() { - // return getAttribute(HttpServer.DOCUMENT_ROOT, ""); - // } - - // public boolean canPublish() { - // return getAttribute(HttpServer.PUBLISH, true); - // } - - // public void setPublish(boolean publish) { - // setAttribute(HttpServer.PUBLISH, publish); - // } - - /** - * Processes the host to return IPv6 addresses in square brackets, e.g. - * "[4ffe:ff2f:101:21:230:6eff:fe04:d9fe]". If the host is just a host name - * or IPv4 address, then it is returned as is. - * - * @param host the host, an IP address or host name - */ - protected static String getURLHost(String host) { - // use ":" to determine if this is an IPv6 address - return (host != null && host.indexOf(":") >= 0) ? "[" + host + "]" : host; - } - - /** - * Return the root URL of this module. - * - * @param module a module - * @return the root URL - */ - public URL getModuleRootURL(IModule module) { - try { - String base = "http://" + getURLHost(getServer().getHost()); - - if (base.equals("")) - base = "http://" + getURLHost(getServer().getHost()); - - int port = getPort(); - URL url = null; - if (port == 80) - url = new URL(base + "/"); - else - url = new URL(base + ":" + port + "/"); - - String prefix = getURLPrefix(); - if (prefix != null && prefix.length() > 0) - url = new URL(url, prefix + "/"); - - IStaticWeb staticWeb = (IStaticWeb) module.loadAdapter(IStaticWeb.class, null); - return new URL(url, staticWeb.getContextRoot()); - } 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, HttpCorePlugin.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(HttpServer.PROPERTY_PORT, 80); - } - - public void setPort(int port) { - setAttribute(HttpServer.PROPERTY_PORT, port); - } - - public void setURLPrefix(String prefix) { - setAttribute(HttpServer.PROPERTY_URL_PREFIX, prefix); - } - - public String getURLPrefix() { - return getAttribute(HttpServer.PROPERTY_URL_PREFIX, ""); - } - - public boolean isPublishing() { - return getAttribute(PROPERTY_IS_PUBLISHING, false); - } - - public void setPublishing(boolean shouldPublish) { - setAttribute(PROPERTY_IS_PUBLISHING, shouldPublish); - } - - public static IServer createHttpServer(String host, String serverName, IProgressMonitor monitor) { - try { - IRuntimeType runtimeType = ServerCore.findRuntimeType(HttpRuntime.ID); - IRuntimeWorkingCopy runtimeCopy = runtimeType.createRuntime(HttpRuntime.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(host); - - return workingCopy.save(true, monitor); - } catch (Exception e) { - Trace.trace(Trace.SEVERE, "Error creating server", e); - } - - return null; - } - - public static IServer findHttpServer(String id) { - IServer[] servers = ServerCore.getServers(); - for (IServer server : servers) { - if (server.getId().equals(id)) - return server; - } - return null; - } - - /*public void setPublishDirectory(String pubDir) { - setAttribute(PROPERTY_PUB_DIR, pubDir); - } - - public String getPublishDirectory() { - if (getHttpRuntime() != null) - return getAttribute(PROPERTY_PUB_DIR, getHttpRuntime().getPublishLocation()); - return getAttribute(PROPERTY_PUB_DIR, ""); - }*/ - - /* - * public static void updateBaseURL(String id, String baseURL) { - * updateBaseURL(checkForHttpServer(id), baseURL); } - */ - - /* - * public static void updateBaseURL(IServer server, String baseURL) { if - * (server == null) return; - * - * IServerWorkingCopy workingCopy = server.createWorkingCopy(); - * - * HttpServer as = (HttpServer) workingCopy.getAdapter(HttpServer.class); if - * (as == null) as = (HttpServer) workingCopy.loadAdapter(HttpServer.class, - * null); - * - * String currentURL = as.getBaseURL(); - * - * if (currentURL.equals(baseURL)) return; as.setBaseURL(baseURL); try { - * as.saveConfiguration(null); workingCopy.save(true, null); } catch - * (CoreException e) { e.printStackTrace(); } } - */ - - 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 "HttpServer"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServerBehaviour.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServerBehaviour.java deleted file mode 100644 index 34ac30a9a..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/HttpServerBehaviour.java +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2009 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.wst.server.http.core.internal; - -import java.io.File; - -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.wst.server.core.IModule; -import org.eclipse.wst.server.core.IServer; -import org.eclipse.wst.server.core.model.IModuleResource; -import org.eclipse.wst.server.core.model.ServerBehaviourDelegate; -import org.eclipse.wst.server.core.util.IStaticWeb; -import org.eclipse.wst.server.core.util.PublishHelper; -/** - * Generic HTTP server implementation. - */ -public class HttpServerBehaviour extends ServerBehaviourDelegate { - // the thread used to ping the server to check for startup - protected transient PingThread ping = null; - - /** - * HttpServer. - */ - public HttpServerBehaviour() { - super(); - } - - public void initialize(IProgressMonitor monitor) { - // do nothing - } - - public HttpRuntime getHttpRuntime() { - if (getServer().getRuntime() == null) - return null; - - return (HttpRuntime) getServer().getRuntime().loadAdapter(HttpRuntime.class, null); - } - - public HttpServer getHttpServer() { - return (HttpServer) getServer().getAdapter(HttpServer.class); - } - - 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 { - if (!getHttpServer().isPublishing()) - return; - - String contextRoot = null; - IModule module = moduleTree[moduleTree.length - 1]; - IStaticWeb sw = (IStaticWeb) module.loadAdapter(IStaticWeb.class, monitor); - if (sw != null) - contextRoot = sw.getContextRoot(); - else - contextRoot = module.getName(); - - IPath to = getServer().getRuntime().getLocation(); - File temp = null; - try { - if (to.removeLastSegments(1).toFile().exists()) - temp = to.removeLastSegments(1).append("temp").toFile(); - } catch (Exception e) { - // ignore - use null temp folder - } - if (contextRoot != null && !contextRoot.equals("")) - to = to.append(contextRoot); - - IModuleResource[] res = getResources(moduleTree); - PublishHelper pubHelper = new PublishHelper(temp); - IStatus[] status = pubHelper.publishSmart(res, to, monitor); - if (temp.exists()) - temp.delete(); - 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(HttpCorePlugin.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) { - setServerState(IServer.STATE_STOPPED); - } - - /** - * Return a string representation of this object. - * - * @return java.lang.String - */ - public String toString() { - return "HttpServer"; - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.java deleted file mode 100644 index 8dae1deb6..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.java +++ /dev/null @@ -1,30 +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.wst.server.http.core.internal; - -import org.eclipse.osgi.util.NLS; -/** - * Translated messages. - */ -public class Messages extends NLS { - public static String errorPublish; - public static String canModifyModules; - public static String httpPort; - public static String actionModifyPort; - public static String actionModifyPrefixURL; - public static String actionModifyPublishing; - - public static String errorPortInUse; - - static { - NLS.initializeMessages(HttpCorePlugin.PLUGIN_ID + ".internal.Messages", Messages.class); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.properties b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.properties deleted file mode 100644 index 520bbe8eb..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Messages.properties +++ /dev/null @@ -1,21 +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 -############################################################################### - -actionModifyPort=set port number -actionModifyPrefixURL=set URL prefix -actionModifyPublishing=set publishing enablement -errorPublish=Error during publish - -httpPort=HTTP Port -canModifyModules=Web modules can be modified. - -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.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/PingThread.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/PingThread.java deleted file mode 100644 index 39360c372..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/PingThread.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.wst.server.http.core.internal; - -import java.io.FileNotFoundException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; - -import org.eclipse.wst.server.core.IServer; - -/** - * 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 = 56; // total: 16 seconds + connection time - - private boolean stop = false; - - private String url; - - private IServer server; - - private HttpServerBehaviour behaviour; - - /** - * Create a new PingThread. - * - * @param server - * @param url - * @param maxPings - * @param behaviour - */ - public PingThread(IServer server, String url, int maxPings, - HttpServerBehaviour behaviour) { - super(); - this.server = server; - this.url = url; - this.maxPings = maxPings; - this.behaviour = behaviour; - Thread t = new Thread() { - public void run() { - ping(); - } - }; - t.setDaemon(true); - t.start(); - } - - /** - * 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"); - 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.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/ProgressUtil.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/ProgressUtil.java deleted file mode 100644 index 788a6567d..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/ProgressUtil.java +++ /dev/null @@ -1,72 +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.wst.server.http.core.internal; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -/** - * 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.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Trace.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Trace.java deleted file mode 100644 index 5977cd0bd..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/Trace.java +++ /dev/null @@ -1,81 +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.wst.server.http.core.internal; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -/** - * Helper class to route trace output. - */ -public class Trace { - public static byte CONFIG = 0; - public static byte WARNING = 1; - public static byte SEVERE = 2; - public static byte FINEST = 3; - public static byte FINER = 4; - - private static final String[] levelNames = new String[] { "CONFIG ", "WARNING ", - "SEVERE ", "FINER ", "FINEST " }; - - private static final SimpleDateFormat sdf = new SimpleDateFormat( - "dd/MM/yy HH:mm.ss.SSS"); - - /** - * Trace constructor comment. - */ - private Trace() { - super(); - } - - /** - * Trace the given text. - * - * @param level the trace level - * @param s a message - */ - public static void trace(byte level, String s) { - Trace.trace(level, s, null); - } - - /** - * Trace the given message and exception. - * - * @param level the trace level - * @param s a message - * @param t a throwable - */ - public static void trace(byte level, String s, Throwable t) { - if (s == null) - return; - - if (level == SEVERE) - HttpCorePlugin.getInstance().getLog().log(new Status(IStatus.ERROR, HttpCorePlugin.PLUGIN_ID, s, t)); - - if (!HttpCorePlugin.getInstance().isDebugging()) - return; - - StringBuffer sb = new StringBuffer(HttpCorePlugin.PLUGIN_ID); - sb.append(" "); - sb.append(levelNames[level]); - sb.append(" "); - sb.append(sdf.format(new Date())); - sb.append(" "); - sb.append(s); - // Platform.getDebugOption(ServerCore.PLUGIN_ID + "/" + "resources"); - - System.out.println(sb.toString()); - if (t != null) - t.printStackTrace(); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPortCommand.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPortCommand.java deleted file mode 100644 index 396021f2c..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPortCommand.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.wst.server.http.core.internal.command; - -import org.eclipse.wst.server.core.ServerPort; -import org.eclipse.wst.server.http.core.internal.HttpServer; -import org.eclipse.wst.server.http.core.internal.Messages; -/** - * Command to change the port. - */ -public class ModifyPortCommand extends ServerCommand { - protected int port; - protected int oldPort; - - /** - * ModifyPortCommand constructor. - * - * @param server a server - * @param port new port number - */ - public ModifyPortCommand(HttpServer server, int port) { - super(server, Messages.actionModifyPort); - this.port = port; - } - - /** - * Execute the command. - */ - public void execute() { - // find old port number - ServerPort temp = server.getServerPorts()[0]; - oldPort = temp.getPort(); - - // make the change - server.setPort(port); - } - - /** - * Undo the command. - */ - public void undo() { - server.setPort(oldPort); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPublishingCommand.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPublishingCommand.java deleted file mode 100644 index adb278f9e..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyPublishingCommand.java +++ /dev/null @@ -1,49 +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.wst.server.http.core.internal.command; - -import org.eclipse.wst.server.http.core.internal.HttpServer; -import org.eclipse.wst.server.http.core.internal.Messages; -/** - * Command to change the publishing state. - */ -public class ModifyPublishingCommand extends ServerCommand { - protected boolean shouldPublish; - protected boolean oldShouldPublish; - - /** - * ModifyPublishingCommand constructor. - * - * @param server a server - * @param shouldPublish - */ - public ModifyPublishingCommand(HttpServer server, boolean shouldPublish) { - super(server, Messages.actionModifyPublishing); - this.shouldPublish = shouldPublish; - } - - /** - * Execute the command. - */ - public void execute() { - oldShouldPublish = server.isPublishing(); - - // make the change - server.setPublishing(shouldPublish); - } - - /** - * Undo the command. - */ - public void undo() { - server.setPublishing(oldShouldPublish); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyURLPrefixCommand.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyURLPrefixCommand.java deleted file mode 100644 index e30759f42..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ModifyURLPrefixCommand.java +++ /dev/null @@ -1,48 +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.wst.server.http.core.internal.command; - -import org.eclipse.wst.server.http.core.internal.HttpServer; -import org.eclipse.wst.server.http.core.internal.Messages; - -public class ModifyURLPrefixCommand extends ServerCommand { - protected String prefix; - protected String oldPrefix; - - /** - * ModifyURLPrefixCommand constructor. - * - * @param server a HTTP configuration - * @param prefix a new prefix - */ - public ModifyURLPrefixCommand(HttpServer server, String prefix) { - super(server, Messages.actionModifyPrefixURL); - this.prefix = prefix; - } - - /** - * Execute the command. - */ - public void execute() { - // find old prefix - oldPrefix = server.getURLPrefix(); - - // make the change - server.setURLPrefix(prefix); - } - - /** - * Undo the command. - */ - public void undo() { - server.setURLPrefix(oldPrefix); - } -}
\ No newline at end of file diff --git a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ServerCommand.java b/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ServerCommand.java deleted file mode 100644 index 0ad3f60a3..000000000 --- a/plugins/org.eclipse.wst.server.http.core/src/org/eclipse/wst/server/http/core/internal/command/ServerCommand.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.wst.server.http.core.internal.command; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.operations.AbstractOperation; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.wst.server.http.core.internal.HttpServer; -/** - * Server command. - */ -public abstract class ServerCommand extends AbstractOperation { - protected HttpServer server; - - /** - * ServerCommand constructor comment. - * - * @param server a server - * @param label a label - */ - public ServerCommand(HttpServer server, String label) { - super(label); - this.server = server; - } - - public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - return execute(monitor, info); - } - - public abstract void execute(); - - public IStatus execute(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - execute(); - return null; - } - - public abstract void undo(); - - public IStatus undo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - undo(); - return null; - } -}
\ No newline at end of file |