1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts.tiles.actions;
24
25 import java.io.PrintWriter;
26
27 import jakarta.servlet.ServletContext;
28 import jakarta.servlet.http.HttpServletRequest;
29 import jakarta.servlet.http.HttpServletResponse;
30
31 import org.apache.struts.action.Action;
32 import org.apache.struts.action.ActionForm;
33 import org.apache.struts.action.ActionForward;
34 import org.apache.struts.action.ActionMapping;
35 import org.apache.struts.tiles.DefinitionsFactory;
36 import org.apache.struts.tiles.DefinitionsFactoryException;
37 import org.apache.struts.tiles.TilesUtil;
38
39
40
41
42
43
44
45
46
47
48
49
50 public class ReloadDefinitionsAction extends Action {
51 private static final long serialVersionUID = -7047330717130537765L;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 public ActionForward execute(ActionMapping mapping,
68 ActionForm form,
69 HttpServletRequest request,
70 HttpServletResponse response)
71 throws Exception
72 {
73 response.setContentType("text/plain");
74 PrintWriter writer = response.getWriter();
75
76 try {
77 ServletContext context = getServlet().getServletContext();
78 DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context);
79 factory.setConfig(factory.getConfig(), context);
80 writer.println("OK");
81 } catch (ClassCastException e) {
82 writer.println("FAIL - " + e.toString());
83 getServlet().log("ReloadAction", e);
84 } catch (DefinitionsFactoryException e) {
85 writer.println("FAIL - " + e.toString());
86 getServlet().log("ReloadAction", e);
87 }
88
89 writer.flush();
90
91 return (null);
92 }
93 }