Skip to content

Instantly share code, notes, and snippets.

@pmuir
Forked from tsurdilo/gist:579321
Created September 14, 2010 17:19
Show Gist options
  • Save pmuir/579397 to your computer and use it in GitHub Desktop.
Save pmuir/579397 to your computer and use it in GitHub Desktop.
@Drools(kbuilderConfigFile = "kbuilderconfig.properties",
kbaseConfigFile = "kbaseconfig.properties",
})
@Produces
@ApplicationScoped
RuleResouces configureRules() {
// Here the RuleResource guesses at being a DRL based on extension (not sure if this is valid)
// I also compressed the URL back to a normal syntax
return new RuleResources().add(new RuleResource("classpath:/kbasetest.drl", "forkbasetest")).add(...);
}
@Generic(Drools.class)
public class KnowledgeProducer
{
private static final Logger log = LoggerFactory.getLogger(KnowledgeSessionProducer.class);
@Inject
BeanManager manager;
@Inject
DroolsExtension droolsExtension;
@Inject
ResourceProvider resourceProvider;
@Inject
SeamDelegate delegate;
@Inject
DroolsConfig config;
@Inject
DroolsConfigUtil configUtils;
@Inject @GenericProduct
RuleResources ruleResources;
private KnowledgeBase kbase;
@PostConstruct
public void init() {
this.kbase = initKbase();
}
@Produces
@RequestScoped
public StatefulKnowledgeSession produceStatefulSession() throws Exception
{...}
@Produces
public KnowledgeBase produceKnowledgeBase() throws Exception
{
return kbase;
}
...}
@Generic(Drools.class)
class RuleResources {
Iterator<RuleResource> iterator() {...}
RuleResources add(RuleResource ruleResource) {...}
RuleResources addAll(RuleResource... ruleResources) {...}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment