docs: public synchronized void clear() throws ChannelException, ChainException, ChainGroupException {
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
              Tr.entry(tc, "clear");
          }
  
          StringBuilder sbErrors = new StringBuilder();
  
          // Stop destroy and remove all running chains.
          Chain[] chains = chainRunningMap.values().toArray(new Chain[chainRunningMap.size()]);
          for (int i = 0; i < chains.length; i++) {
              Chain chain = chains[i];
              if (chain.getState() == RuntimeState.STARTED || chain.getState() == RuntimeState.QUIESCED) {
                  try {
                      stopChainInternal(chain, 0);
                  } catch (Exception e) {
                      FFDCFilter.processException(e, getClass().getName() + ".clear", "322", this, new Object[] { chain, this });
                      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                          Tr.debug(tc, "Caught stopChainInternal exception " + e.getMessage());
                      }
                      sbErrors.append(e.toString());
                  }
              }
              try {
                  destroyChainInternal(chain);
              } catch (ChannelException e) {
                  // FFDC handled in destroyChainInternal.
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught destroyChainInternal exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              } catch (ChainException e) {
                  // FFDC handled in destroyChainInternal.
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught destroyChainInternal exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              } catch (Exception e) {
                  FFDCFilter.processException(e, getClass().getName() + ".clear", "329", this, new Object[] { chain, this });
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught destroyChainInternal exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              }
              try {
                  removeChain(chain.getName());
              } catch (Exception e) {
                  FFDCFilter.processException(e, getClass().getName() + ".clear", "335", this, new Object[] { chain, this });
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught removeChain exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              }
          }
          this.chainRunningMap.clear();
          this.channelRunningMap.clear();
  
          // Remove all chain groups
          String[] keys = chainGroups.keySet().toArray(new String[chainGroups.size()]);
          for (int i = 0; i < keys.length; i++) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Remove chainGroup, " + keys[i]);
              }
              try {
                  removeChainGroup(keys[i]);
              } catch (Exception e) {
                  FFDCFilter.processException(e, getClass().getName() + ".clear", "351", this, new Object[] { keys[i], this });
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught removeChainGroup exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              }
          }
          this.chainGroups.clear();
  
          // Remove all channels.
          keys = channelDataMap.keySet().toArray(new String[channelDataMap.size()]);
          for (int i = 0; i < keys.length; i++) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Remove channelData, " + keys[i]);
              }
              try {
                  String name = keys[i];
                  if (name != null)
                      removeChannel(name);
              } catch (Exception e) {
                  FFDCFilter.processException(e, getClass().getName() + ".clear", "366", this, new Object[] { keys[i], this });
                  if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                      Tr.debug(tc, "Caught removeChannel exception " + e.getMessage());
                  }
                  sbErrors.append(e.toString());
              }
          }
          this.channelDataMap.clear();
          this.chainDataMap.clear();
  
          // Destroy all channel factories
          Class<?>[] factoryList = channelFactories.keySet().toArray(new Class<?>[channelFactories.size()]);
          for (Class<?> target : factoryList) {
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Remove channelFactory, " + target);
              }
              ChannelFactory factory = channelFactories.remove(target).getChannelFactory();
              if (factory != null) {
                  try {
                      factory.destroy();
                  } catch (Exception e) {
                      FFDCFilter.processException(e, getClass().getName() + ".clear", "384", this, new Object[] { factory, this });
                      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                          Tr.debug(tc, "Caught factory.destroy exception " + e.getMessage());
                      }
                      sbErrors.append(e.toString());
                  }
              }
          }
          this.channelFactories.clear();
  
          // Clear the chain event listeners
          this.globalChainEventListeners.clear();
  
          // Clear out the services.
          this.services.clear();
  
          // Check if an error occurred.
          if (sbErrors.length() > 0) {
              // Found an error. Throw an exception containing all the details of the
              // errors caught.
              throw new ChannelException(sbErrors.toString());
          }
  
          this.activatedProviders.clear();
  
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
              Tr.exit(tc, "clear");
          }
      }