首页 / 专利库 / 软件 / 命令行界面 / Command line interface abstraction engine

Command line interface abstraction engine

阅读:196发布:2020-11-07

专利汇可以提供Command line interface abstraction engine专利检索,专利查询,专利分析的服务。并且A CLI description language is implemented to define a set of command keywords and arguments forming CLI description files. The CLI description language is implemented using Extensible Markup Language (XML). A set of XML tags and corresponding semantic definitions are provided. An XML schema is defined for the CLI description language. The CLI description files are compiled into runtime format using the XML schema. The CLI description files provide a mapping of object names to services of the system.,下面是Command line interface abstraction engine专利的具体信息内容。

What is claimed is:1. A method, comprising: defining a set of commands to be used with a command line interface (CLI), each command in the set of commands specifying an action to be performed in a system; defining a set of system interfaces including objects and methods, wherein each action specified in the command is associated with an object and a method, the object and the method performing semantics required by the command; and creating a CLI description file for each command in the set of commands, the CLI description file mapping the command with the action and the associated objects and the methods. 2. The method of claim 1, wherein defining the set of commands comprises defining keywords, arguments, input and output requirements for each command. 3. The method of claim 2, wherein defining the keywords and the arguments for each command comprises defining help texts for the keywords and for the arguments. 4. The method of claim 2, wherein defining the input requirements comprises defining an argument set for the command, and wherein defining the output requirements comprises defining a display format to display a result responsive to executing the command. 5. The method of claim 4, wherein the argument set is associated with the action of the command, and wherein the argument set is included in an input string specified with the command, the argument set comprising zero or more arguments. 6. The method of claim 5, wherein an argument type is selected for each argument, and wherein each argument type is implemented as a Java class. 7. The method of claim 1, wherein defining a set of interfaces including objects and methods comprises defining a Java class for the action, the Java class for the action naming the object associated with the action and having methods that can be invoked when performing the action. 8. The method of claim 7, further comprising registering the object with the system such that when the action is performed, the methods are invoked. 9. The method of claim 1, wherein the CLI description file is created using a generalized markup language. 10. The method of claim 9, wherein the generalized markup language is Extensible Markup Language (XML). 11. The method of claim 10, further comprising: compiling the CLI description file to generate a run time module. 12. A computer readable medium having stored thereon sequences of instructions which are executable by a digital processing system, and which, when executed by the digital processing system, cause the system to perform a method comprising: defining a set of commands to be used with a command line interface (CLI), each command in the set of commands specifying an action to be performed in a system; defining a set of interfaces including objects and methods, wherein each action specified in the command is associated with an object and a method, the object and the method performing semantics required by the command; and creating a CLI description file for each command in the set of commands, the CLI description file mapping the command with the action and the associated objects and the methods. 13. The computer readable medium of claim 12, wherein defining the set of commands comprises defining keywords, arguments, and input and output requirements for each command. 14. The computer readable medium of claim 13, wherein defining the keywords and the arguments for each command comprises defining help texts for the keywords and for the arguments. 15. The computer readable medium of claim 13, wherein defining the input requirements comprises defining an argument set for the command, and wherein defining the output requirements comprises defining a display format to display a result responsive to executing the command. 16. The computer readable medium of claim 15, wherein the argument set is associated with the action of the command, and wherein the argument set is included in an input string specified with the command, the argument set comprising zero or more arguments. 17. The computer readable medium of claim 16, wherein an argument type is selected for each argument, and wherein each argument type is implemented as a Java class. 18. The computer readable medium of claim 12, wherein defining a set of interfaces including objects and methods comprises defining a Java class for the action, the Java class for the action naming the object associated with the action and having methods that can be invoked when performing the action. 19. The computer readable medium of claim 18, further comprising registering the object with the system such that when the action is performed, the methods are invoked. 20. The computer readable medium of claim 12, wherein the CLI description file is created using a generalized markup language. 21. The computer readable medium of claim 20, wherein the generalized markup language is Extensible Markup Language (XML). 22. The computer readable medium of claim 12, further comprising: compiling the CLI description file to generate a run time module. 23. A method, comprising: defining a set of commands to be used with a command line interface (CLI); defining keywords, arguments, input and output requirements for each command, each command in the set of commands specifying an action to be performed in a system; defining a set of interfaces including objects and methods, wherein each action specified by the command is associated with an object and a method, the object and the method performing semantics required by the command; creating a CLI description file for each command in the set of commands, the CLI description file mapping the command with the action and the associated objects and the methods, wherein the CLI description file is created using Extensible Markup Language (XML); and compiling the CLI description file to create a run time module. 24. The method of claim 23, wherein defining the keywords and the arguments for each command comprises defining help texts for the keywords and for the arguments. 25. The method of claim 23, wherein defining the input requirements comprises defining an argument set for the command, and wherein defining the output requirements comprises defining a display format to display a result responsive to executing the command. 26. The method of claim 25, wherein the argument set is associated with the action of the command, and wherein the argument set is included in an input string specified with the command, the argument set comprising zero or more arguments. 27. The method of claim 26, wherein an argument type is selected for each argument, and wherein each argument type is implemented as a Java class. 28. The method of claim 23, wherein defining a set of interfaces including objects and methods comprises defining a Java class for the action, the Java class for the action naming the object associated with the action and having methods that can be invoked when performing the action. 29. The method of claim 28, further comprising registering the object with the system such that when the action is performed, the corresponding methods are invoked.

说明书全文

FIELD OF THE INVENTION

&null;0001&null; The present invention relates generally to field of command line interface application. More specifically, the present invention is directed to abstracting command line interfaces from embedded systems.

BACKGROUND

