public void removeExtension ( Resource rootResource , String moduleName , ManagementResourceRegistration rootRegistration ) throws IllegalStateException { final ManagementResourceRegistration profileReg ; if ( rootRegistration . getPathAddress ( ) . size ( ) == 0 ) { //domain or server extension // Can't use processType.isServer() to determine where to look for profile reg because a lot of test infrastructure // doesn't add the profile mrr even in HC-based tests ManagementResourceRegistration reg = rootRegistration . getSubModel ( PathAddress . pathAddress ( PathElement . pathElement ( PROFILE ) ) ) ; if ( reg == null ) { reg = rootRegistration ; } profileReg = reg ; } else { //host model extension profileReg = rootRegistration ; } ManagementResourceRegistration deploymentsReg = processType . isServer ( ) ? rootRegistration . getSubModel ( PathAddress . pathAddress ( PathElement . pathElement ( DEPLOYMENT ) ) ) : null ; ExtensionInfo extension = extensions . remove ( moduleName ) ; if ( extension != null ) { //noinspection SynchronizationOnLocalVariableOrMethodParameter synchronized ( extension ) { Set < String > subsystemNames = extension . subsystems . keySet ( ) ; final boolean dcExtension = processType . isHostController ( ) ? rootRegistration . getPathAddress ( ) . size ( ) == 0 : false ; for ( String subsystem : subsystemNames ) { if ( hasSubsystemsRegistered ( rootResource , subsystem , dcExtension ) ) { // Restore the data extensions . put ( moduleName , extension ) ; throw ControllerLogger . ROOT_LOGGER . removingExtensionWithRegisteredSubsystem ( moduleName , subsystem ) ; } } for ( Map . Entry < String , SubsystemInformation > entry : extension . subsystems . entrySet ( ) ) { String subsystem = entry . getKey ( ) ; profileReg . unregisterSubModel ( PathElement . pathElement ( ModelDescriptionConstants . SUBSYSTEM , subsystem ) ) ; if ( deploymentsReg != null ) { deploymentsReg . unregisterSubModel ( PathElement . pathElement ( ModelDescriptionConstants . SUBSYSTEM , subsystem ) ) ; deploymentsReg . unregisterSubModel ( PathElement . pathElement ( ModelDescriptionConstants . SUBDEPLOYMENT , subsystem ) ) ; } if ( extension . xmlMapper != null ) { SubsystemInformationImpl subsystemInformation = SubsystemInformationImpl . class . cast ( entry . getValue ( ) ) ; for ( String namespace : subsystemInformation . getXMLNamespaces ( ) ) { extension . xmlMapper . unregisterRootElement ( new QName ( namespace , SUBSYSTEM ) ) ; } } } } } }
Cleans up a extension module s subsystems from the resource registration model .