001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2006 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: * $Id: $
022: * --------------------------------------------------------------------------
023: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
024:
025: import java.io.IOException;
026: import java.util.Set;
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.JoramObjectName;
038:
039: /**
040: * @author Yannick braeuner
041: */
042:
043: public class ReloadJoramAdmin extends EditJoramBaseAction {
044:
045: /**
046: * Process the specified HTTP request, and create the corresponding HTTP
047: * response (or forward to another web component that will create it).
048: * Return an <code>ActionForward</code> instance describing where and how
049: * control should be forwarded, or <code>null</code> if the response has
050: * already been completed.
051: *
052: * @param p_Mapping The ActionMapping used to select this instance
053: * @param p_Form The optional ActionForm bean for this request (if any)
054: * @param p_Request The HTTP request we are processing
055: * @param p_Response The HTTP response we are creating
056: *
057: * @return An <code>ActionForward</code> instance or <code>null</code>
058: *
059: * @exception IOException if an input/output error occurs
060: * @exception ServletException if a servlet exception occurs
061: */
062:
063: public ActionForward executeAction(ActionMapping p_Mapping,
064: ActionForm p_Form, HttpServletRequest p_Request,
065: HttpServletResponse p_Response) throws IOException,
066: ServletException {
067:
068: // Current JOnAS server
069: String jonasServerName = m_WhereAreYou
070: .getCurrentJonasServerName();
071:
072: try {
073: // Object name use
074: Set adapterOns = JonasManagementRepr.queryNames(
075: JoramObjectName.joramAdapter(), jonasServerName);
076: if (adapterOns.isEmpty()) {
077: throw new Exception("No JORAM server available");
078: }
079: ObjectName joramPlatformOn = (ObjectName) adapterOns
080: .iterator().next();
081: // Call method
082: String[] params = new String[1];
083: params[0] = getPathToReloadJoramAdmin() + "/joramAdmin.xml";
084: String[] signature = { "java.lang.String" };
085: JonasManagementRepr.invoke(joramPlatformOn,
086: "executeXMLAdminJMX", params, signature,
087: jonasServerName);
088: // Get the right local Joram id from the server
089: String localJoramServerId = (String) p_Request.getSession()
090: .getAttribute("localId");
091: // Refresh the Joram tree from the joram id server
092: refreshJoramTree(p_Request, localJoramServerId);
093: } catch (Throwable t) {
094: addGlobalError(t);
095: saveErrors(p_Request, m_Errors);
096: return (p_Mapping.findForward("Global Error"));
097: }
098:
099: // Forward to the jsp.
100: return (p_Mapping.findForward("JoramPlatform"));
101: }
102: }
|