Package org.springframework.scripting.support

Examples of org.springframework.scripting.support.ResourceScriptSource


    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("payload", order.getItems().get(0));
    variables.put("timeToPrepare", 1L);

    Object obj = executor.executeScript(
        new ResourceScriptSource(new FileSystemResource("scripts/ruby/barista.rb")), variables);
    assertNotNull(obj);
    assertTrue(obj instanceof Drink);

  }
View Full Code Here


    order.addItem(DrinkType.LATTE, 2, false);
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("payload", order.getItems().get(0));
    variables.put("timeToPrepare", "1");

    Object obj = executor.executeScript(new ResourceScriptSource(
        new FileSystemResource("scripts/python/barista.py")), variables);
    assertNotNull(obj);
    assertTrue(obj instanceof Drink);

  }
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

            // handle pre-compiled
            return createTemplateFromPrecompiled((GroovyPageCompiledScriptSource) scriptSource);
        }

        if (scriptSource instanceof ResourceScriptSource) {
            ResourceScriptSource resourceSource = (ResourceScriptSource) scriptSource;
            Resource resource = resourceSource.getResource();
            return createTemplate(resource, true);
        }

        try {
            return createTemplate(scriptSource.getScriptAsString(), scriptSource.suggestedClassName());
View Full Code Here

        // Create script factory bean definition.
        GroovyScriptFactory groovyScriptFactory = new GroovyScriptFactory(scriptLocation);
        groovyScriptFactory.setBeanFactory(beanFactory);
        groovyScriptFactory.setBeanClassLoader(beanFactory.getBeanClassLoader());
        Object controller =
                groovyScriptFactory.getScriptedObject(new ResourceScriptSource(ctx.getResource(scriptLocation)));

        String controllerBeanName = scriptLocation;
        removeOldControllerMapping(controllerBeanName);
        if (beanFactory.containsBean(controllerBeanName)) {
            beanFactory.destroySingleton(controllerBeanName); //移除单例bean
View Full Code Here

  }

  @Test
  public void testGroovyScriptFromFile() {
    ScriptEvaluator evaluator = new GroovyScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
    assertEquals(6, result);
  }
View Full Code Here

  }

  @Test
  public void testGroovyScriptFromFileUsingJsr223() {
    ScriptEvaluator evaluator = new StandardScriptEvaluator();
    Object result = evaluator.evaluate(new ResourceScriptSource(new ClassPathResource("simple.groovy", getClass())));
    assertEquals(6, result);
  }
View Full Code Here

  @Test
  public void testManualGroovyBeanWithUnconditionalPointcut() throws Exception {
    LogUserAdvice logAdvice = new LogUserAdvice();

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
        new ClassPathResource("GroovyServiceImpl.grv", getClass())));

    testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "GroovyServiceImpl");
  }
View Full Code Here

  @Test
  public void testManualGroovyBeanWithStaticPointcut() throws Exception {
    LogUserAdvice logAdvice = new LogUserAdvice();

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
        new ClassPathResource("GroovyServiceImpl.grv", getClass())));

    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression(String.format("execution(* %s.TestService+.*(..))", ClassUtils.getPackageName(getClass())));
    testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
View Full Code Here

  @Test
  public void testManualGroovyBeanWithDynamicPointcut() throws Exception {
    LogUserAdvice logAdvice = new LogUserAdvice();

    GroovyScriptFactory scriptFactory = new GroovyScriptFactory("GroovyServiceImpl.grv");
    TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(
        new ClassPathResource("GroovyServiceImpl.grv", getClass())));

    AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
    pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
    testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", false);
View Full Code Here

TOP

Related Classes of org.springframework.scripting.support.ResourceScriptSource

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.