public static Resource locateModuleResource(SimpleModuleDefinition definition, String extension) {

		Resource moduleLocation = simpleResourceResolver.getResource(definition.getLocation());
		Assert.isTrue(moduleLocation.exists(), "module resource " + definition.getLocation() + " does not exist");

		String ext = extension.startsWith(".") ? extension : "." + extension;

		try {
			URLClassLoader insulatedClassLoader = new ParentLastURLClassLoader(new URL[] {moduleLocation.getURL()}, NullClassLoader.NO_PARENT, true);
			PathMatchingResourcePatternResolver moduleResolver = new PathMatchingResourcePatternResolver(insulatedClassLoader);

			try {
				Resource[] resources = moduleResolver.getResources("classpath:/config/*" + ext);
				if (resources.length > 1) {
					throw new IllegalStateException("Multiple top level module resources found :" + StringUtils
							.arrayToCommaDelimitedString(resources));
				}
				else if (resources.length == 1) {
					// Convert from ClassPathResource to UrlResource, as CPR.getInputStream()
					// will apply caching, which we don't want we re-deploying. See XD-3141
					Resource resource = resources[0];
					if (resource instanceof ClassPathResource) {
						return new UrlResource(resource.getURL());
					} else {
						return resource;
					}
				}
			}
			catch (IOException e) {
				return null;
			}
		}
		catch (IOException e) {
			throw new RuntimeException("Exception creating module classloader for " + moduleLocation, e);
		}
		return null;
	}
Return an expected module resource given a file extension. Will throw an exception if more than one such
resource exists. The resource is searched using an insulated module ClassLoader that only knows about the flat
contents of the module archive (does not search any parent classloader, nor any additional module library).
spring-xd-module/src/main/java/org/springframework/xd/module/options/ModuleUtils.java