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: ListAppContainersAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service.container;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030: import java.util.Collections;
031: import java.util.Iterator;
032:
033: import javax.management.ObjectName;
034: import javax.servlet.ServletException;
035: import javax.servlet.http.HttpServletRequest;
036: import javax.servlet.http.HttpServletResponse;
037:
038: import org.apache.struts.action.ActionForm;
039: import org.apache.struts.action.ActionForward;
040: import org.apache.struts.action.ActionMapping;
041: import org.objectweb.jonas.jmx.J2eeObjectName;
042: import org.objectweb.jonas.jmx.JonasManagementRepr;
043: import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
044: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
045: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
046:
047: /**
048: * @author Michel-Ange ANTON
049: */
050:
051: public class ListAppContainersAction extends JonasBaseAction {
052:
053: // --------------------------------------------------------- Public Methods
054:
055: public ActionForward executeAction(ActionMapping p_Mapping,
056: ActionForm p_Form, HttpServletRequest p_Request,
057: HttpServletResponse p_Response) throws IOException,
058: ServletException {
059:
060: // Force the node selected in tree
061: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
062: + WhereAreYou.NODE_SEPARATOR + "services"
063: + WhereAreYou.NODE_SEPARATOR + "ear", true);
064:
065: // no Form used
066: try {
067: // Get container list
068: String sPath;
069: String sFile;
070: String sName;
071: ArrayList al = new ArrayList();
072: String p_DomainName = m_WhereAreYou.getCurrentDomainName();
073: String p_ServerName = m_WhereAreYou
074: .getCurrentJonasServerName();
075: ObjectName onContainers = J2eeObjectName.J2EEApplications(
076: p_DomainName, p_ServerName);
077: Iterator itNames = JonasManagementRepr.queryNames(
078: onContainers, p_ServerName).iterator();
079: while (itNames.hasNext()) {
080: ObjectName it_on = (ObjectName) itNames.next();
081: sPath = ((java.net.URL) JonasManagementRepr
082: .getAttribute(it_on, "earUrl", p_ServerName))
083: .toString();
084: //sPath = itNames.next().toString();
085: sFile = JonasAdminJmx.extractFilename(sPath);
086: sName = it_on.getKeyProperty("name");
087: al.add(new ContainerItem(sFile, sPath,
088: it_on.toString(), sName));
089: }
090: Collections.sort(al, new ContainerItemByFile());
091: // Set list in the request
092: p_Request.setAttribute("listAppContainers", al);
093: } catch (Throwable t) {
094: addGlobalError(t);
095: saveErrors(p_Request, m_Errors);
096: return (p_Mapping.findForward("Global Error"));
097: }
098: // Forward to the jsp.
099: return (p_Mapping.findForward("App Containers"));
100: }
101: }
|