code: private void updateEnclosingMonitor() {
          if ( !coveringPaths.isEmpty() ) {
              if ( !listenerRegistered ) {
                  // This container is not yet registered to the enclosing container.
                  // Register this container.
  
                  ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
  
                  // The path to register is the path of the enclosing entry.
                  ArtifactNotification enclosingNotification = new DefaultArtifactNotification(
                      enclosingRootContainer,
                      Collections.singleton( entryInEnclosingContainer.getPath() ) );
  
                  ArtifactNotifier enclosingRootNotifier = enclosingRootContainer.getArtifactNotifier();
  
                  // The enclosing container generally will accept the registration
                  // request.  Just in case it doesn't, set the registration flag
                  // based on the registration result.
                  listenerRegistered = enclosingRootNotifier.registerForNotifications(enclosingNotification, this);
  
                  // The result is that any change to the enclosing container reaches
                  // this notifier through 'notifyEntryChange'.
  
                  // See comments on 'loadZipEntries' for why the entries must be loaded now.
                  loadZipEntries();
  
              } else {
                  // Do nothing: The enclosing entry was already registered
                  // to the enclosing notifier.
              }
  
          } else {
              if ( listenerRegistered ) {
                  // There are no listener registrations active on this container.
                  // Remove the registration of this listener.
                  //
                  // This listener should be registered exactly once to the enclosing
                  // container: Removing all registrations of this listener should remove
                  // that one registration, with no addition, unwanted registration changes.
  
                  ArtifactContainer enclosingRootContainer = entryInEnclosingContainer.getRoot();
                  ArtifactNotifier enclosingNotifier = enclosingRootContainer.getArtifactNotifier();
                  enclosingNotifier.removeListener(this);
  
              } else {
                  // Do nothing: The enclosing monitor already did not have a registration
                  // for this container.
              }
          }
      }
docs: Update the enclosing monitor according to whether any listeners
  are registered.  That is, if any covering paths are present.
  
  When listeners are registered, register the this notifier as
  a listener on the enclosing entry.  When no listeners are
  registered, remove this notifier as a listener on the enclosing
  entry.
  
  Registration as a listener is only done when the notifier is
  a non-exposed notifier.  For an exposed notifier, see
  {@link #updateMonitorService}.