CHAPTER 11 REST-BASED MODEL VIEW CONTROLLER PATTERN (Web site management)
CHAPTER 11 REST-BASED MODEL VIEW CONTROLLER PATTERN 367 Processing a Request The class PermutationsServlet is implemented as an abstract class that requires another class to subclass PermutationsServlet. The goal is to require a class to subclass PermutationsServlet and associate with PermutationsServlet the representations that can process requests. Following is the example implementation for the SynchronousServlet class: public class SynchronousServlet extends PermutationsServlet { public void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException { SearchBuilder.assignConfiguration( config.getInitParameter( “amazon-endpoint”), config.getInitParameter( “amazon-access-key”), config.getInitParameter( “amazon-secret-key”), config.getInitParameter( “google-endpoint”), config.getInitParameter( “google-access-key”)); addRepresentation( new XMLContent()); addRepresentation( new OtherContent()); } } The implementation of the SynchronousServlet class requires the implementation of only the method init. The method init would like AsynchronousServlet to retrieve the configuration information from a web application configuration file. The methods addRepresentation instantiate two types, XMLContentand OtherContent, that are used to generate content as either XML or the default HTML content. What is interesting is that the implementations of the classes XMLContentand OtherContent are very similar to the AsynchronousServlet implementation. The major difference is that SynchronousParent is used instead of AsynchronousParent. Because the similarities are so great, an argument could made that the synchronous and asynchronous functionality should have been combined into a single implementation. The fact is that it probably could have been done, but was not done so that I could illustrate the thinking required to implement either a synchronous or asynchronous interface. Pattern Highlights In conclusion, the REST-Based Model View Controller pattern is an example pattern for which it is more important to understand the details of the architecture than the example implementation. As much as I would like to say that the example implementation should always be used, it is not possible. The reason why I say that every REST-Based Model View Controller is a custom implementation is due to the nature of remote servers defining the model. Maybe it is necessary to call only a single remote server. Or maybe you first call one remote server and then call another remote server. Those details will change how the local client is implemented, and potentially how the controller interacts with the local client.
We recommend high quality webhost to host and run your jsp application: christian web host services.