Context pathContext = new ResolvingKnowledgeCommandContext( this.contexts.get( path.getName() ) );
// increment the clock for all the registered ksessions
for ( StatefulKnowledgeSession ksession : this.ksessions ) {
SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
long newTime = startTime + step.getDistanceMillis();
long currentTime = clock.getCurrentTime();
clock.advanceTime( newTime - currentTime,
TimeUnit.MILLISECONDS );
}
for ( Command cmd : step.getCommands() ) {
if ( cmd instanceof NewStatefulKnowledgeSessionCommand ) {
// instantiate the ksession, set it's clock and register it
StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) executionHandler.execute( (GenericCommand) cmd,
pathContext );
if ( ksession != null ) {
SessionPseudoClock clock = (SessionPseudoClock) ksession.getSessionClock();
long newTime = startTime + step.getDistanceMillis();
long currentTime = clock.getCurrentTime();
clock.advanceTime( newTime - currentTime,
TimeUnit.MILLISECONDS );
this.ksessions.add( ksession );
this.lastReturnValue = ksession;
}
} else if ( cmd instanceof GenericCommand ) {