&null;0002&null; An embedded system is a specialized computer in which operating system and application functions are often combined into the same program. Generally, an embedded system implies a fixed set of functions programmed into a non-volatile memory (ROM, flash memory, etc.) in contrast to a general-purpose computing machine.

&null;0003&null; Embedded systems are growing more and more complex, requiring a range of external management applications such as SNMP, Command Line Interfaces, TNM, WBEM, etc. These applications have completely different interfaces, network protocols and purposes but must all interface to the low-level internals of the embedded system.

&null;0004&null; In order for an embedded system to perform successfully in an environment, it is necessary that the embedded system be configured to operate as desired for troubleshooting and monitoring purposes. Further, the embedded system needs to be able to provide its current configuration or restore to a saved configuration when requested. This functionality is collectively known as &null;management&null; of the embedded system.

&null;0005&null; Management of the embedded system may be effected through a variety of user interfaces. The most common is Command Line Interface (CLI), where configuration and display commands are entered in text mode and promptly executed. Another common interface is Simple Network Management Protocol (SNMP) where configuration and monitoring data is transmitted over the network.

&null;0006&null; Prior technology for implementation of command line user interfaces relies on a set of closely coupled functions between the commands defined and the application functions or services of the embedded system. Typically a set of function calls is provided by the embedded system and utilized in the implementation of the CLI. This leads to a dependency of the user interface application on the underlying implementation of the embedded system which requires the embedded system services to provide a consistent interface to the CLI.

&null;0007&null; Since the user interface application and the application functions (or services) in the embedded system are inextricably linked through this functional interface (i.e., function calls), this leads to a brittle code structure that is not easily extended, difficult to manage and maintain. It would be advantageous to have a method that provides a generalized user interface to an embedded system in such a way that the generalized user interface is decoupled from the services and features delivered and implemented in the embedded system.

SUMMARY OF THE INVENTION

&null;0008&null; In one embodiment, a method for abstracting a command line interface (CLI) from an embedded system is disclosed. A CLI description language is implemented to define a set of command keywords and arguments forming CLI description files. The CLI description language is implemented using Extensible Markup Language (XML). A set of XML tags and corresponding semantic definitions are provided. An XML schema is defined for the CLI description language. The CLI description files are compiled into run time format using the XML schema. The CLI description files provide a mapping of object names to services of the system.

BRIEF DESCRIPTION OF THE DRAWINGS

&null;0009&null; The present invention is illustrated by way of example in the following drawings in which like references indicate similar elements. The following drawings disclose various embodiments of the present invention for purposes of illustration only and are not intended to limit the scope of the invention.

&null;0010&null; FIG. 1 illustrates exemplary XML (Extensible Markup Language) tags used in XML CLI description files.

&null;0011&null; FIG. 2 is an exemplary illustration of CLI commands and a corresponding XML fragment.

&null;0012&null; FIG. 3 is an exemplary illustration of CLI commands with arguments and argument help and a corresponding XML fragment.

&null;0013&null; FIG. 4 illustrates an exemplary DTD schema used in accordance with the present invention.

&null;0014&null; FIG. 5 is an exemplary illustration of a Document Object Model (DOM) tree of an XML fragment describing a &null;clock set&null; command.

&null;0015&null; FIG. 6 is an exemplary illustration of a mapping from a XML CLI description file to a corresponding Java class CLIState.

&null;0016&null; FIG. 7 is an exemplary illustration of relationship among an XML description fragment, a CLI State and a CLI Action.

&null;0017&null; FIG. 8 is an exemplary illustration of the CLIBuilder generating &null;.cli&null; files to be interpreted by a CLIInterpreter.

&null;0018&null; FIG. 9 is an exemplary illustration of a CLI Interpreter.

&null;0019&null; FIG. 10 illustrates an exemplary CLIState tree.

&null;0020&null; FIG. 11 illustrates exemplary CLIState transitions for the CLIState tree in FIG. 10.

&null;0021&null; FIG. 12 illustrates an exemplary block diagram of one embodiment of the design process to implement the CLI application.

&null;0022&null; FIG. 13 illustrates exemplary keyword sets for each of these commands.

&null;0023&null; FIG. 14 illustrates exemplary arguments for the &null;clock set&null; command.

&null;0024&null; FIG. 15 illustrates exemplary help strings for different command sequence.

&null;0025&null; FIG. 16 is an exemplary table illustrating CLI arguments to Java type mapping.

&null;0026&null; FIG. 17 illustrates an exemplary XML CLI description file for the &null;show clock&null; and &null;show clock detail&null; commands.

&null;0027&null; FIG. 18 illustrates an exemplary XML CLI description file for the &null;clock set&null; command.

&null;0028&null; FIG. 19 illustrates exemplary Java methods for the &null;clock set&null; and &null;clock set detail&null; commands.

&null;0029&null; FIG. 20 illustrates an exemplary Java method for the &null;clock set&null; command.

DETAILED DESCRIPTION

&null;0030&null; In one embodiment of the present invention, a method for abstracting a command line interface (CLI) application from an embedded system is disclosed. The abstraction separates high-level applications from the details of the embedded system. A CLI description language is implemented to define a set of command keywords and arguments forming CLI description files. The CLI description files are compiled to create run time modules. The runtime modules are provided as an application from the embedded system to interface applications.

&null;0031&null; The following detailed description sets forth numerous specific details to provide a thorough understanding of the invention. However, those of ordinary skill in the art will appreciate that the invention may be practiced without these specific details. In other instances, well-known methods, procedures, protocols, components, algorithms, and circuits have not been described in detail so as not to obscure the invention.

