private void setModuleDefinitions(CuratorFramework client, StreamDefinition definition) {
		String streamName = definition.getName();
		String path = Paths.build(Paths.STREAMS, streamName);
		try {
			byte[] bytes = client.getData().forPath(path);
			if (bytes != null) {
				Map<String, String> map = ZooKeeperUtils.bytesToMap(bytes);

				// Prior to Spring XD 1.1.1/1.2, the JSON map for stream definitions
				// contained a single key named "definition" with the value being
				// the definition string. As of 1.1.1/1.2, the map contains an additional
				// key "moduleDefinitions" which contains a JSON array of module
				// information such as class name and module URL.
				//
				// The following will convert "old" stream definitions into the
				// new format.
				if (map.get(MODULE_DEFINITIONS_KEY) == null) {
					List<ModuleDescriptor> moduleDescriptors = this.parser.parse(streamName,
							definition.getDefinition(), definitionKind);
					List<ModuleDefinition> moduleDefinitions = createModuleDefinitions(moduleDescriptors);
					if (!moduleDefinitions.isEmpty()) {
						map.put(DEFINITION_KEY, definition.getDefinition());
						try {
							map.put(MODULE_DEFINITIONS_KEY,
									objectWriter.writeValueAsString(moduleDefinitions));
							byte[] binary = ZooKeeperUtils.mapToBytes(map);
							BackgroundPathAndBytesable<?> op = client.checkExists().forPath(path) == null
									? client.create() : client.setData();
							op.forPath(path, binary);
						}
						catch (JsonProcessingException jpe) {
							logger.error("Exception writing module definitions " + moduleDefinitions +
									" for the stream " + streamName, jpe);
						}
					}
				}
			}
		}
		catch (Exception e) {
			logger.error("Exception when updating module definitions for the stream "
					+ streamName, e);
		}
	}
Set the module definitions for the given stream definition.
Module definitions are obtained by parsing the stream definition.

@param client the curator framework client
@param definition the stream definition
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/stream/StreamDeployer.java