[jboss-svn-commits] JBL Code SVN: r24189 - in labs/jbossrules/trunk/drools-examples/drools-examples-drl: src/main/java/org/drools/benchmark/manners and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Dec 1 18:40:57 EST 2008
Author: KrisVerlaenen
Date: 2008-12-01 18:40:57 -0500 (Mon, 01 Dec 2008)
New Revision: 24189
Modified:
labs/jbossrules/trunk/drools-examples/drools-examples-drl/.classpath
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Chosen.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Context.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Guest.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/LastSeat.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Seating.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Account.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Address.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/GroupTransaction.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Security.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/SubTransaction.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Transaction.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltzdb/WaltzDbBenchmark.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/FibonacciExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HonestPoliticianExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/NumberGuessExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PetStore.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PricingRuleDTExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ShoppingExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/CDSSExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/service/RecommendationService.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/AgendaGroupDelegate.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/CellGridImpl.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayAgendaGroupRun.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayRuleFlowGroupRun.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/RuleFlowDelegate.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Border.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Hi.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pentadecathalon.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pulsar.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/SimpleGlider.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/CellGridCanvas.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/ConwayGUI.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/ShippingWorkItemHandler.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ruleflow/WorkItemExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/Main.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExample.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDSL.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketWithDT.java
labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/tutorials/banking/SimpleDate.java
Log:
JBRULES-1878: Update IDE to new API
- updated examples to use new API
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/.classpath 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/.classpath 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,17 +1,13 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
- <classpathentry excluding="**/*.java" kind="src" path="src/main/rules"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/foxtrot-2.0.jar"/>
- <classpathentry kind="lib" path="lib/jgoodies-forms-1.0.4.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-compiler"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-core"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-decisiontables"/>
- <classpathentry combineaccessrules="false" kind="src" path="/drools-templates"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/main/rules"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/foxtrot-2.0.jar"/>
+ <classpathentry kind="lib" path="lib/jgoodies-forms-1.0.4.jar"/>
+ <classpathentry kind="con" path="DROOLS/Drools"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Chosen.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Chosen.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Chosen.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -20,6 +20,8 @@
public class Chosen implements Serializable {
+ private static final long serialVersionUID = 1L;
+
private int id;
private String guestName;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Context.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Context.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Context.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -20,6 +20,8 @@
public class Context implements Serializable {
+ private static final long serialVersionUID = 1L;
+
public static final int START_UP = 0;
public static final int ASSIGN_SEATS = 1;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Guest.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Guest.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Guest.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -19,6 +19,9 @@
import java.io.Serializable;
public class Guest implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
private String name;
private Sex sex;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/LastSeat.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/LastSeat.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/LastSeat.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -19,6 +19,9 @@
import java.io.Serializable;
public class LastSeat implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
private int seat;
public LastSeat() {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/MannersBenchmark.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -24,17 +24,18 @@
import org.drools.runtime.StatefulKnowledgeSession;
public class MannersBenchmark {
+
/** Number of guests at the dinner (default: 16). */
- private int numGuests = 16;
+ private static int numGuests = 16;
/** Number of seats at the table (default: 16). */
- private int numSeats = 16;
+ private static int numSeats = 16;
/** Minimum number of hobbies each guest should have (default: 2). */
- private int minHobbies = 2;
+ private static int minHobbies = 2;
/** Maximun number of hobbies each guest should have (default: 3). */
- private int maxHobbies = 3;
+ private static int maxHobbies = 3;
public static void main(final String[] args) throws Exception {
KnowledgeBuilderConfiguration kbuilderConfig = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
@@ -60,8 +61,8 @@
}
InputStream is = MannersBenchmark.class.getResourceAsStream( filename );
- List list = getInputObjects( is );
- for ( Iterator it = list.iterator(); it.hasNext(); ) {
+ List<Object> list = getInputObjects( is );
+ for ( Iterator<Object> it = list.iterator(); it.hasNext(); ) {
Object object = it.next();
ksession.insert( object );
}
@@ -78,8 +79,8 @@
* Convert the facts from the <code>InputStream</code> to a list of
* objects.
*/
- protected static List getInputObjects(InputStream inputStream) throws IOException {
- List list = new ArrayList();
+ protected static List<Object> getInputObjects(InputStream inputStream) throws IOException {
+ List<Object> list = new ArrayList<Object>();
BufferedReader br = new BufferedReader( new InputStreamReader( inputStream ) );
@@ -132,7 +133,7 @@
return list;
}
- private InputStream generateData() {
+ public static InputStream generateData() {
final String LINE_SEPARATOR = System.getProperty( "line.separator" );
StringWriter writer = new StringWriter();
@@ -144,7 +145,7 @@
int femaleCount = 0;
// init hobbies
- List hobbyList = new ArrayList();
+ List<String> hobbyList = new ArrayList<String>();
for ( int i = 1; i <= maxHobbies; i++ ) {
hobbyList.add( "h" + i );
}
@@ -165,7 +166,7 @@
femaleCount++;
}
- List guestHobbies = new ArrayList( hobbyList );
+ List<String> guestHobbies = new ArrayList<String>( hobbyList );
int numHobbies = minHobbies + rnd.nextInt( maxHobbies - minHobbies + 1 );
for ( int j = 0; j < numHobbies; j++ ) {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Seating.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Seating.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/manners/Seating.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -19,6 +19,9 @@
import java.io.Serializable;
public class Seating implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
private int id, pid;
private int leftSeat, rightSeat;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Account.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Account.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Account.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -16,7 +16,9 @@
implements
Serializable {
- protected String first = null;
+ private static final long serialVersionUID = 1L;
+
+ protected String first = null;
protected String middle = null;
protected String last = null;
/**
@@ -41,7 +43,7 @@
protected String number = null;
protected String ext = null;
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
/**
*
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Address.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Address.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Address.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -14,7 +14,9 @@
implements
Serializable {
- protected String title = null;
+ private static final long serialVersionUID = 1L;
+
+ protected String title = null;
protected String accountId = null;
protected String street = null;
protected String street2 = null;
@@ -25,7 +27,7 @@
protected String houseType = null;
protected String country = null;
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
/**
*
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/GroupTransaction.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/GroupTransaction.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/GroupTransaction.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -10,14 +10,16 @@
*/
public class GroupTransaction extends Security {
- protected String[] accountIds = null;
+ private static final long serialVersionUID = 1L;
+
+ protected String[] accountIds = null;
protected double buyPrice;
protected String purchaseDate = null;
protected double shares;
protected double total;
protected String transactionId = null;
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
public GroupTransaction() {
super();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Security.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Security.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Security.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -13,7 +13,9 @@
implements
Serializable {
- protected String countryCode = null;
+ private static final long serialVersionUID = 1L;
+
+ protected String countryCode = null;
protected double currentPrice;
protected int cusip;
protected String exchange = null;
@@ -24,7 +26,7 @@
protected int sectorID;
protected int subIndustryID;
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
public Security() {
super();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/SubTransaction.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/SubTransaction.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/SubTransaction.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -10,8 +10,10 @@
*/
public class SubTransaction extends Security {
- protected String[] transactionSet = null;
- protected ArrayList listeners = new ArrayList();
+ private static final long serialVersionUID = 1L;
+
+ protected String[] transactionSet = null;
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
public SubTransaction() {
super();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Transaction.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Transaction.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/models/Transaction.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -10,14 +10,16 @@
*/
public class Transaction extends Security {
- protected String accountId = null;
+ private static final long serialVersionUID = 1L;
+
+ protected String accountId = null;
protected double buyPrice;
protected String purchaseDate = null;
protected double shares;
protected double total;
protected String transactionId = null;
- protected ArrayList listeners = new ArrayList();
+ protected ArrayList<PropertyChangeListener> listeners = new ArrayList<PropertyChangeListener>();
public Transaction() {
super();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltz/WaltzBenchmark.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -24,7 +24,6 @@
import java.util.regex.Pattern;
import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltzdb/WaltzDbBenchmark.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltzdb/WaltzDbBenchmark.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/benchmark/waltzdb/WaltzDbBenchmark.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -3,8 +3,9 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
+import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -42,19 +43,14 @@
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- java.util.List lines = WaltzDbBenchmark.loadLines( "waltzdb16.dat" ); //12,8,4
- java.util.List labels = WaltzDbBenchmark.loadLabels( "waltzdb16.dat" ); //12,8,4
+ List<Line> lines = WaltzDbBenchmark.loadLines( "waltzdb16.dat" ); //12,8,4
+ List<Label> labels = WaltzDbBenchmark.loadLabels( "waltzdb16.dat" ); //12,8,4
long now = System.currentTimeMillis();
- Iterator iter = lines.iterator();
- while ( iter.hasNext() ) {
- Line line = (Line) iter.next();
+ for ( Line line: lines ) {
ksession.insert( line );
System.out.println( line.getP1() + " " + line.getP2() );
}
-
- iter = labels.iterator();
- while ( iter.hasNext() ) {
- Label label = (Label) iter.next();
+ for ( Label label: labels ) {
ksession.insert( label );
System.out.println( label.getId() + " " + label.getType() );
}
@@ -67,11 +63,11 @@
}
- private static java.util.List loadLines(String filename) throws IOException {
+ private static List<Line> loadLines(String filename) throws IOException {
BufferedReader reader = new BufferedReader( new InputStreamReader( WaltzDbBenchmark.class.getResourceAsStream( filename ) ) );
Pattern pat = Pattern.compile( ".*make line \\^p1 ([0-9]*) \\^p2 ([0-9]*).*" );
String line = reader.readLine();
- java.util.List result = new java.util.ArrayList();
+ List<Line> result = new ArrayList<Line>();
while ( line != null ) {
Matcher m = pat.matcher( line );
if ( m.matches() ) {
@@ -85,11 +81,11 @@
return result;
}
- private static java.util.List loadLabels(String filename) throws IOException {
+ private static List<Label> loadLabels(String filename) throws IOException {
BufferedReader reader = new BufferedReader( new InputStreamReader( WaltzDbBenchmark.class.getResourceAsStream( filename ) ) );
Pattern pat = Pattern.compile( ".*make label \\^type ([0-9a-z]*) \\^name ([0-9a-zA-Z]*) \\^id ([0-9]*) \\^n1 ([B+-]*) \\^n2 ([B+-]*)( \\^n3 ([B+-]*))?.*" );
String line = reader.readLine();
- java.util.List result = new java.util.ArrayList();
+ List<Label> result = new ArrayList<Label>();
while ( line != null ) {
Matcher m = pat.matcher( line );
if ( m.matches() ) {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/FibonacciExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/FibonacciExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/FibonacciExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -2,11 +2,12 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class FibonacciExample {
@@ -23,14 +24,13 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/fibonacci" );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/fibonacci");
ksession.insert( new Fibonacci( 10 ) );
ksession.fireAllRules();
- logger.writeToDisk();
+ logger.close();
ksession.dispose(); // Stateful rule session must always be disposed when finished
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HelloWorldExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -6,12 +6,13 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.definition.KnowledgePackage;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
/**
@@ -42,13 +43,12 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
ksession.setGlobal( "list",
- new ArrayList() );
+ new ArrayList<Object>() );
// session.addEventListener( new DebugAgendaEventListener() );
// session.addEventListener( new DebugWorkingMemoryEventListener() );
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/helloworld" );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/helloworld");
final Message message = new Message();
message.setMessage( "Hello World" );
@@ -57,7 +57,7 @@
ksession.fireAllRules();
- logger.writeToDisk();
+ logger.close();
ksession.dispose();
}
@@ -95,7 +95,7 @@
}
public boolean isSomething(String msg,
- List list) {
+ List<Object> list) {
list.add( this );
return this.message.equals( msg );
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HonestPoliticianExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HonestPoliticianExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/HonestPoliticianExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -2,12 +2,13 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderConfiguration;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class HonestPoliticianExample {
@@ -31,8 +32,7 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/honest-politician" );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/honest-politician");
final Politician blair = new Politician( "blair",
true );
@@ -50,7 +50,7 @@
ksession.fireAllRules();
- logger.writeToDisk();
+ logger.close();
ksession.dispose();
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/NumberGuessExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/NumberGuessExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/NumberGuessExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -4,11 +4,12 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
public class NumberGuessExample {
@@ -27,8 +28,7 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/numberguess" );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/numberguess");
ksession.insert( new GameRules( 100,
5 ) );
@@ -38,7 +38,7 @@
ksession.startProcess( "Number Guess" );
ksession.fireAllRules();
- logger.writeToDisk();
+ logger.close();
ksession.dispose();
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PetStore.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PetStore.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PetStore.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -27,7 +27,6 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumnModel;
-import org.drools.FactException;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
@@ -50,7 +49,7 @@
//RuleB
- Vector stock = new Vector();
+ Vector<Product> stock = new Vector<Product>();
stock.add( new Product( "Gold Fish",
5 ) );
stock.add( new Product( "Fish Tank",
@@ -75,8 +74,11 @@
* cart ui.
*/
public static class PetStoreUI extends JPanel {
- private JTextArea output;
+ private static final long serialVersionUID = 1L;
+
+ private JTextArea output;
+
private TableModel tableModel;
private CheckoutCallback callback;
@@ -88,7 +90,7 @@
* @param listData
* @param callback
*/
- public PetStoreUI(Vector items,
+ public PetStoreUI(Vector<Product> items,
CheckoutCallback callback) {
super( new BorderLayout() );
this.callback = callback;
@@ -242,14 +244,8 @@
private class CheckoutButtonHandler extends MouseAdapter {
public void mouseReleased(MouseEvent e) {
JButton button = (JButton) e.getComponent();
- try {
- // output.append( callback.checkout( (JFrame) button.getTopLevelAncestor(),
- // tableModel.getItems() ) );
- callback.checkout( (JFrame) button.getTopLevelAncestor(),
- tableModel.getItems() );
- } catch ( org.drools.FactException fe ) {
- fe.printStackTrace();
- }
+ callback.checkout( (JFrame) button.getTopLevelAncestor(),
+ tableModel.getItems() );
}
}
@@ -259,7 +255,6 @@
*/
private class ResetButtonHandler extends MouseAdapter {
public void mouseReleased(MouseEvent e) {
- JButton button = (JButton) e.getComponent();
output.setText( null );
tableModel.clear();
System.out.println( "------ Reset ------" );
@@ -270,7 +265,10 @@
* Used to render the name column in the table
*/
private class NameRenderer extends DefaultTableCellRenderer {
- public NameRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ public NameRenderer() {
super();
}
@@ -284,7 +282,10 @@
* Used to render the price column in the table
*/
private class PriceRenderer extends DefaultTableCellRenderer {
- public PriceRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
+ public PriceRenderer() {
super();
}
@@ -302,13 +303,16 @@
* name and price.
*/
private static class TableModel extends AbstractTableModel {
- private String[] columnNames = {"Name", "Price"};
- private ArrayList items;
+ private static final long serialVersionUID = 1L;
+ private String[] columnNames = {"Name", "Price"};
+
+ private ArrayList<Product> items;
+
public TableModel() {
super();
- items = new ArrayList();
+ items = new ArrayList<Product>();
}
public int getColumnCount() {
@@ -328,7 +332,7 @@
return items.get( row );
}
- public Class getColumnClass(int c) {
+ public Class<?> getColumnClass(int c) {
return Product.class;
}
@@ -344,7 +348,7 @@
row );
}
- public List getItems() {
+ public List<Product> getItems() {
return items;
}
@@ -386,8 +390,7 @@
* @param items
* @return cart.toString();
*/
- public String checkout(JFrame frame,
- List items) throws FactException {
+ public String checkout(JFrame frame, List<Product> items) {
Order order = new Order();
//Iterate through list and add to cart
@@ -423,7 +426,7 @@
}
public static class Order {
- private List items;
+ private List<Purchase> items;
private double grossTotal = -1;
private double discountedTotal = -1;
@@ -431,14 +434,14 @@
private static String newline = System.getProperty( "line.separator" );
public Order() {
- this.items = new ArrayList();
+ this.items = new ArrayList<Purchase>();
}
public void addItem(Purchase item) {
this.items.add( item );
}
- public List getItems() {
+ public List<Purchase> getItems() {
return this.items;
}
@@ -463,7 +466,7 @@
buf.append( "ShoppingCart:" + newline );
- Iterator itemIter = getItems().iterator();
+ Iterator<Purchase> itemIter = getItems().iterator();
while ( itemIter.hasNext() ) {
buf.append( "\t" + itemIter.next() + newline );
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PricingRuleDTExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PricingRuleDTExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/PricingRuleDTExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,7 +1,5 @@
package org.drools.examples;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Arrays;
import org.drools.KnowledgeBase;
@@ -14,7 +12,6 @@
import org.drools.examples.decisiontable.Driver;
import org.drools.examples.decisiontable.Policy;
import org.drools.io.ResourceFactory;
-import org.drools.io.impl.ClassPathResource;
import org.drools.runtime.StatelessKnowledgeSession;
/**
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ShoppingExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ShoppingExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ShoppingExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,7 +1,5 @@
package org.drools.examples;
-import java.io.InputStreamReader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/CDSSExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/CDSSExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/CDSSExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,20 +1,19 @@
package org.drools.examples.cdss;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.Iterator;
import java.util.List;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.examples.cdss.data.Diagnose;
import org.drools.examples.cdss.data.Patient;
+import org.drools.examples.cdss.data.Recommendation;
import org.drools.examples.cdss.service.RecommendationService;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
/**
@@ -29,7 +28,7 @@
KnowledgeBase kbase = readRule();
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/cdss");
// set globals
RecommendationService recommendationService = new RecommendationService();
@@ -48,9 +47,9 @@
ksession.fireAllRules();
// Print out recommendations
- List recommendations = recommendationService.getRecommendations();
- for ( Iterator iterator = recommendations.iterator(); iterator.hasNext(); ) {
- System.out.println( iterator.next() );
+ List<Recommendation> recommendations = recommendationService.getRecommendations();
+ for ( Recommendation recommendation: recommendations ) {
+ System.out.println( recommendation );
}
recommendations.clear();
@@ -61,8 +60,8 @@
// Print out recommendations
recommendations = recommendationService.getRecommendations();
- for ( Iterator iterator = recommendations.iterator(); iterator.hasNext(); ) {
- System.out.println( iterator.next() );
+ for ( Recommendation recommendation: recommendations ) {
+ System.out.println( recommendation );
}
recommendations.clear();
@@ -71,7 +70,7 @@
ksession.insert( diagnose );
ksession.fireAllRules();
- logger.writeToDisk();
+ logger.close();
} catch ( Throwable t ) {
t.printStackTrace();
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/service/RecommendationService.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/service/RecommendationService.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/cdss/service/RecommendationService.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -7,13 +7,13 @@
public class RecommendationService {
- private List recommendations = new ArrayList();
+ private List<Recommendation> recommendations = new ArrayList<Recommendation>();
public void createRecommendation(Recommendation recommendation) {
recommendations.add(recommendation);
}
- public List getRecommendations() {
+ public List<Recommendation> getRecommendations() {
return recommendations;
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/AgendaGroupDelegate.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/AgendaGroupDelegate.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/AgendaGroupDelegate.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,17 +1,10 @@
package org.drools.examples.conway;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
-import org.drools.compiler.PackageBuilder;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/CellGridImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/CellGridImpl.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/CellGridImpl.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,16 +1,5 @@
package org.drools.examples.conway;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.WorkingMemory;
-import org.drools.agent.RuleAgent;
-import org.drools.compiler.PackageBuilder;
-import org.drools.event.AgendaGroupPoppedEvent;
-import org.drools.event.DefaultAgendaEventListener;
import org.drools.examples.conway.patterns.ConwayPattern;
import org.drools.runtime.StatefulKnowledgeSession;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayAgendaGroupRun.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayAgendaGroupRun.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayAgendaGroupRun.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,8 +1,9 @@
package org.drools.examples.conway;
public class ConwayAgendaGroupRun extends AbstractRunConway {
- public static void main(final String[] args) {
- ConwayAgendaGroupRun app = new ConwayAgendaGroupRun( );
- app.start( AbstractRunConway.AGENDAGROUP );
+
+ public static void main(final String[] args) {
+ ConwayAgendaGroupRun.start( AbstractRunConway.AGENDAGROUP );
}
+
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayRuleFlowGroupRun.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayRuleFlowGroupRun.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ConwayRuleFlowGroupRun.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,8 +1,9 @@
package org.drools.examples.conway;
public class ConwayRuleFlowGroupRun extends AbstractRunConway {
+
public static void main(final String[] args) {
- ConwayRuleFlowGroupRun app = new ConwayRuleFlowGroupRun( );
- app.start( AbstractRunConway.RULEFLOWGROUP );
+ ConwayRuleFlowGroupRun.start( AbstractRunConway.RULEFLOWGROUP );
}
+
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/RuleFlowDelegate.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/RuleFlowDelegate.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/RuleFlowDelegate.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,17 +1,10 @@
package org.drools.examples.conway;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
-import org.drools.compiler.PackageBuilder;
import org.drools.io.ResourceFactory;
import org.drools.runtime.StatefulKnowledgeSession;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Border.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Border.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Border.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -11,7 +11,9 @@
implements
ConwayPattern {
- private final boolean[][] grid = {{true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true},
+ private static final long serialVersionUID = 1L;
+
+ private final boolean[][] grid = {{true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true},
{true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true},
{true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true},
{true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true},
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Hi.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Hi.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Hi.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -12,6 +12,8 @@
implements
ConwayPattern {
+ private static final long serialVersionUID = 1L;
+
private final boolean[][] grid = {{true, false, false, false, true, false, false, true, true, true, true, true, true, true}, {true, false, false, false, true, false, false, false, false, false, true, false, false, false},
{true, false, false, false, true, false, false, false, false, false, true, false, false, false}, {true, false, false, false, true, false, false, false, false, false, true, false, false, false},
{true, true, true, true, true, false, false, false, false, false, true, false, false, false}, {true, false, false, false, true, false, false, false, false, false, true, false, false, false},
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pentadecathalon.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pentadecathalon.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pentadecathalon.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -12,6 +12,8 @@
implements
ConwayPattern {
+ private static final long serialVersionUID = 1L;
+
private final boolean[][] grid = {{true, true, true, true, true, true, true, true, true}};
/**
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pulsar.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pulsar.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/Pulsar.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -11,6 +11,8 @@
implements
ConwayPattern {
+ private static final long serialVersionUID = 1L;
+
private final boolean[][] grid = {{false, true, false}, {true, true, true}, {true, false, true}, {true, true, true}, {false, true, false}};
/**
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/SimpleGlider.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/SimpleGlider.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/patterns/SimpleGlider.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -11,6 +11,8 @@
implements
ConwayPattern {
+ private static final long serialVersionUID = 1L;
+
private final boolean[][] grid = {{false, true, false}, {true, false, false}, {true, true, true}};
//private final boolean[][] grid = {{false, false, false}, {true, true, false}, {false, false, false}};
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/CellGridCanvas.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/CellGridCanvas.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/CellGridCanvas.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -19,15 +19,17 @@
* @author <a href="mailto:brown_j at ociweb.com">Jeff Brown</a>
*/
public class CellGridCanvas extends Canvas {
- private Image offScreenImage;
+
+ private static final long serialVersionUID = 1L;
+ private static final Color BACKGROUND_COLOR = Color.gray;
+ private static final Color GRID_COLOR = CellGridCanvas.BACKGROUND_COLOR.brighter();
+
+ private Image offScreenImage;
private Image backgroundImage;
private final int cellSize;
private final CellGrid cellGrid;
private final Image liveCellImage = new ImageIcon( CellGridCanvas.class.getResource( "/org/drools/examples/conway/liveCellImage.gif" ) ).getImage();
- private static final Color BACKGROUND_COLOR = Color.gray;
- private static final Color GRID_COLOR = CellGridCanvas.BACKGROUND_COLOR.brighter();
-
/**
* Constructs a CellGridCanvas.
*
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/ConwayGUI.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/ConwayGUI.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/conway/ui/ConwayGUI.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -34,7 +34,10 @@
* @author <a href="mailto:brown_j at ociweb.com">Jeff Brown</a>
*/
public class ConwayGUI extends JPanel {
- private final JButton nextGenerationButton;
+
+ private static final long serialVersionUID = 1L;
+
+ private final JButton nextGenerationButton;
private final JButton startStopButton;
private final JButton clearButton;
private final JComboBox patternSelector = new JComboBox();
@@ -148,7 +151,7 @@
while ( tokenizer.hasMoreTokens() ) {
className = tokenizer.nextToken().trim();
try {
- final Class clazz = Class.forName( className );
+ final Class<?> clazz = Class.forName( className );
if ( ConwayPattern.class.isAssignableFrom( clazz ) ) {
this.patternSelector.addItem( clazz.newInstance() );
} else {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/OrderExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -7,8 +7,6 @@
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
-import java.io.InputStreamReader;
-import java.io.Reader;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
@@ -22,25 +20,27 @@
import javax.swing.JTextField;
import javax.swing.WindowConstants;
-import org.drools.RuleBase;
-import org.drools.RuleBaseConfiguration;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.audit.WorkingMemoryFileLogger;
-import org.drools.compiler.PackageBuilder;
-import org.drools.process.instance.WorkItemHandler;
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.KnowledgeType;
+import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.process.instance.impl.demo.UIWorkItemHandler;
-import org.drools.rule.Package;
+import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
public class OrderExample extends JFrame {
private static final long serialVersionUID = 4L;
- private RuleBase ruleBase;
- private StatefulSession session;
- private WorkingMemoryFileLogger logger;
+ private KnowledgeBase kbase;
+ private StatefulKnowledgeSession ksession;
+ private KnowledgeRuntimeLogger logger;
private int orderCounter;
private JComboBox itemComboBox;
@@ -160,9 +160,9 @@
private void createWorkingMemory() {
try {
- ruleBase = createKnowledgeBase();
- session = ruleBase.newStatefulSession();
- logger = new WorkingMemoryFileLogger(session);
+ kbase = createKnowledgeBase();
+ ksession = kbase.newStatefulKnowledgeSession();
+ logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/order");
CustomerService customerService = new DefaultCustomerService();
Customer c = new Customer("A-12345");
@@ -172,7 +172,7 @@
c.setFirstName("John");
c.setLastName("Doe");
customerService.addCustomer(c);
- session.setGlobal("customerService", customerService);
+ ksession.setGlobal("customerService", customerService);
ItemCatalog itemCatalog = new DefaultItemCatalog();
Item i = new Item("I-9876");
@@ -182,11 +182,11 @@
i = new Item("I-5432");
i.setName("Laptop");
itemCatalog.addItem(i);
- session.setGlobal("itemCatalog", itemCatalog);
+ ksession.setGlobal("itemCatalog", itemCatalog);
- session.getWorkItemManager().registerWorkItemHandler("Shipping", new ShippingWorkItemHandler(session));
+ ksession.getWorkItemManager().registerWorkItemHandler("Shipping", new ShippingWorkItemHandler(ksession));
- session.getWorkItemManager().registerWorkItemHandler("Email", new WorkItemHandler() {
+ ksession.getWorkItemManager().registerWorkItemHandler("Email", new WorkItemHandler() {
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
System.out.println("***********************************************************");
System.out.println("Sending email:");
@@ -203,7 +203,7 @@
});
UIWorkItemHandler handler = new UIWorkItemHandler();
- session.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
+ ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
handler.setVisible(true);
} catch (Throwable t) {
@@ -213,28 +213,22 @@
private void addDebugRules() {
try {
- PackageBuilder builder = new PackageBuilder();
- Reader source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("logging.drl"));
- builder.addPackageFromDrl(source);
- for (Package p: builder.getPackages()) {
- if (!p.isValid()) {
- System.err.println("Invalid package " + p.getName() + ": " + p.getErrorSummary());
- }
- ruleBase.addPackage(p);
- }
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "logging.drl", OrderExample.class), KnowledgeType.DRL );
+ kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
} catch (Throwable t) {
t.printStackTrace();
}
}
private void removeDebugRules() {
- ruleBase.removePackage("org.drools.examples.process.order.logging");
+ kbase.removeKnowledgePackage("org.drools.examples.process.order.logging");
}
public void dispose() {
super.dispose();
- logger.writeToDisk();
+ logger.close();
}
private void createOrder() {
@@ -243,44 +237,32 @@
order.setCustomerId(customerIdTextField.getText());
ItemInfo itemInfo = (ItemInfo) itemComboBox.getSelectedItem();
order.addOrderItem(itemInfo.getItemId(), new Integer(amountTextField.getText()), itemInfo.getPrice());
- session.insert(order);
+ ksession.insert(order);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("order", order);
parameters.put("email", emailTextField.getText());
- session.startProcess("org.drools.examples.process.ruleset.RuleSetExample", parameters);
- session.fireAllRules();
+ ksession.startProcess("org.drools.examples.process.ruleset.RuleSetExample", parameters);
+ ksession.fireAllRules();
}
- private static RuleBase createKnowledgeBase() throws Exception {
- PackageBuilder builder = new PackageBuilder();
- Reader source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("RuleSetExample.rf"));
- builder.addProcessFromXml(source);
- source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("workflow_rules.drl"));
- builder.addPackageFromDrl(source);
- source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("validation.drl"));
- builder.addPackageFromDrl(source);
- source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("assignment.dslr"));
- Reader dsl = new InputStreamReader(
- OrderExample.class.getResourceAsStream("assignment.dsl"));
- builder.addPackageFromDrl(source, dsl);
- source = new InputStreamReader(
- OrderExample.class.getResourceAsStream("discount.drl"));
- builder.addPackageFromDrl(source);
- RuleBaseConfiguration configuration = new RuleBaseConfiguration();
- configuration.setAdvancedProcessRuleIntegration(true);
- RuleBase ruleBase = RuleBaseFactory.newRuleBase(configuration);
- for (Package p: builder.getPackages()) {
- if (!p.isValid()) {
- System.err.println("Invalid package " + p.getName() + ": " + p.getErrorSummary());
- }
- ruleBase.addPackage(p);
- }
- return ruleBase;
+ private static KnowledgeBase createKnowledgeBase() throws Exception {
+ KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "RuleSetExample.rf", OrderExample.class), KnowledgeType.DRF );
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "workflow_rules.drl", OrderExample.class), KnowledgeType.DRL );
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "validation.drl", OrderExample.class), KnowledgeType.DRL );
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "assignment.dsl", OrderExample.class), KnowledgeType.DSL );
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "assignment.dslr", OrderExample.class), KnowledgeType.DSLR );
+ kbuilder.add(ResourceFactory.newClassPathResource(
+ "discount.drl", OrderExample.class), KnowledgeType.DRL );
+ KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+ return kbase;
}
private class ItemInfo {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/ShippingWorkItemHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/ShippingWorkItemHandler.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/process/order/ShippingWorkItemHandler.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -3,25 +3,25 @@
import java.util.HashMap;
import java.util.Map;
-import org.drools.WorkingMemory;
-import org.drools.process.instance.WorkItemHandler;
+import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
import org.drools.runtime.process.WorkItemManager;
public class ShippingWorkItemHandler implements WorkItemHandler {
- private WorkingMemory workingMemory;
+ private StatefulKnowledgeSession ksession;
private int trackingCounter;
- public ShippingWorkItemHandler(WorkingMemory workingMemory) {
- this.workingMemory = workingMemory;
+ public ShippingWorkItemHandler(StatefulKnowledgeSession ksession) {
+ this.ksession = ksession;
}
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
Order order = (Order) workItem.getParameter("order");
System.out.println("Shipping order " + order.getOrderId());
order.setTrackingId("Tracking-" + ++trackingCounter);
- workingMemory.update(workingMemory.getFactHandle(order), order);
+ ksession.update(ksession.getFactHandle(order), order);
Map<String, Object> results = new HashMap<String, Object>();
results.put("trackingId", order.getTrackingId());
manager.completeWorkItem(workItem.getId(), results);
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ruleflow/WorkItemExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ruleflow/WorkItemExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/ruleflow/WorkItemExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,17 +1,15 @@
package org.drools.examples.ruleflow;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
-import org.drools.process.instance.impl.demo.SystemOutWorkItemHandler;
-import org.drools.process.instance.impl.demo.UIWorkItemHandler;
import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
+import org.drools.runtime.process.WorkItemManager;
public class WorkItemExample {
@@ -20,19 +18,20 @@
KnowledgeBase knowledgeBase = readRule();
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
- // logging all work items to sysout
- SystemOutWorkItemHandler handler = new SystemOutWorkItemHandler();
- ksession.getWorkItemManager().registerWorkItemHandler( "Email",
- handler );
- ksession.getWorkItemManager().registerWorkItemHandler( "Log",
- handler );
+ // logging all work items to System.out
+ WorkItemHandler handler = new WorkItemHandler() {
+ public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
+ System.out.println("Executing work item " + workItem);
+ manager.completeWorkItem(workItem.getId(), null);
+ }
+
+ public void abortWorkItem(WorkItem workItem, WorkItemManager manager) {
+ // Do nothing
+ }
+ };
+ ksession.getWorkItemManager().registerWorkItemHandler( "Email", handler );
+ ksession.getWorkItemManager().registerWorkItemHandler( "Log", handler );
- // using a dialog to show all work items
- UIWorkItemHandler handler2 = new UIWorkItemHandler();
- //workingMemory.getWorkItemManager().registerWorkItemHandler("Email", handler2);
- //workingMemory.getWorkItemManager().registerWorkItemHandler("Log", handler2);
- //handler2.setVisible(true);
-
ksession.startProcess( "com.sample.ruleflow" );
ksession.fireAllRules();
} catch ( Throwable t ) {
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/Main.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/Main.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/Main.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -48,7 +48,6 @@
private FlowLayout flowLayout = new FlowLayout(FlowLayout.RIGHT);
private JPanel buttonPanel = new JPanel(flowLayout);
private JButton solveButton = new JButton("Solve");
- private JButton fireOneRuleButton = new JButton("Step");
private JFileChooser fileChooser;
public static void main(String[] args)
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/sudoku/rules/DroolsUtil.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -6,9 +6,6 @@
*/
package org.drools.examples.sudoku.rules;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseConfiguration;
import org.drools.KnowledgeBaseFactory;
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExample.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExample.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExample.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -2,11 +2,12 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.ThreadedWorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
@@ -27,9 +28,7 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- ThreadedWorkingMemoryFileLogger logger = new ThreadedWorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/trouble_ticket" );
- logger.start( 1000 );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/trouble_ticket");
final Customer a = new Customer( "A",
"Drools",
@@ -77,8 +76,7 @@
ksession.dispose();
- logger.stop();
- logger.writeToDisk();
+ logger.close();
}
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDSL.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDSL.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketExampleWithDSL.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,15 +1,13 @@
package org.drools.examples.troubleticket;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
@@ -34,9 +32,8 @@
final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/state" );
-
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/trouble_ticket");
+
final Customer a = new Customer( "A",
"Drools",
"Gold" );
@@ -55,15 +52,15 @@
final Ticket t3 = new Ticket( c );
final Ticket t4 = new Ticket( d );
- final FactHandle fa = ksession.insert( a );
- final FactHandle fb = ksession.insert( b );
- final FactHandle fc = ksession.insert( c );
- final FactHandle fd = ksession.insert( d );
+ ksession.insert( a );
+ ksession.insert( b );
+ ksession.insert( c );
+ ksession.insert( d );
- final FactHandle ft1 = ksession.insert( t1 );
- final FactHandle ft2 = ksession.insert( t2 );
+ ksession.insert( t1 );
+ ksession.insert( t2 );
final FactHandle ft3 = ksession.insert( t3 );
- final FactHandle ft4 = ksession.insert( t4 );
+ ksession.insert( t4 );
ksession.fireAllRules();
@@ -85,6 +82,6 @@
ksession.dispose();
- logger.writeToDisk();
+ logger.close();
}
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketWithDT.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketWithDT.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/examples/troubleticket/TroubleTicketWithDT.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -1,17 +1,15 @@
package org.drools.examples.troubleticket;
-import java.net.MalformedURLException;
-import java.net.URL;
-
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.audit.WorkingMemoryFileLogger;
import org.drools.builder.DecisionTableConfiguration;
import org.drools.builder.DecisionTableInputType;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.KnowledgeType;
import org.drools.io.ResourceFactory;
+import org.drools.logger.KnowledgeRuntimeLogger;
+import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.rule.FactHandle;
@@ -41,8 +39,7 @@
// typical decision tables are used statelessly
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
- final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( ksession );
- logger.setFileName( "log/trouble_ticket" );
+ KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "log/trouble_ticket");
final Customer a = new Customer( "A",
"Drools",
@@ -90,7 +87,7 @@
ksession.dispose();
- logger.writeToDisk();
+ logger.close();
}
Modified: labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/tutorials/banking/SimpleDate.java
===================================================================
--- labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/tutorials/banking/SimpleDate.java 2008-12-01 23:36:09 UTC (rev 24188)
+++ labs/jbossrules/trunk/drools-examples/drools-examples-drl/src/main/java/org/drools/tutorials/banking/SimpleDate.java 2008-12-01 23:40:57 UTC (rev 24189)
@@ -6,7 +6,9 @@
public class SimpleDate extends Date {
- private static final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
+
+ private static final long serialVersionUID = 1L;
+ private static final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
public SimpleDate(String datestr) throws Exception {
setTime(format.parse(datestr).getTime());
More information about the jboss-svn-commits
mailing list