&null;0032&null; In this description, the CLI application refers to an application that allows for interaction with an embedded system (also referred to as a system or a platform). The CLI application is specified by a collection of modes, commands, keywords, and arguments that are used to command, control, and configure the systems.

&null;0033&null; Generally, a system is managed by using high-level applications that collect data from or send data to the system. The high-level applications may issue commands to the CLI application. In one embodiment of the present invention, a framework is provided for abstracting the low-level elements of the system forming a CLI application. The frame work provides a system wide abstraction layer, below which are kernel device drivers and various system services software in the system and above which are the high-level applications that manage the system. Using this framework, the high-level applications can be insulated from the implementation of services on the system.

&null;0034&null; In one embodiment, architecture for the CLI application includes XML CLI description files, an XML compiler, a CLI interpreter, and a set of system interfaces. The XML CLI description files use XML syntax to describe features and structure of the CLI. This includes CLI modes, command, keyword and sub-keyword structures, help text for keywords and arguments, and specification of actions performed for a command. The XML compiler compiles the XML CLI description files into a format usable by a runtime system. The CLI interpreter is the runtime system responsible for presenting the CLI commands and for executing the actions specified by the CLI commands. The system interfaces includes a collection of Java interfaces (e.g., classes and methods). During runtime, the CLI commands are performed based on their semantics. The XML CLI description files, the XML compiler, the CLI interpreter, and the set of system interfaces form the framework to create the CLI application.

&null;0035&null; FIG. 1 illustrates exemplary XML (Extensible Markup Language) tags used in XML CLI description files. Each XML tag occurs in an XML CLI description file as a <tagname> . . . </tagname> combination. Attributes are enclosed in the tag fields with their values bounded by a pair of double quotation marks. In one embodiment, each of the XML CLI description files have the following form:

1

<&null;xml version&null;&null; 1.0 encoding&null;&null; US-ASCII'&null;>

<&null;DOCTYPE cli SYSTEM &null; cli.dtd&null;>

<&null;&null;CLI Definitions here...-->

&null;0036&null; The first line is an XML declaration that specifies the type of the document as an XML document. The second line is a document type declaration that attaches the .XML file to a particular schema. In this case the schema is &null;cli.dtd&null;. The second line also specifies that the top-level element is &null;cli&null;. The remainder of the document includes the specific tags used to define the CLI constructs.

&null;0037&null; The <cli> tag 105 is the top-level element of the XML document. All other tags are sub tags of this top-level <cli> tag 105. This <cli> tag 105 has no attributes and text inside the <cli> tag 105 is ignored. The <mode> tag 110 contains the mode of the management command. There should be only one <mode> tag 110 in the XML document. The <mode> tag 110 has a single attribute which identifies the name of the mode such as, for examples, <mode name&null;&null;global&null;> or <mode name&null;&null;exec&null;> for global or executive mode.

&null;0038&null; The <command> tag 115 is the top-level tag for a single command. It has no attributes and any text inside the <command> tag 115 is ignored. The <command> tag 115 contains a single <keyword> tag such as, for example,

2

<command>

<keyword text&null;&null;show&null;>

</keyword>

</command>.

&null;0039&null; The <keyword> tag 120 specifies the text of a command keyword in the command set of the CLI such as, for example &null;show&null;, &null;enable&null; or &null;logout&null;. The text is supplied by the single attribute &null;text&null;. The keywords may include other <keyword> tags to specify sub keywords.

&null;0040&null; The <help> tag 125 specifies help information for the command /keyword. The <help> tag 125 has no attributes. The text enclosed by the <help> tag 125 defines the help text for the outlying tag, i.e. for a keyword or argument. One example of the help information follows:

&null;0041&null; <keyword text&null;&null;show&null;>

&null;0042&null; <help>Show running system information </help>

&null;0043&null; <keyword text&null;&null;clock&null;>

&null;0044&null; </keyword>

&null;0045&null; The <action> tag 130 specifies that there is an executable action for the enclosing keyword. For example, the action specified within the <action> tag 130 is carried out for the associated command when the carriage return is presses. The &null;object&null; and &null;method&null; attributes of the <action> tag 130 specify an object and a method in the system by name. A collection of Java type interfaces is created for the &null;objects&null; and &null;methods&null; that get invoked during run-time. Following is one example of the object and the method follows:

&null;0046&null; <action object&null;&null;CLISystem&null; method&null;&null;clock&null;>

&null;0047&null; </action>.

&null;0048&null; The <arg> tag 135 defines an argument type for an <action> tag 130. The <arg> tag 135 has no arguments and text in the <arg> tag 135 is ignored. A single <type> tag or <help> tag may be inserted in the body of the <arg> tag 135. Following is one example of the <arg> tag 135:

3

<arg>

<type type&null;&null;Java.lang.String&null;></type>

<help>destination address or hostname</help>

</arg>

&null;0049&null; The <type> tag 140 describes a Java type for input to the invocation of the object, method pair specified by the <action> tag 130. The Java type name is entered as a &null;type&null; attribute of the <type> tag 140. Other text in the body of the <type> tag 140 other than those associated with the &null;type&null; attribute is ignored.

&null;0050&null; In this example, XML is used to describe the command language. XML is advantageous because there are a lot of available XML tools (e.g., editor tool, browser tool, etc.) for development. Although XML is used, one skilled in the art would recognize that other generalized markup languages might also be used to describe or map the management commands to the objects of the system, where the objects are low-level functions implemented in the system.

&null;0051&null; The CLI commands are generally in the following format:

&null;0052&null; Prompt> keyword1 keyword2 . . . keywordn arg1 . . . argn

&null;0053&null; For example, the commands may be:

&null;0054&null; Prompt> show clock detail, or

&null;0055&null; Prompt> show interfaces fast Ethernet 0/0.

