01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jmx.adaptor.http;
09:
10: import org.apache.velocity.VelocityContext;
11:
12: /**
13: *
14: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
15: */
16:
17: public abstract class AbstractCommand implements Command {
18:
19: protected VelocityContext ctx = new VelocityContext();
20:
21: public VelocityContext execute(HttpRequest request,
22: HttpResponse response) throws Exception {
23: if (request.getParameter("done") == null
24: || !(request.getParameter("done")
25: .equalsIgnoreCase("true"))) {
26: doGet(request, response);
27: } else {
28: doPost(request, response);
29: }
30: return ctx;
31: }
32:
33: /**
34: * set the VelocityContext
35: */
36: public abstract void doGet(HttpRequest request,
37: HttpResponse response) throws Exception;
38:
39: public void doPost(HttpRequest request, HttpResponse response)
40: throws Exception {
41:
42: }
43:
44: public String getTemplateName() {
45: String classname = this .getClass().getName();
46: String templateName = classname.substring(classname
47: .lastIndexOf(".") + 1, classname.length() - 7);
48: // System.out.println(templateName);
49: return templateName.toLowerCase();
50: }
51: }
|