1 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 30 public class UIAdminConsolePortlet extends UICommandPortlet { 31 final static public String COMPONENT_ID = "componentId" ; 32 final static public String CHANGE_COMPONENT_ACTION = "changeComponent" ; 33 final static public Parameter CHANGE_COMPONENT = new Parameter(ACTION, CHANGE_COMPONENT_ACTION) ; 34 35 public UIAdminConsolePortlet() throws Exception { 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 { 47 UINode uiLogNode = (UINode)addChild(UINode.class) ; 48 uiLogNode.setId("UILogNode") ; 49 uiLogNode.setRendererType("SimpleTabRenderer"); 50 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 { 59 UINode uiMonitor = (UINode)addChild(UINode.class) ; 60 uiMonitor.setId("UIMonitors"); 61 uiMonitor.setRendererType("SimpleTabRenderer") ; 62 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 { 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 getComponent(String name) { 105 try { 106 return Class.forName(name) ; 107 } catch(Exception ex) { 108 return null; 109 } 110 } 111 112 static public class ChangeActionListener extends ExoActionListener { 113 public void execute(ExoActionEvent event) throws Exception { 114 UIAdminConsolePortlet uiPortlet = (UIAdminConsolePortlet)event.getComponent() ; 115 String 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 getFamily() { 126 return "org.exoplatform.portlets.console.component.UIAdminConsolePortlet" ; 127 } 128 } | Popular Tags |