1 package org.drools.jsr94.rules;
2
3
4 import org.drools.AssertionException;
5 import org.drools.RetractionException;
6 import org.drools.RuleBase;
7 import org.drools.TransactionalWorkingMemory;
8
9 import java.util.ArrayList;
10 import java.util.List;
11
12 /***
13 * Provide access to the list of objects currently asserted to the working memory.
14 *
15 * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler</a>
16 */
17 public class TransactionalWorkingMemoryImpl extends TransactionalWorkingMemory
18 {
19
20 private List objectList = new ArrayList();
21
22 /***
23 * Construct a new transactional working memory for a ruleBase.
24 *
25 * @param ruleBase The rule base with which this memory is associated.
26 */
27 TransactionalWorkingMemoryImpl( RuleBase ruleBase )
28 {
29 super( ruleBase );
30 }
31
32 /*** Assert a new fact object into this working memory.
33 *
34 * @param object The object to assert.
35 *
36 * @throws AssertionException if an error occurs during assertion.
37 */
38 public synchronized void assertObject( Object object ) throws AssertionException
39 {
40 super.assertObject( object );
41 objectList.add( object );
42 }
43
44 /*** Retract a fact object from this working memory.
45 *
46 * @param object The object to retract.
47 *
48 * @throws RetractionException if an error occurs during retraction.
49 */
50 public synchronized void retractObject( Object object ) throws RetractionException
51 {
52 super.retractObject( object );
53 objectList.remove( object );
54 }
55 }
This page was automatically generated by Maven