001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 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: ApplyLocalDestinationAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.webapp.jonasadmin.joramplatform;
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.jmx.JoramObjectName;
039: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
040: import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
041:
042: /**
043: * @author Adriana Danes
044: * Creation of new destinations
045: */
046:
047: public class ApplyLocalDestinationAction extends BaseDeployAction {
048:
049: // --------------------------------------------------------- Public Methods
050:
051: public ActionForward executeAction(ActionMapping p_Mapping,
052: ActionForm p_Form, HttpServletRequest p_Request,
053: HttpServletResponse p_Response) throws IOException,
054: ServletException {
055:
056: // Current JOnAS server
057: String jonasServerName = m_WhereAreYou
058: .getCurrentJonasServerName();
059:
060: // Form used
061: JoramDestinationForm oForm = (JoramDestinationForm) p_Form;
062:
063: try {
064: ObjectName oObjectName;
065: ObjectName joramAdapterON = (ObjectName) JonasManagementRepr
066: .queryNames(JoramObjectName.joramAdapter(),
067: jonasServerName).iterator().next();
068: if (JonasManagementRepr.isRegistered(joramAdapterON,
069: jonasServerName)) {
070: oObjectName = joramAdapterON;
071: } else {
072: oObjectName = JoramObjectName.joramAdmin();
073: }
074:
075: String[] asParam = { oForm.getName() };
076: String[] asSignature = { "java.lang.String" };
077: String type = oForm.getType();
078: if (type
079: .equals(m_Resources
080: .getMessage("label.joramplatform.destinations.queue"))) {
081: JonasManagementRepr.invoke(oObjectName, "createQueue",
082: asParam, asSignature, jonasServerName);
083: } else if (type
084: .equals(m_Resources
085: .getMessage("label.joramplatform.destinations.topic"))) {
086: JonasManagementRepr.invoke(oObjectName, "createTopic",
087: asParam, asSignature, jonasServerName);
088: }
089: // refresh tree
090: refreshJoramTree(p_Request, (String) m_Session
091: .getAttribute("currentId"));
092:
093: oForm.reset(p_Mapping, p_Request);
094:
095: } catch (Throwable t) {
096: addGlobalError(t);
097: saveErrors(p_Request, m_Errors);
098: return (p_Mapping.findForward("Global Error"));
099: }
100:
101: // Forward to the jsp.
102: return (p_Mapping.findForward("ActionEditJoramServer"));
103: }
104: }
|