@Override
	protected List<String> onContainerLaunchCommands(Container container, ContainerCluster cluster,
			List<String> commands) {

		// only modify container so assume presence of -Dspring.application.name=container
		if (findPosition(commands, "-Dspring.application.name=container") < 0) {
			return commands;
		}

		ArrayList<String> list = new ArrayList<String>(commands);
		Map<String, Object> extraProperties = cluster.getExtraProperties();
		if (extraProperties != null && extraProperties.containsKey("containerGroups")) {
			int position = findPosition(commands, "-Dxd.container.groups=");
			String value = "-Dxd.container.groups=" + cluster.getExtraProperties().get("containerGroups");
			if (position < 0) {
				list.add(Math.max(list.size() - 3, 0), value);
			}
			else {
				list.set(position, value);
			}
		}
		int memory = container.getResource().getMemory();
		int virtualCores = container.getResource().getVirtualCores();
		list.add(Math.max(list.size() - 3, 0), "-Dxd.container.memory=" + memory);
		list.add(Math.max(list.size() - 3, 0), "-Dxd.container.virtualCores=" + virtualCores);
		return list;
	}
Custom application master handling XD containers grouping setting
for launch commands.

@author Janne Valkealahti
spring-xd-yarn/spring-xd-yarn-appmaster/src/main/java/org/springframework/xd/yarn/XdAppmaster.java