private void enhanceWithDeployments(Page<D> page, PagedResources<R> result) {
		@SuppressWarnings("unchecked")
		AbstractInstancePersistingDeployer<D, BaseInstance<D>> ipDeployer = (AbstractInstancePersistingDeployer<D, BaseInstance<D>>) deployer;
		D first = page.getContent().get(0);
		D last = page.getContent().get(page.getNumberOfElements() - 1);
		Iterator<BaseInstance<D>> deployedInstances = ipDeployer.deploymentInfo(first.getName(), last.getName()).iterator();
		BaseInstance<D> instance = deployedInstances.hasNext() ? deployedInstances.next() : null;

		// There are >= more definitions than there are instances, and they're both sorted
		for (R definitionResource : result) {
			String instanceName = (instance != null) ? instance.getDefinition().getName() : null;
			if (definitionResource.getName().equals(instanceName)) {
				((DeployableResource) definitionResource).setStatus(instance.getStatus().getState().toString());
				instance = deployedInstances.hasNext() ? deployedInstances.next() : null;
			}
			else {
				((DeployableResource) definitionResource).setStatus(DeploymentUnitStatus.State.undeployed.toString());
			}
		}
		if (deployedInstances.hasNext()) {
			final List<String> uninspectedInstanceNames = new ArrayList<String>();

			while (deployedInstances.hasNext()) {
				final BaseInstance<D> uninspectedInstance = deployedInstances.next();
				uninspectedInstanceNames.add(uninspectedInstance.getDefinition().getName());
			}
			throw new IllegalStateException("Not all instances were looked at: "
					+ StringUtils.collectionToCommaDelimitedString(uninspectedInstanceNames));
		}
	}
Queries the deployer about deployed instances and enhances the resources with deployment info. Does nothing if
the operation is not supported.
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/rest/XDController.java