drools/drools-core/src/main/java/org/drools/core$ vi impl/KnowledgeBaseImpl.java
public KnowledgeBaseImpl(final String id,
final RuleBaseConfiguration config) {
this.config = (config != null) ? config : new RuleBaseConfiguration();
this.config.makeImmutable();
createRulebaseId(id);
this.rootClassLoader = this.config.getClassLoader();
this.pkgs = new HashMap<String, InternalKnowledgePackage>();
this.processes = new HashMap<String, Process>();
this.globals = new HashMap<String, Class<?>>();
this.classTypeDeclaration = new HashMap<String, TypeDeclaration>();
this.classFieldAccessorCache = new ClassFieldAccessorCache(this.rootClassLoader);
kieComponentFactory = getConfiguration().getComponentFactory();
this.factHandleFactory = kieComponentFactory.getFactHandleFactoryService();
kieComponentFactory.getTraitFactory().setRuleBase(this);
kieComponentFactory.getTripleStore().setId(id);
setupRete();
if ( this.config.getSessionCacheOption().isEnabled() ) {
sessionsCache = new SessionsCache(this.config.getSessionCacheOption().isAsync());
}
sessionConfiguration = new SessionConfigurationImpl( null, this.config.getClassLoader(), this.config.getChainedProperties() );
}
call setupRete()
protected void setupRete() {
this.rete = new Rete( this );
this.reteooBuilder = new ReteooBuilder( this );
NodeFactory nodeFactory = kieComponentFactory.getNodeFactoryService();
// always add the default entry point
EntryPointNode epn = nodeFactory.buildEntryPointNode(this.reteooBuilder.getIdGenerator().getNextId(),
RuleBasePartitionId.MAIN_PARTITION,
this.getConfiguration().isMultithreadEvaluation(),
this.rete,
EntryPointId.DEFAULT);
epn.attach();
BuildContext context = new BuildContext(this);
context.setCurrentEntryPoint(epn.getEntryPoint());
context.setTupleMemoryEnabled(true);
context.setObjectTypeNodeMemoryEnabled(true);
context.setPartitionId(RuleBasePartitionId.MAIN_PARTITION);
ObjectTypeNode otn = nodeFactory.buildObjectTypeNode(this.reteooBuilder.getIdGenerator().getNextId(),
epn,
ClassObjectType.InitialFact_ObjectType,
context);
otn.attach(context);
}
drools/drools-core/src/main/java/org/drools/core$ vi reteoo/ReteooBuilder.java
/**
* Construct a <code>Builder</code> against an existing <code>Rete</code>
* network.
*/
public ReteooBuilder( final InternalKnowledgeBase kBase ) {
this.kBase = kBase;
this.rules = new HashMap<String, BaseNode[]>();
this.queries = new HashMap<String, BaseNode[]>();
this.namedWindows = new HashMap<String, WindowNode>();
//Set to 1 as Rete node is set to 0
this.idGenerator = new IdGenerator();
this.ruleBuilder = kBase.getConfiguration().getComponentFactory().getRuleBuilderFactory().newRuleBuilder();
}