01: /*
02: * $Id: ViewDefinitionsAction.java 471754 2006-11-06 14:55:09Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21:
22: package org.apache.struts.tiles.actions;
23:
24: import java.io.PrintWriter;
25:
26: import javax.servlet.ServletContext;
27: import javax.servlet.http.HttpServletRequest;
28: import javax.servlet.http.HttpServletResponse;
29:
30: import org.apache.struts.action.Action;
31: import org.apache.struts.action.ActionForm;
32: import org.apache.struts.action.ActionForward;
33: import org.apache.struts.action.ActionMapping;
34: import org.apache.struts.tiles.DefinitionsFactory;
35: import org.apache.struts.tiles.TilesUtil;
36:
37: /**
38: * <p>An <strong>Action</strong> that writes the
39: * definitions of the Tiles factory.
40: * Useful to check what is effectivly loaded in a
41: * Tiles factory
42: */
43:
44: public class ViewDefinitionsAction extends Action {
45:
46: /**
47: * Process the specified HTTP request, and create the corresponding HTTP
48: * response (or forward to another web component that will create it),
49: * with provision for handling exceptions thrown by the business logic.
50: *
51: * @param mapping The ActionMapping used to select this instance
52: * @param form The optional ActionForm bean for this request (if any)
53: * @param request The HTTP request we are processing
54: * @param response The HTTP response we are creating
55: *
56: * @exception Exception if the application business logic throws
57: * an exception
58: * @since Struts 1.1
59: */
60: public ActionForward execute(ActionMapping mapping,
61: ActionForm form, HttpServletRequest request,
62: HttpServletResponse response) throws Exception {
63: response.setContentType("text/plain");
64: PrintWriter writer = response.getWriter();
65:
66: try {
67: ServletContext context = getServlet().getServletContext();
68: DefinitionsFactory factory = TilesUtil
69: .getDefinitionsFactory(request, context);
70: writer.println(factory.toString());
71: } catch (Exception e) {
72: writer.println("FAIL - " + e.toString());
73: getServlet().log("ReloadAction", e);
74: }
75:
76: writer.flush();
77: writer.close();
78:
79: return (null);
80:
81: }
82:
83: }
|