&null;0056&null; The structure of the XML CLI description file expresses the format of the commands. The keyword tags embedding expresses the sequence above. Following is an example of a XML CLI description fragment for a command:

4

<command>

<keyword text&null;&null;keyword1&null;>

<keyword text&null;&null;keyword2&null;>

...

<keyword text&null;&null;keywordn&null;>

<action object&null;&null;example&null; method&null;&null;whatever&null;>

<&null;&null;argument arg1-->

<arg><type type&null;&null;Java.lang.Striflg&null;></arg>

...

<&null;&null;argument argm-->

<arg><type type&null;&null;Java.lang.String&null;></arg>

&null;</keyword>

...

</keyword>

<keyword>

<command>

&null;0057&null; FIG. 2 is an exemplary illustration of CLI commands and a corresponding XML fragment. The CLI description fragment 210 may be part of a XML CLI description file. The CLI commands in this example include a &null;show clock&null; command 200 and a &null;show clock detail&null; command 205. The respective output is shown below each command. These commands 200, 205 are represented by the XML CLI description fragment 210 using XML tags described in FIG. 1. The XML CLI description fragment 210 describes the &null;show clock&null; command using keywords, sub-keywords, help text, arguments, and specification of actions to be carried out.

&null;0058&null; The XML CLI description fragment 210 is presented in its source format and is normally compiled using an XML compiler so that it can be used by a run-time system. When a user or a management application issues a CLI command, the run-time system performs object mapping, method mapping and the arguments are provided to carry out the action. For example, when the command &null;show clock&null; command 200 is issued, the run-time system executes the action associated with an object &null;clock&null; and a method &null;show&null;, shown on line 212. When the command SHOW &null;clock detail&null; 205 is issued, the run-time system executes the action associated with an object &null;clock&null; and a method &null;showdetail,&null; as shown on line 215. The run-time system invokes a collection of Java system interfaces corresponding to the object and method specified in the action.

&null;0059&null; Note that the structure of the command's keyword and sub keywords is reflected in the nesting of the <keyword> tags in the XML CLI description. file In addition, any number of commands, keywords, sub keywords and help for each of the associated keywords may be nested and created by this syntax.

&null;0060&null; FIG. 3 is an exemplary illustration of CLI commands with arguments and argument help and a corresponding XML fragment. In this example, the command is a &null;clock set&null; command. The command 321 illustrates the &null;help&null; feature by specifying the &null;&null;&null; as part of the of command argument. This &null;help&null; feature is also illustrated in the command 322 and 323 to get additional information about the format (e.g., time, month, year) of the &null;clock set&null; command. The command 324 illustrates a complete &null;clock set&null; command with all the possible arguments specified.

&null;0061&null; The XML fragment 325 describes the &null;clock set&null; commands 321-324 using the XML tags described in FIG. 1. The XML fragment 325 describes the hierarchy of the CLOCK SET command keyword by keyword. At run-time, the command CLOCK SET issued by the user or the management application is recognized by the CLI interpreter as corresponding to the command keyword CLOCK shown on line 327 and the keyword SET shown on line 328. There may be multiple command keywords in the same XML document in addition to the CLOCK command. The CLI interpreter will parse the XML fragment 325 to determine if the command is a valid command. In the current example, the help information requested in the commands 321-323 is enclosed in the <help> tags on lines 330, 335, 340 and 345 respectively.

&null;0062&null; Depending on the format of each of the CLOCK SET commands 321-324, appropriate data is extracted from the arguments of the XML fragment 325 and is pushed to system. The action specified by the &null;object&null; and &null;method&null; attribute of the <action> tag shown on line 329 is performed by the system.

&null;0063&null; A Document Type Definition (DTD) is used to provide formal description of the structure of the XML CLI description file in terms of XML tags described in FIG. 1. A DTD is a file (or several files to be used together), which contains a formal definition of a particular type of document (e.g., the XML CLI description document). It sets out a schema of names that can be used for element types, where they may occur, and how they all fit together. The format of the DTD is known to one skilled in the art. In one embodiment, the DTD is used in this invention to provide notice of what names and structures to be used for XML CLI description documents. Using the DTD, XML CLI description documents are ensured to be constructed and named in a conformant manner. The DTD not only defines the valid XML CLI description files, but it can also be used by the tools to validate any input file before processing or by editors to assure that edited files conform to the DTD. FIG. 4 illustrates an exemplary DTD schema used in accordance with the present invention.

&null;0064&null; The XML tags and DTD schema described above represent the minimum required to implement the CLI application. It will be apparent to one skilled in the art that the set of XML tags, tag attributes, and the structure of the XML may be extended to accommodate other requirements or features required by the CLI application or other management tools. For example, XML tags may be added for documentation, web interface, or other management applications.

&null;0065&null; The set of CLI modes and commands may be described in XML CLI description files using the XML tags and the DTD schema. The XML CLI description files are translated by a Java tool called CLIBuilder into a format suitable to be interpreted at runtime by the CLI Interpreter (also referred to as a CLIEngine). In one embodiment, each XML CLI description file has a &null;.xml&null; suffix. The CLI Builder tools take the XML CLI description files and generate output files that are used as input to the CLI interpreter at runtime. In one embodiment, each output file has a &null;.cli&null; suffix. The CLIBuilder validates syntax and format of the XML CLI description files against the &null;cli.dtd&null; DTD schema. For example, the CLI Builder validates an XML CLI description file named &null;config.xml&null; and generates a &null;config.cli&null; file. The resulting &null;config.cli&null; file is to be inputted to the CLIEngine at runtime.

