Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[DROOLS-91] fix property reactivity masks for properties inherited fr…

…om interfaces
  • Loading branch information...
commit 6d2840d9ac5e322b9df8b29355d5e5f5d1786004 1 parent cd74443
mariofusco authored March 27, 2013

Showing 21 changed files with 349 additions and 57 deletions. Show diff stats Hide diff stats

  1. 5  drools-compiler/src/main/java/org/drools/compiler/compiler/PackageBuilder.java
  2. 16  drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/DialectUtil.java
  3. 2  drools-compiler/src/test/java/org/drools/compiler/integrationtests/ExecutionFlowControlTest.java
  4. 199  drools-compiler/src/test/java/org/drools/compiler/integrationtests/PropertyReactivityTest.java
  5. 54  drools-compiler/src/test/java/org/drools/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java
  6. 10  drools-core/src/main/java/org/drools/core/base/DefaultKnowledgeHelper.java
  7. 2  drools-core/src/main/java/org/drools/core/base/ModifyInterceptor.java
  8. 4  drools-core/src/main/java/org/drools/core/base/SequentialKnowledgeHelper.java
  9. 5  drools-core/src/main/java/org/drools/core/common/AbstractWorkingMemory.java
  10. 1  drools-core/src/main/java/org/drools/core/common/InternalWorkingMemoryActions.java
  11. 1  drools-core/src/main/java/org/drools/core/common/InternalWorkingMemoryEntryPoint.java
  12. 7  drools-core/src/main/java/org/drools/core/common/NamedEntryPoint.java
  13. 53  drools-core/src/main/java/org/drools/core/common/PropagationContextImpl.java
  14. 2  drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java
  15. 2  drools-core/src/main/java/org/drools/core/impl/StatefulKnowledgeSessionImpl.java
  16. 4  drools-core/src/main/java/org/drools/core/reteoo/DisposedReteooWorkingMemory.java
  17. 4  drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java
  18. 18  drools-core/src/main/java/org/drools/core/rule/Rule.java
  19. 4  drools-core/src/main/java/org/drools/core/spi/KnowledgeHelper.java
  20. 9  drools-core/src/main/java/org/drools/core/spi/PropagationContext.java
  21. 4  drools-core/src/main/java/org/drools/core/util/BitMaskUtil.java
5  drools-compiler/src/main/java/org/drools/compiler/compiler/PackageBuilder.java
@@ -1435,10 +1435,7 @@ private void initTypeDeclaration( Class<?> cls, TypeDeclaration typeDeclaration
1435 1435
     }
1436 1436
 
1437 1437
     private TypeDeclaration createTypeDeclarationForBean( Class<?> cls ) {
1438  
-        String typeName = cls.getName();
1439  
-        int lastDot = typeName.lastIndexOf( '.' );
1440  
-        typeName = lastDot >= 0 ? typeName.substring( lastDot + 1 ) : typeName;
1441  
-        TypeDeclaration typeDeclaration = new TypeDeclaration( typeName );
  1438
+        TypeDeclaration typeDeclaration = new TypeDeclaration( cls.getSimpleName() );
1442 1439
         typeDeclaration.setTypeClass( cls );
1443 1440
 
1444 1441
         PropertySpecificOption propertySpecificOption = configuration.getOption(PropertySpecificOption.class);
16  drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/DialectUtil.java
@@ -652,7 +652,7 @@ private static void rewriteModifyDescr( RuleBuildContext context,
652 652
 
653 653
         addLineBreaks(consequence, originalBlock.substring(end));
654 654
 
655  
-        appendUpdateStatement(consequence, declr, obj, modificationMask);
  655
+        appendUpdateStatement(consequence, declr, obj, modificationMask, typeClass);
656 656
     }
657 657
 
658 658
     private static void rewriteUpdateDescr(RuleBuildContext context,
@@ -686,17 +686,20 @@ private static void rewriteUpdateDescr(RuleBuildContext context,
686 686
             }
687 687
         }
688 688
 
689  
-        appendUpdateStatement(consequence, declr, obj, modificationMask);
  689
+        appendUpdateStatement(consequence, declr, obj, modificationMask, typeClass);
690 690
     }
691 691
 
