-
Notifications
You must be signed in to change notification settings - Fork 210
Architecture: Manager
- Architectural overview
- Manager
- Parameters
- Widgets
The Manager takes as a parameter either solrUrl – if talking to Solr directly – or proxyUrl – if talking to Solr through a proxy. (Usually, you want to talk to the instance through a proxy, so as not to expose the Solr instance to the Internet.) solrUrl must be the absolute URL to the Solr application.
Manager = new AjaxSolr.Manager({ solrUrl: 'http://evolvingweb.ca/solr/reuters/' });
If you are talking to Solr directly, AJAX Solr will by default use the select servlet. You can change the default servlet by passing the parameter servlet to the Manager during initialization. A widget may still use a different servlet by passing the name of the servlet as a second parameter to doRequest.
Manager = new AjaxSolr.Manager({ solrUrl: 'http://evolvingweb.ca/solr/reuters/', servlet: 'readonly' });
The default servlet or the proxy should modify Solr parameters to prevent DOS attacks (by restricting rows to a reasonable maximum) and prevent the release of sensitive data (if Solr stores sensitive data).
The ParameterStore and the widgets attach themselves to the Manager with the setStore and addWidget methods, respectively. The Manager is, effectively, a container for all AJAX Solr object instances.
Manager.setStore(new AjaxSolr.ParameterStore());
Manager.addWidget(new AjaxSolr.AbstractWidget({ id: 'identifier', target: '#css-selector' }));
Once these are attached, the Manager’s init method is typically called, to initialize AJAX Solr. This method calls the init methods of the ParameterStore and widgets:
Manager.init();
Having initialized AJAX Solr, the Manager’s doRequest method is typically called, to send the first request to Solr:
Manager.doRequest();
doRequest calls each widget’s beforeRequest method, in case any widget wants to perform some action before the request is sent to Solr, e.g. display a throbber. It then calls the executeRequest abstract method to send the request.
AJAX Solr is JavaScript framework-agnostic; it only requires an AJAX implementation to send requests to Solr. AJAX Solr is distributed with a Manager.jquery.js file, which implements the executeRequest method using jQuery.
Once the Manager receives a response from Solr, it caches the JSON response in its response property, and calls each widget’s afterRequest method, in which widgets will inspect the response property and update the interface accordingly.
Note that all the above code should only be run once the DOM is ready.