[jboss-svn-commits] JBL Code SVN: r21591 - in labs/jbossrules/trunk/drools-server: .settings and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 18 02:21:46 EDT 2008


Author: michael.neale at jboss.com
Date: 2008-08-18 02:21:46 -0400 (Mon, 18 Aug 2008)
New Revision: 21591

Added:
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/AnonFact.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/NamedFact.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/RuleService.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceRequestMessage.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceResponseMessage.java
   labs/jbossrules/trunk/drools-server/src/test/java/org/drools/Person.java
   labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/
   labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/RuleServiceTest.java
   labs/jbossrules/trunk/drools-server/src/test/resources/org/
   labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/
   labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/
   labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.json
   labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.xml
   labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/test_rules1.drl
Removed:
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsClient.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServer.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServerImpl.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsService.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/HelloWorld.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/ManagedRuleBase.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/Message.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseInfo.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseRepositoryImpl.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseService.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/WorkingMemoryManager.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseInspector.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepository.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepositoryImpl.java
   labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/WorkingMemoryInspector.java
   labs/jbossrules/trunk/drools-server/src/test/java/org/drools/DroolsClientServerTest.java
Modified:
   labs/jbossrules/trunk/drools-server/.classpath
   labs/jbossrules/trunk/drools-server/.project
   labs/jbossrules/trunk/drools-server/.settings/org.eclipse.jdt.core.prefs
   labs/jbossrules/trunk/drools-server/pom.xml
Log:
drools server

Modified: labs/jbossrules/trunk/drools-server/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-server/.classpath	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/.classpath	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,23 +1,35 @@
 <classpath>
   <classpathentry kind="src" path="src/main/java"/>
-  <classpathentry kind="src" path="src/main/resources"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
   <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
-  <classpathentry kind="src" path="src/test/resources" output="target/test-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6/dom4j-1.6.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/colt/colt/1.2.0/colt-1.2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/>
   <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/jboss-common/4.0.4/jboss-common-4.0.4.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jung/jung/1.7.2/jung-1.7.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/jboss-jmx/4.0.4/jboss-jmx-4.0.4.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/drools/drools-core/3.0.2/drools-core-3.0.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.3.4.O/xpp3-1.1.3.4.O.jar"/>
-  <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/jboss-serialization/1.0.0.RC2/jboss-serialization-1.0.0.RC2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.6.2/xercesImpl-2.6.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/jboss-remoting/1.4.1_final/jboss-remoting-1.4.1_final.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/jettison/jettison/1.0.1/jettison-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/stax/stax-api/1.0.1/stax-api-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.SNAPSHOT.jar" sourcepath="M2_REPO/org/drools/drools-compiler/5.0.0.SNAPSHOT/drools-compiler-5.0.0.SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.SNAPSHOT.jar" sourcepath="M2_REPO/org/drools/drools-core/5.0.0.SNAPSHOT/drools-core-5.0.0.SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel/2.0-dp4/mvel-2.0-dp4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0.1/antlr-runtime-3.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/stringtemplate/3.1-b1/stringtemplate-3.1-b1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/gunit/1.0.1/gunit-1.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0/maven-project-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-profile/2.0/maven-profile-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-model/2.0/maven-model-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.jar"/>
+  <classpathentry kind="var" path="M2_REPO/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact-manager/2.0/maven-artifact-manager-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-repository-metadata/2.0/maven-repository-metadata-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/maven/wagon/wagon-provider-api/1.0-alpha-5/wagon-provider-api-1.0-alpha-5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.0.1/antlr-3.0.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/stax/stax/1.2.0/stax-1.2.0.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-server/.project
===================================================================
--- labs/jbossrules/trunk/drools-server/.project	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/.project	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,23 +1,19 @@
 <projectDescription>
   <name>drools-server</name>
-  <comment/>
+  <comment>A rule production system</comment>
   <projects/>
   <buildSpec>
     <buildCommand>
       <name>org.eclipse.wst.common.modulecore.ComponentStructuralBuilder</name>
-      <arguments/>
     </buildCommand>
     <buildCommand>
       <name>org.eclipse.jdt.core.javabuilder</name>
-      <arguments/>
     </buildCommand>
     <buildCommand>
       <name>org.eclipse.wst.validation.validationbuilder</name>
-      <arguments/>
     </buildCommand>
     <buildCommand>
       <name>org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver</name>
-      <arguments/>
     </buildCommand>
   </buildSpec>
   <natures>

Modified: labs/jbossrules/trunk/drools-server/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- labs/jbossrules/trunk/drools-server/.settings/org.eclipse.jdt.core.prefs	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/.settings/org.eclipse.jdt.core.prefs	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,12 +1,12 @@
-#Thu Jul 13 02:32:39 BST 2006
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.4
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
-org.eclipse.jdt.core.compiler.source=1.3
+#Mon Aug 18 15:49:51 EST 2008
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning

