Design of a simple Command Interpreter

Hi,
I have a scenario where a client pgm passes a command string to a Command Interpreter. There are several possible commands. The Command Interpreter accepts these command strings and makes API invocations on some other object.
Some Commands would need to return a value, whereas some others do not need to. These results need to be passed back to the client.
What should the Command Interpreter interface look like ?
For isntance, one command could be somethinfg like <getAllCustomers/>.Another command could be like <deleteCustomer name="foo"/>. The former would return a Document of all Customers. The second one does not return a value,but could throw an Exception.
I was thinking of a CommandInterface with a single method named processCommands(String commandXML(. But this would not work if I need to have different types od return values. Moreover, these APIs are more or less unrelated to each other. i.e. different from a Strategy pattern where there is a specific heirarchy/relationship.
Any ideas are welcome.
rgds.
Menon.

1) What should the Command Interpreter interface look like ?I would use the Command Pattern.
http://www.javaworld.com/javaworld/javatips/jw-javatip68-p2.html
You can combine this with the memento pattern.
Here is the interface that i use when implementing the command pattern.
* An Interface for a Command Object
* see Command Pattern [GOF:233]
* @author martin.spamer
* @version 0.1 - 14:08:58
public interface CommandInterface
   *  An Interface for a Command Object
   *  see Command Pattern [GOF:233]
   *  @param java.util.Properties
   *  @return java.util.Properties
  public java.util.Properties execute( java.util.Properties properties)
    throws CommandException ;
2) What is the best way to dispatch the XML requests to different API
invocations on a particulat object. For instance,I use a CommandFactory which I drive with an xml config file.
and drive it something like:
<actions command="CommandString" classname="uk.co...ClassName"/>

