R
Ramkumar Menon
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.
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.
My questions are:
1) What should the Command Interpreter interface look like ?
2) What is the best way to dispatch the XML requests to different API
invocations on a particulat object. For instance, <getAllCustomers/>
should invoke CustomerManager.getAllCustomers(). <deleteCustomer
name="foo" should invoke CustomerManager.deleteCustomer("foo"); Note
that there is more than one class on which the APIs could be invoked.
For instance, there could be an AccountsManager class on whom Account
related queries would be dispatched to.
Any ideas are welcome.
rgds.
Menon.
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.
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.
My questions are:
1) What should the Command Interpreter interface look like ?
2) What is the best way to dispatch the XML requests to different API
invocations on a particulat object. For instance, <getAllCustomers/>
should invoke CustomerManager.getAllCustomers(). <deleteCustomer
name="foo" should invoke CustomerManager.deleteCustomer("foo"); Note
that there is more than one class on which the APIs could be invoked.
For instance, there could be an AccountsManager class on whom Account
related queries would be dispatched to.
Any ideas are welcome.
rgds.
Menon.