Permalink
Browse files

fix examples + remove JarKieModule

  • Loading branch information...
mariofusco committed Dec 6, 2012
1 parent 95e0676 commit 04894b1e45572268635a68c1e80368058a087283
Showing with 176 additions and 193 deletions.
  1. +0 −49 drools-compiler/src/main/java/org/kie/builder/impl/JarKieModule.java
  2. +35 −7 drools-compiler/src/main/java/org/kie/builder/impl/ZipKieModule.java
  3. +10 −10 drools-examples/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
  4. +8 −8 drools-examples/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java
  5. +10 −10 drools-examples/src/main/java/org/drools/benchmark/waltzdb/WaltzDbBenchmark.java
  6. +3 −3 drools-examples/src/main/java/org/drools/examples/decisiontable/PricingRuleDTExample.java
  7. +5 −5 drools-examples/src/main/java/org/drools/examples/decisiontable/PricingRuleTemplateExample.java
  8. +1 −1 drools-examples/src/main/java/org/drools/examples/fibonacci/FibonacciExample.java
  9. +1 −1 drools-examples/src/main/java/org/drools/examples/golfing/GolfingExample.java
  10. +5 −5 drools-examples/src/main/java/org/drools/examples/helloworld/HelloWorldExample.java
  11. +1 −1 drools-examples/src/main/java/org/drools/examples/honestpolitician/HonestPoliticianExample.java
  12. +8 −8 drools-examples/src/main/java/org/drools/examples/pacman/PacmanExample.java
  13. +13 −28 drools-examples/src/main/java/org/drools/examples/petstore/PetStoreExample.java
  14. +1 −1 drools-examples/src/main/java/org/drools/examples/shopping/ShoppingExample.java
  15. +1 −1 drools-examples/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java
  16. +7 −7 drools-examples/src/main/java/org/drools/examples/templates/SimpleRuleTemplateExample.java
  17. +3 −3 drools-examples/src/main/java/org/drools/examples/traits/TraitExample.java
  18. +1 −1 drools-examples/src/main/java/org/drools/examples/troubleticket/TroubleTicketExample.java
  19. +1 −1 drools-examples/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDSL.java
  20. +1 −1 drools-examples/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDT.java
  21. +1 −1 ...s-examples/src/main/java/org/drools/examples/workitemconsequence/WorkItemConsequenceExample1.java
  22. +1 −1 ...s-examples/src/main/java/org/drools/examples/workitemconsequence/WorkItemConsequenceExample2.java
  23. +7 −7 drools-examples/src/main/java/org/drools/games/adventures/GameEngine.java
  24. +6 −6 drools-examples/src/main/java/org/drools/games/pong/PongMain.java
  25. +3 −3 drools-examples/src/main/java/org/drools/games/wumpus/WumpusWorldMain.java
  26. +3 −3 drools-examples/src/main/java/org/drools/tutorials/banking/RuleRunner.java
  27. +8 −4 drools-scorecards/src/test/java/org/drools/scorecards/DrlFromPMMLTest.java
  28. +16 −8 drools-scorecards/src/test/java/org/drools/scorecards/ExternalObjectModelTest.java
  29. +13 −5 drools-scorecards/src/test/java/org/drools/scorecards/ScorecardReasonCodeTest.java
  30. +3 −4 kie-ci/src/main/java/org/drools/scanner/KieRepositoryScannerImpl.java