692  
-    private static void appendUpdateStatement(StringBuilder consequence, Declaration declr, String obj, long modificationMask) {
  692
+    private static void appendUpdateStatement(StringBuilder consequence, Declaration declr, String obj, long modificationMask, Class<?> typeClass) {
693 693
         boolean isInternalFact = declr == null || declr.isInternalFact();
694 694
         consequence
695 695
                 .append("drools.update( ")
696 696
                 .append(obj)
697 697
                 .append(isInternalFact ? "__Handle2__, " : "__Handle__, ")
698 698
                 .append(modificationMask)
699  
-                .append("L ); }");
  699
+                .append("L, ")
  700
+                .append(typeClass != null ? typeClass.getCanonicalName() : "java.lang.Object")
  701
+                .append(".class")
  702
+                .append(" ); }");
700 703
     }
701 704
 
702 705
     private static long parseModifiedProperties(ConsequenceMetaData.Statement statement,
@@ -778,6 +781,11 @@ private static long updateModificationMask(List<String> settableProperties,
778 781
     }
779 782
 
780 783
     private static Class<?> findDeclarationClass(RuleBuildContext context, JavaBlockDescr d, String statement) {
  784
+        Class<?> inputClass = d.getInputs() == null ? null : d.getInputs().get(statement);
  785
+        if (inputClass != null) {
  786
+            return inputClass;
  787
+        }
  788
+
781 789
         List<JavaLocalDeclarationDescr> localDeclarationDescrs = d.getInScopeLocalVars();
782 790
         if (localDeclarationDescrs == null) {
783 791
             return null;
2  drools-compiler/src/test/java/org/drools/compiler/integrationtests/ExecutionFlowControlTest.java
@@ -984,7 +984,7 @@ public void activationCancelled(ActivationCancelledEvent event,
984 984
                 .getActivation();
985 985
 
986 986
         // simulate a modify inside a consequence
987  
-        wm.update( stiltonHandle, stilton, Long.MAX_VALUE, item );
  987
+        wm.update( stiltonHandle, stilton, Long.MAX_VALUE, Object.class, item );
988 988
 
989 989
         // with true modify, no reactivations should be triggered
990 990
         assertEquals( 3, created.size() );
199  drools-compiler/src/test/java/org/drools/compiler/integrationtests/PropertyReactivityTest.java
... ...
@@ -0,0 +1,199 @@
  1
+package org.drools.compiler.integrationtests;
  2
+
  3
+import org.drools.compiler.CommonTestMethodBase;
  4
+import org.junit.Test;
  5
+import org.kie.api.definition.type.PropertyReactive;
  6
+import org.kie.internal.KnowledgeBase;
  7
+import org.kie.internal.runtime.StatefulKnowledgeSession;
  8
+
  9
+import java.util.ArrayList;
  10
+import java.util.Arrays;
  11
+import java.util.List;
  12
+
  13
+public class PropertyReactivityTest extends CommonTestMethodBase {
  14
+
  15
+    @PropertyReactive
  16
+    public static interface Intf1 {
  17
+        public int getC();
  18
+        public void setC(int c);
  19
+
  20
+        public int getD();
  21
+        public void setD(int d);
  22
+
  23
+        public int getF();
  24
+        public void setF(int f);
  25
+
  26
+        public String getId();
  27
+    }
  28
+
  29
+    @PropertyReactive
  30
+    public static interface Intf2 {
  31
+        public int getD();
  32
+        public void setD(int d);
  33
+
  34
+        public int getE();
  35
+        public void setE(int e);
  36
+
  37
+        public String getId();
  38
+    }
  39
+
  40
+    @PropertyReactive
  41
+    public static class Klass implements Intf1, Intf2 {
  42
+        private String id = "k1";
  43
+        private int a;
  44
+        private int b;
  45
+        private int c;
  46
+        private int d;
  47
+        private int e;
  48
+        private int f;
  49
+
  50
+        public Klass(int a, int b, int c, int d, int e, int f) {
  51
+            this.a = a;
  52
+            this.b = b;
  53
+            this.c = c;
  54
+            this.d = d;
  55
+            this.e = e;
  56
+            this.f = f;
  57
+        }
  58
+
  59
+        public int getA() { return a; }
  60
+        public void setA(int a) { this.a = a; }
  61
+
  62
+        public int getB() { return b; }
  63
+        public void setB(int b) { this.b = b; }
  64
+
  65
+        public int getC() { return c; }
  66
+        public void setC(int c) { this.c = c; }
  67
+
  68
+        public int getD() { return d; }
  69
+        public void setD(int d) { this.d = d; }
  70
+
  71
+        public int getE() { return e; }
  72
+        public void setE(int e) { this.e = e; }
  73
+
  74
+        public int getF() { return f; }
  75
+        public void setF(int f) { this.f = f; }
  76
+
  77
+        public String getId() { return id; }
  78
+    }
  79
+
  80
+    @PropertyReactive
  81
+    public static class Klass2 implements Intf2 {
  82
+        private String id = "k2";
  83
+        private int b;
  84
+        private int c;
  85
+        private int d;
  86
+        private int e;
  87
+
  88
+        public Klass2( int b, int c, int d, int e ) {
  89
+            this.b = b;
  90
+            this.c = c;
  91
+            this.d = d;
  92
+            this.e = e;
  93
+        }
  94
+
  95
+        public int getB() { return b; }
  96
+        public void setB(int b) { this.b = b; }
  97
+
  98
+        public int getC() { return c; }
  99
+        public void setC(int c) { this.c = c; }
  100
+
  101
+        public int getD() { return d; }
  102
+        public void setD(int d) { this.d = d; }
  103
+
  104
+        public int getE() { return e; }
  105
+        public void setE(int e) { this.e = e; }
  106
+
  107
+        public String getId() { return id; }
  108
+    }
  109
+
  110
+
  111
+    @Test
  112
+    public void testScrambleWithInterfaces() {
  113
+    /*
  114
+     *       K1 a b c d e f    1000
  115
+     *       I1     c d   f    10
  116
+     *       I2       d e      1
  117
+     *       K2   b c d e      100
  118
+     */
  119
+
  120
+        // DROOLS-91
  121
+        String str =
  122
+                "package org.drools.test;\n" +
  123
+                "\n" +
  124
+                "import org.drools.compiler.integrationtests.PropertyReactivityTest.Intf1;\n" +
  125
+                "import org.drools.compiler.integrationtests.PropertyReactivityTest.Intf2;\n" +
  126
+                "import org.drools.compiler.integrationtests.PropertyReactivityTest.Klass;\n" +
  127
+                "import org.drools.compiler.integrationtests.PropertyReactivityTest.Klass2;\n" +
  128
+                "\n" +
  129
+                "global java.util.List list;\n" +
  130
+                "\n" +
  131
+                "rule \"Init\"\n" +
  132
+                "when\n" +
  133
+                "then\n" +
  134
+                "  insert( new Klass( 1, 2, 3, 4, 5, 6 ) );\n" +
  135
+                "  insert( new Klass2( 2, 3, 4, 5 ) );\n" +
  136
+                "end\n" +
  137
+                "\n" +
  138
+                "rule \"On1\"\n" +
  139
+                "when\n" +
  140
+                "  $x : Intf1( )\n" +
  141
+                "then\n" +
  142
+                "  System.out.println( \"Modify by interface \" );\n" +
  143
+                "  modify ( $x ) { setD( 200 ) }\n" +
  144
+                "end\n" +
  145
+                "rule \"On2\"\n" +
  146
+                "when\n" +
  147
+                "  $x : Klass2( )\n" +
  148
+                "then\n" +
  149
+                "  System.out.println( \"Modify by class \" );\n" +
  150
+                "  modify ( $x ) { setD( 200 ) }\n" +
  151
+                "end\n" +
  152
+                "\n" +
  153
+                "rule \"Log1\"\n" +
  154
+                "when\n" +
  155
+                "  Klass( d == 200, $id : id ) \n" +
  156
+                "then\n" +
  157
+                "  System.out.println( \"Log1 - As K1 \" + $id );\n" +
  158
+                "  list.add( $id + \"@K1\" );\n" +
  159
+                "end\n" +
  160
+                "\n" +
  161
+                "rule \"Log2\"\n" +
  162
+                "when\n" +
  163
+                "  Klass2( d == 200, $id : id ) \n" +
  164
+                "then\n" +
  165
+                "  System.out.println( \"Log2 - As K2 \" + $id );\n" +
  166
+                "  list.add( $id + \"@K2\" );\n" +
  167
+                "end\n" +
  168
+                "\n" +
  169
+                "rule \"Log3\"\n" +
  170
+                "when\n" +
  171
+                "  Intf1( d == 200, $id : id ) \n" +
  172
+                "then\n" +
  173
+                "  System.out.println( \"Log3 - As I1 \" + $id );\n" +
  174
+                "  list.add( $id + \"@I1\" );\n" +
  175
+                "end\n" +
  176
+                "\n" +
  177
+                "rule \"Log4\"\n" +
  178
+                "when\n" +
  179
+                "  Intf2( d == 200, $id : id ) \n" +
  180
+                "then\n" +
  181
+                "  System.out.println( \"Log4 - As K2 \" + $id );\n" +
  182
+                "  list.add( $id + \"@I2\" );\n" +
  183
+                "end";
  184
+
  185
+        KnowledgeBase kbase = loadKnowledgeBaseFromString(str);
  186
+        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
  187
+
  188
+        List<String> list = new ArrayList<String>();
  189
+        ksession.setGlobal("list", list);
  190
+
  191
+        ksession.fireAllRules();
  192
+
  193
+        System.out.println( list );
  194
+
  195
+        assertTrue( list.containsAll( Arrays.asList( "k1@K1", "k1@I1", "k1@I2" ) ) );
  196
+        assertTrue( list.containsAll( Arrays.asList( "k2@K2", "k2@I2" ) ) );
  197
+        assertEquals( 5, list.size() );
  198
+    }
  199
+}
54  drools-compiler/src/test/java/org/drools/compiler/rule/builder/dialect/java/JavaConsequenceBuilderTest.java
@@ -170,10 +170,10 @@ public void testFixThrows() {
170 170
             String fixed = fixBlockDescr(context, analysis, context.getDeclarationResolver().getDeclarations( context.getRule() ) );
171 171
 
172 172
             String expected = 
173  
-                    " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 6L ); }\r\n" +
  173
+                    " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
174 174
             		"  throw new java.lang.RuntimeException(\"xxx\");\r\n" + 
175 175
             		"  Cheese c1 = $cheese;\r\n" + 
176  
-            		" { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  176
+            		" { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
177 177
             		" \r\n" + 
178 178
             		"";
179 179
 
@@ -281,24 +281,24 @@ public void testFixModifyBlocks() throws Exception {
281 281
                 "  Cheese c1 = $cheese;\r\n" + 
282 282
                 " try { \r\n" + 
283 283
                 "     { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); \r\n" +
284  
-                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  284
+                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
285 285
                 "      Cheese c4 = $cheese;\r\n" + 
286 286
                 "     try { \r\n" + 
287  
-                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  287
+                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
288 288
                 "      } catch (java.lang.Exception e) {\r\n" + 
289  
-                "         { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  289
+                "         { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
290 290
                 "      } finally {\r\n" + 
291 291
                 "          Cheese c3 = $cheese;\r\n" + 
292  
-                "         { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  292
+                "         { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
293 293
                 "     }\r\n" + 
294 294
                 " } catch (java.lang.Exception e) {\r\n" + 
295 295
                 "     Cheese c2 = $cheese;\r\n" + 
296  
-                "     { org.drools.compiler.Cheese __obj__ = ( c2 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  296
+                "     { org.drools.compiler.Cheese __obj__ = ( c2 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
297 297
                 "  } finally {\r\n" + 
298 298
                 "      Cheese c3 = $cheese;\r\n" + 
299  
-                "     { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  299
+                "     { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
300 300
                 " }\r\n" + 
301  
-                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 6L ); }\r\n" +
  301
+                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 6L, org.drools.compiler.Cheese.class ); }\r\n" +
302 302
                 "  System.out.println(\"we are done\");\r\n" + 
303 303
                 " \r\n" + 
304 304
                 "";
@@ -370,23 +370,23 @@ public void testIfElseBlocks() throws Exception {
370 370
                 "  Cheese c1 = $cheese;\r\n" + 
371 371
                 " if( c1 == $cheese )     { \r\n" + 
372 372
                 "     { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); \r\n" +
373  
-                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  373
+                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
374 374
                 "      Cheese c4 = $cheese;\r\n" + 
375 375
                 "     if ( true )     { \r\n" + 
376  
-                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  376
+                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
377 377
                 "      } else if (1==2) {\r\n" + 
378  
-                "         { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  378
+                "         { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
379 379
                 "      } else {\r\n" + 
380 380
                 "          Cheese c3 = $cheese;\r\n" + 
381  
-                "         { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  381
+                "         { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
382 382
                 "     }\r\n" + 
383 383
                 " } else {\r\n" + 
384 384
                 "      Cheese c3 = $cheese;\r\n" + 
385  
-                "     { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
386  
-                "      if ( c4 ==  $cheese ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
387  
-                "      else { $cheese.setPrice( 12 ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  385
+                "     { org.drools.compiler.Cheese __obj__ = ( c3 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
  386
+                "      if ( c4 ==  $cheese ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
  387
+                "      else { $cheese.setPrice( 12 ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
388 388
                 " }\r\n" + 
389  
-                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  389
+                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
390 390
                 "  System.out.println(\"we are done\");\r\n" + 
391 391
                 " \r\n";
392 392
 
@@ -453,17 +453,17 @@ public void testWhileBlocks() throws Exception {
453 453
                 "  Cheese c1 = $cheese;\r\n" + 
454 454
                 " while ( c1 == $cheese )     { \r\n" + 
455 455
                 "     { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); \r\n" +
456  
-                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  456
+                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
457 457
                 "      Cheese c4 = $cheese;\r\n" + 
458 458
                 "     while ( true )     { \r\n" + 
459  
-                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  459
+                "         { org.drools.compiler.Cheese __obj__ = ( c4 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
460 460
                 "      } } \r\n" + 
461 461
                 "  Cheese c3 = $cheese;\r\n" + 
462  
-                " while ( c4 ==  $cheese ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
463  
-                "  { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  462
+                " while ( c4 ==  $cheese ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
  463
+                "  { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
464 464
                 "  System.out.println(\"we are done\");\r\n" + 
465 465
                 "  while (true) { System.out.println(1);}\r\n" + 
466  
-                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  466
+                " { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
467 467
                 "  System.out.println(\"we are done\");\r\n" + 
468 468
                 " \r\n" + 
469 469
                 "";
@@ -522,14 +522,14 @@ public void testForBlocks() throws Exception {
522 522
                 " int i = 0;\r\n" + 
523 523
                 " for ( Cheese c1 = $cheese; i < 10;i++ )     { \r\n" + 
524 524
                 "     { org.drools.compiler.Cheese __obj__ = ( c1 ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); \r\n" +
525  
-                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
  525
+                "__obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
526 526
                 "      Cheese c4 = $cheese;\r\n" + 
527  
-                "     for ( Cheese item : new ArrayList<Cheese>() ) {         { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  527
+                "     for ( Cheese item : new ArrayList<Cheese>() ) {         { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
528 528
                 "       }\r\n" + 
529 529
                 " } \r\n" + 
530  
-                "  for ( ; ; ) { org.drools.compiler.Cheese __obj__ = ( (Cheese) $cheese ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L ); }\r\n" +
531  
-                "  for ( Cheese item : new ArrayList<Cheese>() ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
532  
-                "  { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L ); }\r\n" +
  530
+                "  for ( ; ; ) { org.drools.compiler.Cheese __obj__ = ( (Cheese) $cheese ); org.drools.core.FactHandle __obj____Handle2__ = drools.getFactHandle(__obj__);__obj__.setPrice( 10 ); __obj__.setOldPrice( age ); drools.update( __obj____Handle2__, 9223372036854775807L, java.lang.Object.class ); }\r\n" +
  531
+                "  for ( Cheese item : new ArrayList<Cheese>() ) { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
  532
+                "  { $cheese.setPrice( 10 ); $cheese.setOldPrice( age ); drools.update( $cheese__Handle__, 9223372036854775807L, org.drools.compiler.Cheese.class ); }\r\n" +
533 533
                 "  System.out.println(\"we are done\");\r\n" + 
534 534
                 " \r\n" + 
535 535
                 "";
10  drools-core/src/main/java/org/drools/core/base/DefaultKnowledgeHelper.java
@@ -332,6 +332,7 @@ public void update(final FactHandle handle,
332 332
         ((InternalWorkingMemoryEntryPoint) h.getEntryPoint()).update( h,
333 333
                                                                       newObject,
334 334
                                                                       Long.MAX_VALUE,
  335
+                                                                      Object.class,
335 336
                                                                       this.activation );
336 337
         if ( getIdentityMap() != null ) {
337 338
             this.getIdentityMap().put( newObject,
@@ -343,21 +344,22 @@ public void update(final FactHandle handle) {
343 344
         update( handle, Long.MAX_VALUE );
344 345
     }
345 346
 
346  
-    public void update(final FactHandle handle, long mask) {
  347
+    public void update(final FactHandle handle, long mask, Class<?> modifiedClass) {
347 348
         InternalFactHandle h = (InternalFactHandle) handle;
348 349
         ((InternalWorkingMemoryEntryPoint) h.getEntryPoint()).update( h,
349 350
                                                                       ((InternalFactHandle)handle).getObject(),
350 351
                                                                       mask,
  352
+                                                                      modifiedClass,
351 353
                                                                       this.activation );
352 354
     }
353 355
 
354 356
     
355 357
     public void update( Object object ) {
356  
-        update(object, Long.MAX_VALUE);
  358
+        update(object, Long.MAX_VALUE, Object.class);
357 359
     }
358 360
 
359  
-    public void update(Object object, long mask) {
360  
-        update(getFactHandle(object), mask);
  361
+    public void update(Object object, long mask, Class<?> modifiedClass) {
  362
+        update(getFactHandle(object), mask, modifiedClass);
361 363
     }
362 364
     
363 365
     public void retract(Object object) {
2  drools-core/src/main/java/org/drools/core/base/ModifyInterceptor.java
@@ -76,7 +76,7 @@ public int doAfter(Object value,
76 76
             calculateModificationMask(knowledgeHelper, (WithNode)node);
77 77
         }
78 78
 
79  
-        knowledgeHelper.update(value, modificationMask);
  79
+        knowledgeHelper.update(value, modificationMask, value.getClass());
80 80
         return 0;
81 81
     }
82 82
 
4  drools-core/src/main/java/org/drools/core/base/SequentialKnowledgeHelper.java
@@ -257,7 +257,7 @@ public void update(FactHandle newObject) {
257 257
         // TODO Auto-generated method stub
258 258
     }
259 259
 
260  
-    public void update(FactHandle newObject, long mask) {
  260
+    public void update(FactHandle newObject, long mask, Class<?> typeClass) {
261 261
         // TODO Auto-generated method stub
262 262
     }
263 263
 
@@ -269,7 +269,7 @@ public void update(Object newObject) {
269 269
         // TODO Auto-generated method stub
270 270
     }
271 271
 
272  
-    public void update(Object newObject, long mask) {
  272
+    public void update(Object newObject, long mask, Class<?> typeClass) {
273 273
         // TODO Auto-generated method stub
274 274
     }
275 275
 
5  drools-core/src/main/java/org/drools/core/common/AbstractWorkingMemory.java
@@ -872,17 +872,20 @@ public void update(final org.kie.api.runtime.rule.FactHandle handle,
872 872
         update( (FactHandle) handle,
873 873
                 object,
874 874
                 Long.MAX_VALUE,
  875
+                Object.class,
875 876
                 null );
876 877
     }
877 878
 
878 879
     public void update(final org.kie.api.runtime.rule.FactHandle factHandle,
879 880
                        final Object object,
880 881
                        final long mask,
  882
+                       Class<?> modifiedClass,
881 883
                        final Activation activation) throws FactException {
882 884
 
883 885
         update( (FactHandle) factHandle,
884 886
                 object,
885 887
                 mask,
  888
+                modifiedClass,
886 889
                 activation );
887 890
     }
888 891
 
@@ -895,10 +898,12 @@ public void update(final org.kie.api.runtime.rule.FactHandle factHandle,
895 898
     public void update(FactHandle factHandle,
896 899
                        final Object object,
897 900
                        final long mask,
  901
+                       Class<?> modifiedClass,
898 902
                        final Activation activation) throws FactException {
899 903
         this.defaultEntryPoint.update( factHandle,
900 904
                                        object,
901 905
                                        mask,
  906
+                                       modifiedClass,
902 907
                                        activation );
903 908
     }
904 909
 
1  drools-core/src/main/java/org/drools/core/common/InternalWorkingMemoryActions.java
@@ -28,6 +28,7 @@
28 28
     public void update(FactHandle handle,
29 29
                        Object object,
30 30
                        long mask,
  31
+                       Class<?> modifiedClass,
31 32
                        Activation activation) throws FactException;
32 33
 
33 34
     public void delete(FactHandle handle,
1  drools-core/src/main/java/org/drools/core/common/InternalWorkingMemoryEntryPoint.java
@@ -36,6 +36,7 @@ public void delete(final FactHandle factHandle,
36 36
     public void update(org.kie.api.runtime.rule.FactHandle handle,
37 37
                        Object object,
38 38
                        long mask,
  39
+                       Class<?> modifiedClass,
39 40
                        Activation activation) throws FactException;
40 41
 
41 42
     public EntryPoint getEntryPoint();
7  drools-core/src/main/java/org/drools/core/common/NamedEntryPoint.java
@@ -251,7 +251,7 @@ protected FactHandle insert(final Object object,
251 251
                                 TruthMaintenanceSystemHelper.clearLogicalDependencies( justifiedHandle, propagationContext );
252 252
                                 
253 253
                                 // now update existing handle to new value
254  
-                                return update( justifiedHandle, true, object, Long.MAX_VALUE, activation );                                                                                           
  254
+                                return update( justifiedHandle, true, object, Long.MAX_VALUE, Object.class, activation );
255 255
                         } else   {  // STATED 
256 256
                             handle = createHandle( object,
257 257
                                                    typeConf ); // we know the handle is null                                                    
@@ -380,18 +380,21 @@ public void update(final org.kie.api.runtime.rule.FactHandle factHandle,
380 380
                 false,
381 381
                 object,
382 382
                 Long.MAX_VALUE,
  383
+                Object.class,
383 384
                 null );
384 385
     }
385 386
     
386 387
     public void update(final org.kie.api.runtime.rule.FactHandle factHandle,
387 388
                        final Object object,
388 389
                        final long mask,
  390
+                       final Class<?> modifiedClass,
389 391
                        final Activation activation) throws FactException {
390 392
         InternalFactHandle handle = (InternalFactHandle) factHandle;
391 393
         update( handle,
392 394
                 false,
393 395
                 object,
394 396
                 mask,
  397
+                modifiedClass,
395 398
                 activation );
396 399
     }
397 400
 
@@ -399,6 +402,7 @@ public InternalFactHandle update(InternalFactHandle handle,
399 402
                                      final boolean updateLogical,
400 403
                                      final Object object,
401 404
                                      final long mask,
  405
+                                     final Class<?> modifiedClass,
402 406
                                      final Activation activation) throws FactException {
403 407
         try {
404 408
             this.lock.lock();
@@ -456,6 +460,7 @@ public InternalFactHandle update(InternalFactHandle handle,
456 460
                                                                                       handle,
457 461
                                                                                       entryPoint,
458 462
                                                                                       mask,
  463
+                                                                                      modifiedClass,
459 464
                                                                                       null );
460 465
             
461 466
             if ( typeConf.isTMSEnabled() ) {
53  drools-core/src/main/java/org/drools/core/common/PropagationContextImpl.java
@@ -17,18 +17,23 @@
17 17
 package org.drools.core.common;
18 18
 
19 19
 import org.drools.core.FactHandle;
  20
+import org.drools.core.base.ClassObjectType;
20 21
 import org.drools.core.marshalling.impl.MarshallerReaderContext;
21 22
 import org.drools.core.reteoo.LeftTuple;
22 23
 import org.drools.core.reteoo.WindowTupleList;
23  
-import org.drools.core.rule.EntryPoint;
24  
-import org.drools.core.rule.Rule;
  24
+import org.drools.core.rule.*;
  25
+import org.drools.core.rule.Package;
25 26
 import org.drools.core.spi.ObjectType;
26 27
 import org.drools.core.spi.PropagationContext;
  28
+import org.drools.core.util.BitMaskUtil;
  29
+import org.drools.core.util.ClassUtils;
27 30
 
28 31
 import java.io.IOException;
29 32
 import java.io.ObjectInput;
30 33
 import java.io.ObjectOutput;
  34
+import java.util.ArrayList;
31 35
 import java.util.LinkedList;
  36
+import java.util.List;
32 37
 
33 38
 public class PropagationContextImpl
34 39
         implements
@@ -55,6 +60,9 @@
55 60
     private LinkedList<WorkingMemoryAction> queue2; // for evaluations and fixers
56 61
 
57 62
     private long                            modificationMask = Long.MAX_VALUE;
  63
+    private long                            originalMask = Long.MAX_VALUE;
  64
+
  65
+    private Class<?>                        modifiedClass;
58 66
 
59 67
     private WindowTupleList                 windowTupleList;
60 68
 
@@ -80,6 +88,7 @@ public PropagationContextImpl(final long number,
80 88
               factHandle,
81 89
               EntryPoint.DEFAULT,
82 90
               Long.MAX_VALUE,
  91
+              Object.class,
83 92
               null );
84 93
         this.originOffset = -1;
85 94
     }
@@ -97,6 +106,7 @@ public PropagationContextImpl(final long number,
97 106
               factHandle,
98 107
               entryPoint,
99 108
               Long.MAX_VALUE,
  109
+              Object.class,
100 110
               null );
101 111
     }
102 112
 
@@ -116,6 +126,7 @@ public PropagationContextImpl(final long number,
116 126
               factHandle,
117 127
               entryPoint,
118 128
               modificationMask,
  129
+              Object.class,
119 130
               null );
120 131
     }
121 132
 
@@ -133,6 +144,7 @@ public PropagationContextImpl(final long number,
133 144
               factHandle,
134 145
               entryPoint,
135 146
               Long.MAX_VALUE,
  147
+              Object.class,
136 148
               readerContext );
137 149
     }
138 150
 
@@ -143,6 +155,7 @@ public PropagationContextImpl(final long number,
143 155
                                   final InternalFactHandle factHandle,
144 156
                                   final EntryPoint entryPoint,
145 157
                                   final long modificationMask,
  158
+                                  final Class<?> modifiedClass,
146 159
                                   final MarshallerReaderContext readerContext) {
147 160
         this.type = type;
148 161
         this.rule = rule;
@@ -152,6 +165,8 @@ public PropagationContextImpl(final long number,
152 165
         this.entryPoint = entryPoint;
153 166
         this.originOffset = -1;
154 167
         this.modificationMask = modificationMask;
  168
+        this.originalMask = modificationMask;
  169
+        this.modifiedClass = modifiedClass;
155 170
         this.readerContext = readerContext;
156 171
     }
157 172
 
@@ -307,6 +322,40 @@ public long getModificationMask() {
307 322
         return modificationMask;
308 323
     }
309 324
 
  325
+    public PropagationContext adaptModificationMaskForObjectType(ObjectType type, InternalWorkingMemory workingMemory) {
  326
+        modificationMask = originalMask;
  327
+        if (modificationMask == Long.MAX_VALUE || !(type instanceof ClassObjectType)) {
  328
+            return this;
  329
+        }
  330
+        Class<?> classType = ((ClassObjectType)type).getClassType();
  331
+        if (classType == modifiedClass || !(classType.isInterface() || modifiedClass.isInterface())) {
  332
+            return this;
  333
+        }
  334
+
  335
+        Long cachedMask = rule.getTransformedMask(modifiedClass, classType, originalMask);
  336
+        if (cachedMask != null) {
  337
+            modificationMask = cachedMask;
  338
+            return this;
  339
+        }
  340
+
  341
+        modificationMask = 0L;
  342
+        Package pkg = workingMemory.getRuleBase().getPackage(rule.getPackage());
  343
+        List<String> typeClassProps = pkg.getTypeDeclaration(classType).getSettableProperties();
  344
+        List<String> modifiedClassProps = pkg.getTypeDeclaration(modifiedClass).getSettableProperties();
  345
+
  346
+        for (int i = 0; i < modifiedClassProps.size(); i++) {
  347
+            if (BitMaskUtil.isPositionSet(originalMask, i)) {
  348
+                int posInType = typeClassProps.indexOf(modifiedClassProps.get(i));
  349
+                if (posInType >= 0) {
  350
+                    modificationMask = BitMaskUtil.set(modificationMask, posInType);
  351
+                }
  352
+            }
  353
+        }
  354
+        rule.storeTransformedMask(modifiedClass, classType, originalMask, modificationMask);
  355
+
  356
+        return this;
  357
+    }
  358
+
310 359
     public WindowTupleList getActiveWindowTupleList() {
311 360
         return windowTupleList;
312 361
     }
2  drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java
@@ -260,7 +260,7 @@ public void execute(InternalWorkingMemory workingMemory) {
260 260
             if ( update ) {
261 261
                 if ( !bs.isEmpty() ) {
262 262
                     // We need the isEmpty check, in case the BeliefSet was made empty (due to retract) after this was scheduled
263  
-                    ((NamedEntryPoint) handle.getEntryPoint() ).update( handle, true, handle.getObject(), Long.MAX_VALUE, null );
  263
+                    ((NamedEntryPoint) handle.getEntryPoint() ).update( handle, true, handle.getObject(), Long.MAX_VALUE, Object.class, null );
264 264
                 }
265 265
             } else  {
266 266
                 if ( fullyRetract ) {
2  drools-core/src/main/java/org/drools/core/impl/StatefulKnowledgeSessionImpl.java
@@ -428,10 +428,12 @@ public void delete(org.drools.core.FactHandle factHandle,
428 428
     public void update(FactHandle factHandle,
429 429
                        Object object,
430 430
                        long mask,
  431
+                       Class<?> modifiedClass,
431 432
                        Activation activation) throws FactException {
432 433
         this.session.update( (org.drools.core.FactHandle) factHandle,
433 434
                              object,
434 435
                              mask,
  436
+                             modifiedClass,
435 437
                              activation );
436 438
     }
437 439
 
4  drools-core/src/main/java/org/drools/core/reteoo/DisposedReteooWorkingMemory.java
@@ -77,7 +77,7 @@
77 77
     
78 78
     private DisposedReteooWorkingMemory() {}
79 79
     
80  
-    public void update( FactHandle handle, Object object, long mask, Activation activation ) throws FactException {
  80
+    public void update( FactHandle handle, Object object, long mask, Class<?> modifiedClass, Activation activation ) throws FactException {
81 81
         throw new IllegalStateException( ERRORMSG );
82 82
     }
83 83
 
@@ -477,7 +477,7 @@ public long getFactCount() {
477 477
         throw new IllegalStateException( ERRORMSG );
478 478
     }
479 479
 
480  
-    public void update( org.kie.api.runtime.rule.FactHandle handle, Object object, long mask, Activation activation ) throws FactException {
  480
+    public void update( org.kie.api.runtime.rule.FactHandle handle, Object object, long mask, Class<?> modifiedClass, Activation activation ) throws FactException {
481 481
         throw new IllegalStateException( ERRORMSG );
482 482
     }
483 483
 
4  drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java
@@ -376,12 +376,12 @@ public void modifyObject(InternalFactHandle factHandle,
376 376
         if ( compiledNetwork != null ) {
377 377
             compiledNetwork.modifyObject( factHandle,
378 378
                                           modifyPreviousTuples,
379  
-                                          context,
  379
+                                          context.adaptModificationMaskForObjectType(objectType, workingMemory),
380 380
                                           workingMemory );
381 381
         } else {
382 382
             this.sink.propagateModifyObject( factHandle,
383 383
                                              modifyPreviousTuples,
384  
-                                             context,
  384
+                                             context.adaptModificationMaskForObjectType(objectType, workingMemory),
385 385
                                              workingMemory );
386 386
         }
387 387
     }
18  drools-core/src/main/java/org/drools/core/rule/Rule.java
@@ -133,6 +133,8 @@
133 133
 
134 134
     private ConsequenceMetaData      consequenceMetaData = new ConsequenceMetaData();
135 135
 
  136
+    private transient Map<String, Long> transformedMasks;
  137
+
136 138
     public void writeExternal(ObjectOutput out) throws IOException {
137 139
         out.writeObject( pkg );
138 140
         out.writeObject( name );
@@ -830,4 +832,20 @@ public String getId() {
830 832
     public ConsequenceMetaData getConsequenceMetaData() {
831 833
         return consequenceMetaData;
832 834
     }
  835
+
  836
+    public Long getTransformedMask(Class<?> modifiedClass, Class<?> objectTypeClass, long modificationMask) {
  837
+        if (transformedMasks == null) {
  838
+            return null;
  839
+        }
  840
+        String key = modifiedClass.getName() + ":" + objectTypeClass.getName() + ":" + modificationMask;
  841
+        return transformedMasks.get(key);
  842
+    }
  843
+
  844
+    public void storeTransformedMask(Class<?> modifiedClass, Class<?> objectTypeClass, long modificationMask, long transforedMask) {
  845
+        if (transformedMasks == null) {
  846
+            transformedMasks = new HashMap<String, Long>();
  847
+        }
  848
+        String key = modifiedClass.getName() + ":" + objectTypeClass.getName() + ":" + modificationMask;
  849
+        transformedMasks.put(key, transforedMask);
  850
+    }
833 851
 }
4  drools-core/src/main/java/org/drools/core/spi/KnowledgeHelper.java
@@ -90,10 +90,10 @@ public void insertLogical(Object object,
90 90
     void update(FactHandle handle, Object newObject);
91 91
 
92 92
     void update(FactHandle newObject);
93  
-    void update(FactHandle newObject, long mask);
  93
+    void update(FactHandle newObject, long mask, Class<?> modifiedClass);
94 94
     
95 95
     void update(Object newObject);
96  
-    void update(Object newObject, long mask);
  96
+    void update(Object newObject, long mask, Class<?> modifiedClass);
97 97
 
98 98
     void modify( Object newObject ) ;
99 99
 
9  drools-core/src/main/java/org/drools/core/spi/PropagationContext.java
@@ -70,16 +70,17 @@
70 70
 
71 71
     LinkedList<WorkingMemoryAction> getQueue2();
72 72
 
73  
-    public void evaluateActionQueue(InternalWorkingMemory workingMemory); 
  73
+    void evaluateActionQueue(InternalWorkingMemory workingMemory);
74 74
     
75  
-    public WindowTupleList getActiveWindowTupleList();
  75
+    WindowTupleList getActiveWindowTupleList();
76 76
     
77  
-    public void setActiveWindowTupleList( WindowTupleList list );
  77
+    void setActiveWindowTupleList( WindowTupleList list );
78 78
 
79 79
     long getModificationMask();
  80
+    PropagationContext adaptModificationMaskForObjectType(ObjectType type, InternalWorkingMemory workingMemory);
80 81
 
81 82
     ObjectType getObjectType();
82 83
     void setObjectType(ObjectType objectType);
83 84
 
84  
-    public MarshallerReaderContext getReaderContext();
  85
+    MarshallerReaderContext getReaderContext();
85 86
 }
4  drools-core/src/main/java/org/drools/core/util/BitMaskUtil.java
@@ -19,4 +19,8 @@ public static long reset(long mask, int pos) {
19 19
     public static boolean isSet(long mask, long bit) {
20 20
         return (mask & bit) == bit;
21 21
     }
  22
+
  23
+    public static boolean isPositionSet(long mask, int pos) {
  24
+        return isSet(mask, 1L << pos);
  25
+    }
22 26
 }

0 notes on commit 6d2840d

Please sign in to comment.
Something went wrong with that request. Please try again.