CHAPTER 11 REST-BASED MODEL VIEW CONTROLLER PATTERN (Com web hosting)
CHAPTER 11 REST-BASED MODEL VIEW CONTROLLER PATTERN The method assignParent is used to assign the parent controller with the local client. The association is needed when the local client generates a result and wants to pass the result to the controller, which then passes it to the client. The method getIdentifier is used by the implementation of the method Parent.processRequest( String type, Request request) to identify which Command instance is executed. Implementing the Search Abstractions The search engine local clients (Amazon.com and Google) implement two interfaces: Command and Runnable. The search engine local clients are managed by Parent using the Command interface, but Parent executes the local client by using the Runnable interface. The reason is that the controller executes each local client on its own thread. The reason for an individual thread will be discussed shortly. An example implementation of the Amazon.com search engine local client would be as follows (note that some details have been removed for clarity): public class AmazonSearchCommand implements Command, Runnable { private String _endpoint; private String _accessKey; private String _secretAccessKey; private Parent _parent; public void assignParent( Parent parent) { _parent = parent; } public AmazonSearchCommand( String endpoint, String accessKey, String secretAccessKey) { _endpoint = endpoint; _accessKey = accessKey; _secretAccessKey = secretAccessKey; } public String getIdentifier() { return “amazon”; } } The runmethod implementation has been removed and was already shown in the section Using Amazon.com to Search for Something. What has been kept are the details relating to the instantiating and configuring of the Amazon.com local client. The method getIdentifier is a hard-coded string that returns the identifier amazon. Normally, hard-coded strings are a bad idea, but because the Amazon.com local client is being referenced, the identifier is not going to change. Let s put it this way: you are not going to reference the Amazon.com local client as Google or Barnes & Noble. The identifier amazon is identical to the URL /search/impl/amazon. The same value is not a coincidence because when the /search/impl is retrieved, the generated links are generated by the controller that iterates the local clients, which in turn are queried by using the method getIdentifier. In the section Using Amazon.com to Search for Something, there were references to configuration items such as the access key. The configuration items are passed to the client using the constructor. The constructor was chosen so that under no circumstances can the
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.