code: public void addApplicationInstances(Collection<ApplicationInstance> applicationInstances)
      {
          for(ApplicationInstance applicationInstance : applicationInstances)
          {
              // Add the instance to any application hosts it is associated with
              long applicationHostId = applicationInstance.getLinks().getApplicationHost();
              ApplicationHost applicationHost = applicationHosts.get(applicationHostId);
              if(applicationHost != null)
                  applicationInstances(applicationHostId).add(applicationInstance);
              else
                  logger.severe(String.format("Unable to find application host for application instance '%s': %d", applicationInstance.getName(), applicationHostId));
          }
      }
docs: Adds the application instances to the applications for the account.
  @param applicationInstances The application instances to add