KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > joramplatform > EditJoramPlatformAction


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  */

21
22 package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
23
24 import java.util.ArrayList JavaDoc;
25 import java.util.Iterator JavaDoc;
26 import java.util.List JavaDoc;
27 import java.util.Set JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30 import javax.servlet.http.HttpServletRequest JavaDoc;
31 import javax.servlet.http.HttpServletResponse JavaDoc;
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 /**
41  * @author Frederic MAISTRE
42  */

43
44 public class EditJoramPlatformAction extends EditJoramBaseAction {
45
46 // --------------------------------------------------------- Public Methods
47

48     public ActionForward executeAction(ActionMapping pMapping, ActionForm pForm
49         , HttpServletRequest JavaDoc pRequest, HttpServletResponse JavaDoc pResponse) {
50
51         // Force the node selected in tree
52
m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_DOMAIN) + WhereAreYou.NODE_SEPARATOR
53             + "joramplatform", true);
54
55         // Form used
56
JoramPlatformForm oForm = new JoramPlatformForm();
57         try {
58             // Object name used
59
ObjectName JavaDoc joramPlatformON = JoramObjectName.joramPlatform();
60             ObjectName JavaDoc joramAdapterON = (ObjectName JavaDoc) JonasManagementRepr.queryNames(JoramObjectName.joramAdapter()).iterator().next();
61             boolean isAdapterLoaded = JonasManagementRepr.isRegistered(joramAdapterON);
62             Integer JavaDoc localServerIdValue = (Integer JavaDoc) JonasManagementRepr.getAttribute(joramPlatformON, "LocalServerId");
63             Iterator JavaDoc serverIdsList = ((List JavaDoc) JonasManagementRepr.getAttribute(joramPlatformON, "ServersIds")).iterator();
64             ArrayList JavaDoc serverIds = new ArrayList JavaDoc();
65             int nbRemoteServers = 0;
66             for(; serverIdsList.hasNext(); ) {
67                 Integer JavaDoc serverIdValue = (Integer JavaDoc) 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 JavaDoc[] remoteServers = new String JavaDoc[nbRemoteServers];
76             for (int i = 0; i < nbRemoteServers ; i++) {
77                 remoteServers[i] = (String JavaDoc) serverIds.get(i);
78             }
79             oForm.setRemoteServers(remoteServers);
80             oForm.setConfiguration((String JavaDoc) 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                 // Get configuration info from RA
86
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 JavaDoc defaultDMQinstance = JonasManagementRepr.getAttribute(joramAdapterON, "DefaultDMQ");
100                 if (defaultDMQinstance != null) {
101                     oForm.setDefaultDMQ(defaultDMQinstance.toString());
102                 }
103             } else {
104                 ObjectName JavaDoc 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 JavaDoc t) {
111             return (treatError(t, pMapping, pRequest));
112         }
113
114         // Forward to the jsp.
115
return (pMapping.findForward("JoramPlatform"));
116     }
117
118 }
119
Popular Tags