private byte[] createComposedJobJar(String xml) {

		JarOutputStream target = null;
		try (ByteArrayOutputStream outStream = new ByteArrayOutputStream()) {
			target = new JarOutputStream(outStream);
			JarEntry entry = new JarEntry("config/");
			target.putNextEntry(entry);
			target.closeEntry();
			writeXML(target, xml);
			writeParameters(target, ComposedJobUtil.getPropertyDefinition());

			//This needs to be explicitly closed before we get the bytes so that the
			//compression is complete.  target.flush() does not work for this.
			target.close();
			return outStream.toByteArray();
		}
		catch (Exception e) {
			try{
				if(target != null){
					target.close();
				}
			}catch (IOException ie){
				throw new IllegalStateException(e.getMessage(), e);
			}
			throw new IllegalStateException(e.getMessage(), e);
		}
	}
A service that knows how to handle registration of new module definitions, be it through composition or
upload of actual 'bytecode'. Handles all bookkeeping (such as existence checking, dependency tracking, <i>etc.</i>)
that is common to all registration scenarios.

<p>Also adds pagination to {@code find*()} methods of {@code ModuleRegistry} after the fact.</p>

@author Eric Bottard
@author Gary Russell
spring-xd-dirt/src/main/java/org/springframework/xd/dirt/module/support/ModuleDefinitionService.java