Permalink
Please sign in to comment.
Showing
with
210 additions
and 6 deletions.
- +15 −4 drools-mas-core/src/main/java/org/drools/mas/core/DroolsAgentFactory.java
- +27 −0 drools-mas-core/src/main/java/org/drools/mas/core/SessionManager.java
- +24 −0 drools-mas-core/src/main/resources/org/drools/mas/acl_common.drl
- +78 −0 drools-mas-core/src/test/java/mock/ClasspathURLResourceLocator.java
- +41 −0 drools-mas-core/src/test/java/org/drools/mas/core/tests/TestAgent.java
- +9 −0 drools-mas-core/src/test/resources/newResource.drl
- +15 −1 drools-mas-core/src/test/resources/session1.drl
- +1 −1 drools-mas-core/src/test/resources/test_cbr.drl
@@ -0,0 +1,78 @@ | ||
+/* | ||
+ * To change this template, choose Tools | Templates | ||
+ * and open the template in the editor. | ||
+ */ | ||
+package mock; | ||
+ | ||
+import java.io.IOException; | ||
+import java.io.Serializable; | ||
+import java.net.MalformedURLException; | ||
+import java.net.URL; | ||
+import java.net.URLConnection; | ||
+import java.net.URLStreamHandler; | ||
+import org.drools.builder.ResourceType; | ||
+ | ||
+/** | ||
+ * | ||
+ * @author esteban | ||
+ */ | ||
+public class ClasspathURLResourceLocator implements Serializable{ | ||
+ | ||
+ /** | ||
+ * patient name used for routing | ||
+ */ | ||
+ private String name; | ||
+ | ||
+ private String URL; | ||
+ private ResourceType resourceType; | ||
+ | ||
+ /** A {@link URLStreamHandler} that handles resources on the classpath. */ | ||
+ public class ClasspathURLHandler extends URLStreamHandler { | ||
+ /** The classloader to find resources from. */ | ||
+ private final ClassLoader classLoader; | ||
+ | ||
+ public ClasspathURLHandler() { | ||
+ this.classLoader = getClass().getClassLoader(); | ||
+ } | ||
+ | ||
+ public ClasspathURLHandler(ClassLoader classLoader) { | ||
+ this.classLoader = classLoader; | ||
+ } | ||
+ | ||
+ @Override | ||
+ protected URLConnection openConnection(URL u) throws IOException { | ||
+ final URL resourceUrl = classLoader.getResource(u.getPath()); | ||
+ return resourceUrl.openConnection(); | ||
+ } | ||
+ } | ||
+ | ||
+ public ClasspathURLResourceLocator(String URL, ResourceType resourceType) { | ||
+ this.URL = URL; | ||
+ this.resourceType = resourceType; | ||
+ } | ||
+ | ||
+ public URL getURL() throws MalformedURLException { | ||
+ return new URL(null, URL, new ClasspathURLHandler()); | ||
+ } | ||
+ | ||
+ public void setURL(String URL) { | ||
+ this.URL = URL; | ||
+ } | ||
+ | ||
+ public ResourceType getResourceType() { | ||
+ return resourceType; | ||
+ } | ||
+ | ||
+ public void setResourceType(ResourceType resourceType) { | ||
+ this.resourceType = resourceType; | ||
+ } | ||
+ | ||
+ public String getName() { | ||
+ return name; | ||
+ } | ||
+ | ||
+ public void setName(String name) { | ||
+ this.name = name; | ||
+ } | ||
+ | ||
+} |
@@ -0,0 +1,9 @@ | ||
+package org.drools.mas.test | ||
+ | ||
+rule "Test this" | ||
+when | ||
+then | ||
+ String s = "--------@@ It's alive!! @@--------------"; | ||
+ System.out.println("\n\n\t\t"+s+"\n\n"); | ||
+ insert(s); | ||
+end |
0 comments on commit
b38e004