INT-1507, INT-1545: Add groovy processor for payloads

- Remove unneeded config file
- Upgrade groovy
- fix potential permgen leak in groovy payload processor
- Test concurrent execution
This commit is contained in:
Dave Syer
2010-10-18 10:45:57 -07:00
parent 64fec64d40
commit d7bbbaae17
9 changed files with 378 additions and 68 deletions

View File

@@ -1,17 +1,14 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package org.springframework.integration.handler;
@@ -19,7 +16,6 @@ package org.springframework.integration.handler;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHandlingException;
import org.springframework.scripting.ScriptSource;
import org.springframework.util.Assert;
/**
* Base {@link MessageProcessor} for scripting implementations to extend.
@@ -29,33 +25,29 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractScriptExecutingMessageProcessor<T> implements MessageProcessor<T> {
private final ScriptSource scriptSource;
/**
* Create a processor for the given {@link ScriptSource}.
*/
public AbstractScriptExecutingMessageProcessor(ScriptSource scriptSource) {
Assert.notNull(scriptSource, "scriptSource must not be null");
this.scriptSource = scriptSource;
}
/**
* Executes the script and returns the result.
*/
public final T processMessage(Message<?> message) {
try {
return this.executeScript(this.scriptSource, message);
}
catch (Exception e) {
return this.executeScript(getScriptSource(message), message);
} catch (Exception e) {
throw new MessageHandlingException(message, "failed to execute script", e);
}
}
/**
* Subclasses must implement this method. In doing so, the execution context for the
* script should be populated with the Message's 'payload' and 'headers' as variables.
* Subclasses must implement this method to create a script source, optionally using the message to locate or
* create the script.
*
* @param message the message being processed
* @return a ScriptSource to use to create a script
*/
protected abstract ScriptSource getScriptSource(Message<?> message);
/**
* Subclasses must implement this method. In doing so, the execution context for the script should be populated with
* the Message's 'payload' and 'headers' as variables.
*/
protected abstract T executeScript(ScriptSource scriptSource, Message<?> message) throws Exception;