Modified: labs/jbossrules/trunk/drools-server/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/pom.xml	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/pom.xml	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,7 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
+  <!-- README: if you have problems running the build.
+  you may need to go up one directory, and run "mvn install" to
+  make sure all the deps are ready.
+
+  If by chance the slackers who maintain the other projects have left the build slight broken,
+  you can skip the tests by doing:
+
+  "mvn -Dmaven.test.skip=true install" and it should work.
+
+  -->
+
   <modelVersion>4.0.0</modelVersion>
+
   <parent>
     <artifactId>drools</artifactId>
     <groupId>org.drools</groupId>
@@ -9,21 +21,48 @@
   </parent>
 
   <artifactId>drools-server</artifactId>
-  <packaging>jar</packaging>
+
+  <packaging>war</packaging>
   <name>Drools :: Server</name>
 
+  <build>
+    <finalName>drools-server</finalName>
+  </build>
+
   <dependencies>
-    <!-- Internal dependencies -->
+
+ 	<!-- we are using the most excellent XStream library for fast XML and JSON streaming -->
     <dependency>
+     <groupId>com.thoughtworks.xstream</groupId>
+     <artifactId>xstream</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax</artifactId>
+      <version>1.2.0</version>
+    </dependency>
+
+    <dependency>
+	    <groupId>org.codehaus.jettison</groupId>
+	    <artifactId>jettison</artifactId>
+	    <version>1.0.1</version>
+	</dependency>
+
+
+	<!-- pulling in compiler as we may have to deal with DRLs at some point -->
+    <dependency>
       <groupId>org.drools</groupId>
-      <artifactId>drools-core</artifactId>
+      <artifactId>drools-compiler</artifactId>
     </dependency>
 
-    <!-- External dependencies -->
+
+    <!-- now the deps for the web app -->
     <dependency>
-      <groupId>jboss</groupId>
-      <artifactId>jboss-remoting</artifactId>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
     </dependency>
