1 16 17 package org.apache.webapp.admin.host; 18 19 import java.io.IOException ; 20 import java.util.Locale ; 21 import java.util.Arrays ; 22 import java.util.ArrayList ; 23 import javax.servlet.ServletException ; 24 import javax.management.MBeanServer ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 import javax.servlet.http.HttpSession ; 28 import org.apache.struts.action.Action; 29 import org.apache.struts.action.ActionErrors; 30 import org.apache.struts.action.ActionForm; 31 import org.apache.struts.action.ActionForward; 32 import org.apache.struts.action.ActionMapping; 33 import org.apache.struts.util.MessageResources; 34 import org.apache.webapp.admin.ApplicationServlet; 35 import org.apache.webapp.admin.LabelValueBean; 36 import org.apache.webapp.admin.Lists; 37 import javax.management.ObjectName ; 38 39 45 46 public class AddAliasAction extends Action { 47 48 51 private MBeanServer mBServer = null; 52 53 55 70 public ActionForward execute(ActionMapping mapping, 71 ActionForm form, 72 HttpServletRequest request, 73 HttpServletResponse response) 74 throws IOException , ServletException { 75 76 HttpSession session = request.getSession(); 78 Locale locale = getLocale(request); 79 MessageResources resources = getResources(request); 80 81 try { 83 mBServer = ((ApplicationServlet) getServlet()).getServer(); 84 } catch (Throwable t) { 85 throw new ServletException 86 ("Cannot acquire MBeanServer reference", t); 87 } 88 89 90 String hostName = request.getParameter("hostName"); 93 AliasForm aliasFm = new AliasForm(); 95 session.setAttribute("aliasForm", aliasFm); 96 97 String operation = null; 99 try { 100 ObjectName hname = new ObjectName (hostName); 101 102 operation = "findAliases"; 103 String aliases[] = 104 (String []) mBServer.invoke(hname, operation, null, null); 105 106 aliasFm.setAliasVals(new ArrayList (Arrays.asList(aliases))); 107 108 } catch (Throwable t) { 109 getServlet().log 110 (resources.getMessage(locale, "users.error.invoke", 111 operation), t); 112 response.sendError 113 (HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 114 resources.getMessage(locale, "users.error.invoke", 115 operation)); 116 return (null); 117 } 118 119 aliasFm.setAliasName(""); 120 aliasFm.setHostName(hostName); 121 122 return (mapping.findForward("Alias")); 124 125 } 126 127 } 128 | Popular Tags |