&null;0066&null; FIG. 5 is an exemplary illustration of a Document Object Model (DOM) tree of an XML fragment describing a &null;clock set&null; command. In one embodiment, the CLIBuilder uses a Java DOM library to parse the input XML CLI description file into a DOM object model tree (or DOM tree). The DOM tree is a collection of Java objects that represent the tags, attributes, and text of an XML CLI description file. Each Java object is represented as a node in the DOM tree in FIG. 5. The structure of the DOM tree shows relationship of the XML tags and text in the XML CLI description file. The structure also contains all of the text enclosed by any of the tags so that every piece of information in the XML CLI description file is reflected in the resulting DOM tree.

&null;0067&null; Each XML CLI description file is translated into the DOM tree format that can be interpreted at run-time. In one embodiment, a set of Java classes is used to provide for a more compact representation of the keywords and actions represented in the DOM tree. The CLIBuilder starts with the DOM tree and translates the DOM tree into a collection of Java runtime classes.

&null;0068&null; The DOM tree in FIG. 5 corresponds to the &null;clockset&null; command described in the CLI description fragment 225 illustrated in FIG. 2. Note that there are two keyword nodes 505, 510 corresponding to the keywords &null;clock&null; and &null;set&null; respectively. Note also that there are four argument nodes 520-535 under the action node 515. The four argument nodes 520-535 correspond to the arguments for &null;time&null;, &null;day of month&null;, &null;month&null; and &null;year&null; of the &null;clock set&null; command. The node 540 contains text associated with the &null;help&null; node 538, which provides help information to the &null;arg&null; node 530.

&null;0069&null; FIG. 6 is an exemplary illustration of a mapping from a XML CLI description file to a corresponding Java class CLIState. The Java class CLIState is a construct that implements the CLI behavior based on the user input. It also embodies the structure of the keywords and commands inherent in the XML CLI description files and in the DOM trees. To convert from the XML CLI description files and the DOM trees, the following exemplary attributes may be used for the CLIState class.

&null;0070&null; private String keyword

&null;0071&null; private String help

&null;0072&null; private AbstractMap substates

&null;0073&null; private CLIState superstate

&null;0074&null; private CLIAction action

&null;0075&null; Each CLIState has a keyword label, possible children substates, a parent state, and an action. This is analogous to the <keyword> tag in the XML CLI description file. The keyword is the label or text for the CLIstate. This is the text attribute of the <keyword> tag. Referring to FIG. 6, from the XML fragment 600, the &null;help&null; field 605 gets its content from the text of the <help> tag 610 in the XML fragment 600 of the enclosing <keyword> tag. Each of the keyword tags is represented by a CLIState. For example, the keyword &null;show&null; in the XML fragment 600 is represented by the CLIState 615, and the keyword &null;clock&null; is represented by the CLIState 620.

&null;0076&null; When a keyword tag encloses other keyword tags, then each of the CLIStates is a sub state of an enclosing CLIstate. For example, the CLIState 620 is a sub state of the CLIState 615. Similarly, the CLIState 615 may be a sub state of another CLIState. A super state is a parent node in the CLIstate tree for this CLIState. It is the enclosing keyword tag in the XML CLI description file. For example, the CLIState 615 is the super state for the CLIState 620. If there is no enclosing keyword (i.e. the keyword is already a top-most keyword of a command), then a CLIState representing the mode of the command is the super state. The action is an action for the CLIState. If there is an action tag present in the XML CLI description file, this will be non-null.

&null;0077&null; To translate from the XML CLI description file to the CLIState structure, a CLIState is created for each <keyword> tag in the XML CLI description file. The mapping between the keyword and the CLIState is one-to-one. The keywords enclosed by another <keyword> tag are children (or sub states) of the enclosing CLIState. The <help> and <action> sub tags of a keyword are saved as values in the CLIState representing the keyword tag.

&null;0078&null; FIG. 7 is an exemplary illustration of relationship among an XML description fragment, a CLI State and a CLI Action. In one embodiment, an <action> tag content in the XML CLI description fragment 700 is converted into a Java class CLIAction 720. Similar to the way the CLIState 710 embodies the information and structure of the modes, command, and keyword tags from the XML CLI description fragment 700, the Java class CLIAction 720 contains all the content of the <action> and the sub tags <type> and <help> from the XML CLI description fragment 700. To convert from the XML CLI description files and the DOM trees, the following exemplary attributes may be used for the CLIAction class.

&null;0079&null; private String obeject_name

&null;0080&null; private String method_name

&null;0081&null; private String &null;&null; argument_types

&null;0082&null; private String &null;&null; argument_help

&null;0083&null; The &null;object_name&null; 712 is the same as the value of the &null;Object&null; attribute of the <action> tag in the XML CLI description file. The &null;object_name&null; is the name of the Java object that will be invoked when this action is performed. The &null;method_name&null; 714 is the value of the &null;Method&null; attribute of the <action> tag in the XML CLI description fragment 700. This is the string of the method that will be invoked when this action is performed. The &null;argument_types&null; 716 is the value of the &null;Type&null; attributes of the <type> tag in the XML CLI description fragment 700. The &null;argument_types&null; is an array that is filled in order of the <arg> tags present in the action. The &null;argument_help&null; 718 is the text of the <help> tags for each <arg> in the XML structure. The CLIState 710 and the CLIAction 720 embody the XML CLI description fragment 700 and the corresponding DOM tree representation. The structure of CLIStates and the CLIActions is then serialized by a CLIBuilder into a file to be read by the CLI Engine (or CLI Intepreter) for interpretation, as illustrated in FIG. 8.

