public static synchronized void unregisterModule ( PmiModule instance ) { if ( disabled ) return ; if ( instance == null ) // || instance.getPath().length<=1) return; return ; // check if the path has null in it. if a module is unregistered twice // the path will have null String [ ] path = instance . getPath ( ) ; if ( path == null || path . length == 0 ) return ; for ( int k = 0 ; k < path . length ; k ++ ) { if ( path [ k ] == null ) return ; } if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "unregisterModule: " + instance . getModuleID ( ) + ", " + instance . getName ( ) ) ; // unregister itself String [ ] parentPath = new String [ path . length - 1 ] ; System . arraycopy ( path , 0 , parentPath , 0 , parentPath . length ) ; // locate parent ModuleItem parent = moduleRoot . find ( parentPath , 0 ) ; if ( parent != null ) { // remove "instance" from parent parent . remove ( parent . find ( path [ path . length - 1 ] ) ) ; // do not remove the empty parent group in custom pmi // in custom PMI groups/instances are explicitly created and // should be remove explicitly // in pre-custom groups are create IMPLICITYLY when needed if ( instance . isCustomModule ( ) ) return ; // check if parent is empty if ( parent . children == null || parent . children . size ( ) == 0 ) { if ( parent . getInstance ( ) != null ) { String [ ] mypath = parent . getInstance ( ) . getPath ( ) ; // TODO: ask Wenjian about this? // exclude WEBAPP_MODULE because it is created explicitly and // should be removed explictly by calling PmiFactory.removePmiModule if ( ! ( mypath . length == 2 && ( mypath [ 0 ] . equals ( WEBSERVICES_MODULE ) ) ) ) { // recursive call?: unregisterModule (parent.getInstance()); parent . getInstance ( ) . unregister ( ) ; } } } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "unregisterModule" ) ; }
remove module - never remove TYPE_MODULE .