Source Code Cross Referenced for ReteooStatelessSession.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » reteoo » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Rule Engine » drolls Rule Engine » org.drools.reteoo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.reteoo;
002:
003:        import java.util.Collection;
004:        import java.util.HashMap;
005:        import java.util.Iterator;
006:        import java.util.List;
007:        import java.util.Map;
008:
009:        import org.drools.ObjectFilter;
010:        import org.drools.StatelessSession;
011:        import org.drools.StatelessSessionResult;
012:        import org.drools.WorkingMemory;
013:        import org.drools.base.MapGlobalResolver;
014:        import org.drools.common.InternalRuleBase;
015:        import org.drools.common.InternalWorkingMemory;
016:        import org.drools.concurrent.AssertObject;
017:        import org.drools.concurrent.AssertObjects;
018:        import org.drools.concurrent.CommandExecutor;
019:        import org.drools.concurrent.ExecutorService;
020:        import org.drools.concurrent.FireAllRules;
021:        import org.drools.concurrent.Future;
022:        import org.drools.event.AgendaEventListener;
023:        import org.drools.event.AgendaEventSupport;
024:        import org.drools.event.RuleFlowEventListener;
025:        import org.drools.event.RuleFlowEventSupport;
026:        import org.drools.event.WorkingMemoryEventListener;
027:        import org.drools.event.WorkingMemoryEventSupport;
028:        import org.drools.reteoo.ReteooRuleBase.InitialFactHandleDummyObject;
029:        import org.drools.reteoo.ReteooWorkingMemory.WorkingMemoryReteAssertAction;
030:        import org.drools.spi.AgendaFilter;
031:        import org.drools.spi.GlobalResolver;
032:
033:        public class ReteooStatelessSession implements  StatelessSession {
034:            //private WorkingMemory workingMemory;
035:
036:            private InternalRuleBase ruleBase;
037:            private AgendaFilter agendaFilter;
038:            private GlobalResolver globalResolver = new MapGlobalResolver();
039:
040:            /** The eventSupport */
041:            protected WorkingMemoryEventSupport workingMemoryEventSupport = new WorkingMemoryEventSupport();
042:
043:            protected AgendaEventSupport agendaEventSupport = new AgendaEventSupport();
044:
045:            protected RuleFlowEventSupport ruleFlowEventSupport = new RuleFlowEventSupport();
046:
047:            public ReteooStatelessSession(final InternalRuleBase ruleBase) {
048:                this .ruleBase = ruleBase;
049:            }
050:
051:            public InternalWorkingMemory newWorkingMemory() {
052:                synchronized (this .ruleBase.getPackagesMap()) {
053:                    InternalWorkingMemory wm = new ReteooWorkingMemory(
054:                            this .ruleBase.nextWorkingMemoryCounter(),
055:                            this .ruleBase);
056:
057:                    wm.setGlobalResolver(this .globalResolver);
058:                    wm
059:                            .setWorkingMemoryEventSupport(this .workingMemoryEventSupport);
060:                    wm.setAgendaEventSupport(this .agendaEventSupport);
061:                    wm.setRuleFlowEventSupport(ruleFlowEventSupport);
062:
063:                    final InitialFactHandle handle = new InitialFactHandle(wm
064:                            .getFactHandleFactory().newFactHandle(
065:                                    new InitialFactHandleDummyObject()));
066:
067:                    wm
068:                            .queueWorkingMemoryAction(new WorkingMemoryReteAssertAction(
069:                                    handle, false, true, null, null));
070:                    return wm;
071:                }
072:            }
073:
074:            public void addEventListener(
075:                    final WorkingMemoryEventListener listener) {
076:                this .workingMemoryEventSupport.addEventListener(listener);
077:            }
078:
079:            public void removeEventListener(
080:                    final WorkingMemoryEventListener listener) {
081:                this .workingMemoryEventSupport.removeEventListener(listener);
082:            }
083:
084:            public List getWorkingMemoryEventListeners() {
085:                return this .workingMemoryEventSupport.getEventListeners();
086:            }
087:
088:            public void addEventListener(final AgendaEventListener listener) {
089:                this .agendaEventSupport.addEventListener(listener);
090:            }
091:
092:            public void removeEventListener(final AgendaEventListener listener) {
093:                this .agendaEventSupport.removeEventListener(listener);
094:            }
095:
096:            public List getAgendaEventListeners() {
097:                return this .agendaEventSupport.getEventListeners();
098:            }
099:
100:            public void addEventListener(final RuleFlowEventListener listener) {
101:                this .ruleFlowEventSupport.addEventListener(listener);
102:            }
103:
104:            public void removeEventListener(final RuleFlowEventListener listener) {
105:                this .ruleFlowEventSupport.removeEventListener(listener);
106:            }
107:
108:            public List getRuleFlowEventListeners() {
109:                return this .ruleFlowEventSupport.getEventListeners();
110:            }
111:
112:            public void setAgendaFilter(AgendaFilter agendaFilter) {
113:                this .agendaFilter = agendaFilter;
114:            }
115:
116:            public void setGlobal(String identifier, Object value) {
117:                this .globalResolver.setGlobal(identifier, value);
118:            }
119:
120:            public void setGlobalResolver(GlobalResolver globalResolver) {
121:                this .globalResolver = globalResolver;
122:            }
123:
124:            public void execute(Object object) {
125:                InternalWorkingMemory wm = newWorkingMemory();
126:
127:                wm.insert(object);
128:                wm.fireAllRules(this .agendaFilter);
129:            }
130:
131:            public void execute(Object[] array) {
132:                InternalWorkingMemory wm = newWorkingMemory();
133:
134:                for (int i = 0, length = array.length; i < length; i++) {
135:                    wm.insert(array[i]);
136:                }
137:                wm.fireAllRules(this .agendaFilter);
138:            }
139:
140:            public void execute(Collection collection) {
141:                InternalWorkingMemory wm = newWorkingMemory();
142:
143:                for (Iterator it = collection.iterator(); it.hasNext();) {
144:                    wm.insert(it.next());
145:                }
146:                wm.fireAllRules(this .agendaFilter);
147:            }
148:
149:            public void asyncExecute(final Object object) {
150:                InternalWorkingMemory wm = newWorkingMemory();
151:
152:                final AssertObject assertObject = new AssertObject(object);
153:                ExecutorService executor = this .ruleBase.getConfiguration()
154:                        .getExecutorService();
155:                executor.setCommandExecutor(new CommandExecutor(wm));
156:                executor.submit(assertObject);
157:                executor.submit(new FireAllRules(this .agendaFilter));
158:            }
159:
160:            public void asyncExecute(final Object[] array) {
161:                InternalWorkingMemory wm = newWorkingMemory();
162:
163:                final AssertObjects assertObjects = new AssertObjects(array);
164:                ExecutorService executor = this .ruleBase.getConfiguration()
165:                        .getExecutorService();
166:                executor.setCommandExecutor(new CommandExecutor(wm));
167:                executor.submit(assertObjects);
168:                executor.submit(new FireAllRules(this .agendaFilter));
169:            }
170:
171:            public void asyncExecute(final Collection collection) {
172:                InternalWorkingMemory wm = newWorkingMemory();
173:
174:                final AssertObjects assertObjects = new AssertObjects(
175:                        collection);
176:                ExecutorService executor = this .ruleBase.getConfiguration()
177:                        .getExecutorService();
178:                executor.setCommandExecutor(new CommandExecutor(wm));
179:                executor.submit(assertObjects);
180:                executor.submit(new FireAllRules(this .agendaFilter));
181:            }
182:
183:            public StatelessSessionResult executeWithResults(Object object) {
184:                InternalWorkingMemory wm = newWorkingMemory();
185:
186:                wm.insert(object);
187:                wm.fireAllRules(this .agendaFilter);
188:                return new ReteStatelessSessionResult(wm);
189:            }
190:
191:            public StatelessSessionResult executeWithResults(Object[] array) {
192:                InternalWorkingMemory wm = newWorkingMemory();
193:
194:                for (int i = 0, length = array.length; i < length; i++) {
195:                    wm.insert(array[i]);
196:                }
197:                wm.fireAllRules(this .agendaFilter);
198:                return new ReteStatelessSessionResult(wm);
199:            }
200:
201:            public StatelessSessionResult executeWithResults(
202:                    Collection collection) {
203:                InternalWorkingMemory wm = newWorkingMemory();
204:
205:                for (Iterator it = collection.iterator(); it.hasNext();) {
206:                    wm.insert(it.next());
207:                }
208:                wm.fireAllRules(this .agendaFilter);
209:                return new ReteStatelessSessionResult(wm);
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.