1 5 package org.exoplatform.portlets.jmx.component; 6 7 import java.util.List ; 8 import javax.management.*; 9 import org.exoplatform.faces.core.component.UIExoCommand; 10 import org.exoplatform.faces.core.event.ExoActionEvent; 11 import org.exoplatform.faces.core.event.ExoActionListener; 12 13 17 public class UINavigator extends UIExoCommand { 18 static final public String SELECT_ACTION = "select" ; 19 20 public UINavigator() { 21 setId("UINavigator") ; 22 setClazz("UINavigator") ; 23 setRendererType("NavigatorRenderer") ; 24 List children = getChildren() ; 25 List servers = MBeanServerFactory.findMBeanServer(null) ; 26 boolean render = true ; 27 for(int i = 0 ; i < servers.size(); i++) { 28 MBeanServer server = (MBeanServer) servers.get(i) ; 29 UIMBeanServer uiMBeanServer = new UIMBeanServer(server) ; 30 uiMBeanServer.setRendered(render) ; 31 uiMBeanServer.setId("UIMBeanServer" + i) ; 32 children.add(uiMBeanServer) ; 33 render = false ; 34 } 35 addActionListener(SelectActionListener.class, SELECT_ACTION) ; 36 } 37 38 public String getFamily() { 39 return "org.exoplatform.portlets.jmx.component.UINavigator" ; 40 } 41 42 public boolean isRendered() { return true ; } 43 44 public UIMBeanServer getDefaultUIMBeanServer() { 45 List children = getChildren() ; 46 for(int i = 0; i < children.size() ; i++) { 47 UIMBeanServer ui = (UIMBeanServer) children.get(i) ; 48 if(ui.isRendered()) return ui ; 49 } 50 return null ; 51 } 52 53 static public class SelectActionListener extends ExoActionListener { 54 public void execute(ExoActionEvent event) throws Exception { 55 UINavigator uiParent = (UINavigator)event.getComponent() ; 56 String mserver = event.getParameter("mserver") ; 57 UIMBeanServer uiMServer =(UIMBeanServer) uiParent.findComponent(mserver) ; 58 uiParent.setRenderedComponent(mserver) ; 59 UIListMBean uiListMBean = (UIListMBean) uiParent.getSibling(UIListMBean.class) ; 60 uiListMBean.setMBeanServerDomain(uiMServer.getMBeanServer(), uiMServer.getRootDomain()) ; 61 uiParent.setRenderedSibling(UIListMBean.class) ; 62 } 63 } 64 } | Popular Tags |