From: Chris Koeritz Date: Sat, 8 Sep 2012 20:02:23 +0000 (-0400) Subject: yeehah, got kona compiling again. didn't even know it was having issues. X-Git-Tag: 2.140.90~1253 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=21f089c2c404a27bed5bdaf88a80214cf63f6ee4;p=feisty_meow.git yeehah, got kona compiling again. didn't even know it was having issues. --- diff --git a/kona/src/org/feistymeow/dragdrop/dragdrop_list_test.java b/kona/src/org/feistymeow/dragdrop/dragdrop_list_test.java index afe63029..2775560e 100644 --- a/kona/src/org/feistymeow/dragdrop/dragdrop_list_test.java +++ b/kona/src/org/feistymeow/dragdrop/dragdrop_list_test.java @@ -21,14 +21,15 @@ import org.apache.log4j.PropertyConfigurator; * @license This file is free software; you can modify and redistribute it under the terms of the * Apache License v2.0: http://www.apache.org/licenses/LICENSE-2.0 */ -@SuppressWarnings("serial") +@SuppressWarnings({"serial", "rawtypes"}) public class dragdrop_list_test extends JFrame implements ListSelectionListener { private DraggableDroppableList list; private JTextField fileName; static private Log logger = LogFactory.getLog(dragdrop_list_test.DraggableDroppableList.class); - public dragdrop_list_test(String startPath) + @SuppressWarnings("unchecked") + public dragdrop_list_test(String startPath) { super("dragdrop_test"); @@ -97,7 +98,8 @@ public class dragdrop_list_test extends JFrame implements ListSelectionListener public class DraggableDroppableList extends JList implements IDragonDropDataProvider { - public DraggableDroppableList() + @SuppressWarnings("unchecked") + public DraggableDroppableList() { setModel(new DefaultListModel()); setTransferHandler(new DragonTransferHandler(this)); diff --git a/kona/src/org/feistymeow/networking/BasicWebServer.java b/kona/src/org/feistymeow/networking/BasicWebServer.java index 7e374298..8e6685a9 100644 --- a/kona/src/org/feistymeow/networking/BasicWebServer.java +++ b/kona/src/org/feistymeow/networking/BasicWebServer.java @@ -7,8 +7,6 @@ import java.net.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.feistymeow.dragdrop.ListTransferable; - /** * Provides a lightweight way for RNS structures to be accessible over http. * @@ -20,7 +18,8 @@ import org.feistymeow.dragdrop.ListTransferable; * http://cs.fit.edu/~mmahoney/cse3103/java/Webserver.java */ -public class BasicWebServer { +public class BasicWebServer +{ static private Log logger = LogFactory.getLog(BasicWebServer.class); private int port; @@ -28,11 +27,13 @@ public class BasicWebServer { servingThread socketThread; private ServerSocket realSocket; - BasicWebServer(int portIn) { + BasicWebServer(int portIn) + { port = portIn; } - public void shutDown() { + public void shutDown() + { leaving = true; if (realSocket != null) { try { @@ -45,18 +46,21 @@ public class BasicWebServer { } } - public class servingThread implements Runnable { + public class servingThread implements Runnable + { private Thread thread; private ServerSocket serverSocket; - servingThread(ServerSocket socket) { + servingThread(ServerSocket socket) + { serverSocket = socket; thread = new Thread(this); thread.start(); } @Override - public void run() { + public void run() + { while (!leaving) { try { logger.debug("about to accept on server socket."); @@ -66,16 +70,15 @@ public class BasicWebServer { new ClientHandler(s); // Handle the client in a separate // thread } catch (Throwable cause) { - logger.error( - "exception raised while handling accepted socket", - cause); + logger.error("exception raised while handling accepted socket", cause); } } } } // enums for outcomes? really need better reporting. - public int startServing() { + public int startServing() + { if (socketThread != null) return 1; // already running outcome. try { @@ -89,42 +92,42 @@ public class BasicWebServer { return 0; } - public String predictMimeType(String filename) { + public String predictMimeType(String filename) + { // kludge to try one type: return "text/plain;charset=utf-8"; /* * - * if (filename.endsWith(".html") || filename.endsWith(".htm")) return - * "text/html"; if (filename.endsWith(".jpg") || - * filename.endsWith(".jpeg")) return "image/jpeg"; if - * (filename.endsWith(".gif")) return "image/gif"; if - * (filename.endsWith(".class")) return "application/octet-stream"; - * return "text/plain"; + * if (filename.endsWith(".html") || filename.endsWith(".htm")) return "text/html"; if + * (filename.endsWith(".jpg") || filename.endsWith(".jpeg")) return "image/jpeg"; if + * (filename.endsWith(".gif")) return "image/gif"; if (filename.endsWith(".class")) return + * "application/octet-stream"; return "text/plain"; */ } // A ClientHandler reads an HTTP request and responds - class ClientHandler extends Thread { + class ClientHandler extends Thread + { private Socket socket; // The accepted socket from the Webserver // Start the thread in the constructor - public ClientHandler(Socket s) { + public ClientHandler(Socket s) + { socket = s; start(); } // Read the HTTP request, respond, and close the connection - public void run() { + public void run() + { try { logger.debug("into client run(): listening for gets."); // Open connections to the socket - BufferedReader in = new BufferedReader(new InputStreamReader( - socket.getInputStream())); - PrintStream out = new PrintStream(new BufferedOutputStream( - socket.getOutputStream())); + BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); + PrintStream out = new PrintStream(new BufferedOutputStream(socket.getOutputStream())); // Read filename from first input line "GET /filename.html ..." // or if not in this format, treat as a file not found. @@ -142,12 +145,9 @@ public class BasicWebServer { // get the command first. String command = st.nextToken(); // Parse the filename from the command. - if (st.hasMoreElements() && command.equalsIgnoreCase("GET") - && st.hasMoreElements()) { + if (st.hasMoreElements() && command.equalsIgnoreCase("GET") && st.hasMoreElements()) { filename = st.nextToken(); - } else if (st.hasMoreElements() - && command.equalsIgnoreCase("HEAD") - && st.hasMoreElements()) { + } else if (st.hasMoreElements() && command.equalsIgnoreCase("HEAD") && st.hasMoreElements()) { filename = st.nextToken(); transferFile = false; // don't need to do that, just the // header. @@ -175,23 +175,18 @@ public class BasicWebServer { // Check for illegal characters to prevent access to // superdirectories - if (filename.indexOf("..") >= 0 - || filename.indexOf(':') >= 0 - || filename.indexOf('|') >= 0) + if (filename.indexOf("..") >= 0 || filename.indexOf(':') >= 0 || filename.indexOf('|') >= 0) throw new FileNotFoundException(); logger.info("got past filename checks for: " + filename); /* - * this doesn't actually check that trailing slash is - * missing! // If a directory is requested and the trailing - * / is missing, // send the client an HTTP request to - * append it. (This is // necessary for relative links to - * work correctly in the client). if ((new - * GeniiPath(filename)).isDirectory()) { - * out.print("HTTP/1.0 301 Moved Permanently\r\n" + - * "Location: /" + filename + "/\r\n\r\n"); out.close(); - * return; } + * this doesn't actually check that trailing slash is missing! // If a directory + * is requested and the trailing / is missing, // send the client an HTTP + * request to append it. (This is // necessary for relative links to work + * correctly in the client). if ((new GeniiPath(filename)).isDirectory()) { + * out.print("HTTP/1.0 301 Moved Permanently\r\n" + "Location: /" + filename + + * "/\r\n\r\n"); out.close(); return; } */ // trying to get around worrying about mime types by saying @@ -201,30 +196,26 @@ public class BasicWebServer { File source = new File(filename); if (!source.exists()) { - logger.error("source does not exist for serving: " - + filename); + logger.error("source does not exist for serving: " + filename); // do something! // hmmm: below could be abstracted to more general // denial method. - out.println("HTTP/1.1 404 Not Found\r\n" - + "Content-type: text/html\r\n\r\n" - + "" + filename - + " not found\n"); + out.println("HTTP/1.1 404 Not Found\r\n" + "Content-type: text/html\r\n\r\n" + + "" + filename + " not found\n"); out.close(); } - out.print("HTTP/1.1 200 OK\r\n" + "Content-type: " - + mimeType + "\r\n" + "Connection: close" + "\r\n" - // // + "\r\nContent-Length: " + source.size? + - // "\r\n" - + "\r\n"); + out.print("HTTP/1.1 200 OK\r\n" + "Content-type: " + mimeType + "\r\n" + "Connection: close" + "\r\n" + // // + "\r\nContent-Length: " + source.size? + + // "\r\n" + + "\r\n"); if (!transferFile) { logger.debug("closing stream for finished HEAD request."); out.close(); return; } logger.debug("moving to handle GET request."); - InputStream f = source.openInputStream(); + FileInputStream f = new FileInputStream(filename); logger.debug("opened stream on source"); // Send file contents to client, then close the connection. byte[] a = new byte[4096]; @@ -235,15 +226,12 @@ public class BasicWebServer { out.close(); } catch (FileNotFoundException x) { logger.error("failed to find requested file: " + filename); - out.println("HTTP/1.1 404 Not Found\r\n" - + "Content-type: text/html\r\n\r\n" - + "" + filename - + " not found\n"); + out.println("HTTP/1.1 404 Not Found\r\n" + "Content-type: text/html\r\n\r\n" + "" + + filename + " not found\n"); out.close(); } } catch (IOException x) { - logger.error("exception blew out in outer area of web server", - x); + logger.error("exception blew out in outer area of web server", x); // / System.out.println(x); } } diff --git a/kona/src/org/feistymeow/process/ethread.java b/kona/src/org/feistymeow/process/ethread.java index 0f2e860f..280a0830 100644 --- a/kona/src/org/feistymeow/process/ethread.java +++ b/kona/src/org/feistymeow/process/ethread.java @@ -5,15 +5,6 @@ package org.feistymeow.process; // not compilable yet probably, // plus missing the timed features of ethread. - -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,6 +23,7 @@ class ethread implements Runnable // the only variable on which both synchronize is the "thread finished" variable. public ethread() { + c_logger.warn("this class needs to be implemented and used in an example."); } /** diff --git a/kona/src/org/feistymeow/windowing/ExitListener.java b/kona/src/org/feistymeow/windowing/ExitListener.java index f53b0e29..2dd19f39 100644 --- a/kona/src/org/feistymeow/windowing/ExitListener.java +++ b/kona/src/org/feistymeow/windowing/ExitListener.java @@ -1,6 +1,5 @@ package org.feistymeow.windowing; -import java.awt.*; import java.awt.event.*; /** A listener that you attach to the top-level Frame or JFrame of