1 16 17 18 package org.apache.webapp.admin.host; 19 20 import java.io.IOException ; 21 import java.util.Collections ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 import java.util.Arrays ; 25 import java.util.Locale ; 26 import java.util.TreeSet ; 27 import java.util.Set ; 28 import java.util.ArrayList ; 29 import javax.servlet.ServletException ; 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 import javax.servlet.http.HttpSession ; 33 import org.apache.struts.action.Action; 34 import org.apache.struts.action.ActionErrors; 35 import org.apache.struts.action.ActionForm; 36 import org.apache.struts.action.ActionForward; 37 import org.apache.struts.action.ActionMapping; 38 39 import javax.management.MBeanServer ; 40 import javax.management.MBeanServerFactory ; 41 import javax.management.QueryExp ; 42 import javax.management.Query ; 43 import javax.management.ObjectInstance ; 44 import javax.management.ObjectName ; 45 import javax.management.JMException ; 46 import org.apache.struts.util.MessageResources; 47 48 import org.apache.webapp.admin.ApplicationServlet; 49 import org.apache.webapp.admin.TomcatTreeBuilder; 50 51 57 58 public class DeleteAliasAction extends Action { 59 60 61 64 private MBeanServer mBServer = null; 65 66 67 69 84 public ActionForward execute(ActionMapping mapping, 85 ActionForm form, 86 HttpServletRequest request, 87 HttpServletResponse response) 88 throws IOException , ServletException { 89 90 91 HttpSession session = request.getSession(); 93 Locale locale = getLocale(request); 94 MessageResources resources = getResources(request); 95 96 try { 98 mBServer = ((ApplicationServlet) getServlet()).getServer(); 99 } catch (Throwable t) { 100 throw new ServletException 101 ("Cannot acquire MBeanServer reference", t); 102 } 103 104 AliasesForm aliasesFm = new AliasesForm(); 107 ArrayList aliasesList = null; 108 109 String hostName = request.getParameter("hostName"); 110 aliasesFm.setHostName(hostName); 111 112 String operation = null; 114 try { 115 ObjectName hname = new ObjectName (hostName); 116 117 operation = "findAliases"; 118 String aliases[] = 119 (String []) mBServer.invoke(hname, operation, null, null); 120 aliasesFm.setAliases(aliases); 121 aliasesList = new ArrayList (Arrays.asList(aliases)); 122 123 } catch (Throwable t) { 124 getServlet().log 125 (resources.getMessage(locale, "users.error.invoke", 126 operation), t); 127 response.sendError 128 (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 129 resources.getMessage(locale, "users.error.invoke", 130 operation)); 131 return (null); 132 } 133 134 Collections.sort(aliasesList); 135 request.setAttribute("aliasesForm", aliasesFm); 136 request.setAttribute("aliasesList", aliasesList); 137 138 return (mapping.findForward("Aliases")); 140 141 } 142 143 } 144 | Popular Tags |