Example usage for org.springframework.scripting.support StaticScriptSource StaticScriptSource

List of usage examples for org.springframework.scripting.support StaticScriptSource StaticScriptSource

Introduction

In this page you can find the example usage for org.springframework.scripting.support StaticScriptSource StaticScriptSource.

Prototype

public StaticScriptSource(String script, @Nullable String className) 

Source Link

Document

Create a new StaticScriptSource for the given script.

Usage

From source file:org.iff.infra.util.spring.script.ScriptFactoryPostProcessor.java

/**
 * Convert the given script source locator to a ScriptSource instance.
 * <p>By default, supported locators are Spring resource locations
 * (such as "file:C:/myScript.bsh" or "classpath:myPackage/myScript.bsh")
 * and inline scripts ("inline:myScriptText...").
 * @param beanName the name of the scripted bean
 * @param scriptSourceLocator the script source locator
 * @param resourceLoader the ResourceLoader to use (if necessary)
 * @return the ScriptSource instance/*from  w w w  .  ja  v a2 s .co m*/
 */
protected ScriptSource convertToScriptSource(String beanName, String scriptSourceLocator,
        ResourceLoader resourceLoader) {

    if (scriptSourceLocator.startsWith(INLINE_SCRIPT_PREFIX)) {
        return new StaticScriptSource(scriptSourceLocator.substring(INLINE_SCRIPT_PREFIX.length()), beanName);
    } else {
        return new ResourceScriptSource(resourceLoader.getResource(scriptSourceLocator));
    }
}