View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // RequestHandlerBase.java
20  // Since: 2007/11/27
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.server;
26  
27  import java.io.IOException;
28  
29  import javax.servlet.ServletException;
30  import javax.servlet.http.HttpServlet;
31  import javax.servlet.http.HttpServletRequest;
32  import javax.servlet.http.HttpServletResponse;
33  
34  import org.utgenome.UTGBException;
35  
36  /**
37   * Abstract base implementation of the {@link RequestHandler}
38   * 
39   * @author leo
40   * 
41   */
42  public abstract class RequestHandlerBase extends HttpServlet implements RequestHandler {
43  	/**
44  	 * 
45  	 */
46  	private static final long serialVersionUID = 1L;
47  
48  	public abstract void handle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException;
49  
50  	public void validate(HttpServletRequest request, HttpServletResponse response) throws ServletException, UTGBException {
51  		// do nothing in default
52  	}
53  
54  	@Override
55  	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
56  		RequestDispatcher.setRequestParametersToHandler(this, req);
57  		this.handle(req, resp);
58  	}
59  
60  	@Override
61  	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
62  		this.doGet(req, resp);
63  	}
64  
65  }