From 485a521c4c9e88be41cfbc45df86550ea0b3fb9f Mon Sep 17 00:00:00 2001 From: Luca Piccarreta Date: Sun, 21 Jul 2024 15:48:27 +0200 Subject: [PATCH] Removed obsolete jetty code --- .../META-INF/MANIFEST.MF | 1 - .../eclipse/platform/jetty/IJettyServer.java | 28 --- .../gdt/eclipse/platform/jetty/JSON.java | 26 --- .../platform/jetty/JettyEclipseLogger.java | 165 ------------------ .../eclipse/platform/jetty/JettyServer.java | 94 ---------- 5 files changed, 314 deletions(-) delete mode 100644 plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/IJettyServer.java delete mode 100644 plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JSON.java delete mode 100644 plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyEclipseLogger.java delete mode 100644 plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyServer.java diff --git a/plugins/com.gwtplugins.gdt.eclipse.platform/META-INF/MANIFEST.MF b/plugins/com.gwtplugins.gdt.eclipse.platform/META-INF/MANIFEST.MF index 9d75723b..41fc37b7 100644 --- a/plugins/com.gwtplugins.gdt.eclipse.platform/META-INF/MANIFEST.MF +++ b/plugins/com.gwtplugins.gdt.eclipse.platform/META-INF/MANIFEST.MF @@ -12,7 +12,6 @@ Export-Package: com.google.gdt.eclipse.platform.debug.ui, com.google.gdt.eclipse.platform.jdt.formatter, com.google.gdt.eclipse.platform.jdt.model, com.google.gdt.eclipse.platform.jdt.text.correction.proposals, - com.google.gdt.eclipse.platform.jetty, com.google.gdt.eclipse.platform.launch, com.google.gdt.eclipse.platform.shared.ui, com.google.gdt.eclipse.platform.ui, diff --git a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/IJettyServer.java b/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/IJettyServer.java deleted file mode 100644 index 4666e5d6..00000000 --- a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/IJettyServer.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright 2012 Google Inc. All Rights Reserved. - * - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *******************************************************************************/ -package com.google.gdt.eclipse.platform.jetty; - -import javax.servlet.Servlet; - -/** - * A wrapper around the Jetty server built into Eclipse. - */ -public interface IJettyServer { - void addServlet(String path, Servlet servlet); - - int getPort(); - - void setPort(int port); -} diff --git a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JSON.java b/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JSON.java deleted file mode 100644 index b8cfa1e2..00000000 --- a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JSON.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * Copyright 2012 Google Inc. All Rights Reserved. - * - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *******************************************************************************/ -package com.google.gdt.eclipse.platform.jetty; - -import java.util.Map; - -/** - * Delegate to the real JSON implementation. - */ -public class JSON { - public static String toString(Map map) { - return org.mortbay.util.ajax.JSON.toString(map); - } -} diff --git a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyEclipseLogger.java b/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyEclipseLogger.java deleted file mode 100644 index 4c3b6eea..00000000 --- a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyEclipseLogger.java +++ /dev/null @@ -1,165 +0,0 @@ -/******************************************************************************* - * Copyright 2012 Google Inc. All Rights Reserved. - * - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *******************************************************************************/ -package com.google.gdt.eclipse.platform.jetty; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.jetty.util.log.Logger; - -/** - * This class routes the logging output from Jetty to the Eclipse log. - */ -public class JettyEclipseLogger implements Logger { - - private static ILog platformLog; - - private static final String LOGGER_NAME = "org.eclipse.jetty"; - - private static final String PLUGIN_ID = "com.gwtplugins.gdt.eclipse.platform.shared"; - - static { - platformLog = Platform.getLog(Platform.getBundle(PLUGIN_ID)); - } - - private boolean debug; - - private boolean info; - - public JettyEclipseLogger() { - debug = info = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/jetty/debug")); - - if (debug) { - info = true; - } else { - info = "true".equalsIgnoreCase(Platform.getDebugOption(PLUGIN_ID + "/jetty/info")); - } - } - - private String format(String msg, Object... args) { - msg = String.valueOf(msg); // Avoids NPE - String braces = "{}"; - StringBuilder builder = new StringBuilder(); - int start = 0; - for (Object arg : args) { - int bracesIndex = msg.indexOf(braces, start); - if (bracesIndex < 0) { - builder.append(msg.substring(start)); - builder.append(" "); - builder.append(arg); - start = msg.length(); - } else { - builder.append(msg.substring(start, bracesIndex)); - builder.append(String.valueOf(arg)); - start = bracesIndex + braces.length(); - } - } - builder.append(msg.substring(start)); - return builder.toString(); - } - - @Override - public Logger getLogger(String name) { - return this; - } - - @Override - public String getName() { - return LOGGER_NAME; - } - - @Override - public void ignore(Throwable ignored) {} - - @Override - public void info(String msg, Object... args) { - if (info) { - log(IStatus.INFO, format(msg, args), null); - } - } - - @Override - public void info(String msg, Throwable thrown) { - log(IStatus.WARNING, msg, thrown); - } - - @Override - public void info(Throwable thrown) { - info("", thrown); - } - - @Override - public boolean isDebugEnabled() { - return debug; - } - - private void log(int severity, String message, Throwable exception) { - IStatus status = new Status(severity, PLUGIN_ID, "org.mortbay.jetty: " + message, exception); - - platformLog.log(status); - } - - @Override - public void setDebugEnabled(boolean enabled) { - debug = enabled; - } - - @Override - public void warn(String msg, Object... args) { - log(IStatus.WARNING, format(msg, args), null); - } - - @Override - public void warn(String msg, Throwable th) { - log(IStatus.WARNING, msg, th); - } - - @Override - public void warn(Throwable thrown) { - warn("", thrown); - } - - - // TODO api change don't override - // @Override - public void debug(String msg, Object... args) { - if (debug) { - log(IStatus.OK, format(msg, args), null); - } - } - - // TODO api change don't override - // @Override - public void debug(String msg, Throwable th) { - if (debug) { - log(IStatus.OK, msg, th); - } - } - - // TODO api change don't override - // @Override - public void debug(Throwable thrown) { - debug("", thrown); - } - - - // TODO api change don't override - // @Override - public void debug(String msg, long value) { - log(IStatus.INFO, format(msg, value), null); - } - -} diff --git a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyServer.java b/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyServer.java deleted file mode 100644 index 56874015..00000000 --- a/plugins/com.gwtplugins.gdt.eclipse.platform/src/com/google/gdt/eclipse/platform/jetty/JettyServer.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright 2012 Google Inc. All Rights Reserved. - * - * 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 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - *******************************************************************************/ -package com.google.gdt.eclipse.platform.jetty; - -import org.eclipse.jetty.server.Server; -import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.servlet.ServletHandler; -import org.eclipse.jetty.servlet.ServletHolder; - -import javax.servlet.Servlet; - -/** - * Helper to set up the server which listens for viewSource HTTP requests. - */ -public class JettyServer implements IJettyServer { - - static { - initLogging(); - } - - private static void initLogging() { - // This plugin is not in the classpath of the plugins that use Jetty, so - // Jetty will not be able to use a Class.forName() to find our Eclipse - // logger. - // System.setProperty("org.mortbay.log.class", - // JettyEclipseLogger.class.getName()); - - org.eclipse.jetty.util.log.Log.setLog(new JettyEclipseLogger()); - } - - private int port; - - private Server server; - - private final ServletHandler servletHandler = new ServletHandler(); - - /** - * Creates a JettyServer instance. - * - * @param classLoader unused - */ - public JettyServer(ClassLoader classLoader) { - // This implementation does not require the class loader - } - - @Override - public void addServlet(String path, Servlet servlet) { - servletHandler.addServletWithMapping(new ServletHolder(servlet), path); - } - - @Override - public int getPort() { - return port; - } - - @Override - public void setPort(int port) { - this.port = port; - } - - public void start() throws Exception { - - if (server != null) { - return; - } - - server = new Server(port); - ServletContextHandler root = new ServletContextHandler(server, "/"); - root.setServletHandler(servletHandler); - server.start(); - } - - public void stop() throws Exception { - if (server == null) { - return; - } - - server.stop(); - server = null; - } - -}