Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Integrating with custom asynchronous backend

$
0
0
We have a very strange back office that is completly non standard (Does not use websservices/rest) and uses propietary protocols and such. The one API that we use to interact with this back end is based on listeners/callbacks in java. We do not have any way to communicate with this backend via javascript, only java.

What I am trying to do is something similar to this article:
http://gillius.org/blog/2012/11/adapting-smartclient-datasource-to-requestfactory.html

With the normal datasource and basicdatasource it seems to me that it is assumed that the responses from whatever backend server you have will be synchronous. I say this because the executeFetch has the following method signature:

Code:

public DSResponse executeFetch(DSRequest req)
Its expecting me to return a DSResponse as the result of the fetch. Problem is my implementing code inside executeFetch looks as follows:

Code:

@Override
public DSResponse executeFetch(DSRequest req)  {
        Map criteria = req.getCriteria();
        DSResponse fetchResponse = new DSResponse();
        final String instrumentCode = (String) criteria.get("CODE");
        final String request = (String) criteria.get("REQUEST");

        if (request.equalsIgnoreCase("directorsList")) {
                DirectorDAO directorDAO = new DirectorDAO(INetSecurityContext.getReqManager());

                directorDAO.companyDirectorListRequest(instrumentCode, false, new ResponseCallback<List<DirectorRecord>>() {
                        @Override
                        public void response(List<DirectorRecord> directorList) {
                                //This is where I get my async response back. By this time executeFetch has already finished.
                                //NOTE: Would really prefer not to use CountDownLatch to make executeFetch wait for the response. (Although we do use it in unit testing)
                        }
                });
        }               
}


Am I going about this all wrong, or is there a more elegant solution like the one in the link that I posted that I am simply missing.
Thanks in Advance.

Viewing all articles
Browse latest Browse all 4756

Trending Articles