Skip to content

Commit

Permalink
BZ-1078337 - Unfinished support for Custom Work Item Handlers in busi…
Browse files Browse the repository at this point in the history
…ness-central
  • Loading branch information
mswiderski committed Mar 21, 2014
1 parent be8d3c7 commit e961107
Showing 1 changed file with 12 additions and 2 deletions.
Expand Up @@ -40,14 +40,20 @@ public static void wireListnersAndWIHs(KieSessionModel model, KieSession kSessio
}

private static void wireListnersAndWIHs(BeanCreator beanCreator, KieSessionModel model, KieSession kSession) {
BeanCreator fallbackBeanCreator = new ReflectionBeanCreator();
ClassLoader cl = ((InternalRuleBase)((InternalKnowledgeBase)kSession.getKieBase()).getRuleBase()).getRootClassLoader();

for (ListenerModel listenerModel : model.getListenerModels()) {
Object listener;
try {
listener = beanCreator.createBean(cl, listenerModel.getType(), listenerModel.getQualifierModel());
} catch (Exception e) {
throw new RuntimeException("Cannot instance listener " + listenerModel.getType(), e);
try {
listener = fallbackBeanCreator.createBean(cl, listenerModel.getType(), listenerModel.getQualifierModel());
} catch (Exception ex) {
throw new RuntimeException("Cannot instance listener " + listenerModel.getType(), e);
}

}
switch(listenerModel.getKind()) {
case AGENDA_EVENT_LISTENER:
Expand All @@ -66,7 +72,11 @@ private static void wireListnersAndWIHs(BeanCreator beanCreator, KieSessionModel
try {
wih = beanCreator.createBean(cl, wihModel.getType(), wihModel.getQualifierModel());
} catch (Exception e) {
throw new RuntimeException("Cannot instance WorkItemHandler " + wihModel.getType(), e);
try {
wih = fallbackBeanCreator.createBean(cl, wihModel.getType(), wihModel.getQualifierModel() );
} catch (Exception ex) {
throw new RuntimeException("Cannot instance WorkItemHandler " + wihModel.getType(), e);
}
}
kSession.getWorkItemManager().registerWorkItemHandler(wihModel.getName(), wih );
}
Expand Down

0 comments on commit e961107

Please sign in to comment.