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: ListServicesAction.java 9680 2006-10-06 12:08:33Z danesa $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.webapp.jonasadmin.service;
027:
028: import java.io.IOException;
029: import java.util.ArrayList;
030: import java.util.Collections;
031:
032: import javax.servlet.ServletException;
033: import javax.servlet.http.HttpServletRequest;
034: import javax.servlet.http.HttpServletResponse;
035:
036: import org.apache.struts.action.ActionForm;
037: import org.apache.struts.action.ActionForward;
038: import org.apache.struts.action.ActionMapping;
039: import org.objectweb.jonas.jmx.JonasObjectName;
040: import org.objectweb.jonas.webapp.jonasadmin.JonasAdminJmx;
041: import org.objectweb.jonas.webapp.jonasadmin.JonasBaseAction;
042: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
043:
044: /**
045: * @author Michel-Ange ANTON
046: */
047:
048: public class ListServicesAction extends JonasBaseAction {
049:
050: // --------------------------------------------------------- Public Methods
051:
052: public ActionForward executeAction(ActionMapping p_Mapping,
053: ActionForm p_Form, HttpServletRequest p_Request,
054: HttpServletResponse p_Response) throws IOException,
055: ServletException {
056:
057: // Force the node selected in tree
058: m_WhereAreYou.selectNameNode(getTreeBranchName(DEPTH_SERVER)
059: + WhereAreYou.NODE_SEPARATOR + "services", true);
060:
061: WhereAreYou oWhere = (WhereAreYou) p_Request.getSession()
062: .getAttribute(WhereAreYou.SESSION_NAME);
063: String serverName = oWhere.getCurrentJonasServerName();
064:
065: // no Form used
066: try {
067: ArrayList al = new ArrayList();
068: // Detail Service
069: al.add(new ServiceItem(m_Resources
070: .getMessage("treenode.jonas.server.services.ear"),
071: JonasAdminJmx.hasMBeanName(JonasObjectName
072: .earService(), serverName),
073: "ActionListAppContainers"));
074: al
075: .add(new ServiceItem(
076: m_Resources
077: .getMessage("treenode.jonas.server.services.ejbContainers"),
078: JonasAdminJmx.hasMBeanName(JonasObjectName
079: .ejbService(), serverName),
080: "ActionListContainers"));
081: al.add(new ServiceItem(m_Resources
082: .getMessage("treenode.jonas.server.services.web"),
083: JonasAdminJmx.hasMBeanName(JonasObjectName
084: .webContainerService(), serverName),
085: "ActionListWebContainers"));
086: al
087: .add(new ServiceItem(
088: m_Resources
089: .getMessage("treenode.jonas.server.services.database"),
090: JonasAdminJmx.hasMBeanName(JonasObjectName
091: .databaseService(), serverName),
092: "ActionListDatabases"));
093: al
094: .add(new ServiceItem(
095: m_Resources
096: .getMessage("treenode.jonas.server.services.resource"),
097: JonasAdminJmx.hasMBeanName(JonasObjectName
098: .resourceService(), serverName),
099: "ActionListResourceAdapters"));
100: al
101: .add(new ServiceItem(
102: m_Resources
103: .getMessage("treenode.jonas.server.services.transaction"),
104: JonasAdminJmx.hasMBeanName(JonasObjectName
105: .transactionService(), serverName),
106: "ActionEditJtmService"));
107: al.add(new ServiceItem(m_Resources
108: .getMessage("treenode.jonas.server.services.jms"),
109: JonasAdminJmx.hasMBeanName(JonasObjectName
110: .jmsService(), serverName),
111: "ActionEditJmsService"));
112: al.add(new ServiceItem(m_Resources
113: .getMessage("treenode.jonas.server.services.mail"),
114: JonasAdminJmx.hasMBeanName(JonasObjectName
115: .mailService(), serverName),
116: "ActionEditMailService"));
117: al
118: .add(new ServiceItem(
119: m_Resources
120: .getMessage("treenode.jonas.server.services.security"),
121: JonasAdminJmx.hasMBeanName(JonasObjectName
122: .securityService(), serverName),
123: "ActionEditServiceSecurity"));
124: al
125: .add(new ServiceItem(
126: m_Resources
127: .getMessage("treenode.jonas.server.services.discovery"),
128: JonasAdminJmx.hasMBeanName(JonasObjectName
129: .discoveryService(), serverName),
130: "ActionEditServiceDiscovery"));
131: al
132: .add(new ServiceItem(
133: m_Resources
134: .getMessage("treenode.jonas.server.services.webservices"),
135: JonasAdminJmx.hasMBeanName(JonasObjectName
136: .wsService(), serverName),
137: "ActionListWebService"));
138:
139: // sort
140: Collections.sort(al, new ServiceItemByNameComparator());
141: // Set list in the request
142: p_Request.setAttribute("listServices", al);
143: } catch (Throwable t) {
144: addGlobalError(t);
145: saveErrors(p_Request, m_Errors);
146: return (p_Mapping.findForward("Global Error"));
147: }
148: // Forward to the jsp.
149: return (p_Mapping.findForward("Services"));
150: }
151: }
|