1 21 22 package org.objectweb.jonas.webapp.jonasadmin.joramplatform; 23 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.util.Set ; 28 29 import javax.management.ObjectName ; 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.apache.struts.action.ActionForm; 34 import org.apache.struts.action.ActionForward; 35 import org.apache.struts.action.ActionMapping; 36 import org.objectweb.jonas.jmx.JonasManagementRepr; 37 import org.objectweb.jonas.jmx.JoramObjectName; 38 import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou; 39 40 43 44 public class EditJoramPlatformAction extends EditJoramBaseAction { 45 46 48 public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm 49 , HttpServletRequest pRequest, HttpServletResponse pResponse) { 50 51 m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR 53 + "joramplatform", true); 54 55 JoramPlatformForm oForm = new JoramPlatformForm(); 57 try { 58 ObjectName joramPlatformON = JoramObjectName.joramPlatform(); 60 ObjectName joramAdapterON = (ObjectName ) JonasManagementRepr.queryNames(JoramObjectName.joramAdapter()).iterator().next(); 61 boolean isAdapterLoaded = JonasManagementRepr.isRegistered(joramAdapterON); 62 Integer localServerIdValue = (Integer ) JonasManagementRepr.getAttribute(joramPlatformON, "LocalServerId"); 63 Iterator serverIdsList = ((List ) JonasManagementRepr.getAttribute(joramPlatformON, "ServersIds")).iterator(); 64 ArrayList serverIds = new ArrayList (); 65 int nbRemoteServers = 0; 66 for(; serverIdsList.hasNext(); ) { 67 Integer serverIdValue = (Integer ) serverIdsList.next(); 68 if (!serverIdValue.equals(localServerIdValue)) { 69 serverIds.add(serverIdValue.toString()); 70 nbRemoteServers++; 71 } 72 } 73 oForm.setAdapterLoaded(isAdapterLoaded); 74 oForm.setLocalServer(localServerIdValue.toString()); 75 String [] remoteServers = new String [nbRemoteServers]; 76 for (int i = 0; i < nbRemoteServers ; i++) { 77 remoteServers[i] = (String ) serverIds.get(i); 78 } 79 oForm.setRemoteServers(remoteServers); 80 oForm.setConfiguration((String ) JonasManagementRepr.getAttribute(joramPlatformON, "Configuration")); 81 oForm.setLocalPort(getIntegerAttribute(joramPlatformON, "LocalPort")); 82 oForm.setLocalHost(getStringAttribute(joramPlatformON, "LocalHost")); 83 oForm.setDefaultThreshold(getIntegerAttribute(joramPlatformON, "DefaultThreshold")); 84 if (isAdapterLoaded) { 85 oForm.setVersion(joramAdapterON.getKeyProperty("version")); 87 oForm.setCollocatedServer(getBooleanAttribute(joramAdapterON, "CollocatedServer")); 88 oForm.setConfigDir(getStringAttribute(joramAdapterON, "PlatformConfigDir")); 89 oForm.setAdminFile(getStringAttribute(joramAdapterON, "AdminFile")); 90 oForm.setPersistentServer(getBooleanAttribute(joramAdapterON, "PersistentPlatform")); 91 oForm.setServerIdTxt(toStringShortAttribute(joramAdapterON, "ServerId")); 92 oForm.setServerName(getStringAttribute(joramAdapterON, "ServerName")); 93 oForm.setHostName(getStringAttribute(joramAdapterON, "HostName")); 94 oForm.setServerPortTxt(toStringIntegerAttribute(joramAdapterON, "ServerPort")); 95 oForm.setCnxPendingTimerTxt(toStringIntegerAttribute(joramAdapterON, "CnxPendingTimer")); 96 oForm.setConnectingTimerTxt(toStringIntegerAttribute(joramAdapterON, "ConnectingTimer")); 97 oForm.setTxPendingTimerTxt(toStringIntegerAttribute(joramAdapterON, "TxPendingTimer")); 98 oForm.setTimeOutToAbortRequest(getLongAttribute(joramAdapterON, "TimeOutToAbortRequest")); 99 Object defaultDMQinstance = JonasManagementRepr.getAttribute(joramAdapterON, "DefaultDMQ"); 100 if (defaultDMQinstance != null) { 101 oForm.setDefaultDMQ(defaultDMQinstance.toString()); 102 } 103 } else { 104 ObjectName joramAdminON = JoramObjectName.joramAdmin(); 105 oForm.setTimeOutToAbortRequest(getLongAttribute(joramAdminON, "TimeOutToAbortRequest")); 106 oForm.setDefaultDMQ(JonasManagementRepr.getAttribute(joramAdminON, "DefaultDMQ").toString()); 107 } 108 m_Session.setAttribute("joramPlatformForm", oForm); 109 m_Session.setAttribute("localId", oForm.getLocalServer()); 110 } catch (Throwable t) { 111 return (treatError(t, pMapping, pRequest)); 112 } 113 114 return (pMapping.findForward("JoramPlatform")); 116 } 117 118 } 119 | Popular Tags |