01: /*
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: BaseLoggerAction.java 9680 2006-10-06 12:08:33Z danesa $
23: * --------------------------------------------------------------------------
24: */
25:
26: package org.objectweb.jonas.webapp.jonasadmin.logging;
27:
28: import javax.management.ObjectName;
29: import javax.servlet.http.HttpServletRequest;
30:
31: import org.objectweb.jonas.jmx.J2eeObjectName;
32: import org.objectweb.jonas.webapp.jonasadmin.JonasTreeBuilder;
33: import org.objectweb.jonas.webapp.jonasadmin.WhereAreYou;
34: import org.objectweb.jonas.webapp.jonasadmin.deploy.BaseDeployAction;
35: import org.objectweb.jonas.webapp.taglib.TreeControl;
36: import org.objectweb.jonas.webapp.taglib.TreeControlNode;
37:
38: /**
39: * @author Michel-Ange ANTON
40: */
41: abstract public class BaseLoggerAction extends BaseDeployAction {
42:
43: // --------------------------------------------------------- Protected Methods
44:
45: /**
46: * Refresh the tree.
47: *
48: * @param p_Request Current instance
49: * @throws Exception
50: */
51: protected void refreshTree(HttpServletRequest p_Request)
52: throws Exception {
53: // Refresh Logger Tree
54: refreshLoggersTree(p_Request);
55: // Refresh MBeans Tree
56: refreshMBeansTree(p_Request);
57: // Force display to refresh
58: m_WhereAreYou.setTreeToRefresh(true);
59: }
60:
61: /**
62: * Refresh the loggers branch tree.
63: *
64: * @param p_Request Current instance
65: * @throws Exception
66: */
67: protected void refreshLoggersTree(HttpServletRequest p_Request)
68: throws Exception {
69: // Get the domain and server name
70: String sDomainLabel = "domain";
71: ObjectName oObjectName = J2eeObjectName.J2EEServer(
72: m_WhereAreYou.getCurrentDomainName(), m_WhereAreYou
73: .getCurrentJonasServerName());
74: String sServerName = getStringAttribute(oObjectName,
75: "serverName");
76: // Get the node name
77: String sCurrentNodeNameItem = sDomainLabel
78: + WhereAreYou.NODE_SEPARATOR + sServerName
79: + WhereAreYou.NODE_SEPARATOR + "logging";
80: // Get current tree
81: TreeControl oControl = m_WhereAreYou.getTreeControl();
82: // Get branch root node
83: TreeControlNode oBranchRootNode = oControl
84: .findNode(sCurrentNodeNameItem);
85: // Enable auto-refresh mode
86: oControl.enableAutoRefresh();
87: // Remove old children
88: TreeControlNode[] aoNodes = oBranchRootNode.findChildren();
89: for (int i = 0; i < aoNodes.length; i++) {
90: aoNodes[i].remove();
91: }
92: // Build node for the Service
93: JonasTreeBuilder oBuilder = new JonasTreeBuilder();
94: oBuilder.getLoggers(oBranchRootNode, m_Resources, p_Request);
95: // Disable auto-refresh mode
96: oControl.disableAutoRefresh();
97: }
98: }
|