[jboss-svn-commits] JBL Code SVN: r18062 - labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jan 23 09:35:11 EST 2008
Author: fmeyer
Date: 2008-01-23 09:35:11 -0500 (Wed, 23 Jan 2008)
New Revision: 18062
Modified:
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel
Log:
SOA-336 JBRULES-1421 Update mvel version to 1.2.21 and update mvel templates
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel 2008-01-23 13:44:04 UTC (rev 18061)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaInvokers.mvel 2008-01-23 14:35:11 UTC (rev 18062)
@@ -4,7 +4,7 @@
java.io.InputStream is = @{ruleClassName}.class.getClassLoader().getResourceAsStream( "@{package}.@{ruleClassName}".replace( '.', '/' ) + ".class" );
-
+
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
byte[] data = new byte[1024];
int byteCount;
@@ -12,21 +12,21 @@
while ( (byteCount = is.read( data,
0,
1024 )) > -1 )
- {
+ {
bos.write(data, 0, byteCount);
}
} catch ( java.io.IOException e ) {
throw new org.drools.RuntimeDroolsException("Unable getResourceAsStream for Class '@{ruleClassName}' ");
- }
-
+ }
+
org.drools.asm.ClassReader classReader = new org.drools.asm.ClassReader( bos.toByteArray() );
classReader.accept( visit, true );
org.drools.asm.util.TraceMethodVisitor trace = visit.getTrace();
- return trace.getText();
+ return trace.getText();
}
>>=::
-
+
equals() ::=<<
public boolean equals(Object object) {
if (object == null ) {
@@ -34,13 +34,13 @@
} else if ( object == this ){
return true;
}
-
+
if ( ! (object instanceof org.drools.spi.CompiledInvoker) ) {
return false;
}
-
+
org.drools.spi.CompiledInvoker other = ( org.drools.spi.CompiledInvoker ) object;
-
+
return org.drools.util.asm.MethodComparator.compareBytecode( getMethodBytecode(), other.getMethodBytecode() );
}
>>=::
@@ -57,15 +57,15 @@
public class @{invokerClassName} implements org.drools.spi.ReturnValueExpression, org.drools.spi.CompiledInvoker
{
private static final long serialVersionUID = 400L;
-
+
public org.drools.spi.FieldValue evaluate(java.lang.Object object,
org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] previousDeclarations,
- org.drools.rule.Declaration[] localDeclarations,
- org.drools.WorkingMemory workingMemory) throws Exception {
+ org.drools.rule.Declaration[] previousDeclarations,
+ org.drools.rule.Declaration[] localDeclarations,
+ org.drools.WorkingMemory workingMemory) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) previousDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( previousDeclarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@if{readLocalsFromTuple}
@foreach{localDeclarationTypes as type, localDeclarations as declr} @{type} @{declr.identifier} = ( @{type} ) localDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( localDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -75,22 +75,22 @@
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
+
+ return @{ruleClassName}.@{methodName}(
@foreach{declarations as declr} @{declr.identifier}
- @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
+ @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
@foreach{localDeclarations as declr} @{declr.identifier}
@end{","}@if{globals != empty && (localDeclarations != empty || declarations != empty)}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+}
>>=::
predicateInvoker() ::=<<
@@ -99,35 +99,35 @@
public class @{invokerClassName} implements org.drools.spi.PredicateExpression, org.drools.spi.CompiledInvoker
{
private static final long serialVersionUID = 400L;
-
+
public boolean evaluate(java.lang.Object object,
org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] previousDeclarations,
- org.drools.rule.Declaration[] localDeclarations,
- org.drools.WorkingMemory workingMemory) throws Exception {
+ org.drools.rule.Declaration[] previousDeclarations,
+ org.drools.rule.Declaration[] localDeclarations,
+ org.drools.WorkingMemory workingMemory) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) previousDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( previousDeclarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@foreach{localDeclarationTypes as type, localDeclarations as declr} @{type} @{declr.identifier} = ( @{type} ) localDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, object );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
- @foreach{declarations as declr} @{declr.identifier}
- @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
- @foreach{localDeclarations as declr} @{declr.identifier}
+
+ return @{ruleClassName}.@{methodName}(
+ @foreach{declarations as declr} @{declr.identifier}
+ @end{","} @if{localDeclarations != empty && declarations != empty}, at end{}
+ @foreach{localDeclarations as declr} @{declr.identifier}
@end{","}@if{globals != empty && (localDeclarations != empty || declarations != empty)}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+}
>>=::
evalInvoker() ::=<<
@@ -136,29 +136,29 @@
public class @{invokerClassName} implements org.drools.spi.EvalExpression, org.drools.spi.CompiledInvoker
{
private static final long serialVersionUID = 400L;
-
+
public boolean evaluate(org.drools.spi.Tuple tuple,
- org.drools.rule.Declaration[] declarations,
- org.drools.WorkingMemory workingMemory) throws Exception {
+ org.drools.rule.Declaration[] declarations,
+ org.drools.WorkingMemory workingMemory) throws Exception {
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) tuple.get( declarations[@{i0}] ) ).getObject() );
- @end{}
+ @end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
@end{}
-
- return @{ruleClassName}.@{methodName}(
- @foreach{declarations as declr} @{declr.identifier}
+
+ return @{ruleClassName}.@{methodName}(
+ @foreach{declarations as declr} @{declr.identifier}
@end{","} @if{globals != empty && declarations != empty}, at end{}
@foreach{globals as identifier}@{identifier}
@end{","} );
- }
-
+ }
+
@includeByRef{hashCode(hashCode = hashCode)}
-
+
@includeByRef{getMethodBytecode(package = package, ruleClassName = ruleClassName, methodName = methodName)}
-
- @includeByRef{equals()}
-}
+
+ @includeByRef{equals()}
+}
>>=::
accumulateInvoker() ::=<<
@@ -171,11 +171,11 @@
public class @{invokerClassName} implements org.drools.spi.Accumulator, org.drools.spi.CompiledInvoker
{
private static final long serialVersionUID = 400L;
-
+
public Object createContext() {
return new @{ruleClassName}.@{className}();
}
-
+
public void init(java.lang.Object workingMemoryContext,
java.lang.Object context,
org.drools.spi.Tuple leftTuple,
@@ -184,12 +184,12 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
+ @end{}
+
((@{ruleClassName}.@{className})context).init(
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","} );
-
+
}
public void accumulate(java.lang.Object workingMemoryContext,
@@ -202,7 +202,7 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
+ @end{}
@if{isMultiPattern}
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( innerDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -213,7 +213,7 @@
((@{ruleClassName}.@{className})context).accumulate(
workingMemory,
innerDeclarations,
- handle.getObject()@if{declarations != empty}, at end{}
+ handle.getObject()@if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr} @{declr.identifier}@end{","});
@@ -229,7 +229,7 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
+ @end{}
@if{isMultiPattern}
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( innerDeclarations[@{i0}] ) ).getObject() );
@end{}
@@ -237,11 +237,11 @@
@foreach{innerDeclarations as declr} @{declr.extractor.extractToClassName} @{declr.identifier} = (@{declr.extractor.extractToClassName}) innerDeclarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, handle.getObject() );
@end{}
@end{}
-
+
((@{ruleClassName}.@{className})context).reverse(
workingMemory,
innerDeclarations,
- handle.getObject()@if{declarations != empty}, at end{}
+ handle.getObject()@if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr} @{declr.identifier}@end{","});
@@ -255,13 +255,13 @@
@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier} = ( @{type} ) declarations[@{i0}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, ( (org.drools.common.InternalFactHandle) leftTuple.get( declarations[@{i0}] ) ).getObject() );
@end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
+ @end{}
+
return ((@{ruleClassName}.@{className})context).getResult(
@foreach{declarations as declr} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}@end{","} );
}
-
+
public boolean supportsReverse() {
return @{supportsReverse};
}
@@ -269,14 +269,14 @@
public Object createWorkingMemoryContext() {
return null;
}
-
+
@includeByRef{hashCode(hashCode = hashCode)}
-
- @includeByRef{equals()}
+ @includeByRef{equals()}
+
public java.util.List getMethodBytecode() {
java.io.InputStream is = @{ruleClassName}.class.getClassLoader().getResourceAsStream( "@{package}.@{ruleClassName}".replace( '.', '/' ) + "$@{className}" + ".class" );
-
+
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
byte[] data = new byte[1024];
int byteCount;
@@ -284,15 +284,15 @@
while ( (byteCount = is.read( data,
0,
1024 )) > -1 )
- {
+ {
bos.write(data, 0, byteCount);
}
} catch ( java.io.IOException e ) {
throw new org.drools.RuntimeDroolsException("Unable getResourceAsStream for Class '@{ruleClassName}$@{className}' ");
- }
- return Collections.singletonList( bos );
+ }
+ return Collections.singletonList( bos );
}
-}
+}
>>=::
consequenceInvoker() ::=<<
@@ -303,27 +303,65 @@
private static final long serialVersionUID = 400L;
public void evaluate(org.drools.spi.KnowledgeHelper knowledgeHelper,
- org.drools.WorkingMemory workingMemory) throws Exception {
-
+ org.drools.WorkingMemory workingMemory) throws Exception {
+
org.drools.spi.Tuple tuple = knowledgeHelper.getTuple();
org.drools.rule.Rule rule = knowledgeHelper.getRule();
- org.drools.rule.Declaration[] declarations = rule.getDeclarations();
+ org.drools.rule.Declaration[] declarations = rule.getDeclarations();
@foreach{declarationTypes as type, declarations as declr ,indexes as index, notPatterns as notPattern}
- org.drools.common.InternalFactHandle @{declr.identifier}__Handle__ = ( org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration( declarations[@{index}].getIdentifier() ) );
+ org.drools.common.InternalFactHandle @{declr.identifier}__Handle__ = ( org.drools.common.InternalFactHandle ) tuple.get( knowledgeHelper.getDeclaration( declarations[@{index}].getIdentifier() ) );
@{type} @{declr.identifier} = ( @{type} ) declarations[@{index}].@{declr.nativeReadMethod.name}( (org.drools.common.InternalWorkingMemory) workingMemory, @{declr.identifier}__Handle__.getObject() );
@if{notPattern}@{declr.identifier}__Handle__ = (org.drools.common.InternalFactHandle) knowledgeHelper.getWorkingMemory().getFactHandle( @{declr.identifier} );@end{}
@end{}
-
- @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
- @end{}
-
- @{ruleClassName}.@{methodName} (
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ @{ruleClassName}.@{methodName} (
knowledgeHelper at if{declarations != empty}, at end{}
@foreach{declarations as declr} @{declr.identifier}, @{declr.identifier}__Handle__
@end{","}@if{globals != empty}, at end{}
@foreach{globals as identifier} @{identifier}
@end{","} );
}
-}
+}
+>>=::
+
+actionInvoker() ::=<<
+package @{package};
+
+public class @{invokerClassName} implements org.drools.spi.Action
+{
+ private static final long serialVersionUID = 400L;
+
+ public void execute(org.drools.WorkingMemory workingMemory) throws Exception {
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ @{processClassName}.@{methodName} (
+ @foreach{globals as identifier} @{identifier}
+ @end{","} );
+ }
+}
+>>=::
+
+returnValueEvaluatorInvoker() ::=<<
+package @{package};
+
+public class @{invokerClassName} implements org.drools.spi.ReturnValueEvaluator
+{
+ private static final long serialVersionUID = 400L;
+
+ public Object evaluate(org.drools.WorkingMemory workingMemory) throws Exception {
+
+ @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} = ( @{type} ) workingMemory.getGlobal( "@{identifier}" );
+ @end{}
+
+ return @{processClassName}.@{methodName} (
+ @foreach{globals as identifier} @{identifier}
+ @end{","} );
+ }
+}
>>=::
\ No newline at end of file
Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel 2008-01-23 13:44:04 UTC (rev 18061)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/main/resources/org/drools/rule/builder/dialect/java/javaRule.mvel 2008-01-23 14:35:11 UTC (rev 18062)
@@ -25,43 +25,43 @@
public static class @{className} {
@foreach{attributesTypes as type, attributes as attr} private @{type} @{attr};
- @end{}
-
+ @end{}
+
public @{className}() {
}
- public void init(@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
+ public void init(@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","}
) throws Exception {
@{initCode}
}
-
+
public void accumulate(org.drools.WorkingMemory workingMemory,
- org.drools.rule.Declaration[] innerDeclarations,
+ org.drools.rule.Declaration[] innerDeclarations,
Object object @if{declarations != empty}, @end{}
- @foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
+ @foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr}@{declr.extractor.extractToClassName} @{declr.identifier}@end{","}
) throws Exception {
@{actionCode}
}
-
+
public void reverse(org.drools.WorkingMemory workingMemory,
- org.drools.rule.Declaration[] innerDeclarations,
+ org.drools.rule.Declaration[] innerDeclarations,
Object object @if{declarations != empty}, @end{}
- @foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
+ @foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","}@if{innerDeclarations != empty}, at end{}
@foreach{innerDeclarations as declr}@{declr.extractor.extractToClassName} @{declr.identifier}@end{","}
) throws Exception {
@{reverseCode}
}
-
- public Object getResult(@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
+
+ public Object getResult(@foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}@end{","}@if{globals != empty}, at end{}
@foreach{globalTypes as type, globals as identifier}@{type} @{identifier} @end{","}
) throws Exception {
return ( @{resultCode} );
}
-
+
public boolean supportsReverse() {
return @{supportsReverse};
}
@@ -72,4 +72,16 @@
public static void @{methodName}(org.drools.spi.KnowledgeHelper drools at if{declarations != empty}, at end{} @foreach{declarationTypes as type, declarations as declr} @{type} @{declr.identifier}, org.drools.FactHandle @{declr.identifier}__Handle__ @end{","}@if{globals != empty}, at end{} @foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","} ) throws Exception {
@{text}
}
+>>=::
+
+actionMethod() ::=<<
+public static void @{methodName}(@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","} ) throws Exception {
+ @{text}
+}
+>>=::
+
+returnValueEvaluatorMethod() ::=<<
+public static Object @{methodName}(@foreach{globalTypes as type, globals as identifier} @{type} @{identifier} @end{","} ) throws Exception {
+ @{text}
+}
>>=::
\ No newline at end of file
More information about the jboss-svn-commits
mailing list