(S)FTP Lambdas
AMQP Lambdas Event Lambdas Feed/File Lambdas Gemfile/Groovy Lambdas * Ensure that JavaDocs are checked via ` check.dependsOn javadoc` * Add `@return` tag to the `MessageBuilder.readOnlyHeaders()`
This commit is contained in:
committed by
Artem Bilan
parent
3402a86fb5
commit
e5ae7d886d
@@ -56,6 +56,7 @@ import groovy.transform.CompileStatic;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Stefan Reuter
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecutingMessageProcessor<Object>
|
||||
@@ -69,13 +70,7 @@ public class GroovyScriptExecutingMessageProcessor extends AbstractScriptExecuti
|
||||
private volatile ScriptSource scriptSource;
|
||||
|
||||
private volatile GroovyClassLoader groovyClassLoader = AccessController.doPrivileged(
|
||||
new PrivilegedAction<GroovyClassLoader>() {
|
||||
|
||||
public GroovyClassLoader run() {
|
||||
return new GroovyClassLoader(ClassUtils.getDefaultClassLoader());
|
||||
}
|
||||
|
||||
});
|
||||
(PrivilegedAction<GroovyClassLoader>) () -> new GroovyClassLoader(ClassUtils.getDefaultClassLoader()));
|
||||
|
||||
private volatile Class<?> scriptClass;
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ public class GroovyScriptExecutingMessageProcessorTests {
|
||||
ScriptSource scriptSource = new ResourceScriptSource(resource);
|
||||
Object result = null;
|
||||
class CustomScriptVariableGenerator implements ScriptVariableGenerator {
|
||||
@Override
|
||||
public Map<String, Object> generateScriptVariables(Message<?> message) {
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
variables.put("date", System.nanoTime());
|
||||
@@ -197,24 +198,16 @@ public class GroovyScriptExecutingMessageProcessorTests {
|
||||
|
||||
ScriptSource scriptSource = new StaticScriptSource(script, Script.class.getName());
|
||||
final MessageProcessor<Object> processor =
|
||||
new GroovyScriptExecutingMessageProcessor(scriptSource, new ScriptVariableGenerator() {
|
||||
@Override
|
||||
public Map<String, Object> generateScriptVariables(Message<?> message) {
|
||||
Map<String, Object> variables = new HashMap<String, Object>(2);
|
||||
variables.put("var1", var1);
|
||||
variables.put("var2", var2);
|
||||
return variables;
|
||||
}
|
||||
new GroovyScriptExecutingMessageProcessor(scriptSource, message1 -> {
|
||||
Map<String, Object> variables = new HashMap<String, Object>(2);
|
||||
variables.put("var1", var1);
|
||||
variables.put("var2", var2);
|
||||
return variables;
|
||||
});
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processor.processMessage(message);
|
||||
}
|
||||
});
|
||||
executor.execute(() -> processor.processMessage(message));
|
||||
}
|
||||
executor.shutdown();
|
||||
assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS));
|
||||
@@ -246,6 +239,7 @@ public class GroovyScriptExecutingMessageProcessorTests {
|
||||
this.script = script;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "test";
|
||||
}
|
||||
@@ -255,6 +249,7 @@ public class GroovyScriptExecutingMessageProcessorTests {
|
||||
return this.filename;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(script.getBytes("UTF-8"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user