290 likes | 521 Views
Morph. Abstracting the Underlying Multiple Operating System Architecture for Comprehensive Command Line Graphical Interface. Objectives. Bridge the gap for new users Create a more user friendly environment with the Command Line feel Dynamic program that fits the user’s needs. Design.
E N D
Morph Abstracting the Underlying Multiple Operating System Architecture for Comprehensive Command Line Graphical Interface
Objectives • Bridge the gap for new users • Create a more user friendly environment with the Command Line feel • Dynamic program that fits the user’s needs
Data Storage • Data about functions are stored in an XML file. • Additional functions can be added as they are needed. • Follows a standard format so Linux & Windows commands can easily be swapped and the same parser can be used. • XML allows for commands to easily be added and removed (not hardcoded).
Data Storage This is what our XML syntax is: <category name="Terminal Management"> <command name="man"> <phrase>view help pages</phrase> <summary>This command is used to view help pages for...</summary> <commonparameters>Common parameters for this command include... </commonparameters> <synopsis>man [-acdfFhkKtwW] [--path] [-m system] [-p string]...</synopsis> <description>man formats and displays the on-line manual pages. If...</description> <parameters> <parameter name="-C config_file">Specify the configuration file ...</parameter> <parameter name="-M path">Specify the list of directories to...</parameter> </parameters> <examples> <example name="man ls">displays the manpage for the ls command</example> <example name="man -f ping">displays very short description of what...</example> </examples> </command> </category name>
Parser • The parser is the part of the project that takes the data from the XML and makes it available to the calling class. • It is agnostic to whether the XML is for Linux or Windows. It simply takes the file as a parameter and parses it. • It provides the parsed data as a series of get() methods. There are no set() methods.
Parser • The parser generates a DOM (Document-Object Model) tree from the XML document. • This tree is then parsed and the data from the tree is placed into a hash-table • The hash-table structure allows very quick O(1) access time for the data. • All the work is done on instantiation.
Testing • Testing was crucial to make sure that everything worked. • Several interacting parts • Run with or without SSH • Run on Linux/Windows/Mac • Proper Dropdowns • Help text • Parser • XML Files
Research and Operating System Principles Process Builder • allows for execution of system processes • similar to concepts of Process Creation in Chapter 3 of our textbook • ProcessBuilder.start() fork • ProcessBuilder.waitFor() join
Research and Operating System Principles Threads • used to isolate the execution of the thread so the main GUI remained responsive (avoids complexity of thread synchronization) • two ways to implement threads in Java • implement the Runnable interface • extend the Thread class
Research and Operating System Principles Threads • override run() method with code wanted to be run separately as a thread • start a thread by simply calling the Thread.start() method.
Networking Class • Sends commands directly to a server bypassing third party programs such as Putty or Chameleon • Application receives output sent from server and displays it in the command prompt window.
Networking Class • Modification of the open source terminal emulator JCTerm by Jcraft. • Licensed under GNU LGPL License (allows use of library in proprietary programs, either open or closed source) • JC Term is in turn based on the JSch SSH client, also by Jcraft • Licensed under BSD License (same restrictions as LGPL, BSD code used in Mac OS X)
Networking Class • Features of JCTerm • Local/Remote Port Forwarding • SFTP Support • SSH2 Protocol Support • Pack Compression Support • Anti-Aliasing (set to disabled for Morph)
Interfacing with Command Line • If not using the networking class, the command is executed using on the user’s local operating system using the ProcessBuilder class. • Since different tasks are independent and isolated processes, an additional command will be needed to get the current working directory. • Works on any operating systems, but the syntax is obviously different
Interfacing with Command Line • Windows • Commands must be preceded by “cmd /c” • This especially calls the Windows command interpreter with the /c switch indicating to execute the command and then exit • Example: “cmd /c dir” command to list contents of current directory • To get current directory, append command with “ & cd” (ex: “cmd /c cd .. & cd”)
Interfacing with Command Line • Linux • Commands must be preceded by “/bin/bash -c” • This especially passes the Linux command to the bash shell which then executes the command • Example: “/bin/bash -c ls” command to list contents of current directory • To get current directory, append command with “;pwd” (ex: “/bin/bash cd ..;pwd”)
Commands Linux Windows • clear • cp • ls • mv • mkdir • rm • ps • top • kill • cd • Compilation commands (javac, g++, gcc) • Execute commands (java, gdb, a.out) • man • grep • locate • lpr • exit • ping • ifconfig • vi • cls • copy • xcopy • dir • move • mkdir • rmdir • del • tasklist • taskkill • cd • javac • java • help • find • findstr • print • exit • ping • ipconfig • rename
References • Alexander, A. (2010, February 4). Java exec - execute system processes with Java ProcessBuilder and Process (part 2). devdaily. Retrieved December 2, 2010, from http://www.devdaily.com/java/java-exec-processbuilder-process-2 • Class ProcessBuilder. (2010).Java API. Retrieved December 2, 2010, from http://download.oracle.com/javase/1.5.0/docs/api/java/lang/ProcessBuilder.html • Class System. (2010). Java API. Retrieved December 2, 2010, from http://download.oracle.com/javase/1.4.2/docs/api/java/lang/System.html • Display ToolTip in JComboBox. (n.d.). Happy Codings - Java Programming. Retrieved December 2, 2010, from http://www.java.happycodings.com/Java_Swing/code17.html • Drake, Donald. G. (1996, April 1). Introduction to Java threads.JavaWorld. Retrieved December 3, 2010, from http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html • Freitag, P. (2005, September 27). Parsing, Modifying, and outputting XML Documents with Java. Retrieved December 2, 2010, from http://www.petefreitag.com/
References • From Runtime.exec() to ProcessBuilder. (2008). Java Tips. Retrieved December 2, 2010, from http://www.java-tips.org/java-se-tips/java.util/from-runtime.exec-to-processbuilder.html • How to read XML file in Java. (n.d.). Java Tips - Home. Retrieved December 2, 2010, from http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html • Img source: http://www3.ntu.edu.sg/home/ehchua/programming/java/J6d_xml.html • JCTerm - SSH2 Terminal Emulator in Pure Java. (2010). JCraft. Retrieved December 2, 2010, from http://www.jcraft.com/jcterm/ • Jericho HTML Parser. (n.d.).Jericho HTML Parser. Retrieved December 2, 2010, from http://jericho.htmlparser.net/docs/index.html • JSch - Java Secure Channel. (n.d.). JCraft. Retrieved December 2, 2010, from http://www.jcraft.com/jsch/ • Tutorial: XML generation with Java. (2002, July 5).JavaZOOM. Retrieved December 2, 2010, from http://www.javazoom.net/ • XML Tutorial. (2010). W3Schools Online Web Tutorials. Retrieved December 2, 2010, from http://www.w3schools.com/xml/