Source Code Cross Referenced for RuleExecutionSetImpl.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » jsr94 » rules » admin » 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.jsr94.rules.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.jsr94.rules.admin;
002:
003:        /*
004:         * Copyright 2005 JBoss Inc
005:         * 
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *      http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import java.util.ArrayList;
020:        import java.util.HashMap;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import javax.rules.ObjectFilter;
025:        import javax.rules.admin.RuleExecutionSet;
026:
027:        import org.drools.IntegrationException;
028:        import org.drools.RuleBase;
029:        import org.drools.RuleBaseConfiguration;
030:        import org.drools.RuleIntegrationException;
031:        import org.drools.StatefulSession;
032:        import org.drools.StatelessSession;
033:        import org.drools.jsr94.rules.Constants;
034:        import org.drools.jsr94.rules.Jsr94FactHandleFactory;
035:        import org.drools.rule.Package;
036:        import org.drools.rule.Rule;
037:        import org.drools.util.UUIDGenerator;
038:
039:        /**
040:         * The Drools implementation of the <code>RuleExecutionSet</code> interface
041:         * which defines a named set of executable <code>Rule</code> instances. A
042:         * <code>RuleExecutionSet</code> can be executed by a rules engine via the
043:         * <code>RuleSession</code> interface.
044:         *
045:         * @see RuleExecutionSet
046:         *
047:         * @author N. Alex Rupp (n_alex <at>codehaus.org)
048:         * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
049:         * @author <a href="mailto:michael.frandsen@syngenio.de">michael frandsen </a>
050:         */
051:        public class RuleExecutionSetImpl implements  RuleExecutionSet {
052:            /**
053:             * 
054:             */
055:            private static final long serialVersionUID = 400L;
056:
057:            /**
058:             * A description of this rule execution set or null if no
059:             * description is specified.
060:             */
061:            private String description;
062:
063:            /**
064:             * The default ObjectFilter class name
065:             * associated with this rule execution set.
066:             */
067:            private String defaultObjectFilterClassName;
068:
069:            /** A <code>Map</code> of user-defined and Drools-defined properties. */
070:            private Map properties;
071:
072:            /**
073:             * The <code>RuleBase</code> associated with this
074:             * <code>RuleExecutionSet</code>.
075:             */
076:            private RuleBase ruleBase;
077:
078:            /**
079:             * The <code>Package</code> associated with this
080:             * <code>RuleExecutionSet</code>.
081:             */
082:            private Package pkg;
083:
084:            /**
085:             * The default ObjectFilter class name
086:             * associated with this rule execution set.
087:             */
088:            private ObjectFilter objectFilter;
089:
090:            /**
091:             * Instances of this class should be obtained from the
092:             * <code>LocalRuleExecutionSetProviderImpl</code>. Each
093:             * <code>RuleExecutionSetImpl</code> corresponds with an
094:             * <code>org.drools.Package</code> object.
095:             *
096:             * @param package The <code>Package</code> to associate with this
097:             *        <code>RuleExecutionSet</code>.
098:             * @param properties A <code>Map</code> of user-defined and
099:             *        Drools-defined properties. May be <code>null</code>.
100:             *
101:             * @throws RuleIntegrationException if an error occurs integrating
102:             *         a <code>Rule</code> or <code>Package</code>
103:             *         into the <code>RuleBase</code>
104:             * @throws RuleSetIntegrationException if an error occurs integrating
105:             *         a <code>Rule</code> or <code>Package</code>
106:             *         into the <code>RuleBase</code>
107:             */
108:            RuleExecutionSetImpl(final Package pkg, final Map properties)
109:                    throws IntegrationException {
110:                if (null == properties) {
111:                    this .properties = new HashMap();
112:                } else {
113:                    this .properties = properties;
114:                }
115:                this .pkg = pkg;
116:                this .description = pkg.getName();//..getDocumentation( );
117:
118:                RuleBaseConfiguration config = (RuleBaseConfiguration) this .properties
119:                        .get(Constants.RES_RULEBASE_CONFIG);
120:                org.drools.reteoo.ReteooRuleBase ruleBase;
121:                if (config != null) {
122:                    ruleBase = new org.drools.reteoo.ReteooRuleBase(
123:                            UUIDGenerator.getInstance()
124:                                    .generateRandomBasedUUID().toString(),
125:                            config, new Jsr94FactHandleFactory());
126:                } else {
127:                    ruleBase = new org.drools.reteoo.ReteooRuleBase(
128:                            UUIDGenerator.getInstance()
129:                                    .generateRandomBasedUUID().toString(),
130:                            new Jsr94FactHandleFactory());
131:                }
132:                ruleBase.addPackage(pkg);
133:
134:                this .ruleBase = ruleBase;
135:            }
136:
137:            /**
138:             * Get an instance of the default filter, or null.
139:             *
140:             * @return An instance of the default filter, or null.
141:             */
142:            public synchronized ObjectFilter getObjectFilter() {
143:                if (this .objectFilter != null) {
144:                    return this .objectFilter;
145:                }
146:
147:                if (this .defaultObjectFilterClassName != null) {
148:                    ClassLoader cl = Thread.currentThread()
149:                            .getContextClassLoader();
150:
151:                    if (cl == null) {
152:                        cl = RuleExecutionSetImpl.class.getClassLoader();
153:                    }
154:
155:                    try {
156:                        final Class filterClass = cl
157:                                .loadClass(this .defaultObjectFilterClassName);
158:                        this .objectFilter = (ObjectFilter) filterClass
159:                                .newInstance();
160:                    } catch (final ClassNotFoundException e) {
161:                        throw new RuntimeException(e.toString());
162:                    } catch (final InstantiationException e) {
163:                        throw new RuntimeException(e.toString());
164:                    } catch (final IllegalAccessException e) {
165:                        throw new RuntimeException(e.toString());
166:                    }
167:                }
168:
169:                return this .objectFilter;
170:            }
171:
172:            /**
173:             * Returns a new WorkingMemory object.
174:             *
175:             * @return A new WorkingMemory object.
176:             */
177:            public StatefulSession newStatefulSession(boolean keepReference) {
178:                return this .ruleBase.newStatefulSession(keepReference);
179:            }
180:
181:            /**
182:             * Returns a new WorkingMemory object.
183:             *
184:             * @return A new WorkingMemory object.
185:             */
186:            public StatelessSession newStatelessSession() {
187:                return this .ruleBase.newStatelessSession();
188:            }
189:
190:            // JSR94 interface methods start here -------------------------------------
191:
192:            /**
193:             * Get the name of this rule execution set.
194:             *
195:             * @return The name of this rule execution set.
196:             */
197:            public String getName() {
198:                return this .pkg.getName();
199:            }
200:
201:            /**
202:             * Get a description of this rule execution set.
203:             *
204:             * @return A description of this rule execution set or null of no
205:             *         description is specified.
206:             */
207:            public String getDescription() {
208:                return this .description;
209:            }
210:
211:            /**
212:             * Get a user-defined or Drools-defined property.
213:             *
214:             * @param key the key to use to retrieve the property
215:             *
216:             * @return the value bound to the key or null
217:             */
218:            public Object getProperty(final Object key) {
219:                return this .properties.get(key);
220:            }
221:
222:            /**
223:             * Set a user-defined or Drools-defined property.
224:             *
225:             * @param key the key for the property value
226:             * @param value the value to associate with the key
227:             */
228:            public void setProperty(final Object key, final Object value) {
229:                this .properties.put(key, value);
230:            }
231:
232:            /**
233:             * Set the default <code>ObjectFilter</code> class. This class is
234:             * instantiated at runtime and used to filter result objects unless
235:             * another filter is specified using the available APIs in the runtime
236:             * view of a rule engine.
237:             * <p/>
238:             * Setting the class name to null removes the default
239:             * <code>ObjectFilter</code>.
240:             *
241:             * @param objectFilterClassname the default <code>ObjectFilter</code> class
242:             */
243:            public void setDefaultObjectFilter(
244:                    final String objectFilterClassname) {
245:                this .defaultObjectFilterClassName = objectFilterClassname;
246:            }
247:
248:            /**
249:             * Returns the default ObjectFilter class name
250:             * associated with this rule execution set.
251:             *
252:             * @return the default ObjectFilter class name
253:             */
254:            public String getDefaultObjectFilter() {
255:                return this .defaultObjectFilterClassName;
256:            }
257:
258:            /**
259:             * Return a list of all <code>Rule</code>s that are part of the
260:             * <code>RuleExecutionSet</code>.
261:             *
262:             * @return a list of all <code>Rule</code>s that are part of the
263:             *         <code>RuleExecutionSet</code>.
264:             */
265:            public List getRules() {
266:                final List jsr94Rules = new ArrayList();
267:
268:                final Rule[] rules = (this .pkg.getRules());
269:                for (int i = 0; i < rules.length; ++i) {
270:                    jsr94Rules.add(new RuleImpl(rules[i]));
271:                }
272:
273:                return jsr94Rules;
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.