Repository: tika Updated Branches: refs/heads/2.x 6ea9df810 -> 7a574bbd4
TIKA-1983: remove tika-app's legacy server for 2.0 Project: http://git-wip-us.apache.org/repos/asf/tika/repo Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/7a574bbd Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/7a574bbd Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/7a574bbd Branch: refs/heads/2.x Commit: 7a574bbd43bffec81644e99da2dd856c33387dfa Parents: 6ea9df8 Author: tballison <[email protected]> Authored: Mon May 23 08:57:21 2016 -0400 Committer: tballison <[email protected]> Committed: Mon May 23 08:57:21 2016 -0400 ---------------------------------------------------------------------- .../main/java/org/apache/tika/cli/TikaCLI.java | 71 +------------------- 1 file changed, 2 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tika/blob/7a574bbd/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java ---------------------------------------------------------------------- diff --git a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java index a2b91c9..8f2d6d6 100644 --- a/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java +++ b/tika-app/src/main/java/org/apache/tika/cli/TikaCLI.java @@ -37,8 +37,6 @@ import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; import java.lang.reflect.Field; -import java.net.ServerSocket; -import java.net.Socket; import java.net.URI; import java.net.URL; import java.nio.charset.Charset; @@ -331,8 +329,6 @@ public class TikaCLI { private boolean pipeMode = true; - private boolean serverMode = false; - private boolean fork = false; private boolean prettyPrint; @@ -444,8 +440,7 @@ public class TikaCLI { prettyPrint = true; } else if (arg.equals("-p") || arg.equals("--port") || arg.equals("-s") || arg.equals("--server")) { - serverMode = true; - pipeMode = false; + throw new IllegalArgumentException("Tika-app's server no longer supported in 2.x. Please migrate to tika-server (https://wiki.apache.org/tika/TikaJAXRS)."); } else if (arg.startsWith("-c")) { URI uri = new URI(arg.substring("-c".length())); parser = new NetworkParser(uri); @@ -454,9 +449,7 @@ public class TikaCLI { parser = new NetworkParser(uri); } else { pipeMode = false; - if (serverMode) { - new TikaServer(Integer.parseInt(arg)).start(); - } else if (arg.equals("-")) { + if (arg.equals("-")) { try (InputStream stream = TikaInputStream.get( new CloseShieldInputStream(System.in))) { type.process(stream, System.out, new Metadata()); @@ -524,7 +517,6 @@ public class TikaCLI { out.println(" -V or --version Print the Apache Tika version number"); out.println(); out.println(" -g or --gui Start the Apache Tika GUI"); - out.println(" -s or --server Start the Apache Tika server"); out.println(" -f or --fork Use Fork Mode for out-of-process extraction"); out.println(); out.println(" --config=<tika-config.xml>"); @@ -590,12 +582,6 @@ public class TikaCLI { out.println(" a normal file explorer to the GUI window to extract"); out.println(" text content and metadata from the files."); out.println(); - out.println("- Server mode"); - out.println(); - out.println(" Use the \"--server\" (or \"-s\") option to start the"); - out.println(" Apache Tika server. The server will listen to the"); - out.println(" ports you specify as one or more arguments."); - out.println(); out.println("- Batch mode"); out.println(); out.println(" Simplest method."); @@ -1087,59 +1073,6 @@ public class TikaCLI { } } - private class TikaServer extends Thread { - - private final ServerSocket server; - - public TikaServer(int port) throws IOException { - super("Tika server at port " + port); - server = new ServerSocket(port); - } - - @Override - public void run() { - try { - try { - while (true) { - processSocketInBackground(server.accept()); - } - } finally { - server.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void processSocketInBackground(final Socket socket) { - Thread thread = new Thread() { - @Override - public void run() { - try { - InputStream input = null; - try { - InputStream rawInput = socket.getInputStream(); - OutputStream output = socket.getOutputStream(); - input = TikaInputStream.get(rawInput); - type.process(input, output, new Metadata()); - output.flush(); - } finally { - if (input != null) { - input.close(); - } - socket.close(); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - }; - thread.setDaemon(true); - thread.start(); - } - - } - private class NoDocumentMetHandler extends DefaultHandler { protected final Metadata metadata;
