diff --git a/.gitignore b/.gitignore
index 6597bc0..74effc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
.classpath
.project
.settings/*
+/target/
diff --git a/pom.xml b/pom.xml
index bc187d7..649aa4b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,16 +42,6 @@
-
- drools-core
- org.drools
- 5.4.0.Final
-
-
- drools-compiler
- org.drools
- 5.4.0.Final
-
xstream
com.thoughtworks.xstream
diff --git a/src/main/java/org/integrallis/drools/DroolsTest.java b/src/main/java/org/integrallis/drools/DroolsTest.java
index 5f46e74..414efa6 100644
--- a/src/main/java/org/integrallis/drools/DroolsTest.java
+++ b/src/main/java/org/integrallis/drools/DroolsTest.java
@@ -1,56 +1,30 @@
package org.integrallis.drools;
import org.apache.log4j.Logger;
-import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseFactory;
-import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderError;
-import org.drools.builder.KnowledgeBuilderErrors;
-import org.drools.builder.KnowledgeBuilderFactory;
-import org.drools.builder.ResourceType;
-import org.drools.io.ResourceFactory;
-import org.drools.logger.KnowledgeRuntimeLogger;
-import org.drools.logger.KnowledgeRuntimeLoggerFactory;
-import org.drools.runtime.StatefulKnowledgeSession;
+import org.kie.api.KieServices;
+import org.kie.api.runtime.KieContainer;
+import org.kie.api.runtime.KieSession;
public class DroolsTest {
private static Logger applicationLogger = Logger.getLogger(DroolsTest.class);
public static final void main(String[] args) {
- try {
- // load up the knowledge base
- KnowledgeBase knowledgeBase = readKnowledgeBase();
- StatefulKnowledgeSession knowledgeSession = knowledgeBase.newStatefulKnowledgeSession();
-
- knowledgeSession.setGlobal("myLogger", applicationLogger);
-
- KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(knowledgeSession, "test");
+ KieSession knowledgeSession = null;
+ try {
+ // load up the knowledge base
+ KieServices ks = KieServices.Factory.get();
+ KieContainer kContainer = ks.getKieClasspathContainer();
+ knowledgeSession = kContainer.newKieSession("ksession-rules");
+ knowledgeSession.setGlobal("applicationLogger", applicationLogger);
knowledgeSession.insert(new SomeClass("Hey you!"));
knowledgeSession.fireAllRules();
- logger.close();
} catch (Throwable t) {
t.printStackTrace();
- }
- }
-
- private static KnowledgeBase readKnowledgeBase() throws Exception {
- KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
- knowledgeBuilder.add(ResourceFactory.newClassPathResource("sample.drl"), ResourceType.DRL);
- KnowledgeBuilderErrors errors = knowledgeBuilder.getErrors();
- if (errors.size() > 0) {
- for (KnowledgeBuilderError error: errors) {
- System.err.println(error);
- }
- throw new IllegalArgumentException("Could not parse knowledge.");
- }
- KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
- knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
- return knowledgeBase;
+ } finally {
+ knowledgeSession.dispose();
+ }
}
-
-
-
}
\ No newline at end of file
diff --git a/src/main/resources/META-INF/kmodule.xml b/src/main/resources/META-INF/kmodule.xml
new file mode 100644
index 0000000..a5e55bf
--- /dev/null
+++ b/src/main/resources/META-INF/kmodule.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/main/resources/META-INF/maven/pom.properties b/src/main/resources/META-INF/maven/pom.properties
new file mode 100644
index 0000000..4c4050d
--- /dev/null
+++ b/src/main/resources/META-INF/maven/pom.properties
@@ -0,0 +1,3 @@
+groupId=org.integrallis
+artifactId=drools-greeter
+version=0.0.1
diff --git a/src/main/resources/rules/sample.drl b/src/main/resources/rules/sample.drl
new file mode 100644
index 0000000..2bbc26e
--- /dev/null
+++ b/src/main/resources/rules/sample.drl
@@ -0,0 +1,12 @@
+package org.integrallis.drools
+
+global org.apache.log4j.Logger applicationLogger
+
+rule "LoggingWithLog4J"
+ when
+ object : SomeClass()
+ then
+ applicationLogger.info("SomeClass says " + object.getMessage());
+
+end
+
diff --git a/src/main/rules/sample.drl b/src/main/rules/sample.drl
deleted file mode 100644
index d83fd64..0000000
--- a/src/main/rules/sample.drl
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.integrallis.drools
-
-global org.apache.log4j.Logger myLogger
-
-rule "LoggingWithLog4J"
- when
- object : SomeClass()
- then
- myLogger.info("SomeClass says " + object.getMessage());
-
-end
-