"global java.util.List list; " +
"rule C when $s : String() then System.out.println( 'CCC' + $s ); list.add( 'C' + $s ); end " +
"";
KieServices ks = KieServices.Factory.get();
KieFileSystem kfs = ks.newKieFileSystem();
ReleaseId id = ks.newReleaseId( "org.test", "foo", "1.0-SNAPSHOT" );
KieBuilder kieBuilder = ks.newKieBuilder( kfs );
kfs.generateAndWritePomXML( id );
kfs.write( ks.getResources()
.newReaderResource( new StringReader( drl1 ) )
.setResourceType( ResourceType.DRL )
.setSourcePath( "drl1.drl" ) );
kieBuilder.buildAll();
KieContainer kc = ks.newKieContainer( id );
KieSession ksession = kc.newKieSession();
List<String> list = new ArrayList<String>();
ksession.setGlobal( "list", list );
ksession.insert( "X" );
ksession.fireAllRules();
assertTrue( list.contains( "AX" ) );
KieFileSystem kfs2 = ks.newKieFileSystem();
KieBuilder kieBuilder2 = ks.newKieBuilder( kfs2 );
kfs2.generateAndWritePomXML( id );
kfs2.write( ks.getResources()
.newReaderResource( new StringReader( drl2 ) )
.setResourceType( ResourceType.DRL )
.setSourcePath( "drla.drl" ) );
kieBuilder2.buildAll();
KieContainer kc2 = ks.newKieContainer( id );
KieSession ksession2 = kc2.newKieSession();
ksession2.setGlobal( "list", list );
ksession2.insert( "X" );
ksession2.fireAllRules();
kfs2.write( ks.getResources()
.newReaderResource( new StringReader( drl3 ) )
.setResourceType( ResourceType.DRL )
.setSourcePath( "drlb.drl" ) );
IncrementalResults results = ( (InternalKieBuilder) kieBuilder2 ).incrementalBuild();