Project: springxd
Issue XD-3729: Make module class loader or module available to implementation of custom module 
Requirements: Make the class loader of the custom XD module available to the code of the custom module. Javassist's toClass method uses the thread's local class loader to [load classes|https://jboss-javassist.github.io/javassist/html/javassist/CtClass.html#toClass--]. This is most definitely inappropriate in the case of Spring XD modules, since many classes come from the lib/ directory of the module. Those will produce a ClassDefNotFound exception in javassist. Currently the ModuleFactory basically "throws away" the class loader, after generating it: {code}	private Module createSimpleModule(ModuleDescriptor moduleDescriptor, ModuleOptions moduleOptions,	ModuleDeploymentProperties deploymentProperties) {	if (log.isInfoEnabled()) {	log.info("creating simple module " + moduleDescriptor);	}	SimpleModuleDefinition definition = (SimpleModuleDefinition) moduleDescriptor.getModuleDefinition();	ClassLoader moduleClassLoader = ModuleUtils.createModuleRuntimeClassLoader(definition, moduleOptions, this.parentClassLoader);	Class moduleClass = determineModuleClass((SimpleModuleDefinition) moduleDescriptor.getModuleDefinition(),	moduleOptions);	Assert.notNull(moduleClass,	String.format("Required module artifacts are either missing or invalid. Unable to determine module type for module definition: '%s:%s'.",	moduleDescriptor.getType(), moduleDescriptor.getModuleName()));	return SimpleModuleCreator	.createModule(moduleDescriptor, deploymentProperties, moduleClassLoader, moduleOptions, moduleClass);	} {code} I think it would be sufficient if either the current module or the class loader itself could be injected into the custom classes of the custom XD module. As far as I can see I cannot get a grip on the Module instance in the current state of XD system.
Story points: 3