Uploaded image for project: 'Spring XD'
  1. Spring XD
  2. XD-3729

Make module class loader or module available to implementation of custom module

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: To Do
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Stream Module
    • Labels:
      None
    • Story Points:
      3
    • Rank (Obsolete):
      9223372036854775807

      Description

      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. 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:

      	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<? extends SimpleModule> 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);
      	}
      

      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.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            arne.schmitz Arne Schmitz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: