Pro开发者_高级运维blem Domain:
I am working on a new revision of a Java application that connects via SSH to a proprietary, Linux-based platform's Command Line Interface (CLI). Everything on the platform that I would want to do or know is only available via CLI commands and stdout.
One of the commands available retrieves information from an internal database (not using SQL) with the following command arguments: query, sub-query, result format, and sorting preference.
Solution Being Considered:
I would like to expose an API that encapsulates the low-level details of the SSH/CLI behavior and achieve the following:
- Eliminate the current error-prone method of embedded query strings (currently very prone to typos).
- Make the API intuitive as the current query and command formats are not commonly understood.
- Provide consistent error and result responses.
I am considering creating query builder and response classes at the lowest level that implement the SSH/CLI behavior; then creating a layer above that to allow retrieval of attributes from the platform by attribute-category (as compared with database tables).
Question:
I have been digging through my Gang of Four book and other resources to find any sensible approaches that might be a starting point; also looking at information on Syntax Trees.
Before I find myself implementing "SQL for proprietary platform" I wanted to see if anyone has any advice, similar experience, resources, or other input on solutions to this problem. Any thoughts on implementation, available frameworks, CLI processing, or other resources would be appreciated.
It can't hurt to look at Sun/Oracle's guide For Driver Writers. Even if the JDBC API isn't a good fit, you'll end up inventing something similar. You may even be able to leverage some of the myriad existing JDBC tools.
I found what I was looking for after stumbling on a different question: ID 2068478 at
Query Object Pattern (Design Pattern), which lead me to the "Repository" pattern as well:
http://martinfowler.com/eaaCatalog/repository.html
There is an example of the Query Object Pattern using C# and a Syntax Tree here: http://www.lostechies.com/blogs/chad_myers/archive/2008/08/01/query-objects-with-the-repository-pattern.aspx
Note: I will attempt to update with an example if possible.
Thank you,
-bn
精彩评论