Package org.springframework.scripting

Examples of org.springframework.scripting.ScriptSource


  @Resource
  private Configuration config;

  @Test
  public void testRhinoScript() throws Exception {
    ScriptSource script = new StaticScriptSource("msg = 'Hello, world!'");

    Jsr223ScriptEvaluator eval = new Jsr223ScriptEvaluator();
    eval.setLanguage("javascript");

    assertEquals("Hello, world!", eval.evaluate(script));
View Full Code Here


  }

  @Test
  public void testRhinoHadoopScript() throws Exception {
    UrlResource urlResource = new UrlResource(getClass().getResource("basic-script.js"));
    ScriptSource script = new ResourceScriptSource(urlResource);

    Jsr223ScriptEvaluator eval = new Jsr223ScriptEvaluator();
    eval.setLanguage("javascript");

    Map<String, Object> args = new LinkedHashMap<String, Object>();
View Full Code Here

    ctx.getBean("distcp");
  }

  @Test
  public void testNullCfg() throws Exception {
    ScriptSource script = new StaticScriptSource("null");
   
    HdfsScriptRunner hsfb = new HdfsScriptRunner();
    GenericApplicationContext gac = new GenericApplicationContext();
    gac.refresh();
    hsfb.setApplicationContext(gac);
View Full Code Here

    String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
    prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);

    ScriptFactory scriptFactory =
        (ScriptFactory) this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
    ScriptSource scriptSource =
        getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
    Class[] interfaces = scriptFactory.getScriptInterfaces();

    Class scriptedType = null;
    try {
View Full Code Here

    String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
    prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);

    ScriptFactory scriptFactory =
        (ScriptFactory) this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
    ScriptSource scriptSource =
        getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
    boolean isFactoryBean = false;
    try {
      Class scriptedObjectType = scriptFactory.getScriptedObjectType(scriptSource);
      // returned type may be null if the factory is unable to determine
View Full Code Here

        this.scriptBeanFactory.registerBeanDefinition(
            scriptFactoryBeanName, createScriptFactoryBeanDefinition(bd));
        ScriptFactory scriptFactory =
            (ScriptFactory) this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
        ScriptSource scriptSource =
            getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
        Class[] interfaces = scriptFactory.getScriptInterfaces();

        Class[] scriptedInterfaces = interfaces;
        if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
View Full Code Here

   * @return the corresponding ScriptSource instance
   * @see #convertToScriptSource
   */
  protected ScriptSource getScriptSource(String beanName, String scriptSourceLocator) {
    synchronized (this.scriptSourceCache) {
      ScriptSource scriptSource = (ScriptSource) this.scriptSourceCache.get(beanName);
      if (scriptSource == null) {
        scriptSource = convertToScriptSource(scriptSourceLocator, this.resourceLoader);
        this.scriptSourceCache.put(beanName, scriptSource);
      }
      return scriptSource;
View Full Code Here

        this.scriptBeanFactory.registerBeanDefinition(scriptFactoryBeanName,
            createScriptFactoryBeanDefinition(bd));
        ScriptFactory scriptFactory = this.scriptBeanFactory
            .getBean(scriptFactoryBeanName, ScriptFactory.class);
        ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName,
            scriptFactory.getScriptSourceLocator());
        Class<?>[] interfaces = scriptFactory.getScriptInterfaces();

        Class<?>[] scriptedInterfaces = interfaces;
        if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) {
View Full Code Here

   * @return the corresponding ScriptSource instance
   * @see #convertToScriptSource
   */
  protected ScriptSource getScriptSource(String beanName, String scriptSourceLocator) {
    synchronized (this.scriptSourceCache) {
      ScriptSource scriptSource = this.scriptSourceCache.get(beanName);
      if (scriptSource == null) {
        scriptSource = convertToScriptSource(beanName, scriptSourceLocator, this.resourceLoader);
        this.scriptSourceCache.put(beanName, scriptSource);
      }
      return scriptSource;
View Full Code Here

      String scriptFactoryBeanName = SCRIPT_FACTORY_NAME_PREFIX + beanName;
      String scriptedObjectBeanName = SCRIPTED_OBJECT_NAME_PREFIX + beanName;
      prepareScriptBeans(bd, scriptFactoryBeanName, scriptedObjectBeanName);

      ScriptFactory scriptFactory = this.scriptBeanFactory.getBean(scriptFactoryBeanName, ScriptFactory.class);
      ScriptSource scriptSource = getScriptSource(scriptFactoryBeanName, scriptFactory.getScriptSourceLocator());
      Class[] interfaces = scriptFactory.getScriptInterfaces();

      Class scriptedType = scriptFactory.getScriptedObjectType(scriptSource);
      if (scriptedType != null) {
        return scriptedType;
View Full Code Here

TOP

Related Classes of org.springframework.scripting.ScriptSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.