[jboss-svn-commits] JBL Code SVN: r24274 - in labs/jbossrules/trunk: drools-api/src/main/java/org/drools and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 7 00:40:42 EST 2008
Author: mark.proctor at jboss.com
Date: 2008-12-07 00:40:42 -0500 (Sun, 07 Dec 2008)
New Revision: 24274
Modified:
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/ChangeSet.java
labs/jbossrules/trunk/drools-api/src/main/java/org/drools/io/ResourceChangeMonitor.java
labs/jbossrules/trunk/drools-api/src/main/java/overview.html
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/ResourceChangeScannerImpl.java
Log:
JBRULES-1874 Create Resource Framework
-fixed javadocs from addResource to add
Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/ChangeSet.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/ChangeSet.java 2008-12-07 05:14:31 UTC (rev 24273)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/ChangeSet.java 2008-12-07 05:40:42 UTC (rev 24274)
@@ -2,9 +2,15 @@
import java.util.Collection;
-import org.drools.definition.KnowledgeDefinition;
import org.drools.io.Resource;
+/**
+ * This class is used to provide a ChangeSet info to a ResourceChangeNotifier. It should be used when you implement the ResourceChangeMonitor interface.
+ * Each method provides a Collection of removed, added and modified resources, and determined by the monitor. Drools currently only provides the
+ * ResourceChangeScanner, which scans the local disk for changes.
+ *
+ * This interface, as well as ResourceChangeMonitor and ResourceChangeNotifier are still considered subject to change.
+ */
public interface ChangeSet {
public Collection<Resource> getResourcesRemoved();
@@ -13,7 +19,4 @@
public Collection<Resource> getResourcesModified();
-
- //public Collection<KnowledgeDefinition> getKnowledgeDefinitionsRemoved();
-
}
Modified: labs/jbossrules/trunk/drools-api/src/main/java/org/drools/io/ResourceChangeMonitor.java
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/org/drools/io/ResourceChangeMonitor.java 2008-12-07 05:14:31 UTC (rev 24273)
+++ labs/jbossrules/trunk/drools-api/src/main/java/org/drools/io/ResourceChangeMonitor.java 2008-12-07 05:40:42 UTC (rev 24274)
@@ -1,6 +1,9 @@
package org.drools.io;
-
+/**
+ *
+ * * This interface, as well as ResourceChangeNotifier are still considered subject to change.
+ */
public interface ResourceChangeMonitor {
void subscribeNotifier(ResourceChangeNotifier notifier, Resource resource);
void unsubscribeNotifier(ResourceChangeNotifier notifier, Resource resource);
Modified: labs/jbossrules/trunk/drools-api/src/main/java/overview.html
===================================================================
--- labs/jbossrules/trunk/drools-api/src/main/java/overview.html 2008-12-07 05:14:31 UTC (rev 24273)
+++ labs/jbossrules/trunk/drools-api/src/main/java/overview.html 2008-12-07 05:40:42 UTC (rev 24274)
@@ -52,7 +52,7 @@
<pre>
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add( ResourceFactory.newUrlResource( url ),
- ResourceType.DRF );
+ ResourceType.DRF );
if ( kbuilder.hasErrors() ) {
System.err.println( builder.getErrors().toString() );
}
@@ -72,6 +72,29 @@
</p>
<p>
+It is also possible to configure a KnowledgeBase using configuration, via a xml change set, instead of programmatically. Here is a simple change set:
+</p>
+<pre>
+<change-set xmlns='http://drools.org/drools-5.0/change-set'
+ xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
+ xs:schemaLocation='http://drools.org/drools-5.0/change-set change-set-5.0.xsd' >
+ <add>
+ <resource source='classpath:org/domain/someRules.drl' type='DRL' />
+ <resource source='classpath:org/domain/aFlow.drf' type='DRF' />
+ </add>
+</change-set>
+</pre>
+
+<p>
+And it is added just like any other ResourceType
+</p>
+<pre>
+KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+kbuilder.add( ResourceFactory.newUrlResource( url ),
+ ResourceType.ChangeSet );
+</pre>
+
+<p>
The majority of Drools API is considered stable and should not change, experimental classes and apis will be marked as such.
</p>
</body>
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java 2008-12-07 05:14:31 UTC (rev 24273)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/agent/KnowledgeAgentTest.java 2008-12-07 05:40:42 UTC (rev 24274)
@@ -6,18 +6,15 @@
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
-import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderFactory;
-import org.drools.builder.ResourceType;
import org.drools.io.ResourceChangeScannerConfiguration;
import org.drools.io.ResourceFactory;
+import org.drools.io.impl.ResourceChangeScannerImpl;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.util.FileManager;
@@ -27,15 +24,17 @@
protected void setUp() throws Exception {
fileManager = new FileManager();
fileManager.setUp();
+ ((ResourceChangeScannerImpl)ResourceFactory.getResourceChangeScannerService()).reset();
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
}
protected void tearDown() throws Exception {
- //fileManager.tearDown();
+ fileManager.tearDown();
ResourceFactory.getResourceChangeNotifierService().stop();
ResourceFactory.getResourceChangeScannerService().stop();
+ ((ResourceChangeScannerImpl)ResourceFactory.getResourceChangeScannerService()).reset();
}
public void testModifyFile() throws IOException,
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/ResourceChangeScannerImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/ResourceChangeScannerImpl.java 2008-12-07 05:14:31 UTC (rev 24273)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/ResourceChangeScannerImpl.java 2008-12-07 05:40:42 UTC (rev 24274)
@@ -199,6 +199,11 @@
this.resources.notify(); // notify wait, so that it will wait again
}
}
+
+ public void reset() {
+ this.resources.clear();
+ this.directories.clear();
+ }
private Thread thread;
private ProcessChangeSet scannerScheduler;
More information about the jboss-svn-commits
mailing list