Groovy 표현식에서 사용자 지정 GroovyShell 인스턴스를 사용해야 하는 경우가 있습니다. 사용자 정의 GroovyShell 을 제공하려면 org.apache.camel. Cryostat.groovy.GroovyShell SPI 인터페이스를 Camel 레지스트리에 추가합니다. 예를 들어 Spring 컨텍스트에 다음 빈을 추가한 후입니다.
public class CustomGroovyShellFactory implements GroovyShellFactory {
public GroovyShell createGroovyShell(Exchange exchange) {
ImportCustomizer importCustomizer = new ImportCustomizer();
importCustomizer.addStaticStars("com.example.Utils");
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.addCompilationCustomizers(importCustomizer);
return new GroovyShell(configuration);
}
}
public class CustomGroovyShellFactory implements GroovyShellFactory {
public GroovyShell createGroovyShell(Exchange exchange) {
ImportCustomizer importCustomizer = new ImportCustomizer();
importCustomizer.addStaticStars("com.example.Utils");
CompilerConfiguration configuration = new CompilerConfiguration();
configuration.addCompilationCustomizers(importCustomizer);
return new GroovyShell(configuration);
}
}
Copy to ClipboardCopied!Toggle word wrapToggle overflow
…Camel은 기본 정적 가져오기 대신 사용자 지정 GroovyShell 인스턴스(사용자 정의 정적 가져오기 포함)를 사용합니다.