use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class ClearActivationGroupCommand method execute.
public Void execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ksession.getAgenda().getActivationGroup(this.name).clear();
return null;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class ClearAgendaGroupCommand method execute.
public Void execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
ksession.getAgenda().getAgendaGroup(this.name).clear();
return null;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class FireAllRulesCommand method execute.
public Integer execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
int fired;
if (max != -1 && agendaFilter != null) {
fired = ((StatefulKnowledgeSessionImpl) ksession).fireAllRules(agendaFilter, max);
} else if (max != -1) {
fired = ksession.fireAllRules(max);
} else if (agendaFilter != null) {
fired = ((StatefulKnowledgeSessionImpl) ksession).fireAllRules(agendaFilter);
} else {
fired = ksession.fireAllRules();
}
if (this.outIdentifier != null) {
((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, fired);
}
return fired;
}
use of org.drools.core.command.impl.RegistryContext in project drools by kiegroup.
the class NewKieSessionCommand method execute.
public KieSession execute(Context context) {
KieContainer kieContainer;
if (releaseId != null) {
// use the new API to retrieve the session by ID
KieServices kieServices = KieServices.Factory.get();
kieContainer = kieServices.newKieContainer(releaseId);
} else {
kieContainer = ((RegistryContext) context).lookup(KieContainer.class);
if (kieContainer == null) {
throw new RuntimeException("ReleaseId was not specfied, nor was an existing KieContainer assigned to the Registry");
}
}
KieSession ksession = sessionId != null ? kieContainer.newKieSession(sessionId) : kieContainer.newKieSession();
((RegistryContext) context).register(KieSession.class, ksession);
return ksession;
}
use of org.drools.core.command.impl.RegistryContext 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;
}
Aggregations