&null;0084&null; The runtime behavior of the CLI system is performed by multiple Java classes. The Java class CLIState implements the structure of the CLI commands keywords via transitions, as described above. The Java class CLIAction translates arguments from the input string and then invokes the object and method required for that input. The CLIEngine class initializes and keeps track of global states of the CLI and houses the object registry. The system interface class is the collection of Java objects that are invoked by the CLIActions.

&null;0085&null; FIG. 9 is an exemplary illustration of a CLI Interpreter. The Java class CLI Interpreter 900 is the main control structure of the CLI runtime and performs housekeeping duties including initialization, object registration, action resolution and context data. During initialization, the CLI Interpreter 900 installs the CLIState trees 905 into the system. The CLIState trees 905 are internally installed and are associated with the CLI modes 910. The system interface 925 includes objects that are registered and associated with an object name in an object registry 915. This is the same name that is referenced by the actions in the CLIState tree or with the object attribute in the XML CLI description file. For action resolution, the CLIAction instances (in the CLIState trees) contain string references to the objects and methods that comprise the system interface 925. These are resolved into action objects and methods using the object registry 915 of the CLI Interpreter 900. Context data refers to all data that is global to the running of the engine itself and includes &null;current mode&null;, &null;prompt&null; and &null;I/O stream&null;. The CLI is generally in a &null;current&null; mode which corresponds to a particular CLIState tree that is active. A CLI prompt is formatted according to the current mode, and the CLI can take input from or output to (i.e., I/O stream) any kind of stream (e.g., a file or interactive input).

&null;0086&null; In one embodiment, the objects are registered in the system through a static method of the CLIEngine. For example, the method is

&null;0087&null; RegisterObject (Object, String).

&null;0088&null; This registration function should be done sometime during the initialization of the system. The method takes the object being registered and its &null;string name&null; (i.e., the name found in the XML CLI description file) as the object attribute of the action tag. For example, using the above method, the following registration can be done:

&null;0089&null; CLIEngine.registerObject (new InterfaceManager, &null;ethManager&null;);

&null;0090&null; The object registry is used to resolve the static CLIAction information from the XML CLI description file to references to the actual objects and methods of the system interface.

&null;0091&null; As previously described, the CLIStates model the keyword tags of the XML CLI description files, their keyword labels, and the structure of possible substates and parent state (or super state). Recall that the CLIStates have the following attributes:

&null;0092&null; private String keyword;

&null;0093&null; private String help

&null;0094&null; private AbstractMap sub states;

&null;0095&null; private CLIState super state;

&null;0096&null; private CLIAction action.

&null;0097&null; The CLIStates also model behavior of the interfaces through the transition functions. In addition to the above method, another method is:

&null;0098&null; public void transition (StringTokenizer input);

&null;0099&null; where the &null;keyword&null; is the label or the text for the CLIState. During runtime, the valid input to transition to this state is from its parent. The &null;help&null; is displayed when the transition input is the help token &null;&null;&null;. The &null;sub states&null; is an abstract map &null;M&null; such that:

&null;0100&null; M: String &null; CLIState.

&null;0101&null; The keyword field of the sub states is the key set for this mapping. The &null;sub states&null; themselves are the resulting values. This allows for implementing the transition function. The &null;super state&null; is the upper node in the CLIState tree for this CLIState. The transition is the function that implements a walk of the CLIState tree based on the user input. For example, for an input token string k, CLIState p with sub state s, the transition function is:

&null;0102&null; p.transition(k)&null;s if and only if (s.keyword&null;k)

&null;0103&null; The &null;action&null; indicates action for the CLIState. The action is invoked when it is at the end of the input and/or when the CLIState is a terminal node (i.e. no children). FIG. 10 illustrates an exemplary CLIState tree. The CLIState tree 1000 represents the &null;show clock&null; and the &null;show clock detail&null; commands. The different CLIStates 1005, 1010, 1015 are labeled in the CLIState tree 1000 in FIG. 10. There may be other sub states under the initial state, show states, etc.

&null;0104&null; FIG. 11 illustrates exemplary CLIState transitions for the CLIState tree in FIG. 10. Each CLI State represents a possible transition from an input token that matches its keyword. The transitions of the CLI State tree from the initial node down to the leaf are illustrated in FIG. 10. The CLIState tree 1105 is similar to the CLIState tree 1000. The CLIState tree 1110 illustrates transition after encountering the token &null;show&null;. The CLIState tree 1115 illustrates transition after further encountering the token &null;clock&null;. The CLIState tree 1120 illustrates transition after further encountering the token &null;detail&null;.

&null;0105&null; The CLIState tree is navigated based on the input tokens using the transition method of the current node in the CLIState tree. The transition function implements all of the runtime behavior of the CLIState tree, including navigation, command help, partial command help, unknown and incomplete command checks and whether an action should be invoked.

&null;0106&null; Upon receiving the serialized input (i.e., the serialized CLIState tree file described in FIG. 8), the CLIAction object in the CLIState contains the static description of the object, method, and types of the arguments. The CLIAction invokes the specific action specified by the CLIState. This is basically the XML content described above, including:

&null;0107&null; private String obeject_name,

&null;0108&null; private String method_name,

&null;0109&null; private String &null;&null; argument_types, and

&null;0110&null; private String &null;&null; argument_help.

&null;0111&null; Via the resolve method of the CLIAction, these strings are converted, using reflection and the input object_map from the CLIEngine, into the actual object, method, and constructors that are used to invoke the method.

&null;0112&null; Consider the following exemplary action:

&null;0113&null; private Object object;

&null;0114&null; private Method method;

&null;0115&null; private Constructor &null;&null; constructor;

&null;0116&null; public void resolve (AbstractMap object_map)

&null;0117&null; &null; . . . &null;

&null;0118&null; public void execute (StringTokenizer input)

&null;0119&null; &null; . . . &null;