@@ -1,49 +0,0 @@
-package org.kie.builder.impl;
-
-import static org.drools.compiler.io.memory.MemoryFileSystem.readFromJar;
-import static org.kie.builder.impl.KieBuilderImpl.buildKieModule;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.drools.kproject.models.KieModuleModelImpl;
-import org.kie.builder.GAV;
-import org.kie.builder.KieModuleModel;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JarKieModule extends MemoryKieModule {
-
- private static final Logger log = LoggerFactory.getLogger(JarKieModule.class);
-
- private Messages messages;
-
- public JarKieModule(GAV gav, File jar) {
- super(gav, getKieModuleModelFromJar(jar), readFromJar(jar));
- }
-
- public Messages build() {
- if (messages == null) {
- messages = new Messages();
- buildKieModule(this, messages);
- }
- return messages;
- }
-
- private static KieModuleModel getKieModuleModelFromJar(File jar) {
- ZipFile zipFile = null;
- try {
- zipFile = new ZipFile( jar );
- ZipEntry zipEntry = zipFile.getEntry( KieModuleModelImpl.KMODULE_JAR_PATH );
- return KieModuleModelImpl.fromXML(zipFile.getInputStream(zipEntry));
- } catch ( Exception e ) {
- throw new RuntimeException("Unable to load kmodule.xml from" + jar.getAbsolutePath());
- } finally {
- try {
- zipFile.close();
- } catch ( IOException e ) { }
- }
- }
-}
@@ -1,28 +1,56 @@
package org.kie.builder.impl;
+import org.drools.core.util.IoUtils;
+import org.drools.kproject.models.KieModuleModelImpl;
+import org.kie.builder.GAV;
+import org.kie.builder.KieModuleModel;
+
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import org.drools.core.util.IoUtils;
-import org.kie.builder.GAV;
-import org.kie.builder.KieModuleModel;
+import static org.kie.builder.impl.KieBuilderImpl.buildKieModule;
public class ZipKieModule extends AbstractKieModule implements InternalKieModule {
private final File file;
private Map<String, ZipEntry> zipEntries;
+ public ZipKieModule(GAV gav, File jar) {
+ this(gav, getKieModuleModelFromJar(jar), jar);
+ }
+
public ZipKieModule(GAV gav,
- KieModuleModel kieProject,
- File file) {
+ KieModuleModel kieProject,
+ File file) {
super( gav, kieProject );
- this.file = file;
+ this.file = file;
this.zipEntries = IoUtils.buildZipFileMapEntries( file );
}
-
+
+ public Messages build() {
+ Messages messages = new Messages();
+ buildKieModule(this, messages);
+ return messages;
+ }
+
+ private static KieModuleModel getKieModuleModelFromJar(File jar) {
+ ZipFile zipFile = null;
+ try {
+ zipFile = new ZipFile( jar );
+ ZipEntry zipEntry = zipFile.getEntry( KieModuleModelImpl.KMODULE_JAR_PATH );
+ return KieModuleModelImpl.fromXML(zipFile.getInputStream(zipEntry));
+ } catch ( Exception e ) {
+ throw new RuntimeException("Unable to load kmodule.xml from" + jar.getAbsolutePath());
+ } finally {
+ try {
+ zipFile.close();
+ } catch ( IOException e ) { }
+ }
+ }
+
@Override
public File getFile() {
return this.file;
@@ -16,6 +16,16 @@
package org.drools.benchmark.manners;
+import org.kie.KnowledgeBase;
+import org.kie.KnowledgeBaseFactory;
+import org.kie.builder.KnowledgeBuilder;
+import org.kie.builder.KnowledgeBuilderConfiguration;
+import org.kie.builder.KnowledgeBuilderFactory;
+import org.kie.definition.KnowledgePackage;
+import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
+import org.kie.runtime.StatefulKnowledgeSession;
+
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -29,16 +39,6 @@
import java.util.Random;
import java.util.StringTokenizer;
-import org.kie.KnowledgeBase;
-import org.kie.KnowledgeBaseFactory;
-import org.kie.builder.KnowledgeBuilder;
-import org.kie.builder.KnowledgeBuilderConfiguration;
-import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
-import org.kie.definition.KnowledgePackage;
-import org.kie.io.ResourceFactory;
-import org.kie.runtime.StatefulKnowledgeSession;
-
public class MannersBenchmark {
/** Number of guests at the dinner (default: 16). */
@@ -16,23 +16,23 @@
package org.drools.benchmark.waltz;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Collection;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.definition.KnowledgePackage;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
import org.kie.runtime.rule.WorkingMemory;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* This is a sample file to launch a rule package from a rule source file.
*/
@@ -16,25 +16,25 @@
package org.drools.benchmark.waltzdb;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseConfiguration;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.definition.KnowledgePackage;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
/**
* This example is incomplete, it run's, but is no way near correct.
*/
@@ -16,18 +16,18 @@
package org.drools.examples.decisiontable;
-import java.util.Arrays;
-
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.DecisionTableConfiguration;
import org.kie.builder.DecisionTableInputType;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatelessKnowledgeSession;
+import java.util.Arrays;
+
/**
* This shows off a decision table.
*/
@@ -15,21 +15,21 @@
*/
package org.drools.examples.decisiontable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-
import org.drools.decisiontable.ExternalSpreadsheetCompiler;
import org.drools.io.impl.ByteArrayResource;
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderError;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+
/**
* This shows off a rule template where the data provider is a spreadsheet.
* This example uses the same spreadsheet as the Decision table example ({@link PricingRuleDTExample})
@@ -20,8 +20,8 @@
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
public class FibonacciExample {
@@ -20,8 +20,8 @@
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
public class GolfingExample {
@@ -16,21 +16,21 @@
package org.drools.examples.helloworld;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.definition.KnowledgePackage;
import org.kie.event.rule.DebugAgendaEventListener;
import org.kie.event.rule.DebugWorkingMemoryEventListener;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* This is a sample file to launch a rule package from a rule source file.
*/
@@ -21,8 +21,8 @@
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderConfiguration;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
public class HonestPoliticianExample {
@@ -16,21 +16,21 @@
package org.drools.examples.pacman;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
import org.kie.KnowledgeBase;
import org.kie.KnowledgeBaseFactory;
import org.kie.builder.KnowledgeBuilder;
import org.kie.builder.KnowledgeBuilderFactory;
-import org.kie.builder.ResourceType;
import org.kie.io.ResourceFactory;
+import org.kie.io.ResourceType;
import org.kie.runtime.StatefulKnowledgeSession;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
public class PacmanExample {
volatile StatefulKnowledgeSession ksession = null;
PacMan pacMan;
Oops, something went wrong.

0 comments on commit 04894b1

Please sign in to comment.