/**
   * Add an extension to this connector. This method is protected to allow extensions to select
   * which targets they can extend.
   *
   * @param extension the extension to add
   */
  protected void addExtension(Extension extension) {
    ClientConnector previousParent = extension.getParent();
    if (previousParent == this) {
      // Nothing to do, already attached
      return;
    } else if (previousParent != null) {
      throw new IllegalStateException(
          "Moving an extension from one parent to another is not supported");
    }

    extensions.add(extension);
    extension.setParent(this);
    markAsDirty();
  }
 @Override
 public void removeExtension(Extension extension) {
   extension.setParent(null);
   extensions.remove(extension);
   markAsDirty();
 }