use of org.springframework.integration.scripting.jsr223.ScriptExecutingMessageProcessor in project spring-integration by spring-projects.
the class DslScriptExecutingMessageProcessor method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (StringUtils.hasText(this.location)) {
this.script = this.applicationContext.getResource(this.location);
}
ScriptSource scriptSource = new RefreshableResourceScriptSource(this.script, this.refreshCheckDelay);
if (!StringUtils.hasText(this.lang)) {
String filename = this.script.getFilename();
int index = filename.lastIndexOf(".") + 1;
if (index < 1) {
throw new BeanCreationException("'lang' isn't provided and there is 'file extension' for script " + "resource: " + this.script);
}
this.lang = filename.substring(index);
}
if (this.applicationContext.containsBean(ScriptExecutingProcessorFactory.BEAN_NAME)) {
ScriptExecutingProcessorFactory processorFactory = this.applicationContext.getBean(ScriptExecutingProcessorFactory.BEAN_NAME, ScriptExecutingProcessorFactory.class);
this.delegate = processorFactory.createMessageProcessor(this.lang, scriptSource, this.variableGenerator);
} else {
this.delegate = new ScriptExecutingMessageProcessor(scriptSource, this.variableGenerator, ScriptExecutorFactory.getScriptExecutor(this.lang));
}
this.delegate.setBeanFactory(this.applicationContext);
this.delegate.setBeanClassLoader(this.applicationContext.getClassLoader());
}
Aggregations