public DynaTreeNode getDomainTree ( String domainName ) { DynaTreeNode domainNode = new DynaTreeNode ( ) . setTitle ( domainName ) . setKey ( domainName ) . setMode ( MODE_DOMAIN ) ; try { // List all objects in the domain ObjectName name = new ObjectName ( domainName + ":*" ) ; Set < ObjectName > objs = mBeanServer . queryNames ( name , null ) ; // Convert object naems to a tree for ( ObjectName objName : objs ) { MBeanInfo info = mBeanServer . getMBeanInfo ( objName ) ; Matcher m = csvRE . matcher ( objName . getKeyPropertyListString ( ) ) ; DynaTreeNode node = domainNode ; StringBuilder innerKey = new StringBuilder ( ) ; innerKey . append ( domainName ) . append ( ":" ) ; while ( m . find ( ) ) { String title = StringUtils . removeEnd ( m . group ( ) , "," ) ; String key = StringUtils . substringBefore ( title , "=" ) ; String value = StringUtils . substringAfter ( title , "=" ) ; value = StringUtils . removeStart ( value , "\"" ) ; value = StringUtils . removeEnd ( value , "\"" ) ; innerKey . append ( title ) . append ( "," ) ; DynaTreeNode next = node . getChild ( value ) ; if ( next == null ) { next = new DynaTreeNode ( ) . setTitle ( value ) . setMode ( MODE_INNER ) . setKey ( innerKey . toString ( ) + "*" ) . setNoLink ( false ) ; node . putChild ( next ) ; } node = next ; } node . setKey ( objName . getCanonicalName ( ) ) . setMode ( MODE_LEAF ) ; if ( info . getAttributes ( ) != null || info . getOperations ( ) != null || info . getNotifications ( ) != null ) { node . setNoLink ( false ) ; } } } catch ( MalformedObjectNameException e ) { LOG . error ( "Exception in getDomainTree " , e ) ; } catch ( IntrospectionException e ) { LOG . error ( "Exception in getDomainTree " , e ) ; } catch ( ReflectionException e ) { LOG . error ( "Exception in getDomainTree " , e ) ; } catch ( InstanceNotFoundException e ) { LOG . error ( "Exception in getDomainTree " , e ) ; } catch ( RuntimeException e ) { LOG . error ( "Exception in getDomainTree " , e ) ; } return domainNode ; }
Return subtree of nodes for a domain