001: package org.drools;
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.io.IOException;
020: import java.io.InputStream;
021: import java.io.Serializable;
022:
023: import org.drools.rule.Package;
024: import org.drools.ruleflow.common.core.Process;
025:
026: /**
027: * Active collection of <code>Rule</code>s.
028: *
029: * <p>
030: * From a <code>RuleBase</code> many <code>WorkingMemory</code> rule
031: * sessions may be instantiated. Additionally, it may be inspected to determine
032: * which <code>Package</code> s it contains.
033: * </p>
034: *
035: * @see WorkingMemory
036: */
037: public interface RuleBase extends Serializable {
038:
039: public static final int RETEOO = 1;
040:
041: StatelessSession newStatelessSession();
042:
043: /**
044: * Create a new <code>WorkingMemory</code> session for this
045: * <code>RuleBase</code>. By default the RuleBase retains a
046: * weak reference to returned WorkingMemory.
047: *
048: * <p>
049: * The created <code>WorkingMemory</code> uses the default conflict
050: * resolution strategy.
051: * </p>
052: *
053: * @see WorkingMemory
054: * @see org.drools.conflict.DefaultConflictResolver
055: *
056: * @return A newly initialized <code>WorkingMemory</code>.
057: */
058: StatefulSession newStatefulSession();
059:
060: /**
061: * Create a new <code>WorkingMemory</code> session for this
062: * <code>RuleBase</code>. Optionally the RuleBase retains a
063: * weak reference to returned WorkingMemory.
064: *
065: * <p>
066: * The created <code>WorkingMemory</code> uses the default conflict
067: * resolution strategy.
068: * </p>
069: *
070: * @see WorkingMemory
071: * @see org.drools.conflict.DefaultConflictResolver
072: *
073: * @return A newly initialized <code>WorkingMemory</code>.
074: */
075: StatefulSession newStatefulSession(boolean keepReference);
076:
077: /**
078: * RuleBases handle the returning of a Serialized WorkingMemory
079: * pass as an InputStream. If the reference is a byte[] then
080: * wrap with new ByteArrayInputStream. By default the RuleBase retains a
081: * weak reference to returned WorkingMemory.
082: *
083: * <p>
084: * The created <code>WorkingMemory</code> uses the default conflict
085: * resolution strategy.
086: * </p>
087: *
088: * @see WorkingMemory
089: * @see org.drools.conflict.DefaultConflictResolver
090: *
091: * @return A serialised initialized <code>WorkingMemory</code>.
092: */
093: StatefulSession newStatefulSession(InputStream stream)
094: throws IOException, ClassNotFoundException;
095:
096: /**
097: * RuleBases handle the returning of a Serialized WorkingMemory
098: * pass as an InputStream. If the reference is a byte[] then
099: * wrap with new ByteArrayInputStream. Optionally the RuleBase retains a
100: * weak reference to returned WorkingMemory.
101: *
102: * <p>
103: * The created <code>WorkingMemory</code> uses the default conflict
104: * resolution strategy.
105: * </p>
106: *
107: * @see WorkingMemory
108: * @see org.drools.conflict.DefaultConflictResolver
109: *
110: * @return A serialised initialized <code>WorkingMemory</code>.
111: */
112: StatefulSession newStatefulSession(InputStream stream,
113: boolean keepReference) throws IOException,
114: ClassNotFoundException;
115:
116: Package[] getPackages();
117:
118: Package getPackage(String name);
119:
120: void addPackage(Package pkg) throws Exception;
121:
122: void removePackage(String packageName);
123:
124: void removeRule(String packageName, String ruleName);
125:
126: void removeFunction(String packageName, String functionName);
127:
128: void removeProcess(String id);
129:
130: public StatefulSession[] getStatefulSessions();
131: }
|