+
   </dependencies>
 
 </project>

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsClient.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsClient.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsClient.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,133 +0,0 @@
-package org.drools;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.detection.multicast.MulticastDetector;
-import org.jboss.remoting.network.NetworkNotification;
-import org.jboss.remoting.network.NetworkRegistry;
-import org.jboss.remoting.transporter.TransporterClient;
-
-public class DroolsClient
-    implements
-    NotificationListener {
-    
-    private String locatorURI = "rmi://localhost:5400/?" + InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString();
-    
-    private Set       servers = new HashSet();
-    MBeanServer       server;
-    MulticastDetector detector;
-
-    DroolsServer      droolsServer;
-    
-    /**
-     * Sets up NetworkRegistry and MulticastDetector so we can listen for any additions or removals of remoting
-     * servers on the network.
-     *
-     * @throws Exception
-     */
-    public void start() throws Exception {
-        if ( this.detector != null ) {
-            return;
-        }
-
-        // we need an MBeanServer to store our network registry and multicast detector services
-        server = MBeanServerFactory.createMBeanServer();
-
-        // the registry will house all remoting servers discovered
-        NetworkRegistry registry = NetworkRegistry.getInstance();
-        server.registerMBean( registry,
-                              new ObjectName( "remoting:type=NetworkRegistry" ) );
-        System.out.println( "NetworkRegistry has been created" );
-
-        // register class as listener, so know when new server found
-        registry.addNotificationListener( this,
-                                          null,
-                                          null );
-        System.out.println( "NetworkRegistry has added the client as a listener" );
-
-        // multicast detector will detect new network registries that come online
-        detector = new MulticastDetector();
-        server.registerMBean( detector,
-                              new ObjectName( "remoting:type=MulticastDetector" ) );
-        detector.start();
-        System.out.println( "MulticastDetector has been created and is listening for new NetworkRegistries to come online" );
-    }
-
-    public void stop() throws Exception {
-        this.detector.stop();
-    }
-
-    public void reset() throws Exception {
-        this.detector.stop();
-        this.servers.clear();
-        this.detector.start();
-    }
-
-    //    public static void main(String[] args) {
-    //        DroolsClient client = new DroolsClient();
-    //        try {
-    //            client.start();
-    //            Thread.sleep( 1000 );
-    //            
-    //            client.connect();
-    //            
-    //            client.stop();
-    //
-    //        } catch ( Exception e ) {
-    //            e.printStackTrace();
-    //        }
-    //    }   
-
-    public void connect() throws Exception {
-//        InvokerLocator locator = (InvokerLocator) this.servers.toArray()[0];
-//        DroolsServer server = (DroolsServer) TransporterClient.createTransporterClient( locator.getLocatorURI(),
-//                                                                                        DroolsServer.class );
-        
-        this.droolsServer = (DroolsServer) TransporterClient.createTransporterClient( this.locatorURI,
-                                                                                        DroolsServer.class );        
-    }
-
-    public void disconnect() {
-        TransporterClient.destroyTransporterClient( this.droolsServer );
-    }
-
-    /**
-     * Callback method from the broadcaster MBean this listener implementation is registered to. When a new server
-     * is detected, a welcome message will immediately be sent to the newly discovered server.
-     *
-     * @param notification the notification object
-     * @param handback     the handback object given to the broadcaster upon listener registration
-     */
-    public void handleNotification(Notification notification,
-                                   Object handback) {
-        if ( notification instanceof NetworkNotification ) {
-            System.out.println( "GOT A NETWORK-REGISTRY NOTIFICATION: " + notification.getType() );
-
-            NetworkNotification networkNotification = (NetworkNotification) notification;
-
-            if ( NetworkNotification.SERVER_ADDED.equals( networkNotification.getType() ) ) { // notification is for new servers being added
-                System.out.println( "New server(s) have been detected - getting locators and sending welcome messages" );
-                InvokerLocator[] locators = networkNotification.getLocator();
-                for ( int i = 0; i < locators.length; i++ ) {
-                    this.servers.add( locators[i] );
-                }
-            } else if ( NetworkNotification.SERVER_REMOVED.equals( networkNotification.getType() ) ) {
-                System.out.println( "Server(s) have gone offline - getting locators and sending welcome messages" );
-                InvokerLocator[] locators = networkNotification.getLocator();
-                for ( int i = 0; i < locators.length; i++ ) {
-                    this.servers.remove( locators[i] );
-                }
-            }
-        }
-
-        return;
-    }
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServer.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServer.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServer.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,13 +0,0 @@
-package org.drools;
-
-public interface DroolsServer {
-    public boolean registerRuleBase(RuleBase ruleBase,
-                                    RuleBaseInfo info);
-    
-    public boolean deregisterRuleBase(String id);
-    
-    public boolean isRegistered(String id);
-    
-    public RuleBaseInfo[] listRuleBases();    
-    
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServerImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServerImpl.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsServerImpl.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,27 +0,0 @@
-package org.drools;
-
-import org.drools.client.RuleBaseRepository;
-
-public class DroolsServerImpl implements DroolsServer {
-    private RuleBaseRepository ruleBaseRepositoryImpl = new RuleBaseRepositoryImpl();
-
-    public boolean registerRuleBase(RuleBase ruleBase,
-                                    RuleBaseInfo info) {        
-        return this.ruleBaseRepositoryImpl.registerRuleBase( ruleBase, info );
-    }
-    
-    public boolean deregisterRuleBase(String id) {
-        //return this.ruleBaseRepositoryImpl.deregisterRuleBase( id );
-        return false;
-    }
-
-    public boolean isRegistered(String id) {
-        //return this.ruleBaseRepositoryImpl.isRegistered( id );
-        return false;
-    }
-
-    public RuleBaseInfo[] listRuleBases() {
-        //  return this.ruleBaseRepositoryImpl.listRuleBases();
-        return null;
-    }      
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsService.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsService.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/DroolsService.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,72 +0,0 @@
-package org.drools;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.detection.multicast.MulticastDetector;
-import org.jboss.remoting.transporter.TransporterServer;
-import org.jboss.util.id.UID;
-
-import sun.security.x509.UniqueIdentity;
-
-public class DroolsService implements Runnable
-{
-   // Default locator values
-    private String locatorURI = "rmi://localhost:5400/?" + InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString();
-    private TransporterServer server = null;
-    private MulticastDetector detector;       
-
-   public void start() throws Exception
-   {       
-      Thread thread = new Thread( this );
-      thread.run();       
-      server = TransporterServer.createTransporterServer(locatorURI, new DroolsServerImpl() );
-      
-      // we need an MBeanServer to store our network registry and multicast detector services
-      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-
-      // multicast detector will detect new network registries that come online
-      detector = new MulticastDetector();
-      mbeanServer.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
-      detector.start();
-      System.out.println("MulticastDetector has been created and is listening for new NetworkRegistries to come online");      
-   }
-
-   public void stop() throws Exception
-   {
-      if(server != null)
-      {
-          detector.stop();
-          server.stop();
-      }
-   }
-   
-   public void exit() throws Exception {
-       stop();
-       this.server = null;
-       this.detector = null;
-   }
-
-    public void run() {
-        try
-        {
-            while ( this.server != null ) {
-                Thread.sleep( 200 );
-            }
-        }
-        catch(Exception e)
-        {
-           e.printStackTrace();
-        }
-        finally
-        {
-           try {
-               stop();
-           } catch ( Exception e ) {
-               e.printStackTrace();
-           }
-        }
-    }
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/HelloWorld.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/HelloWorld.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/HelloWorld.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,14 +0,0 @@
-package org.drools;
-
-import java.io.Serializable;
-
-public class HelloWorld implements Message, Serializable {
-    
-    public HelloWorld() {
-        
-    }
-    
-    public String getMessage() {
-        return "Hello World";
-    }
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/ManagedRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/ManagedRuleBase.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/ManagedRuleBase.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,60 +0,0 @@
-package org.drools;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import org.drools.rule.Package;
-
-public class ManagedRuleBase
-    implements
-    RuleBase {    
-    RuleBase ruleBase;
-               
-    public ManagedRuleBase(RuleBase ruleBase) {
-        this.ruleBase = ruleBase;
-    }
-
-    public void addPackage(Package pkg) throws Exception {
-        this.ruleBase.addPackage( pkg );
-    }
-
-    public Package[] getPackages() {
-        return this.ruleBase.getPackages();
-    }
-
-    public Set getWorkingMemories() {
-        return this.ruleBase.getWorkingMemories();
-    }
-
-    public WorkingMemory newWorkingMemory() {
-        return this.ruleBase.newWorkingMemory();
-    }
-
-    public WorkingMemory newWorkingMemory(boolean keepReference ) {
-        return this.ruleBase.newWorkingMemory( keepReference );
-    }
-
-    public WorkingMemory newWorkingMemory(InputStream stream) throws IOException,
-                                                           ClassNotFoundException {
-        return this.ruleBase.newWorkingMemory( stream );        
-    }
-
-    public WorkingMemory newWorkingMemory(InputStream stream,
-                                          boolean keepReference) throws IOException,
-                                                       ClassNotFoundException {
-        return this.newWorkingMemory( stream,
-                                      keepReference );
-    }
-
-    public void removePackage(String packageName) {
-        this.ruleBase.removePackage( packageName );
-    }
-
-    public void removeRule(String packageName,
-                           String ruleName) {
-        this.ruleBase.removeRule( packageName,
-                                  ruleName );
-    }
-
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/Message.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/Message.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/Message.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,5 +0,0 @@
-package org.drools;
-
-public interface Message {
-    public String getMessage();
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseInfo.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseInfo.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseInfo.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,55 +0,0 @@
-package org.drools;
-
-import java.io.Serializable;
-
-import org.drools.rule.LiteralConstraint;
-
-public class RuleBaseInfo
-    implements
-    Serializable {
-    private String id;
-    private String name;
-
-    public RuleBaseInfo() {
-    }
-
-    /**
-     * @return the name
-     */
-    public String getName() {
-        return this.name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    /**
-     * @return the uuid
-     */
-    public String getId() {
-        return this.id;
-    }
-
-    public void setId(String id) {
-        this.id = id;
-    }
-
-    public int hashCode() {
-        return this.id.hashCode();
-    }
-
-    public boolean equals(final Object object) {
-        if ( this == object ) {
-            return true;
-        }
-
-        if ( object == null || object.getClass() != RuleBaseInfo.class ) {
-            return false;
-        }
-
-        final RuleBaseInfo other = (RuleBaseInfo) object;
-
-        return this.id.equals( other.id ) && this.name.equals( other.name );
-    }
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseRepositoryImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseRepositoryImpl.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseRepositoryImpl.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,88 +0,0 @@
-package org.drools;
-
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.drools.client.RuleBaseRepository;
-import org.drools.common.InternalRuleBase;
-
-public class RuleBaseRepositoryImpl implements RuleBaseRepository {
-    /* @todo: I'm not sure if these need to be LinkedHashMaps, but predictable ordering helps with unit tests :) */
-    private Map ruleBases = new LinkedHashMap();
-    private Map info = new LinkedHashMap();    
-    
-    public RuleBaseRepositoryImpl() {
-        
-    }
-    
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#registerRuleBase(org.drools.RuleBase, org.drools.RuleBaseInfo)
-     */
-    public boolean registerRuleBase(RuleBase ruleBase,
-                                    RuleBaseInfo info) {        
-        
-        InternalRuleBase internalRuleBase = ( InternalRuleBase ) ruleBase;
-        if ( internalRuleBase.getId().equals( "default" ) ) {
-            // We cannot register a RuleBase that has been created without a UUID
-            return false;
-        }
-        info.setId( internalRuleBase.getId() );
-        this.ruleBases.put( internalRuleBase.getId(), ruleBase );
-        this.info.put(  internalRuleBase.getId(), info );
-        return true;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#deregisterRuleBase(java.lang.String)
-     */
-    public boolean deregisterRuleBase(String id) {
-        InternalRuleBase ruleBase = ( InternalRuleBase ) this.ruleBases.remove( id );
-        if ( ruleBase != null ) {
-            this.info.remove( id );
-        }
-        
-        return ( ruleBase != null );
-    }   
-    
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#isRegistered(java.lang.String)
-     */
-    public boolean isRegistered(String id) {
-        InternalRuleBase ruleBase = ( InternalRuleBase ) this.ruleBases.get( id );
-        return this.ruleBases.containsKey( ruleBase.getId() );
-    }
-    
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#listRuleBases()
-     */
-    public RuleBaseInfo[] listRuleBases() {
-        return ( RuleBaseInfo[] ) info.values().toArray( new RuleBaseInfo[ info.size() ] );
-    }
-       
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#get(org.drools.RuleBaseInfo)
-     */
-    public RuleBase get(RuleBaseInfo info) {
-        //return ( RuleBase ) this.ruleBases.get( info.getId() );
-        return null;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.drools.RuleBaseRepository#release(org.drools.RuleBaseInfo)
-     */
-    public void  release(RuleBaseInfo info) {
-        //this.ruleBases.get( info.getId() ); 
-    }
-
-    public boolean deregisterRuleBase(RuleBase ruleBase) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    public boolean isRegistered(RuleBase ruleBase) {
-        // TODO Auto-generated method stub
-        return false;
-    }    
-    
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseService.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseService.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/RuleBaseService.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,68 +0,0 @@
-package org.drools;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.detection.multicast.MulticastDetector;
-import org.jboss.remoting.transporter.TransporterServer;
-
-public class RuleBaseService implements Runnable {
-    // Default locator values
-    private String locatorURI = "rmi://localhost:5401/?" + InvokerLocator.BYVALUE + "=" + Boolean.TRUE.toString();
-    private TransporterServer server = null;
-    private MulticastDetector detector;       
-
-   public void start() throws Exception
-   {       
-      Thread thread = new Thread( this );
-      thread.run();       
-      server = TransporterServer.createTransporterServer(locatorURI, new DroolsServerImpl() );
-      
-      // we need an MBeanServer to store our network registry and multicast detector services
-      MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-
-      // multicast detector will detect new network registries that come online
-      detector = new MulticastDetector();
-      mbeanServer.registerMBean(detector, new ObjectName("remoting:type=MulticastDetector"));
-      detector.start();
-      System.out.println("MulticastDetector has been created and is listening for new NetworkRegistries to come online");      
-   }
-
-   public void stop() throws Exception
-   {
-      if(server != null)
-      {
-          detector.stop();
-          server.stop();
-      }
-   }
-   
-   public void exit() throws Exception {
-       stop();
-       this.server = null;
-       this.detector = null;
-   }
-
-    public void run() {
-        try
-        {
-            while ( this.server != null ) {
-                Thread.sleep( 200 );
-            }
-        }
-        catch(Exception e)
-        {
-           e.printStackTrace();
-        }
-        finally
-        {
-           try {
-               stop();
-           } catch ( Exception e ) {
-               e.printStackTrace();
-           }
-        }
-    }
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/WorkingMemoryManager.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/WorkingMemoryManager.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/WorkingMemoryManager.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,5 +0,0 @@
-package org.drools;
-
-public class WorkingMemoryManager {
-
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseInspector.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseInspector.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseInspector.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,5 +0,0 @@
-package org.drools.client;
-
-public interface RuleBaseInspector {
-    
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepository.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepository.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepository.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,21 +0,0 @@
-package org.drools.client;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseInfo;
-
-public interface RuleBaseRepository {
-
-    public abstract boolean registerRuleBase(RuleBase ruleBase,
-                                             RuleBaseInfo info);
-
-    public abstract boolean deregisterRuleBase(RuleBase ruleBase);
-
-    public abstract boolean isRegistered(RuleBase ruleBase);
-
-    public abstract RuleBaseInfo[] listRuleBases();
-
-    public abstract RuleBase get(RuleBaseInfo info);
-
-    public abstract void release(RuleBaseInfo info);
-
-}
\ No newline at end of file

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepositoryImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepositoryImpl.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/RuleBaseRepositoryImpl.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,46 +0,0 @@
-package org.drools.client;
-
-import org.drools.DroolsClient;
-import org.drools.DroolsServer;
-import org.drools.RuleBase;
-import org.drools.RuleBaseInfo;
-import org.drools.common.InternalRuleBase;
-
-public class RuleBaseRepositoryImpl implements RuleBaseRepository {
-    
-    DroolsServer server;
-    
-    public RuleBaseRepositoryImpl() {
-        
-    }
-    
-
-    public boolean registerRuleBase(RuleBase ruleBase,
-                                    RuleBaseInfo info) {
-        return this.server.registerRuleBase( ruleBase, 
-                                             info );
-    }    
-
-    public boolean deregisterRuleBase(RuleBase ruleBase) {
-        return this.server.deregisterRuleBase( ( ( InternalRuleBase ) ruleBase ).getId() );
-    }
-
-    public RuleBase get(RuleBaseInfo info) {
-        //return this.server
-        return null;
-    }
-
-    public boolean isRegistered(RuleBase ruleBase) {
-        return this.server.isRegistered( ( ( InternalRuleBase ) ruleBase ).getId() );
-    }
-
-    public RuleBaseInfo[] listRuleBases() {
-        return this.server.listRuleBases();
-    }
-
-
-    public void release(RuleBaseInfo info) {
-        
-    }
-
-}

Deleted: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/WorkingMemoryInspector.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/WorkingMemoryInspector.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/client/WorkingMemoryInspector.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,5 +0,0 @@
-package org.drools.client;
-
-public interface WorkingMemoryInspector {
-
-}

Added: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/AnonFact.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/AnonFact.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/AnonFact.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,14 @@
+package org.drools.server;
+
+public class AnonFact {
+
+	public Object fact;
+
+	public AnonFact(Object fact) {
+		this.fact = fact;
+	}
+
+	public AnonFact() {}
+
+}
+


Property changes on: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/AnonFact.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/NamedFact.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/NamedFact.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/NamedFact.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,17 @@
+package org.drools.server;
+
+
+public class NamedFact {
+
+
+
+	public NamedFact(String id, Object fact) {
+		this.id = id;
+		this.fact = fact;
+	}
+
+	public NamedFact() {}
+	public String id;
+	public Object fact;
+
+}


Property changes on: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/NamedFact.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/RuleService.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/RuleService.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/RuleService.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,154 @@
+package org.drools.server;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.ServletInputStream;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.drools.Person;
+import org.drools.RuleBase;
+import org.drools.StatefulSession;
+import org.drools.StatelessSession;
+import org.drools.common.InternalRuleBase;
+
+import com.thoughtworks.xstream.XStream;
+import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
+
+public class RuleService extends HttpServlet {
+
+
+	static XStream xmlInstance = configureXStream(false);
+	static XStream jsonInstance = configureXStream(true);
+
+
+	@Override
+	protected void doPost(HttpServletRequest request, HttpServletResponse resp)
+			throws ServletException, IOException {
+
+		String uri = request.getRequestURI();
+		RuleBase rb =  getRuleBaseFromURI(uri);
+
+		//doService(request.getInputStream(), resp.getOutputStream(), rb);
+
+
+		//sample();
+
+
+	}
+
+	void doService(InputStream inputStream,
+			OutputStream outputStream, RuleBase rb, boolean json) {
+		InternalRuleBase irb = (InternalRuleBase) rb;
+		ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
+		try {
+			ClassLoader cl = irb.getCompositePackageClassLoader();
+			Thread.currentThread().setContextClassLoader(cl);
+
+			XStream xs = (json) ? jsonInstance : xmlInstance;
+			ServiceRequestMessage req = (ServiceRequestMessage) xs.fromXML(inputStream);
+			StatelessSession session  = rb.newStatelessSession();
+			if (req.globals != null) {
+				for (NamedFact nf : req.globals) {
+					session.setGlobal(nf.id, nf.fact);
+				}
+			}
+			List<Object> facts = new ArrayList<Object>();
+			if (req.inFacts != null) {
+				for (AnonFact f : req.inFacts) {
+					facts.add(f.fact);
+				}
+			}
+			if (req.inOutFacts != null) {
+				for (NamedFact nf : req.inOutFacts) {
+					facts.add(nf.fact);
+				}
+			}
+
+			session.execute(facts);
+
+			ServiceResponseMessage res = new ServiceResponseMessage();
+			if (req.globals != null) {
+				res.globals = req.globals;
+			}
+			if (req.inOutFacts != null) {
+				res.inOutFacts = req.inOutFacts;
+			}
+
+			xs.toXML(res, outputStream);
+
+
+
+		} finally {
+			Thread.currentThread().setContextClassLoader(originalCL);
+		}
+	}
+
+	private RuleBase getRuleBaseFromURI(String uri) {
+
+		return null;
+	}
+
+
+
+
+
+
+	private void sample() {
+		XStream xs = configureXStream(true);
+
+		ServiceRequestMessage req = new ServiceRequestMessage();
+
+		req.globals = new NamedFact[1];
+		req.inFacts = new AnonFact[1];
+		req.inOutFacts = new NamedFact[1];
+		req.globals[0] = new NamedFact("jo", new Person("Jo", "Chocolote"));
+		//req.inFacts[0] = new AnonFact(new Person("Mike", "beer"));
+		req.inFacts[0] = new AnonFact(new Person("Mike", "wine"));
+		req.inOutFacts[0] = new NamedFact("mark", new Person("Mark", "Cheese"));
+
+		String requestMessage = xs.toXML(req);
+
+		ServiceRequestMessage req_ = (ServiceRequestMessage) xs.fromXML(requestMessage);
+		String requestMessage_ = xs.toXML(req_);
+
+		System.out.println(requestMessage);
+
+		if (!requestMessage_.equals(requestMessage)) throw new RuntimeException("fail !");
+	}
+
+	static XStream configureXStream(boolean json) {
+		if (json) {
+			XStream xs = new XStream(new JettisonMappedXmlDriver());
+			alias(xs);
+			return xs;
+
+		} else {
+			XStream xs = new XStream();
+			alias(xs);
+			return xs;
+		}
+	}
+
+	private static void alias(XStream xs) {
+		xs.alias("knowledgebase-request", ServiceRequestMessage.class);
+		xs.alias("knowledgebase-response", ServiceResponseMessage.class);
+		xs.alias("named-fact", NamedFact.class);
+		xs.alias("anon-fact", AnonFact.class);
+	}
+
+	public static void main(String[] args) throws ServletException, IOException {
+		RuleService rs = new RuleService();
+		rs.sample();
+
+	}
+
+
+}


Property changes on: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/RuleService.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceRequestMessage.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceRequestMessage.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceRequestMessage.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,8 @@
+package org.drools.server;
+
+
+public class ServiceRequestMessage {
+	public NamedFact[] globals;
+	public NamedFact[] inOutFacts;
+	public AnonFact[] inFacts;
+}


Property changes on: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceRequestMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceResponseMessage.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceResponseMessage.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceResponseMessage.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,8 @@
+package org.drools.server;
+
+import java.util.List;
+
+public class ServiceResponseMessage {
+	public NamedFact[] globals;
+	public NamedFact[] inOutFacts;
+}


Property changes on: labs/jbossrules/trunk/drools-server/src/main/java/org/drools/server/ServiceResponseMessage.java
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/DroolsClientServerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/java/org/drools/DroolsClientServerTest.java	2008-08-18 03:01:23 UTC (rev 21590)
+++ labs/jbossrules/trunk/drools-server/src/test/java/org/drools/DroolsClientServerTest.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -1,56 +0,0 @@
-package org.drools;
-
-import org.drools.common.InternalRuleBase;
-
-import junit.framework.TestCase;
-
-public class DroolsClientServerTest extends TestCase {
-    private DroolsClient client;
-    private DroolsService service;
-    
-//    protected void setUp() throws Exception {
-//        this.service = new DroolsService();
-//        this.service.start();
-//        
-//        client = new DroolsClient();
-//        this.client.start();        
-//        Thread.sleep( 1000 );
-//    }
-//
-//    public void test1() throws Exception {
-//        DroolsServer server = client.connect();
-//        
-//        InternalRuleBase ruleBase1 = ( InternalRuleBase ) RuleBaseFactory.newRuleBase();               
-//        RuleBaseInfo info1 = new RuleBaseInfo();
-//        info1.setName( "test 1" );                
-//        server.registerRuleBase( ruleBase1, info1 );
-//        
-//        InternalRuleBase ruleBase2 = ( InternalRuleBase ) RuleBaseFactory.newRuleBase();               
-//        RuleBaseInfo info2 = new RuleBaseInfo();
-//        info2.setName( "test 2" );                
-//        server.registerRuleBase( ruleBase2, info2 );        
-//        
-//        RuleBaseInfo[] infos = server.listRuleBases();
-//        
-//        assertEquals( 2, infos.length );
-//        
-//        assertNotSame( info1, infos[0] );
-//        assertNotSame( info2, infos[1] );
-//        assertNotSame( infos[1], infos[0] );
-//                
-//        info1 = infos[0];
-//        assertEquals(info1.getId(), ruleBase1.getId());
-//        assertEquals(info1.getName(), "test 1");
-//
-//        info2 = infos[1];
-//        assertEquals(info2.getId(), ruleBase2.getId());
-//        assertEquals(info2.getName(), "test 2");        
-//        
-//        client.disconnect( server );
-//    }
-//    
-//    protected void tearDown() throws Exception {
-//        this.client.stop();
-//        this.service.exit();
-//    }
-}

Added: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/java/org/drools/Person.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/java/org/drools/Person.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,233 @@
+package org.drools;
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class Person
+    implements
+    Serializable{
+    /**
+     *
+     */
+    private static final long serialVersionUID = 400L;
+    private String            name;
+    private String            likes;
+    private int               age;
+    private BigDecimal        bigDecimal;
+    private BigInteger        bigInteger;
+    private String            hair;
+
+    private char              sex;
+
+    private boolean           alive;
+
+    private String            status;
+
+
+    public Person() {
+
+    }
+
+    public Person(final String name) {
+        this( name,
+              "",
+              0 );
+    }
+
+    public Person(final String name,
+                  final String likes) {
+        this( name,
+              likes,
+              0 );
+    }
+
+    public Person(final String name,
+                  final String likes,
+                  final int age) {
+        this.name = name;
+        this.likes = likes;
+        this.age = age;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getStatus()
+     */
+    public String getStatus() {
+        return this.status;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setStatus(java.lang.String)
+     */
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getLikes()
+     */
+    public String getLikes() {
+        return this.likes;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getName()
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getAge()
+     */
+    public int getAge() {
+        return this.age;
+    }
+
+    public void setAge(final int age) {
+        this.age = age;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#isAlive()
+     */
+    public boolean isAlive() {
+        return this.alive;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setAlive(boolean)
+     */
+    public void setAlive(final boolean alive) {
+        this.alive = alive;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getSex()
+     */
+    public char getSex() {
+        return this.sex;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setSex(char)
+     */
+    public void setSex(final char sex) {
+        this.sex = sex;
+    }
+
+    public String getHair() {
+        return this.hair;
+    }
+
+    public void setHair(final String hair) {
+        this.hair = hair;
+    }
+
+    public String toString() {
+        return "[Person name='" + this.name + "']";
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + this.age;
+        result = PRIME * result + (this.alive ? 1231 : 1237);
+        result = PRIME * result + ((this.name == null) ? 0 : this.name.hashCode());
+        result = PRIME * result + this.sex;
+        return result;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean equals(final Object obj) {
+        if ( this == obj ) {
+            return true;
+        }
+        if ( obj == null ) {
+            return false;
+        }
+        if ( getClass() != obj.getClass() ) {
+            return false;
+        }
+        final Person other = (Person) obj;
+        if ( this.age != other.age ) {
+            return false;
+        }
+        if ( this.alive != other.alive ) {
+            return false;
+        }
+        if ( this.name == null ) {
+            if ( other.name != null ) {
+                return false;
+            }
+        } else if ( !this.name.equals( other.name ) ) {
+            return false;
+        }
+        if ( this.sex != other.sex ) {
+            return false;
+        }
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getBigDecimal()
+     */
+    public BigDecimal getBigDecimal() {
+        return this.bigDecimal;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setBigDecimal(java.math.BigDecimal)
+     */
+    public void setBigDecimal(final BigDecimal bigDecimal) {
+        this.bigDecimal = bigDecimal;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getBigInteger()
+     */
+    public BigInteger getBigInteger() {
+        return this.bigInteger;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setBigInteger(java.math.BigInteger)
+     */
+    public void setBigInteger(final BigInteger bigInteger) {
+        this.bigInteger = bigInteger;
+    }
+
+    public void setLikes(final String likes) {
+        this.likes = likes;
+    }
+
+
+}
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/RuleServiceTest.java
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/RuleServiceTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/RuleServiceTest.java	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,68 @@
+package org.drools.server;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.server.RuleService;
+
+import junit.framework.TestCase;
+
+public class RuleServiceTest extends TestCase {
+
+
+	public void testSample() throws Exception {
+
+		PackageBuilder pb = new PackageBuilder();
+		pb.addPackageFromDrl(new InputStreamReader(getClass().getResourceAsStream("test_rules1.drl")));
+		assertFalse(pb.hasErrors());
+
+		RuleBase rb = RuleBaseFactory.newRuleBase();
+		rb.addPackage(pb.getPackage());
+
+		RuleService serv = new RuleService();
+
+		final InputStream inXML = getClass().getResourceAsStream("sample_request.xml");
+		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+
+
+		ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+		serv.doService(inXML, outStream, rb, false);
+
+		String result = new String(outStream.toByteArray());
+
+		assertTrue(result.indexOf("<id>prs</id>") > -1);
+		assertTrue(result.indexOf("<id>result</id>") > -1);
+		assertTrue(result.indexOf("<name>Jo</name>") > -1);
+		assertTrue(result.indexOf("<status>crazy</status>") > -1);
+		assertTrue(result.indexOf("<value>42</value>") > -1);
+		assertTrue(result.indexOf("<explanation>just cause it is</explanation>") > -1);
+
+		assertSame(cl, Thread.currentThread().getContextClassLoader());
+
+
+		InputStream inJSON = getClass().getResourceAsStream("sample_request.json");
+		outStream = new ByteArrayOutputStream();
+		serv.doService(inJSON, outStream, rb, true);
+
+		result = new String(outStream.toByteArray());
+
+		assertTrue(result.indexOf("\"id\":\"prs\"") > -1);
+		assertTrue(result.indexOf("\"id\":\"result\"") > -1);
+		assertTrue(result.indexOf("\"status\":\"crazy\"") > -1);
+
+
+	}
+
+	public void testInitialise() {
+		RuleService rs = new RuleService();
+		assertNotNull(rs.jsonInstance);
+		assertNotNull(rs.xmlInstance);
+
+	}
+
+}


Property changes on: labs/jbossrules/trunk/drools-server/src/test/java/org/drools/server/RuleServiceTest.java
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.json
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.json	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.json	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,8 @@
+{"knowledgebase-request":{"globals":{"named-fact":{"id":"prs",
+"fact":{"@class":"org.drools.Person",
+"name":"Jo"}}},
+"inOutFacts":{"named-fact":{"id":"result",
+"fact":{"@class":"something.Result"}}},
+"inFacts":{"anon-fact":{"fact":{"@class":"something.Car",
+"name":"saab",
+"type":"wagon"}}}}}
\ No newline at end of file


Property changes on: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.json
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.xml
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.xml	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.xml	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,24 @@
+<knowledgebase-request>
+  <globals>
+    <named-fact>
+      <id>prs</id>
+      <fact class="org.drools.Person">
+        <name>Jo</name>
+      </fact>
+    </named-fact>
+  </globals>
+  <inOutFacts>
+    <named-fact>
+      <id>result</id>
+      <fact class="something.Result"/>
+    </named-fact>
+  </inOutFacts>
+  <inFacts>
+    <anon-fact>
+      <fact class="something.Car">
+        <name>saab</name>
+        <type>wagon</type>
+      </fact>
+    </anon-fact>
+  </inFacts>
+</knowledgebase-request>
\ No newline at end of file


Property changes on: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/sample_request.xml
___________________________________________________________________
Name: svn:eol-style
   + native

Added: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/test_rules1.drl
===================================================================
--- labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/test_rules1.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/test_rules1.drl	2008-08-18 06:21:46 UTC (rev 21591)
@@ -0,0 +1,46 @@
+package something
+
+
+global org.drools.Person prs
+
+declare Car
+   name: String
+   type: String
+end
+
+declare Result
+	value: Integer
+	explanation: String
+end
+
+
+
+rule "wagons"
+ dialect "mvel"
+ when
+   Car(name == "saab", type == "wagon")
+   r: Result()
+ then
+   r.value = 42
+   r.explanation = "just cause it is"
+end
+
+rule "cars"
+ dialect "mvel"
+ when
+   Car(type=="car")
+   r: Result()
+ then
+   r.value = 40
+   r.explanation = "not as useful"
+end
+
+rule "another"
+  when
+   Car()
+  then
+    prs.setStatus("crazy");
+end
+
+
+


Property changes on: labs/jbossrules/trunk/drools-server/src/test/resources/org/drools/server/test_rules1.drl
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the jboss-svn-commits mailing list