KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > portlets > console > component > UIAdminConsolePortlet


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.portlets.console.component;
6
7 import org.exoplatform.container.RootContainer;
8 import org.exoplatform.container.monitor.jvm.JVMRuntimeInfo;
9 import org.exoplatform.faces.core.component.UICommandPortlet;
10 import org.exoplatform.faces.core.component.UIExoComponent;
11 import org.exoplatform.faces.core.component.UINode;
12 import org.exoplatform.faces.core.component.model.Parameter;
13 import org.exoplatform.faces.core.event.ExoActionEvent;
14 import org.exoplatform.faces.core.event.ExoActionListener;
15 import org.exoplatform.portlets.log.component.UILog;
16 import org.exoplatform.portlets.log.component.UILogConfig;
17 import org.exoplatform.portlets.log.component.UILogError;
18 import org.exoplatform.portlets.monitor.jvm.component.*;
19 import org.exoplatform.portlets.monitor.portlet.component.UIPortalMonitor;
20 import org.exoplatform.portlets.monitor.portlet.component.UIPortletContainerMonitor;
21 import org.exoplatform.portlets.monitor.session.component.UIActionHistory;
22 import org.exoplatform.portlets.monitor.session.component.UILiveSessions;
23 import org.exoplatform.portlets.monitor.session.component.UISessionLogManager;
24 /**
25  * Wed, Dec 22, 2003 @ 23:14
26  * @author: Tuan Nguyen
27  * @email: tuan08@users.sourceforge.net
28  * @version: $Id: UIMonitorPortlet.java,v 1.1 2004/08/02 12:04:26 tuan08 Exp $
29  */

30 public class UIAdminConsolePortlet extends UICommandPortlet {
31   final static public String JavaDoc COMPONENT_ID = "componentId" ;
32   final static public String JavaDoc CHANGE_COMPONENT_ACTION = "changeComponent" ;
33   final static public Parameter CHANGE_COMPONENT = new Parameter(ACTION, CHANGE_COMPONENT_ACTION) ;
34   
35   public UIAdminConsolePortlet() throws Exception JavaDoc {
36     setId("UIAdminConsolePortlet") ;
37     setRendererType("AdminConsolePortletRenderer") ;
38     addExoMonitors() ;
39     addLogNode() ;
40     addChild(UIListCache.class).setRendered(false) ;
41     addJVMManagement() ;
42    
43     addActionListener(ChangeActionListener.class, CHANGE_COMPONENT_ACTION) ;
44     }
45   
46   private void addLogNode() throws Exception JavaDoc {
47     UINode uiLogNode = (UINode)addChild(UINode.class) ;
48     uiLogNode.setId("UILogNode") ;
49     uiLogNode.setRendererType("SimpleTabRenderer");
50     //uiLogNode.setRendererType("ChildrenRenderer");
51
uiLogNode.setName("UINode.label.log") ;
52     uiLogNode.setRendered(false);
53     uiLogNode.addChild(UILog.class);
54     uiLogNode.addChild(UILogError.class).setRendered(false) ;
55     uiLogNode.addChild(UILogConfig.class).setRendered(false) ;
56   }
57   
58   public void addExoMonitors() throws Exception JavaDoc {
59     UINode uiMonitor = (UINode)addChild(UINode.class) ;
60     uiMonitor.setId("UIMonitors");
61     uiMonitor.setRendererType("SimpleTabRenderer") ;
62     //setRendererType("ChildrenRenderer") ;
63
uiMonitor.setName("UINode.label.monitors");
64   
65     UINode uiSessionNode = (UINode)uiMonitor.addChild(UINode.class) ;
66     uiSessionNode.setId("UISessionNode") ;
67     uiSessionNode.setRendererType("ChildrenRenderer");
68     uiSessionNode.addChild(UILiveSessions.class) ;
69     uiSessionNode.addChild(UIActionHistory.class).setRendered(false) ;
70     
71     uiMonitor.addChild(UISessionLogManager.class).setRendered(false) ;
72     
73     uiMonitor.addChild(UIPortalMonitor.class).setRendered(false) ;
74     uiMonitor.addChild(UIPortletContainerMonitor.class).setRendered(false) ;
75   }
76   
77   public void addJVMManagement() throws Exception JavaDoc {
78     UINode jvm = (UINode)addChild(UINode.class) ;
79     jvm.setRendered(false) ;
80     jvm.setId("UIJVMManagement");
81     jvm.setName("UINode.label.UIJVMManagement");
82     jvm.setRendererType("ChildrenRenderer") ;
83     jvm.addChild(UIOSInfo.class) ;
84     jvm.addChild(UIJVMRuntimInfo.class).setRendered(false) ;
85     JVMRuntimeInfo info =
86       (JVMRuntimeInfo)RootContainer.getComponent(JVMRuntimeInfo.class) ;
87     if(info.isManagementSupported()) {
88       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIProcessInfo")).
89           setRendered(false) ;
90       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIClassInfo")).
91           setRendered(false) ;
92       
93       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIMemoryInfo")).
94           setRendered(false) ;
95       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIMemoryManagerInfo")).
96           setRendered(false) ;
97       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIMemoryPoolInfo")).
98           setRendered(false) ;
99       jvm.addChild(getComponent("org.exoplatform.portlets.monitor.jvm.component.UIGCInfo")).
100           setRendered(false) ;
101     }
102   }
103   
104   private Class JavaDoc getComponent(String JavaDoc name) {
105     try {
106       return Class.forName(name) ;
107     } catch(Exception JavaDoc ex) {
108       return null;
109     }
110   }
111   
112   static public class ChangeActionListener extends ExoActionListener {
113     public void execute(ExoActionEvent event) throws Exception JavaDoc {
114       UIAdminConsolePortlet uiPortlet = (UIAdminConsolePortlet)event.getComponent() ;
115       String JavaDoc componentId = event.getParameter(COMPONENT_ID) ;
116       UIExoComponent uiComponent = uiPortlet.findComponentById(componentId) ;
117       UIExoComponent uiParent = (UIExoComponent) uiComponent.getParent() ;
118       if(uiParent != uiPortlet) {
119         uiPortlet.setRenderedComponent(uiParent.getId());
120       }
121       uiParent.setRenderedComponent(componentId) ;
122     }
123   }
124   
125   public String JavaDoc getFamily() {
126     return "org.exoplatform.portlets.console.component.UIAdminConsolePortlet" ;
127   }
128 }
Popular Tags