001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: ApplyJonasServerAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.domain;
025:
026: import java.io.IOException;
027:
028: import javax.management.ObjectName;
029: import javax.servlet.ServletException;
030: import javax.servlet.http.HttpServletRequest;
031: import javax.servlet.http.HttpServletResponse;
032:
033: import org.apache.struts.action.ActionForm;
034: import org.apache.struts.action.ActionForward;
035: import org.apache.struts.action.ActionMapping;
036: import org.objectweb.jonas.jmx.JonasManagementRepr;
037: import org.objectweb.jonas.jmx.JonasObjectName;
038: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
039:
040: /**
041: * This action is called when confirming a server add the domain.
042: * @author Adriana Danes
043: */
044: public class ApplyJonasServerAction extends JonasBaseAction {
045:
046: // --------------------------------------------------------- Public Methods
047: public ActionForward executeAction(ActionMapping p_Mapping,
048: ActionForm p_Form, HttpServletRequest p_Request,
049: HttpServletResponse p_Response) throws IOException,
050: ServletException {
051: String currentServerName = m_WhereAreYou
052: .getCurrentJonasServerName();
053: // Form used
054: NewServerForm oForm = (NewServerForm) p_Form;
055: // Server to add
056: String serverName = null;
057: String serverURL = null;
058: String clusterDaemon = null;
059: String[] selecetedServerNames = null;
060: //
061: boolean isCluster = oForm.isCluster();
062: if (isCluster) {
063: selecetedServerNames = oForm.getSelectedItems();
064: } else {
065: // Server to add - name, connection URL, cluster daemon
066: serverName = oForm.getServerName();
067: serverURL = oForm.getServerURL();
068: clusterDaemon = oForm.getServerCld();
069: }
070: // Reset form
071: oForm.reset(p_Mapping, p_Request);
072:
073: String clusterName = (String) m_Session
074: .getAttribute("currentCluster");
075: String clusterType = "LogicalCluster";
076: try {
077: ObjectName on = JonasObjectName.cluster(clusterName,
078: clusterType);
079: String[] signature = { "java.lang.String",
080: "[Ljava.lang.String;", "java.lang.String" };
081: Object[] params = new Object[3];
082: if (serverName != null) {
083: params[0] = serverName;
084: String[] urls = { serverURL };
085: params[1] = urls;
086: params[2] = clusterDaemon;
087: JonasManagementRepr.invoke(on, "addServer", params,
088: signature, currentServerName);
089: } else {
090: params[1] = null;
091: params[2] = null;
092: for (int i = 0; i < selecetedServerNames.length; i++) {
093: params[0] = selecetedServerNames[i];
094: JonasManagementRepr.invoke(on, "addServer", params,
095: signature, currentServerName);
096: }
097: }
098: m_Session.setAttribute("mapChanged", new Boolean(true));
099: } catch (Throwable t) {
100: addGlobalError(t);
101: saveErrors(p_Request, m_Errors);
102: return (p_Mapping.findForward("Global Error"));
103: }
104: // Forward to the connector display page or the list if create
105: return p_Mapping.findForward("ActionEditDomain");
106: }
107: }
|