Similar Messages

  • SCCM 2012 - Problems running vbscript or simple command line

    Hey everybody, I'm having a heck of a time trying to get SCCM 2012 to deploy some very simple Vbscripts or even a simple command line.  I need to deploy some registry fixes across the company as well as a Vbscript that uninstalls some old applications. 
    If I run these scripts/commands outside of SCCM everything works fine, inside of SCCM it always shows "succeeded" but it doesn't actually run correct on the client.
    What's confusing to me is the use of distribution points when you're running a command line that doesn't actually have any source files.  For instance this is what I'm trying to run "regedit /s \\servername\folder\registryfix.reg".  I've also tried
    a similar bat file as well with the same result.  I've tried it with a source folder specified, I've tried it using Run Program From Server or Download locally.  I've gone through everything I can think of but can't get it to work.
    Similarly with a vbscript I'm trying "cscript.exe /s \\servername\folder\uninstallapps.wsf" and various different settings in the package deployment.
    I'm really confused here guys so any help would be greatly appreciated.  Thanks

    What I have found is that if you try and run the REG.EXE command line directly, either as a program or via a CMD/BAT file, the 64-bit redirection will occur.  So, if you had something like this in a program or via a CMD/BAT file that ran against a 64-bit
    system:
    REG ADD HKLM\Software\Microsoft\Test /v Test /d Test
    You would end up with this registry entry existing under:
    HKLM\Software\Wow6432Node\Microsoft\Test
    That's because SCCM uses the 32-bit launcher to take care of this and redirection occurs - You can see this via the "CCM32BitLauncher.log" on the client.
    To work around this problem, I have done the following:
    On a reference machine, create/export the registry entry I want into a *.reg file - An example export of "Test.reg" for the above mentioned registry entry would look something like this:
    Windows Registry Editor Version 5.00
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Test]
    "Test"="Test"
      2.  Stick our "Test.reg" file in a source share, create a package with the share as the source content, and distribute it
      3.  Create a program for the package with a command line like this: 
    REG IMPORT Test.reg
    This is obviously not as clean as having a command line with a package to distribute, but I find it works fine for me and gets around the redirection for registry entries.

  • Brightness buttons not working and glitchy with simple commands

    I bought a macbook pro 6 months ago. The computer is in mint condition, but has been glitchy, especially with signing in or the simple command of putting in a login password. In order to login you must shut down the computer because the screen is frozen after a logout previously. On top of that the brightness keys show they work but the brightness doesn't change. This computer has no scratches, never been dropeed, has barely been used, and should be working perfectly. Any ideas?

    You have a 1 year warranty, I would take it in and have them deal with it (you paid for it), they might find something that will really bite you further down the road.  USE your warranty, they are usually quite good at customer support.

  • Help! My original and very expensive CS6 has crashed with a  simple command of selection-.

    Help! My original and very expensive CS6 has crashed with a  simple command of selection….

    Thanks JJMack,
    unfortunately I'm Italian and I do not speak English, and most importantly
    I'm not a genius in the world of computing. In fact, if you talks to me
    about preferences folder  User id and I do not even know where to look ....
    why has crashed in your opinion? I was creating patterns with low
    resolutions. It can if you have the time and patience to help me understand
    where look the folder  and what to do in a primitive language so that an
    incompetent like me can understand.
    Thank you in advance.
    greetings
    Vittorio.
    Il 06/apr/2014 15:19 "JJMack" <[email protected]> ha scritto:
        Re: Help! My original and very expensive CS6 has crashed with a
    simple command of selection....  created by JJMack<http://forums.adobe.com/people/JJMack>in *Photoshop
    General Discussion* - View the full discussion<http://forums.adobe.com/message/6275517#6275517

  • Is there any way to bring back the font type and background of Safari reader from iOS6 in to the iOS7 ? I really miss it, the new design is awful, simple and has now class at all.

    Is there any way to bring back the font type and background of Safari Reader from iOS6 in to the iOS7 ? I really miss it, the new design is awful, simple and has now class at all.

    I agree with you, many things in the ios 6.x were more elegant. The reader was the most one of them. I think the ios7 wants to be the windows 8.

  • How to invoke the command interpreter to run the "NS.exe" using Runtime?

    hi,everyone
    I need to invoke the command interpreter,and enter the disk directory "c:/ns2/bin/",then run the "ns myfilename" command.My program is followed:
    try{
    String s[]=new String[4];
    s[0]="cmd.exe";
    s[1]="/c";
    s[2]="cd c:/ns2/bin";
    s[3]="ns.exe c:/ns2/bin/100n-500k-5.tcl";
    Runtime R=Runtime.getRuntime();
    Process p=R.exec(s);
    int exitVal = p.waitFor();
    System.out.println("Process exitValue: " + exitVal);
    But this doesn't work!
    please help me! thanks!

    hi,everyone
    I need to invoke the command interpreter,and
    and enter the disk directory "c:/ns2/bin/",then run
    the "ns myfilename" command.My program is followed:
    try{
    String s[]=new String[4];
    s[0]="cmd.exe";
    s[1]="/c";
    s[2]="cd c:/ns2/bin";
    s[3]="ns.exe c:/ns2/bin/100n-500k-5.tcl";
    Runtime R=Runtime.getRuntime();
    Process p=R.exec(s);
    int exitVal = p.waitFor();
    System.out.println("Process exitValue: " +
    alue: " + exitVal);
    But this doesn't work!
    please help me! thanks!CDing will not change the directory.
    should write:
    String cmd= "cmd /c c:\\ns2\\bin\\ns.exe c\\ns2\\bin\\100n-500k-5.tcl"
    for further details on how to use Runtime.exec(), see http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Batch changes don't function. Apt 3.2. From simple commands like "rotate clockwise" to "lift and stamp" the command only affects to the last image in the group selected. Similar problems? Solutions?

    Batch changes don't function. From simple commands like "rotate clockwise" to "lift and stamp" the command only affects to the last image in the group selected. Similar problems? Solutions? Suggestions? Thanks, Bruce

    Glad it helped. Everyone has been bitten by this at one time or another. Fortunately you only get bit once
    Well if you haven't already read it two or three times the User manual is really very good. Apple really did a nice job with it. The on-line version is nice because it is searchable.
    After that the Apple Pro Training Series book Aperture 3 is very useful. Its basically split into three parts. The library, adjustments and sharing. In addition if you get all the way through it you can take the Certification test and become, well certified.
    Rwboyer who posts here on and off has a good site and a couple of ebooks that I found useful.
    good luck

  • Simple command to refresh data of all declared internal tables & variables!

    Hi All,
    I have declared many internal tables & variables in my program in declaration include.
    Is there any Simple command which can refresh data of all declared internal tables & variables!
    Instead of clearing & refreshing each i.table & variable i want to use single command to refresh data.
    Is this possible!
    Thanks in advance.
    Thanks,
    Deep.

    CLEAR: lv_field1,
                 lv_field2,
                 lt_itab1[],
                 lt_itab2[].
    ONE simple command (CLEAR), can initialize fields, workareas, field-symbols,.... and internal tables.

  • .xlsm Can't exit design mode because Control 'Command Button 3' can not be created

    I have several Windows 7 Enterprise machines that cannot open one .xlsm file properly. When it opens, it is opening in Design mode rather than as a spreadsheet with macros. My users are getting the error "Can't exit design mode because Control
    'Command Button 3' can not be created". All our machines have Office 2010 ProPlus, but this file will only open on the XP PC's that have yet to be upgraded. Any ideas?

    Hi,
    How do you create the button in Excel 2010? Just insert the control manually or insert it using a macro?  This issue may be caused by the controls aren't instantiated before you can exit design mode.
    Please try the method:
    Code can only run after all controls are instantiated and properly connected. Make sure every file needed for the control is available before trying again.
    Quote from:
    http://msdn.microsoft.com/en-us/library/office/gg251344(v=office.14).aspx
    Regards,
    George Zhao
    TechNet Community Support

  • Adding simple commands to boot under systemd

    now that the rc.xxxx files are gone, where is the preferred location for adding a simple command one might like to execute upon boot, e.g. "echo 'search somewhere.somedomain' >> /etc/resolv.conf"
    obviously there are several ways to do this, i'm just wondering what a systemd expert would do.

    djg1971 wrote:olive:  please try to think a little more abstractly.  it is not for you to judge whose one-line commands are good, not good, stupid, etc.
    Please read my posts more carefully. I never said that there is no valid reason to run a custom command at boot, I was just pointed out, in a part of my post, that your example was not the best one; that's all and I do not understand why it seems to affect you so much.
    Anyway, forget about the bad example. I have tried to answer your original question the best as I could: to run a custom command at boot, you have to write a .service or use a general rc-local script but apparently you do not like the answer. What do you want now? I do not know if I am an expert but I have read enough of systemd to know there is no real other way: systemd take in charge every program that is run at boot via .services (or .target, etc...) files. So this is the way you have to follow to run a custom command at boot. Writing a .service file is not that difficult, maybe easier than to write a custom rc.somewhat file. Just take one existing .service file, understand what there is in it and modify it.
    The post of ewaller give a method to create tempory files, often used by .service files (or the programs they launches); I was not under the impression that is what you really want.
    As for the benefits of systemd, there are a few advantages. Anyway it is not me that I have decided to switch to systemd and discussing lengthy of the advantages of disadvantages of it would lead to nowhere.
    Last edited by olive (2013-02-25 22:09:21)

  • Design Pattern for simple AIA processes

    I have been using AIA Foundation Pack v2.4 with SOA Suite 10.1.3.4 for a while now and have developed a variety of interfaces using the standard AIA model of:
    Source Adapter (ESB)
    Requester ABCS (BPEL)
    Enterprise Business Service (ESB)
    Provider ABCS (BPEL)
    Target Adapter (ESB)
    I can see the value in usng this model but we are coming up with requirements for more specific Application to Application Integrations where we may just be interfacing some reference data. Therefore there is no available EBO and it is also overkill to develop 5 separate processes to satisfy a simple integration that could be developed with a simple ESB process.
    Are there any best practices or preffered design models for implementing this kind of simple interface but still make use of some of the functionality of the AIA Foundation Pack, such as CAVS, Error Handling and setting dynamic endpoints etc..
    We are also looking to utilise the Service Registry so we can define and manage the differnet services that we have developed.
    I'd be interested to hear peoples thoughts.
    Regards
    Stuart

    In the process of attacking daFei (a truly pointless excercise) everybody forgot to answer the OPs question.
    Here's my take: composition will work better for this. There are several approaches you could use. One is to make a basic concrete Command and put the minimal base properties in it and let the other Command classes wrap other commands without copying.
    Another approach would be to make this class a holder for all the possible attributes. The advantage is that in the above situatiuon (and your current situation, I beleive) one command can be created from another where they share properties that are not in the root set of attributes but these specialized properties will be lost in the copy. You can deal with this through a number of hacks but none are especially pretty. The downside is that you create a kind cyclic dependency by doing this.
    Lastly and people will probably balk at this: you can put the properties in a map and encapsulate this inside each of your command classes. Then copying one from the other is just a matter of cloning the map or just wrapping the same instance, depending on what you want. This addresses theissue described in the paragraph above without creating cyclic dependencies. The downside is that you lose some type checking but you can mitigate to a large degree this by using static literals to get an put values and only access the map through methods specific to each property.

  • How do I design/program a simple app for an iPad?

    Hi, I don't even know where to start.
    What program is used to design apps for iPads?
    The app in mind is a simple application with my videos and the user is able to select which video they want to watch by picking it. I would also want the app to be locked so that the user cannot wander freely around the iPad.
    Thanks in advance!

    empipergear wrote:
    Hi, I don't even know where to start.
    http://developer.apple.com

  • Any simple command to query the zone ID on Solaris 10?

    Hello,
    As we know, the APIs in zone.h can be used in C/C++ codes to get the ID of a zone on Solaris 10. The other commands like ps can also show the zone ID together with other information:
    # ps -o zoneid
    ZONEID
    0
    0
    However, does anyone know if there is a simple system command which can be easily used in shell script to find the zone id for the current system?
    There is the command "zonename" and I really hope to have the command like "zoneid" which can give zone ID for the current zone (global or non-global). If there is no such a tool from Solaris, I can easily create one with the APIs or parse the output from "ps -o zoneid". However, I like to check with the experts here in case I missed some command which can do this simple task:-)
    I expect the command simply return the zone id like:
    #zoneid
    0
    Thanks and Regards
    Frank

    Hello,
    Thanks for your reply. The zoneadm command shows the IDs of all zones. I try to find a command which can simply display the ID number for the current zone where the command is run. Any more hints?
    Frank

  • Using a simple command...

    I am sure this doesn't belong in this forum, but hopefully no
    one minds, but I am sorry. In Director you can stop the movie
    completely by these lines of code:
    on mouseUp me
    _movie.halt()
    end
    But how do you use this code in flash? I have imported my
    .swf file just fine, but I don't want to make a button in Director
    to stop the movie, just in Flash (for animation purposes). How do I
    write Actionscript code so that it will stop the Director movie?
    Please help, thanks.

    greg,
    to start, I am a director novice, but with flash AS the base
    movie (in your case a director movie) which loads another movie is
    called _level0 or _root.
    I think that since you are using director as the base if you
    use this it may work.
    place this on the root timeline of the fla file, if the
    button is in a movieclip off the root timeline you may need to
    point to it ie. myMC.buttonName.onRelease
    buttonName.onRelease = function() {
    _level0.halt();
    in place of buttonName put the instance name of your button,
    assigned in the properties panel. this should pass the halt()
    command back to the director movie.
    Also in AS halt() would be stop()

  • Satellite C50-B cursor unable to execute simple commands

    I bought a customized Sateliite C50-B laptop and have been using it since September. I partitioned the harddrive, half of it is dedicated to running Windows 9, the other half dedicated to running Ubuntu 14.04. The computer had been running great, but yesterday I ran Ubuntu to realize that the system did not respond to any command that I issued with my tracker pad, or mouse.
    For example, I could not open a file to edit in a word processor. In my web broswer, I couldn't use the search icon to find anything. I couldn't navigate throught folders in my home drive. My cursor moved freely around, and I could open up any program, yet once in the program every command I gave via my tracker pad or mouse would not execute.
    I turned off my computer, took off and battery pack, then put the battery pack back on, and turned my computer back on and the same issue occured. I decided to check out what happened when I used my windows OS. In windows, the same issue occures, but not has extreme. In Ubuntu, I could barley do anything. Conversely with Windows, I can open up a program, such as Chrome my internet browser, and can use the internet. But, I can't switched between tabs.
    I believe the issue has to do with hardware, rather than with the OS. Any advice or suggestions how to furter troubleshoot my issue? Has someone experienced similar behaviors with their Toshiba Laptop??
    Thanks,
    Kate

    Kate,
    Best way to tell if having hardware issue is to restore the computer to out-of-box state and then see if it operating normal.  If so, it was likely a software issue.  You could make an image of your computer before the restore just as a precaution in case you want to return the system to that state afterwards for additional troubleshooting. 
    L305-S5955, T9300 Intel Core 2 Duo, 4GB RAM, 60GB SSD, Win 7 Ultimate 64-bit

Maybe you are looking for