&null;0120&null; where the &null;object&null; is the reference to the actual object that will be invoked when this action is executed. The &null;object_name&null; field is used as the key to index into the input &null;object_map&null;. The &null;object_map&null; is the object repository that is compiled by the CLI Interpreter. The &null;method&null; corresponds to the Method_name of the CLIAction. The Method_name may be retrieved using a &null;getMethod ( )&null; method in the class of the objects described above. For each of the types in the &null;argument_types&null; array, a &null;constructor&null; from &null;String&null; is retrieved and stored in the array in argument order. In this way arguments can be constructed from the tokens on the command line.

&null;0121&null; When a CLIState is reached such that an action should be performed (i.e. it is either a terminal node with a resolved action, or it is an input that has ended at a non terminal node with an action), an &null;execute ( )&null; method of the CLIAction is called for that CLIState. This method marshals the remaining tokens into method arguments by calling the constructors in the &null;constructors &null;&null;&null; array. The method is then invoked for the resolved object. The following example illustrates a resolved CLIAction instance. The left side is the CLIAction and the right side is the resolved &null;ethManager&null; instance.

5

object_name &null;&null;ethManager&null;

method_name &null;&null;show&null;

argument_types &null;&null;&null;java.lang.String&null;&null;

argument_help &null;&null;&null;<0-6> Fast...&null;&null;

{close oversize brace}

public void show (String id) &null; &null;

object

method

constructor &null; &null; String(String), &null;

&null;0122&null; FIG. 12 illustrates an exemplary block diagram of one embodiment of the design process to implement the CLI application. The design process integrates and implements CLI commands in the framework described herein. The process starts at block 1200. At block 1205, the CLI commands are defined. For example, this may include defining command input and output requirements, assignment of the mode for the command, defining the set of keywords and sub keywords for the command, defining the argument set for each action of the command (this may include a consideration of the Java classes that will be constructed from the string input), defining help texts for each keywords and argument, etc.

&null;0123&null; At block 1210, the system interface is designed and implemented. This includes defining the Java classes and methods with each action specified in the command definition having an object and method associated with them to perform the semantics required by the command. This also includes defining the arguments where each argument of the specified method having a constructor from &null;String&null; that can be invoked, and defining object registration to establish names for each object instance for mapping in XML.

&null;0124&null; At block 1215, the XML CLI description files are created. The XML CLI description files may be written and added directly to the CLIBuilder after the command definition and system interface design are complete. At block 1220, the new &null;.xml&null; XML CLI description files are built using the CLIBuilder to create &null;.cli&null; files. The resulting &null;.cli&null; files may then be downloaded to the system and tested. The design process ends at block 1225.

&null;0125&null; Following is an example of designing a CLI application using the design process illustrated in the flow diagram in FIG. 12. The example is described using the commands &null;show date&null;, &null;show date detail&null;, and &null;set clock&null;.

&null;0126&null; Following are exemplary desired input and output formats for these commands:

6

input>

show clock

output>

04:10:12.621 UTC Thu May 6 1993

input>

show clock detail

output>

04:10:28.109 UTC Thu May 6 1993

Time source is user configuration

input>

clock set&null;

output>

hh:mm:ss Current Time

input>

clock set 00:00:00&null;

output>

<1-31> Day of the month

input>

clock set 00:00:00 1&null;

output>

MONTH Month of the year

input>

clock set 00:00:00 25 Sep&null;

output>

<1993-2035>Year

input>

clock set 00:00:00 31 Feb 2000

output>

