1 18 19 20 package org.apache.struts.tiles.actions; 21 22 import java.io.PrintWriter ; 23 24 import javax.servlet.ServletContext ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 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.DefinitionsFactoryException; 34 import org.apache.struts.tiles.TilesUtil; 35 36 37 38 46 47 public class ReloadDefinitionsAction extends Action { 48 49 63 public ActionForward execute(ActionMapping mapping, 64 ActionForm form, 65 HttpServletRequest request, 66 HttpServletResponse response) 67 throws Exception 68 { 69 response.setContentType("text/plain"); 70 PrintWriter writer = response.getWriter(); 71 72 try { 73 ServletContext context = getServlet().getServletContext(); 74 DefinitionsFactory factory = TilesUtil.getDefinitionsFactory(request, context); 75 factory.setConfig(factory.getConfig(), context); 76 writer.println("OK"); 77 } catch (ClassCastException e) { 78 writer.println("FAIL - " + e.toString()); 79 getServlet().log("ReloadAction", e); 80 } catch (DefinitionsFactoryException e) { 81 writer.println("FAIL - " + e.toString()); 82 getServlet().log("ReloadAction", e); 83 } 84 85 writer.flush(); 86 writer.close(); 87 88 return (null); 89 90 } 91 92 } 93 94 | Popular Tags |