1 12 13 package org.ejtools.jmx.browser.web.action; 14 15 16 17 import java.io.IOException ; 18 19 import java.util.Locale ; 20 21 22 23 import javax.servlet.ServletContext ; 24 25 import javax.servlet.ServletException ; 26 27 import javax.servlet.http.HttpServletRequest ; 28 29 import javax.servlet.http.HttpServletResponse ; 30 31 32 33 import org.apache.log4j.Logger; 34 35 import org.apache.struts.action.Action; 36 37 import org.apache.struts.action.ActionErrors; 38 39 import org.apache.struts.action.ActionForm; 40 41 import org.apache.struts.action.ActionForward; 42 43 import org.apache.struts.action.ActionMapping; 44 45 import org.apache.struts.util.MessageResources; 46 47 import org.ejtools.jmx.browser.web.Constants; 48 49 import org.ejtools.jmx.browser.web.JMXContainer; 50 51 52 53 68 69 public class RefreshAction extends Action 70 71 { 72 73 74 75 private static Logger logger = Logger.getLogger(RefreshAction.class); 76 77 78 79 80 81 82 83 public RefreshAction() { } 84 85 86 87 88 89 110 111 public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 112 113 throws IOException , ServletException 114 115 { 116 117 JMXContainer tree = null; 118 119 120 121 123 Locale locale = getLocale(request); 124 125 MessageResources messages = getResources(); 126 127 128 129 131 ActionErrors errors = new ActionErrors(); 132 133 134 135 logger.debug("Connecting to JMX Server"); 136 137 138 139 ServletContext context = this.getServlet().getServletContext(); 140 141 tree = (JMXContainer) context.getAttribute(Constants.TREE); 142 143 144 145 if (tree == null) 146 147 { 148 149 tree = new JMXContainer(); 150 151 context.setAttribute(Constants.TREE, tree); 152 153 } 154 155 156 157 tree.refresh(); 158 159 160 161 163 if (!errors.empty()) 164 165 { 166 167 saveErrors(request, errors); 168 169 return (mapping.findForward("home")); 170 171 } 172 173 174 175 return (mapping.findForward("view")); 176 177 } 178 179 } 180 181 182 183 | Popular Tags |