Search in sources :

Example 6 with SessionClock

use of org.kie.api.time.SessionClock in project drools by kiegroup.

the class GetSessionTimeCommand method execute.

@Override
public Long execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    SessionClock sessionClock = ksession.<SessionClock>getSessionClock();
    long result = sessionClock.getCurrentTime();
    ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
    if (results != null) {
        results.getResults().put(this.outIdentifier, result);
    }
    return result;
}
Also used : ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) SessionClock(org.kie.api.time.SessionClock)

Aggregations

KieSession (org.kie.api.runtime.KieSession)6 SessionClock (org.kie.api.time.SessionClock)6 Test (org.junit.Test)5 Ignore (org.junit.Ignore)4 SessionPseudoClock (org.kie.api.time.SessionPseudoClock)4 ArrayList (java.util.ArrayList)3 KieBase (org.kie.api.KieBase)3 KieSessionConfiguration (org.kie.api.runtime.KieSessionConfiguration)3 List (java.util.List)2 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)2 KiePackage (org.kie.api.definition.KiePackage)2 Resource (org.kie.api.io.Resource)2 Arrays.asList (java.util.Arrays.asList)1 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 FactA (org.drools.compiler.FactA)1 IteratorToList (org.drools.compiler.integrationtests.IteratorToList)1 RegistryContext (org.drools.core.command.impl.RegistryContext)1 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)1 PseudoClockScheduler (org.drools.core.time.impl.PseudoClockScheduler)1