KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > webapp > jonasadmin > logging > BaseLoggerAction


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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,v 1.6 2005/04/08 14:52:24 danesa Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.webapp.jonasadmin.logging;
27
28 import javax.management.ObjectName JavaDoc;
29 import javax.servlet.http.HttpServletRequest JavaDoc;
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 JavaDoc p_Request)
52         throws Exception JavaDoc {
53         // Refresh Logger Tree
54
refreshLoggersTree(p_Request);
55         // Refresh MBeans Tree
56
refreshMBeansTree();
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 JavaDoc p_Request)
68         throws Exception JavaDoc {
69         // Get the domain and server name
70
String JavaDoc sDomainLabel = "domain";
71         ObjectName JavaDoc oObjectName = J2eeObjectName.J2EEServer(m_WhereAreYou.getCurrentDomainName()
72             , m_WhereAreYou.getCurrentJonasServerName());
73         String JavaDoc sServerName = getStringAttribute(oObjectName, "serverName");
74         // Get the node name
75
String JavaDoc sCurrentNodeNameItem = sDomainLabel + WhereAreYou.NODE_SEPARATOR + sServerName + WhereAreYou.NODE_SEPARATOR + "logging";
76         // Get current tree
77
TreeControl oControl = m_WhereAreYou.getTreeControl();
78         // Get branch root node
79
TreeControlNode oBranchRootNode = oControl.findNode(sCurrentNodeNameItem);
80         // Enable auto-refresh mode
81
oControl.enableAutoRefresh();
82         // Remove old children
83
TreeControlNode[] aoNodes = oBranchRootNode.findChildren();
84         for (int i = 0; i < aoNodes.length; i++) {
85             aoNodes[i].remove();
86         }
87         // Build node for the Service
88
JonasTreeBuilder oBuilder = new JonasTreeBuilder();
89         oBuilder.getLoggers(oBranchRootNode, m_Resources, p_Request);
90         // Disable auto-refresh mode
91
oControl.disableAutoRefresh();
92     }
93 }
94
Popular Tags