Skip to content

Commit

Permalink
Use WEB-INF/security.drl if security.drl not found on classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
maschmid committed Aug 5, 2011
1 parent 8adb507 commit 3db9cac
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -32,6 +32,10 @@ public class SecurityRuleProducer {
@Resource("security.drl")
InputStream securityRules;

@Inject
@Resource("WEB-INF/security.drl")
InputStream webInfSecurityRules;

@Produces
@ApplicationScoped
@Security
Expand All @@ -41,7 +45,9 @@ public KnowledgeBase createSecurityKnowledgeBase() {

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);

org.drools.io.Resource resource = ResourceFactory.newInputStreamResource(securityRules);
org.drools.io.Resource resource = ResourceFactory.newInputStreamResource(
securityRules != null ? securityRules : webInfSecurityRules);

kbuilder.add(resource, ResourceType.DRL);

KnowledgeBuilderErrors kbuildererrors = kbuilder.getErrors();
Expand Down

0 comments on commit 3db9cac

Please sign in to comment.