use of org.kie.api.runtime.process.WorkItemHandler in project drools by kiegroup.
the class CustomWorkItemHandlerTest method testRegisterHandlerWithKsessionUsingConfiguration.
@Test
public void testRegisterHandlerWithKsessionUsingConfiguration() {
KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
Properties props = new Properties();
props.setProperty("drools.workItemHandlers", "CustomWorkItemHandlers.conf");
KieSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(props);
KieSession ksession = kbase.newKieSession(config, EnvironmentFactory.newEnvironment());
assertNotNull(ksession);
// this test would fail on creation of the work item manager if injecting session is not supported
WorkItemManager manager = ksession.getWorkItemManager();
assertNotNull(manager);
Map<String, WorkItemHandler> handlers = ((SessionConfiguration) config).getWorkItemHandlers();
assertNotNull(handlers);
assertEquals(1, handlers.size());
assertTrue(handlers.containsKey("Custom"));
}
use of org.kie.api.runtime.process.WorkItemHandler in project drools by kiegroup.
the class DefaultWorkItemManager method internalExecuteWorkItem.
public void internalExecuteWorkItem(WorkItem workItem) {
((WorkItemImpl) workItem).setId(workItemCounter.incrementAndGet());
internalAddWorkItem(workItem);
WorkItemHandler handler = this.workItemHandlers.get(workItem.getName());
if (handler != null) {
handler.executeWorkItem(workItem, this);
} else
throw new WorkItemHandlerNotFoundException("Could not find work item handler for " + workItem.getName(), workItem.getName());
}
Aggregations