Invalid date (doesn't exist)

input>

clock set 00:00:00 25 Sep 2000

output>

&null;0127&null; The above exemplary commands reside in an &null;executive&null; mode of the CLI. The &null;show date&null; and &null;show date detail&null; commands are also in the global mode or user mode so the same XML text to describe the commands are put in XML CLI description file for the global mode and for the user mode. FIG. 13 illustrates exemplary keyword sets for each of these commands. For example, for the command &null;show date detail&null; 1305, the corresponding keyword set 1310 include the keywords &null;show&null;, &null;date&null; and &null;detail&null;. In the current example, the &null;show date&null; and &null;show date detail&null; commands do not have arguments. However, the &null;clock set&null; command has several arguments. FIG. 14 illustrates exemplary arguments for the &null;clock set&null; command.

&null;0128&null; FIG. 15 illustrates exemplary help strings for different command sequence. It is suggested that each command keyword have a help message. In the current example, following are some help messages for the clock command.

&null;0129&null; Prompt>&null;

&null;0130&null; . . .

&null;0131&null; clock Manage the system clock

&null;0132&null; . . .

&null;0133&null; show Show running system information

&null;0134&null; Prompt>show &null;

&null;0135&null; . . .

&null;0136&null; clock Display the system clock

&null;0137&null; . . .

&null;0138&null; Prompt>show clock detail&null;

&null;0139&null; clock Display detailed information

&null;0140&null; Prompt>clock &null;

&null;0141&null; set Set the time and date

&null;0142&null; The following descriptions involve system interface design and implementation. This includes Java class definition, method definition and argument mapping. To implement the command definition, a Java class is written having methods that can be invoked by the CLI to perform the required semantics. For example, for the exemplary commands described above, a single Java class called &null;clock&null; is created with the following methods:

7

public class clock &null;

/** Display the system clock */

public void show ()

/** Display detailed information */

public void showDetail ()

/** Set the time and date */

public void set

(String time, Integer day, String month,

Integer year)

&null;0143&null; FIG. 16 is an exemplary table illustrating CLI arguments to Java type mapping. The table list argument number 1605, the argument description 1610 and the Java type 1615 for the arguments of the &null;clock set&null; command. Using the &null;clock set&null; command example, to implement the command via the description of the arguments, each argument is converted from the input string into a selected Java type 1615. Each of the selected Java types 1615 is an existing Java class that has an existing constructor &null;Java.lang.String&null; 1620. If a user-defined class is used, a constructor from &null;Java.land.String&null; 1620 needs to be provided in order for the CLI to be able to construct and marshal the arguments from the input to the method.

&null;0144&null; Given the class definition described above, at some point during the initialization of the system an instance of the class will be created. In the current example, the top-level CLI object will create a &null;Clock&null; instance during startup, then register (i.e., object registration) the instance with the CLI with the name &null;Clock&null;, such as, for example:

&null;0145&null; CLIEngine.registerObject (&null;Clock&null;, new Clock ( )).

&null;0146&null; Once the commands are defined, the system interface methods are defined and implemented, and the instance is named and registered, the full XML CLI description files for the commands can be written. FIG. 17 illustrates an exemplary XML CLI description file for the &null;show clock&null; and &null;show clock detail&null; commands. FIG. 18 illustrates an exemplary XML CLI description file for the &null;clock set&null; command.

&null;0147&null; FIG. 19 illustrates exemplary Java methods for the &null;clock set&null; and &null;clock set detail&null; commands. The methods output the current date to the output stream in the proper format. Using the Java data formatting classes greatly simplifies the effort. The &null;clock set&null; command is a little more complex because it includes arguments. The presence of the arguments to the method requires additional processing for the method. There are two parts to this processing, validating the arguments and performing the required action.

&null;0148&null; Argument validation comes in two forms, individual validation and multiple argument consistency. A command may require either, both or none of these validations. For example consider the day of the month argument for the &null;clock set&null; command. A string input to this argument that cannot be parsed into an integer is invalid. The expected input also must be in the range from 1 to 31 to be considered a valid input to this argument. This is an example of individual argument validation. The day of the month value of &null;31&null; will be individually validated by the above definition but makes sense only for certain values of the next argument (i.e., the month). For example, &null;February 31&null; is obviously an invalid date. This is an example of multiple argument consistency. In one embodiment, individual argument consistency checks can be done at two levels, by the constructor for the input argument or by the method itself, while multiple argument consistency checks are performed by the method.

&null;0149&null; In one embodiment, argument correctness violations are handled in the method by throwing an ArgumentException instance. The number of the offending argument and position of the error in the argument can be set in the ArgumentException. The CLI interpreter responds to the exception with an output making the invalid argument. The following example illustrates the invalid argument and the output marking &null;&null; &null; by the CLI application.

8

Prompt> clock set 00:00:00 ggg Feb 2000

%Invalid input detected at the &null;{circumflex over (&null;)}&null; marker

&null;0150&null; FIG. 20 illustrates an exemplary Java method for the &null;clock set&null; command. Again the use of the Java language greatly simplifies the implementation.

&null;0151&null; Using the method of the present invention, commands that are associated with the system to control the system can be shielded from the user. These commands can be described and expressed using a generalized markup up language (e.g., XML) as a description language. A set of commands is defined by describing all of the commands to be used with the system. The commands are mapped to the services available in the system using objects and methods defined in Java classes. Using this method also shield the users from changes or version upgrades applied to the operating software of the system. In addition, when a new system is used, the commands can be made to be the same by describing and mapping the commands to the objects and methods of the new system.

&null;0152&null; The operations of the various methods of the present invention may be implemented by a processing unit in a digital processing system, which executes sequences of computer program instructions which are stored in a memory which may be considered to be a machine readable storage media. The memory may be random access memory, read only memory, a persistent storage memory, such as mass storage device or any combination of these devices. Execution of the sequences of instruction causes the processing unit to perform operations according to the present invention. The instructions may be loaded into memory of the computer from a storage device or from one or more other digital processing systems (e.g. a server computer system) over a network connection. The instructions may be stored concurrently in several storage devices (e.g. DRAM and a hard disk, such as virtual memory). Consequently, the execution of these instructions may be performed directly by the processing unit.

&null;0153&null; In other cases, the instructions may not be performed directly or they may not be directly executable by the processing unit. Under these circumstances, the executions may be executed by causing the processor to execute an interpreter that interprets the instructions, or by causing the processor to execute instructions which convert the received instructions to instructions which can be directly executed by the processor. In other embodiments, hard-wired circuitry may be used in place of or in combination with software instructions to implement the present invention. Thus, the present invention is not limited to any specific combination of hardware circuitry and software, nor to any particular source for the instructions executed by the computer or digital processing system.

&null;0154&null; Although the present invention has been described with reference to specific exemplary embodiments, it will be evident that various modifications and changes may be made to these embodiments without departing from the broader spirit and scope of the invention as set forth in the claims. Accordingly, the specification and drawings are to be regarded in an illustrative rather than a restrictive sense.

高效检索全球专利

专利汇是专利免费检索,专利查询,专利分析-国家发明专利查询检索分析平台,是提供专利分析,专利查询,专利检索等数据服务功能的知识产权数据服务商。

我们的产品包含105个国家的1.26亿组数据,免费查、免费专利分析。

申请试用

分析报告

专利汇分析报告产品可以对行业情报数据进行梳理分析,涉及维度包括行业专利基本状况分析、地域分析、技术分析、发明人分析、申请人分析、专利权人分析、失效分析、核心专利分析、法律分析、研发重点分析、企业专利处境分析、技术处境分析、专利寿命分析、企业定位分析、引证分析等超过60个分析角度,系统通过AI智能系统对图表进行解读,只需1分钟,一键生成行业专利分析报告。

申请试用

QQ群二维码
意见反馈