public ServiceController<?> removeService(final ServiceName name)
     throws UnsupportedOperationException {
   assert isControllingThread();
   Stage currentStage = this.currentStage;
   if (currentStage == null) {
     throw MESSAGES.operationAlreadyComplete();
   }
   if (currentStage != Stage.RUNTIME && currentStage != Stage.VERIFY && !isRollingBack()) {
     throw MESSAGES.serviceRemovalRuntimeOperationsOnly();
   }
   if (!affectsRuntime) {
     takeWriteLock();
     affectsRuntime = true;
     acquireContainerMonitor();
     awaitContainerMonitor();
   }
   ServiceController<?> controller = modelController.getServiceRegistry().getService(name);
   if (controller != null) {
     doRemove(controller);
   }
   return controller;
 }
 public ServiceRegistry getServiceRegistry(final boolean modify)
     throws UnsupportedOperationException {
   assert isControllingThread();
   Stage currentStage = this.currentStage;
   if (currentStage == null) {
     throw MESSAGES.operationAlreadyComplete();
   }
   if (!(!modify
       || currentStage == Stage.RUNTIME
       || currentStage == Stage.MODEL
       || currentStage == Stage.VERIFY
       || isRollingBack())) {
     throw MESSAGES.serviceRegistryRuntimeOperationsOnly();
   }
   if (modify && !affectsRuntime) {
     takeWriteLock();
     affectsRuntime = true;
     acquireContainerMonitor();
     awaitContainerMonitor();
   }
   return modelController.getServiceRegistry();
 }