1 25 26 package org.objectweb.jonas.webapp.jonasadmin.catalina; 27 28 import java.io.IOException ; 29 30 import javax.management.ObjectName ; 31 import javax.servlet.ServletException ; 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import org.apache.struts.action.ActionMessage; 36 import org.apache.struts.action.ActionForm; 37 import org.apache.struts.action.ActionForward; 38 import org.apache.struts.action.ActionMapping; 39 import org.objectweb.jonas.jmx.JonasManagementRepr; 40 import org.objectweb.jonas.jmx.JonasObjectName; 41 import org.objectweb.jonas.jmx.CatalinaObjectName; 42 import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx; 43 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 44 45 51 public class ApplyConnectorAction extends CatalinaBaseAction { 52 53 56 private String [] saCreateStandardConnectorTypes = { 57 "java.lang.String", "java.lang.String", "int" }; 59 60 62 public ActionForward executeAction(ActionMapping p_Mapping, ActionForm p_Form 63 , HttpServletRequest p_Request, HttpServletResponse p_Response) 64 throws IOException , ServletException { 65 String sForward = "Catalina Connector"; 67 ConnectorForm oForm = (ConnectorForm) p_Form; 69 String sAction = oForm.getAction(); 70 String sObjectName = oForm.getObjectName(); 71 String sConnectorType = oForm.getConnectorType(); 72 73 try { 75 if ("create".equals(sAction)) { 77 String address = oForm.getAddress(); 79 ObjectName onConnector = CatalinaObjectName.catalinaConnector( 81 m_WhereAreYou.getCurrentCatalinaDomainName(), 82 oForm.getPortText()); 83 if (JonasAdminJmx.hasMBeanName(onConnector) == true) { 84 m_Errors.add("connector", new ActionMessage("error.catalina.connector.exists")); 85 saveErrors(p_Request, m_Errors); 86 return (new ActionForward(p_Mapping.getInput())); 87 } 88 89 ObjectName onConnectorFactory = JonasObjectName.catalinaConnectorFactory( 91 m_WhereAreYou.getCurrentDomainName()); 92 Object values[] = new Object [3]; 93 values[0] = sConnectorType; 94 values[1] = address; 95 values[2] = new Integer (oForm.getPortText()); 96 String operation = "createConnector"; 97 sObjectName = (String ) JonasManagementRepr.invoke(onConnectorFactory, operation, values 98 , saCreateStandardConnectorTypes); 99 100 121 if (sObjectName == null) { 122 saveErrors(p_Request, m_Errors); 123 return (p_Mapping.findForward("Global Error")); 124 } 125 refreshTree(p_Request); 127 String nodeName = getTreeBranchName(DEPTH_SERVER) 129 + WhereAreYou.NODE_SEPARATOR + "protocols" 130 + WhereAreYou.NODE_SEPARATOR + "connectors" 131 + WhereAreYou.NODE_SEPARATOR + oForm.getPortText(); 133 if (address != null) { 134 nodeName = nodeName 135 + WhereAreYou.NODE_SEPARATOR + address; 136 } 137 m_WhereAreYou.selectNameNode(nodeName, true); 138 139 } 140 141 ObjectName oObjectName = new ObjectName (sObjectName); 142 143 setIntegerAttribute(oObjectName, "debug", oForm.getDebugLvl()); 144 setIntegerAttribute(oObjectName, "acceptCount", oForm.getAcceptCountText()); 145 setIntegerAttribute(oObjectName, "connectionTimeout", oForm.getConnTimeOutText()); 146 setIntegerAttribute(oObjectName, "bufferSize", oForm.getBufferSizeText()); 147 setBooleanAttribute(oObjectName, "enableLookups", oForm.isEnableLookups()); 148 setIntegerAttribute(oObjectName, "redirectPort", oForm.getRedirectPortText()); 149 setIntegerAttribute(oObjectName, "maxProcessors", oForm.getMaxThreadsText()); 150 setIntegerAttribute(oObjectName, "minProcessors", oForm.getMinSpareThreadsText()); 151 setIntegerAttribute(oObjectName, "maxSpareThreads", oForm.getMaxSpareThreadsText()); 152 153 if ("AJP".equalsIgnoreCase(sConnectorType) == false) { 155 setStringAttribute(oObjectName, "proxyName", oForm.getProxyName()); 156 setIntegerAttribute(oObjectName, "proxyPort", oForm.getProxyPortText()); 157 } 158 159 if ("HTTPS".equalsIgnoreCase(sConnectorType) == true) { 161 setBooleanAttribute(oObjectName, "clientAuth", oForm.isClientAuth()); 162 setStringAttribute(oObjectName, "keystoreFile", oForm.getKeystoreFile()); 163 setStringAttribute(oObjectName, "keystorePass", oForm.getKeystorePass()); 164 } 165 166 if ("create".equals(sAction) == true) { 167 m_Session.removeAttribute(p_Mapping.getAttribute()); 168 sForward = "ActionListCatalinaConnectors"; 169 } 170 171 if (oForm.isSave() == true) { 173 oForm.setSave(false); 174 p_Request.setAttribute("forward", sForward); 175 sForward = "ActionEditServletServer"; 176 } 179 } catch (Throwable t) { 180 addGlobalError(t); 181 saveErrors(p_Request, m_Errors); 182 return (p_Mapping.findForward("Global Error")); 183 } 184 185 return p_Mapping.findForward(sForward); 187 } 188 } 189 | Popular Tags |