Drools & jBPM provide an knowledge-centric API, where rules and processes are first class citizens.

The most common interfaces you will use are:

- `org.drools.builder.KnowledgeBuilder`
- `org.drools.KnowledgeBase`
- `org.drools.agent.KnowledgeAgent`
- `org.drools.runtime.StatefulKnowledgeSession`
- `org.drools.runtime.StatelessKnowledgeSession`

Factory classes, with static methods, provide instances of the above interfaces. A pluggable provider approach is used to allow provider implementations to be wired up to the factories at runtime. The Factories you will most commonly used are:

- `org.drools.builder.KnowledgeBuilderFactory`
- `org.drools.io.ResourceFactory`
- `org.drools.KnowledgeBaseFactory`
- `org.drools.agent.KnowledgeAgentFactory`

A Typical example to load a rule resource.

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add( ResourceFactory.newUrlResource( url ),
                          ResourceType.DRL );
    if ( kbuilder.hasErrors() ) {
        System.err.println( builder.getErrors().toString() );
    }

    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    kbase.addKnowledgePackages( builder.getKnowledgePackages() );

    StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
    ksession.insert( new Fibonacci( 10 ) );
    ksession.fireAllRules();

    ksession.dispose();

A Typical example to load a process resource. Notice the ResourceType is changed to BPMN2 in this example.

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add( ResourceFactory.newUrlResource( url ),
                  ResourceType.BPMN2 );
    KnowledgeBase kbase = kbuilder.newKnowledgeBase();
    StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
    ksession.startProcess( "Buy Order Process" );
    ksession.dispose();

'kbuilder', 'kbase', 'ksession' are the variable identifiers often used, the k prefix is for 'knowledge'.

It is also possible to configure a KnowledgeBase using configuration, via a xml change set, instead of programmatically. Here is a simple change set:

    <change-set xmlns='http://drools.org/drools-5.0/change-set'
               xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
               xs:schemaLocation='http://drools.org/drools-5.0/change-set change-set-5.0.xsd' >
      <add>
        <resource source='classpath:org/domain/someRules.drl' type='DRL' />
        <resource source='classpath:org/domain/myProcess.bpmn2' type='BPMN2' />
      </add>
    </change-set>

And it is added just like any other ResourceType

    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    kbuilder.add( ResourceFactory.newUrlResource( url ),
                  ResourceType.ChangeSet );

The majority of knowledge API is considered stable and should not change, experimental classes and API's will be marked as such.