Search in sources :

Example 1 with ScriptExecutingProcessorFactory

use of org.springframework.integration.scripting.config.ScriptExecutingProcessorFactory 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());
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) RefreshableResourceScriptSource(org.springframework.integration.scripting.RefreshableResourceScriptSource) ScriptExecutingProcessorFactory(org.springframework.integration.scripting.config.ScriptExecutingProcessorFactory) ScriptSource(org.springframework.scripting.ScriptSource) RefreshableResourceScriptSource(org.springframework.integration.scripting.RefreshableResourceScriptSource) AbstractScriptExecutingMessageProcessor(org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor) ScriptExecutingMessageProcessor(org.springframework.integration.scripting.jsr223.ScriptExecutingMessageProcessor)

Aggregations

BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 AbstractScriptExecutingMessageProcessor (org.springframework.integration.scripting.AbstractScriptExecutingMessageProcessor)1 RefreshableResourceScriptSource (org.springframework.integration.scripting.RefreshableResourceScriptSource)1 ScriptExecutingProcessorFactory (org.springframework.integration.scripting.config.ScriptExecutingProcessorFactory)1 ScriptExecutingMessageProcessor (org.springframework.integration.scripting.jsr223.ScriptExecutingMessageProcessor)1 ScriptSource (org.springframework.scripting.ScriptSource)1