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: PresentConnectionFactoryAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.jms;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030: import java.util.Collections;
031:
032: import javax.management.ObjectName;
033: import javax.servlet.ServletException;
034: import javax.servlet.http.HttpServletRequest;
035: import javax.servlet.http.HttpServletResponse;
036:
037: import org.apache.struts.action.ActionForm;
038: import org.apache.struts.action.ActionForward;
039: import org.apache.struts.action.ActionMapping;
040: import org.objectweb.jonas.jmx.JonasManagementRepr;
041: import org.objectweb.jonas.jmx.JonasObjectName;
042: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
043: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
044: import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItem;
045: import org.objectweb.jonas.webapp.jonasadmin.service.ejb.EjbItemByNameComparator;
046:
047: /**
048: * Action presenting a given JMS Connection Factory's attributes.
049: * @author Adriana Danes
050: */
051: public class PresentConnectionFactoryAction extends JonasBaseAction {
052: /**
053: */
054: public ActionForward executeAction(ActionMapping p_Mapping,
055: ActionForm p_Form, HttpServletRequest p_Request,
056: HttpServletResponse p_Response) throws IOException,
057: ServletException {
058:
059: // Selected Connection Factory
060: String cfName = p_Request.getParameter("name");
061:
062: // Form used
063: CfForm oForm = null;
064: if (cfName != null) {
065: // Build a new form
066: oForm = new CfForm();
067: oForm.reset(p_Mapping, p_Request);
068: m_Session.setAttribute("cfForm", oForm);
069: oForm.setName(cfName);
070: } else {
071: // Used last form in session
072: oForm = (CfForm) m_Session.getAttribute("cfForm");
073: }
074:
075: // Force the node selected in tree
076: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
077: + WhereAreYou.NODE_SEPARATOR + "services"
078: + WhereAreYou.NODE_SEPARATOR + "jms"
079: + WhereAreYou.NODE_SEPARATOR + "cf"
080: + WhereAreYou.NODE_SEPARATOR + oForm.getName(), true);
081:
082: // Current server
083: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
084: .getAttribute(WhereAreYou.SESSION_NAME);
085: String jonasServerName = oWhere.getCurrentJonasServerName();
086:
087: // Populuate
088: try {
089: if (cfName != null) {
090: ArrayList al = new ArrayList();
091: String[] asParam = new String[1];
092: String[] asSignature = new String[1];
093: asSignature[0] = "java.lang.String";
094: asParam[0] = cfName;
095: ObjectName ejbServiceMB = JonasObjectName.ejbService();
096: if (JonasManagementRepr.isRegistered(ejbServiceMB,
097: jonasServerName)) {
098: java.util.Iterator it = ((java.util.Set) JonasManagementRepr
099: .invoke(
100: ejbServiceMB,
101: "getJmsConnectionFactoryDependence",
102: asParam, asSignature,
103: jonasServerName)).iterator();
104: while (it.hasNext()) {
105: al.add(new EjbItem((ObjectName) it.next(),
106: jonasServerName));
107: }
108: // Sort by name
109: Collections.sort(al, new EjbItemByNameComparator());
110: }
111: // Set list in form
112: oForm.setListUsedByEjb(al);
113:
114: // Set monitoting info
115: ObjectName jmsServiceMB = JonasObjectName.jmsService();
116: String mode = (String) JonasManagementRepr.invoke(
117: jmsServiceMB, "getConnectionFactoryMode",
118: asParam, asSignature, jonasServerName);
119: oForm.setMode(mode);
120: }
121: } catch (Throwable t) {
122: addGlobalError(t);
123: saveErrors(p_Request, m_Errors);
124: return (p_Mapping.findForward("Global Error"));
125: }
126:
127: // Forward to the jsp.
128: return (p_Mapping.findForward("Connection Factory"));
129: }
130: }
|