use of org.springframework.scripting.support.ResourceScriptSource in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithStaticPointcut.
@Test
public void manualGroovyBeanWithStaticPointcut() throws Exception {
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);
}
use of org.springframework.scripting.support.ResourceScriptSource in project grails-core by grails.
the class GroovyPagesTemplateEngine method createTemplate.
public Template createTemplate(ScriptSource scriptSource) {
if (scriptSource instanceof GroovyPageCompiledScriptSource) {
// 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());
} catch (IOException e) {
throw new RuntimeException("IOException in createTemplate", e);
}
}
use of org.springframework.scripting.support.ResourceScriptSource in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcut.
@Test
public void manualGroovyBeanWithDynamicPointcut() throws Exception {
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);
}
use of org.springframework.scripting.support.ResourceScriptSource in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithUnconditionalPointcut.
@Test
public void manualGroovyBeanWithUnconditionalPointcut() throws Exception {
TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "GroovyServiceImpl");
}
use of org.springframework.scripting.support.ResourceScriptSource in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcutProxyTargetClass.
@Test
public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
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", true);
}
Aggregations