ivan mckinley created RTGOV-644:
-----------------------------------
Summary: Enable MVELExpressionEvaluator to evaluate more complex scripts
(with Variables)
Key: RTGOV-644
URL:
https://issues.jboss.org/browse/RTGOV-644
Project: RTGov (Run Time Governance)
Issue Type: Feature Request
Components: Information Processor
Affects Versions: 1.0.0.M1
Reporter: ivan mckinley
Assignee: Gary Brown
if a user wishes to execute more complex mvel scripts with variables during information
processing then MVEL fails with exception, {1}.
The following test case,2, demonstrates this behaviour in action.
Recommendation is to update line 44
https://github.com/Governance/rtgov/blob/master/modules/activity-manageme...
Object result=MVEL.executeExpression(_compiledExpression, information, new HashMap());
{1}Exception
activity event: org.mvel2.ScriptRuntimeException: cannot assign variables; no variable
resolver factory available.
at
org.mvel2.integration.impl.ImmutableDefaultFactory.throwError(ImmutableDefaultFactory.java:32)
at
org.mvel2.integration.impl.ImmutableDefaultFactory.createVariable(ImmutableDefaultFactory.java:36)
at
org.mvel2.integration.impl.ClassImportResolverFactory.createVariable(ClassImportResolverFactory.java:61)
at
org.mvel2.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:70)
at org.mvel2.MVELRuntime.execute(MVELRuntime.java:86)
at
org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119)
at
org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113)
at org.mvel2.MVEL.executeExpression(MVEL.java:954)
at
org.overlord.rtgov.activity.processor.mvel.MVELExpressionEvaluator.evaluate(MVELExpressionEvaluator.java:44)
at
org.overlord.rtgov.activity.processor.TypeProcessor$PropertyEvaluator.process(TypeProcessor.java:310)
at
org.overlord.rtgov.activity.processor.TypeProcessor.process(TypeProcessor.java:166)
at
org.overlord.rtgov.activity.processor.InformationProcessor.process(InformationProcessor.java:137)
at
org.overlord.rtgov.activity.processor.AbstractInformationProcessorManager.process(AbstractInformationProcessorManager.ja
{2} Test Case
@Test
public void testTransformDOM2() {
org.w3c.dom.Document doc=null;
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
org.w3c.dom.Element elem=doc.createElement("test");
doc.appendChild(elem);
elem.appendChild(doc.createTextNode("This is a test"));
} catch (Exception e) {
fail("Failed to build DOM: "+e);
}
String expression = "import javax.xml.transform.TransformerFactory; import
javax.xml.transform.Transformer; import javax.xml.transform.dom.DOMSource; import
javax.xml.transform.stream.StreamResult; import java.io.ByteArrayOutputStream;
ByteArrayOutputStream out = new ByteArrayOutputStream(); DOMSource source = new
DOMSource(this); StreamResult result = new StreamResult(out); TransformerFactory
transFactory = TransformerFactory.newInstance(); Transformer transformer =
transFactory.newTransformer(); transformer.transform(source, result); out.close(); return
new String(out.toByteArray());";
Object _compiledExpression=null;
_compiledExpression = MVEL.compileExpression(expression);
Object result=MVEL.executeExpression(_compiledExpression, doc);
if (result == null) {
fail("Failed to parse");
}
System.out.println(result);
--
This message was sent by Atlassian JIRA
(v6.3.11#6341)