KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > tiles > actions > ViewDefinitionsAction


1 /*
2  * $Id: ViewDefinitionsAction.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.tiles.actions;
21
22 import java.io.PrintWriter JavaDoc;
23
24 import javax.servlet.ServletContext JavaDoc;
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26 import javax.servlet.http.HttpServletResponse JavaDoc;
27
28 import org.apache.struts.action.Action;
29 import org.apache.struts.action.ActionForm;
30 import org.apache.struts.action.ActionForward;
31 import org.apache.struts.action.ActionMapping;
32 import org.apache.struts.tiles.DefinitionsFactory;
33 import org.apache.struts.tiles.TilesUtil;
34
35
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,
62                                  HttpServletRequest JavaDoc request,
63                                  HttpServletResponse JavaDoc response)
64         throws Exception JavaDoc
65     {
66         response.setContentType("text/plain");
67         PrintWriter JavaDoc writer = response.getWriter();
68
69         try {
70           ServletContext JavaDoc context = getServlet().getServletContext();
71             DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context );
72             writer.println( factory.toString() );
73         } catch (Exception JavaDoc e) {
74             writer.println("FAIL - " + e.toString());
75             getServlet().log("ReloadAction", e);
76         }
77
78         writer.flush();
79         writer.close();
80
81         return (null);
82
83     }
84
85 }
86
87
Popular Tags