public void createExtensionLink(StackManager stackManager, StackInfo stackInfo, ExtensionInfo extensionInfo) throws AmbariException {
    validateCreateExtensionLinkRequest(stackInfo, extensionInfo);
    ExtensionHelper.validateCreateLink(stackManager, stackInfo, extensionInfo);
    ExtensionLinkEntity linkEntity = createExtensionLinkEntity(stackInfo, extensionInfo);
    stackManager.linkStackToExtension(stackInfo, extensionInfo);

    try {
      linkDAO.create(linkEntity);
    } catch (RollbackException e) {
      String message = "Unable to create extension link";
      LOG.debug(message, e);
      String errorMessage = message
              + ", stackName=" + stackInfo.getName()
              + ", stackVersion=" + stackInfo.getVersion()
              + ", extensionName=" + extensionInfo.getName()
              + ", extensionVersion=" + extensionInfo.getVersion();
      LOG.warn(errorMessage);
      throw new AmbariException(errorMessage, e);
    }
  }
This method will create a link between an extension version and a stack version (Extension Link).

An extension version is like a stack version but it contains custom services.  Linking an extension
version to the current stack version allows the cluster to install the custom services contained in
the extension version.
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementHelper.java