Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools;
 
 import java.util.Set;
 

The KnowledgeBase is a repository of all the application's knowledge definitions. It will contain rules, processes, functions, type models. The KnowledgeBase itself does not contain runtime data, instead sessions are created from the KnowledgeBase in which data can be inserted and process instances started. Creating the KnowledgeBase can be heavy, where as session creation is very light, so it is recommended that KnowledgeBases be cached where possible to allow for repeated session creation. The KnowledgeAgent can be used for this purpose. The KnowledgeBase is created from the KnowledgeBaseFactory, and a KnowledgeBaseConfiguration can be used.

 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
 

Create sequential KnowledgeBase using the given ClassLoader.

 Properties properties = new Properties();
 properties.setProperty( "org.drools.sequential", "true");
 KnowledgeBaseConfiguration kbConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(properties, myClassLoader);
 KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbConf);
 

 
 public interface KnowledgeBase
     extends
     KnowledgeBaseEventManager {

    
Add the collection of KnowledgePackages to the KnowledgeBase. It is recommended that you ALWAYS check KnowledgeBuilder.hasErrors() first before doing this.

Parameters:
knowledgePackage
 
     void addKnowledgePackages(Collection<KnowledgePackagekpackages);

    
Return an immutable collection of the packages that exist in this KnowledgeBase.

Returns:
 
     Collection<KnowledgePackagegetKnowledgePackages();
    
    
Returns a reference to the KnowledgePackage identified by the given name.

Parameters:
packageName the name of the KnowledgePackage to return
Returns:
the KnowledgePackage identified by the the given name or null if package not found.
 
     KnowledgePackage getKnowledgePackageString packageName );

    
Remove a KnowledgePackage and all the definitions it contains from the KnowledgeBase.

Parameters:
packageName
 
     void removeKnowledgePackage(String packageName);

    
Returns a reference to the Rule identified by the given package and rule names.

Parameters:
packageName the package name to which the rule belongs to.
ruleName the name of the rule.
Returns:
the Rule object or null if not found.
 
    Rule getRuleString packageName
                  String ruleName );
    
Remove a rule from the specified package.

Parameters:
packageName
ruleName
    void removeRule(String packageName,
                    String ruleName);
    
    
Returns a reference to the Rule identified by the given package and rule names.

Parameters:
packageName the package name to which the rule belongs to.
ruleName the name of the rule.
Returns:
the Rule object or null if not found.
    Query getQueryString packageName
                  String queryName );
    
Remove a rule from the specified package.

Parameters:
packageName
ruleName
    void removeQuery(String packageName,
                    String queryName);
    
    
Remove a function from the specified package.

Parameters:
packageName
ruleName
    void removeFunction(String packageName,
                        String ruleName);

    
Returns the FactType identified by the given package and type names.

Parameters:
packageName the name of the package the fact belongs to.
typeName the name of the type.
Returns:
the FactType identified by the parameters or null if FactType not found.
    FactType getFactTypeString packageName
                          String typeName );

    
Returns a referent to the Process identified by the given processId

Parameters:
processId the id of the process
Returns:
the Process identified by the given processId or null if process not found.
    Process getProcessString processId );
    
    
Remove a process from the specified package.

Parameters:
processId
    void removeProcess(String processId);
    
    Collection<ProcessgetProcesses();
    
    
Create a new StatefulKnowledgeSession using the given session configuration and/or environment. Either one can be null and it will use a default. Don't forget to dispose() session when you are done.

Parameters:
conf
environment
Returns:
The StatefulKnowledgeSession.
Create a new StatefulKnowledgeSession using the default session configuration. Don't forget to dispose() session when you are done.

Returns:
The StatefulKnowledgeSession.
Return a collection of the StatefulKnowledgeSessions that exist in this KnowledgeBase. Be careful as sessions are not thread-safe and could be in use elsewhere.

Returns:
a Collection of StatefulKnowledgeSessions
Create a new StatelessKnowledgeSession using the given session configuration. You do not need to call dispose() on this.

Parameters:
conf
Returns:
The StatelessKnowledgeSession.
Create a new StatelessKnowledgeSession using the default session configuration. You do not need to call dispose() on this.

Returns:
The StatelessKnowledgeSession.
Returns the set of the entry points declared and/or used in this knowledge base

Returns:
New to GrepCode? Check out our FAQ X