[jboss-svn-commits] JBL Code SVN: r36698 - in labs/jbossrules/tags/5.2.0.M1: drools-container and 42 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Feb 24 10:34:38 EST 2011
Author: ge0ffrey
Date: 2011-02-24 10:34:37 -0500 (Thu, 24 Feb 2011)
New Revision: 36698
Added:
labs/jbossrules/tags/5.2.0.M1/drools-container/
labs/jbossrules/tags/5.2.0.M1/drools-container/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/pom.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/pom.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/pom.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/.gitignore
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/pom.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/AbstractKnowledgeSessionBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/DroolsResourceAdapter.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridNodeBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeAgentBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeBaseBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeStoreBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceChangeScannerBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatefulKnowledgeSessionBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatelessKnowledgeSessionBeanFactory.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringTransactionManager.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/SpringTransactionSynchronizationAdapter.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/DefinitionParserHelper.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridNodeDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeAgentDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeBaseDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeSessionDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeStoreDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceChangeScannerDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceDefinitionParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/SpringDroolsHandler.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/XsdParser.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.handlers
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.schemas
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.1.0.xsd
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.2.0.xsd
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/Person.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockAccumulateFunction.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockConsequenceExceptionHandler.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockEvaluatorDefinition.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsGridTest.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsTest.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/JPASingleSessionCommandServiceFactoryTest.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntity.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityMethods.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityOnlyFields.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyVariableSerializable.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/TestWorkItemHandler.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyTest.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/MyDroolsBean.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TestWorkItemHandler.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TimerFlowTest.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/helper/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/helper/FileHelper.java
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/MyWorkItemHandlers.conf
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/drools.session.conf
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/orm.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/persistence.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/log4j.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/.~lock.IntegrationExampleTest.xls#
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/IntegrationExampleTest.xls
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyProcess.rf
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beans.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beansVarPersistence.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/rollbackRules.drl
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/drl/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/drl/testSpring.drl
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/grid.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/kagents-beans.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/model.xsd
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/no-node-beans.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/session-conf-beans.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/testSpring.drl
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/conf/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/conf/spring-conf.xml
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/flow/
labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/flow/timer-flow.rf
labs/jbossrules/tags/5.2.0.M1/drools-container/pom.xml
Log:
All monolothic build versions (<= 5.2.0.M1) stay in subversion
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/.gitignore 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/.gitignore 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/.gitignore 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam2/pom.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,69 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-seam</artifactId>
+ <version>5.2.0.M1</version>
+ </parent>
+
+ <artifactId>drools-seam2</artifactId>
+ <packaging>jar</packaging>
+ <name>Drools :: Seam2</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-templates</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-workitems</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-persistence-jpa</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-flow-builder</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-flow</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-persistence-jpa</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/.gitignore 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/drools-seam3/pom.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,69 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-seam</artifactId>
+ <version>5.2.0.M1</version>
+ </parent>
+
+ <artifactId>drools-seam3</artifactId>
+ <packaging>jar</packaging>
+ <name>Drools :: Seam3</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-templates</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-workitems</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-persistence-jpa</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-flow-builder</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-flow</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-persistence-jpa</artifactId>
+ </dependency>
+
+ </dependencies>
+
+</project>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-seam/pom.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,21 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools</artifactId>
+ <version>5.2.0.M1</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>drools-seam</artifactId>
+ <packaging>pom</packaging>
+ <name>Drools :: Seam</name>
+
+ <modules>
+ <module>drools-seam2</module>
+ <module>drools-seam3</module>
+ </modules>
+
+</project>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/.gitignore (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/.gitignore 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/pom.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,132 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools</artifactId>
+ <version>5.2.0.M1</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>drools-spring</artifactId>
+ <packaging>jar</packaging>
+ <name>Drools :: Spring</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-decisiontables</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-persistence-jpa</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-persistence-jpa</artifactId>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-grid-impl</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-xjc</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-jdbc</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jdt.core.compiler</groupId>
+ <artifactId>ecj</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>antlr</groupId>
+ <artifactId>antlr</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr-runtime</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/AbstractKnowledgeSessionBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/AbstractKnowledgeSessionBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/AbstractKnowledgeSessionBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,132 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.List;
+import java.util.Map;
+
+import org.drools.KnowledgeBase;
+import org.drools.command.Command;
+import org.drools.grid.GridNode;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.KnowledgeSessionConfiguration;
+import org.drools.runtime.process.WorkItemHandler;
+import org.springframework.beans.factory.BeanNameAware;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.NamedBean;
+
+public abstract class AbstractKnowledgeSessionBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean,
+ BeanNameAware,
+ NamedBean {
+
+ private GridNode node;
+ private Map<String, WorkItemHandler> workItems;
+ private KnowledgeSessionConfiguration conf;
+ private KnowledgeBase kbase;
+ private String beanName;
+ private String name;
+
+ private List<Command< ? >> batch;
+
+ public AbstractKnowledgeSessionBeanFactory() {
+ super();
+ }
+
+ public Object getObject() throws Exception {
+ return getCommandExecutor();
+ }
+
+ public Map<String, WorkItemHandler> getWorkItems() {
+ return workItems;
+ }
+
+ public void setWorkItems(Map<String, WorkItemHandler> workItems) {
+ this.workItems = workItems;
+ }
+
+ public KnowledgeSessionConfiguration getConf() {
+ return conf;
+ }
+
+ public void setConf(KnowledgeSessionConfiguration conf) {
+ this.conf = conf;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public KnowledgeBase getKbase() {
+ return kbase;
+ }
+
+ public void setKbase(KnowledgeBase kbase) {
+ this.kbase = kbase;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public List<Command< ? >> getBatch() {
+ return batch;
+ }
+
+ public void setBatch(List<Command< ? >> commands) {
+ this.batch = commands;
+ }
+
+ public final void afterPropertiesSet() throws Exception {
+ if ( kbase == null ) {
+ throw new IllegalArgumentException( "kbase property is mandatory" );
+ }
+ if ( name == null ) {
+ name = beanName;
+ }
+ internalAfterPropertiesSet();
+ }
+
+ protected abstract CommandExecutor getCommandExecutor();
+
+ protected abstract void internalAfterPropertiesSet();
+
+ public GridNode getNode() {
+ return node;
+ }
+
+ public void setNode(GridNode node) {
+ this.node = node;
+ }
+
+ public void setBeanName(String name) {
+ this.beanName = name;
+
+ }
+
+ public String getBeanName() {
+ return beanName;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/DroolsResourceAdapter.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/DroolsResourceAdapter.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/DroolsResourceAdapter.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,138 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import org.drools.builder.ResourceConfiguration;
+import org.drools.builder.ResourceType;
+import org.drools.io.Resource;
+import org.drools.io.impl.ClassPathResource;
+import org.drools.io.impl.UrlResource;
+import org.springframework.beans.factory.InitializingBean;
+
+public class DroolsResourceAdapter
+ implements
+ InitializingBean {
+ private Resource resource;
+ private ResourceType resourceType;
+ private ResourceConfiguration resourceConfiguration;
+
+ public DroolsResourceAdapter() {
+
+ }
+
+ public DroolsResourceAdapter(String resource,
+ ResourceType resourceType,
+ ResourceConfiguration resourceConfiguration) {
+ super();
+ setResource( resource );
+ this.resourceType = resourceType;
+ this.resourceConfiguration = resourceConfiguration;
+ }
+
+ public void setResource(String resource) {
+ if ( resource.trim().startsWith( "classpath:" ) ) {
+ this.resource = new ClassPathResource( resource.substring( resource.indexOf( ':' ) + 1 ),
+ ClassPathResource.class.getClassLoader() );
+ } else {
+ this.resource = new UrlResource( resource );
+ }
+ }
+
+ public void setBasicAuthenticationEnabled(Boolean enabled) {
+ if ( enabled && !(this.resource instanceof UrlResource) ) {
+ throw new IllegalArgumentException( "Authentication Attributes are only valid for URL Resources" );
+ }
+
+ if ( this.resource instanceof UrlResource ) {
+ ((UrlResource) this.resource).setBasicAuthentication( enabled ? "enabled" : "disabled" );
+ }
+ }
+
+ public void setBasicAuthenticationUsername(String username) {
+ if ( !(this.resource instanceof UrlResource) ) {
+ throw new IllegalArgumentException( "Authentication Attributes are only valid for URL Resources" );
+ }
+ ((UrlResource) this.resource).setUsername( username );
+ }
+
+ public void setBasicAuthenticationPassword(String password) {
+ if ( !(this.resource instanceof UrlResource) ) {
+ throw new IllegalArgumentException( "Authentication Attributes are only valid for URL Resources" );
+ }
+ ((UrlResource) this.resource).setPassword( password );
+ }
+
+ public DroolsResourceAdapter(String resource,
+ ResourceType resourceType) {
+ this( resource,
+ resourceType,
+ null );
+ }
+
+ public DroolsResourceAdapter(String resource) {
+ this( resource,
+ ResourceType.DRL,
+ null );
+ }
+
+ public DroolsResourceAdapter(String resource,
+ String resourceType,
+ ResourceConfiguration resourceConfiguration) {
+ this( resource,
+ ResourceType.getResourceType( resourceType ),
+ resourceConfiguration );
+ }
+
+ public DroolsResourceAdapter(String resource,
+ String resourceType) {
+ this( resource,
+ resourceType,
+ null );
+ }
+
+ public Resource getDroolsResource() {
+ return resource;
+ }
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public ResourceConfiguration getResourceConfiguration() {
+ return resourceConfiguration;
+ }
+
+ public void setResourceConfiguration(ResourceConfiguration resourceConfiguration) {
+ this.resourceConfiguration = resourceConfiguration;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ if ( resource == null ) {
+ throw new IllegalArgumentException( "resource property is mandatory" );
+ }
+ if ( resourceType == null ) {
+ throw new IllegalArgumentException( "resourceType property is mandatory" );
+ }
+ if ( resourceConfiguration != null && !(ResourceType.DTABLE.equals( resourceType ) || ResourceType.XSD.equals( resourceType )) ) {
+ throw new IllegalArgumentException( "Only Decision Tables or XSD resources can have configuration" );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,207 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.SystemEventListenerFactory;
+import org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory.JpaConfiguration;
+import org.drools.grid.Grid;
+import org.drools.grid.conf.GridPeerServiceConfiguration;
+import org.drools.grid.conf.impl.GridPeerConfiguration;
+import org.drools.grid.impl.GridImpl;
+import org.drools.grid.impl.MultiplexSocketServerImpl;
+import org.drools.grid.io.AcceptorFactoryService;
+import org.drools.grid.io.impl.MultiplexSocketServiceCongifuration;
+import org.drools.grid.remote.mina.MinaAcceptorFactoryService;
+import org.drools.grid.service.directory.WhitePages;
+import org.drools.grid.service.directory.impl.CoreServicesLookupConfiguration;
+import org.drools.grid.service.directory.impl.WhitePagesLocalConfiguration;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class GridBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ private String id;
+ private GridImpl grid;
+
+ private Map coreServices;
+
+ private WhitePages whitePages;
+
+ private JpaConfiguration jpaConfiguration;
+
+ private SocketServiceConfiguration socketServiceConfiguration;
+
+ // private String type;
+ // private GenericConnection connection;
+ //
+ public Object getObject() throws Exception {
+ return this.grid;
+ }
+
+ //
+ public Class<Grid> getObjectType() {
+ return Grid.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ this.grid = new GridImpl( new HashMap() );
+ MultiplexSocketServiceCongifuration socketConf = null;
+
+ if ( this.coreServices == null ) {
+ this.coreServices = new HashMap();
+ }
+
+ GridPeerConfiguration conf = new GridPeerConfiguration();
+ GridPeerServiceConfiguration coreSeviceLookupConf = new CoreServicesLookupConfiguration( this.coreServices );
+ conf.addConfiguration( coreSeviceLookupConf );
+
+ //Configuring the WhitePages
+ if ( this.whitePages != null ) {
+ WhitePagesLocalConfiguration wplConf = new WhitePagesLocalConfiguration();
+ wplConf.setWhitePages( this.whitePages );
+ conf.addConfiguration( wplConf );
+ }
+
+ conf.configure( this.grid );
+
+ // We do this after the main grid configuration, to make sure all services are instantiated
+ if ( this.socketServiceConfiguration != null ) {
+ AcceptorFactoryService acc = null;
+ if ( "mina".equals( this.socketServiceConfiguration.getAcceptor() ) ) {
+ acc = new MinaAcceptorFactoryService();
+ }
+
+ if ( acc == null ) {
+ // Mina is the default for the moment
+ acc = new MinaAcceptorFactoryService();
+ }
+
+ socketConf = new MultiplexSocketServiceCongifuration( new MultiplexSocketServerImpl( this.socketServiceConfiguration.getIp(),
+ acc,
+ SystemEventListenerFactory.getSystemEventListener(),
+ this.grid ) );
+
+ for ( String[] services : this.socketServiceConfiguration.getServices() ) {
+ Object service = ((GridImpl) this.grid).get( services[0].trim() );
+ if ( service == null ) {
+ throw new RuntimeException( "Unable to configure socket. Service '" + services[0] + "' could not be found" );
+ }
+ if ( "auto".equals( services[1].trim() ) ) {
+
+ } else {
+ socketConf.addService( services[0].trim(),
+ service,
+ Integer.parseInt( services[1].trim() ) );
+ }
+ }
+
+ socketConf.configureService( this.grid );
+ }
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public WhitePages getWhitePages() {
+ return whitePages;
+ }
+
+ public void setWhitePages(WhitePages whitePages) {
+ this.whitePages = whitePages;
+ }
+
+ public Map getCoreServices() {
+ return coreServices;
+ }
+
+ public void setCoreServices(Map coreServices) {
+ this.coreServices = coreServices;
+ }
+
+ public JpaConfiguration getJpaConfiguration() {
+ return jpaConfiguration;
+ }
+
+ public void setJpaConfiguration(JpaConfiguration jpaConfiguration) {
+ this.jpaConfiguration = jpaConfiguration;
+ }
+
+ public SocketServiceConfiguration getSocketServiceConfiguration() {
+ return socketServiceConfiguration;
+ }
+
+ public void setSocketServiceConfiguration(SocketServiceConfiguration socketServiceConfiguration) {
+ this.socketServiceConfiguration = socketServiceConfiguration;
+ }
+
+ public static class SocketServiceConfiguration {
+ private String ip;
+ private String acceptor;
+ private List<String[]> services;
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public String getAcceptor() {
+ return acceptor;
+ }
+
+ public void setAcceptor(String acceptor) {
+ this.acceptor = acceptor;
+ }
+
+ public List<String[]> getServices() {
+ if ( this.services == null ) {
+ this.services = new ArrayList<String[]>();
+ }
+ return services;
+ }
+
+ public void setServices(List<String[]> services) {
+ this.services = services;
+ }
+
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridNodeBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridNodeBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/GridNodeBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.HashMap;
+
+import org.drools.grid.Grid;
+import org.drools.grid.GridNode;
+import org.drools.grid.SocketService;
+import org.drools.grid.impl.GridImpl;
+import org.drools.grid.service.directory.WhitePages;
+import org.drools.grid.service.directory.impl.WhitePagesImpl;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.util.StringUtils;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class GridNodeBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ private String id;
+ private Grid grid;
+ private GridNode node;
+
+ private String port;
+
+ //
+ public Object getObject() throws Exception {
+ return node;
+ }
+
+ public Class< ? extends GridNode> getObjectType() {
+ return GridNode.class;
+ }
+
+ //
+ public boolean isSingleton() {
+ return true;
+ }
+
+ //
+ public void afterPropertiesSet() throws Exception {
+ if ( grid == null ) {
+ this.grid = new GridImpl( new HashMap<String, Object>() );
+ ((GridImpl) this.grid).addService( WhitePages.class,
+ new WhitePagesImpl() );
+ }
+ this.node = this.grid.createGridNode( id );
+
+ if ( StringUtils.hasText( this.port ) ) {
+ this.grid.get( SocketService.class ).addService( id,
+ Integer.parseInt( port ),
+ this.node );
+ }
+ // connection.addExecutionNode(new LocalNodeConnector());
+ // connection.addDirectoryNode(new LocalDirectoryConnector());
+ // node = connection.getExecutionNode();
+ // node.setId( id );
+ }
+
+ //
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Grid getGrid() {
+ return grid;
+ }
+
+ public void setGrid(Grid grid) {
+ this.grid = grid;
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeAgentBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeAgentBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeAgentBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,139 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.drools.KnowledgeBase;
+import org.drools.agent.KnowledgeAgent;
+import org.drools.agent.KnowledgeAgentConfiguration;
+import org.drools.agent.KnowledgeAgentFactory;
+import org.drools.io.Resource;
+import org.drools.io.impl.ChangeSetImpl;
+import org.drools.io.internal.InternalResource;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class KnowledgeAgentBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ private KnowledgeBase kbase;
+
+ private KnowledgeAgent kagent;
+
+ private String id;
+
+ private String newInstance;
+
+ private List<DroolsResourceAdapter> resources = Collections.emptyList();
+
+ public Object getObject() throws Exception {
+ return this.kagent;
+ }
+
+ public Class<KnowledgeAgent> getObjectType() {
+ return KnowledgeAgent.class;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ KnowledgeAgentConfiguration kagentConf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();
+ if ( kbase == null ) {
+ throw new RuntimeException( "kagent must reference an existing kbase" );
+ }
+
+ kagentConf.setProperty( "drools.agent.newInstance",
+ newInstance );
+
+ this.kagent = KnowledgeAgentFactory.newKnowledgeAgent( this.id,
+ this.kbase,
+ kagentConf );
+
+ if ( resources != null && !resources.isEmpty() ) {
+ Collection<Resource> rs = new ArrayList<Resource>();
+ for ( DroolsResourceAdapter res : resources ) {
+ InternalResource resource = (InternalResource) res.getDroolsResource();
+
+ resource.setResourceType( res.getResourceType() );
+
+ if ( res.getResourceConfiguration() != null ) {
+ resource.setConfiguration( res.getResourceConfiguration() );
+ }
+
+ rs.add( resource );
+ }
+ ChangeSetImpl changeSet = new ChangeSetImpl();
+ changeSet.setResourcesAdded( rs );
+
+ kagent.applyChangeSet( changeSet );
+ }
+ }
+
+ public KnowledgeBase getKbase() {
+ return kbase;
+ }
+
+ public void setKbase(KnowledgeBase kbase) {
+ this.kbase = kbase;
+ }
+
+ public KnowledgeAgent getKagent() {
+ return kagent;
+ }
+
+ public void setKagent(KnowledgeAgent kagent) {
+ this.kagent = kagent;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getNewInstance() {
+ return newInstance;
+ }
+
+ public void setNewInstance(String newInstance) {
+ this.newInstance = newInstance;
+ }
+
+ public List<DroolsResourceAdapter> getResources() {
+ return resources;
+ }
+
+ public void setResources(List<DroolsResourceAdapter> resources) {
+ this.resources = resources;
+ }
+
+ public boolean isSingleton() {
+ return false;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeBaseBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeBaseBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeBaseBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,182 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseConfiguration;
+import org.drools.KnowledgeBaseFactoryService;
+import org.drools.base.accumulators.AccumulateFunction;
+import org.drools.base.evaluators.EvaluatorDefinition;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderErrors;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.KnowledgeBuilderFactoryService;
+import org.drools.builder.ResourceType;
+import org.drools.builder.conf.AccumulateFunctionOption;
+import org.drools.builder.conf.EvaluatorOption;
+import org.drools.builder.conf.impl.JaxbConfigurationImpl;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.grid.GridNode;
+import org.drools.grid.impl.GridNodeImpl;
+import org.drools.impl.KnowledgeBaseImpl;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class KnowledgeBaseBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ private KnowledgeBaseConfiguration conf;
+ private Map<String, AccumulateFunction> accumulateFunctions;
+ private Map<String, EvaluatorDefinition> evaluators;
+
+ private KnowledgeBase kbase;
+ private GridNode node;
+ private List<DroolsResourceAdapter> resources = Collections.emptyList();
+
+ public Object getObject() throws Exception {
+ return kbase;
+ }
+
+ public Class< ? extends KnowledgeBase> getObjectType() {
+ return KnowledgeBase.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ if ( this.node == null ) {
+ this.node = new GridNodeImpl();
+ // GenericConnection connection = new GridConnection();
+ // connection.addExecutionNode(new LocalNodeConnector());
+ // connection.addDirectoryNode(new LocalDirectoryConnector());
+ // this.node = connection.getExecutionNode();
+
+ }
+
+ PackageBuilderConfiguration kconf = (PackageBuilderConfiguration) KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration();
+ if ( this.accumulateFunctions != null && !this.accumulateFunctions.isEmpty() ) {
+ for ( Entry<String, AccumulateFunction> entry : this.accumulateFunctions.entrySet() ) {
+ kconf.setOption( AccumulateFunctionOption.get( entry.getKey(),
+ entry.getValue() ) );
+ }
+ }
+
+ if ( this.evaluators != null && !this.evaluators.isEmpty() ) {
+ for ( Entry<String, EvaluatorDefinition> entry : this.evaluators.entrySet() ) {
+ kconf.setOption( EvaluatorOption.get( entry.getKey(),
+ entry.getValue() ) );
+ }
+ }
+
+ KnowledgeBuilder kbuilder = node.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder( kconf );
+ if ( this.conf != null ) {
+ kbase = node.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase( conf );
+ } else {
+ kbase = node.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();
+ }
+
+ List<JaxbConfigurationImpl> xsds = new ArrayList<JaxbConfigurationImpl>();
+
+ for ( DroolsResourceAdapter res : resources ) {
+ if ( res.getResourceType().equals( ResourceType.XSD ) ) {
+ xsds.add( (JaxbConfigurationImpl) res.getResourceConfiguration() );
+ }
+
+ if ( res.getResourceConfiguration() == null ) {
+ kbuilder.add( res.getDroolsResource(),
+ res.getResourceType() );
+ } else {
+ kbuilder.add( res.getDroolsResource(),
+ res.getResourceType(),
+ res.getResourceConfiguration() );
+ }
+ }
+
+ KnowledgeBuilderErrors errors = kbuilder.getErrors();
+ if ( !errors.isEmpty() ) {
+ throw new RuntimeException( errors.toString() );
+ }
+
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ KnowledgeBaseImpl kbaseImpl = (KnowledgeBaseImpl) kbase;
+ kbaseImpl.jaxbClasses = new ArrayList<List<String>>();
+ for ( JaxbConfigurationImpl conf : xsds ) {
+ kbaseImpl.jaxbClasses.add( conf.getClasses() );
+ }
+
+ }
+
+ public Map<String, AccumulateFunction> getAccumulateFunctions() {
+ return accumulateFunctions;
+ }
+
+ public void setAccumulateFunctions(Map<String, AccumulateFunction> accumulateFunctions) {
+ this.accumulateFunctions = accumulateFunctions;
+ }
+
+ public Map<String, EvaluatorDefinition> getEvaluators() {
+ return evaluators;
+ }
+
+ public void setEvaluators(Map<String, EvaluatorDefinition> evaluators) {
+ this.evaluators = evaluators;
+ }
+
+ public KnowledgeBaseConfiguration getConf() {
+ return conf;
+ }
+
+ public void setConf(KnowledgeBaseConfiguration conf) {
+ this.conf = conf;
+ }
+
+ public KnowledgeBase getKbase() {
+ return kbase;
+ }
+
+ public void setKbase(KnowledgeBase kbase) {
+ this.kbase = kbase;
+ }
+
+ public GridNode getNode() {
+ return node;
+ }
+
+ public List<DroolsResourceAdapter> getResources() {
+ return resources;
+ }
+
+ public void setResources(List<DroolsResourceAdapter> resources) {
+ this.resources = resources;
+ }
+
+ public void setNode(GridNode gridNode) {
+ this.node = gridNode;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeStoreBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeStoreBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/KnowledgeStoreBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import org.drools.persistence.jpa.KnowledgeStoreService;
+import org.drools.persistence.jpa.KnowledgeStoreServiceImpl;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+public class KnowledgeStoreBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ public Object getObject() throws Exception {
+ return new KnowledgeStoreServiceImpl();
+ }
+
+ public Class< ? extends KnowledgeStoreService> getObjectType() {
+ return KnowledgeStoreService.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import org.drools.io.Resource;
+import org.drools.io.impl.ClassPathResource;
+import org.drools.io.impl.UrlResource;
+import org.springframework.beans.factory.FactoryBean;
+
+public class ResourceBeanFactory
+ implements
+ FactoryBean {
+
+ private Resource resource;
+
+ public ResourceBeanFactory(String source) {
+ if ( source.trim().startsWith( "classpath:" ) ) {
+ resource = new ClassPathResource( source.substring( source.indexOf( ':' ) + 1 ),
+ ClassPathResource.class.getClassLoader() );
+ } else {
+ resource = new UrlResource( source );
+ }
+ }
+
+ public Object getObject() throws Exception {
+ return resource;
+ }
+
+ public Class<Resource> getObjectType() {
+ return Resource.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceChangeScannerBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceChangeScannerBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/ResourceChangeScannerBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import org.drools.io.ResourceChangeScanner;
+import org.drools.io.ResourceFactory;
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class ResourceChangeScannerBeanFactory
+ implements
+ FactoryBean,
+ InitializingBean {
+
+ private String id;
+ private int interval;
+
+ public Object getObject() throws Exception {
+ return ResourceFactory.getResourceChangeScannerService();
+ }
+
+ public Class<ResourceChangeScanner> getObjectType() {
+ return ResourceChangeScanner.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public void afterPropertiesSet() throws Exception {
+ ResourceFactory.getResourceChangeScannerService().setInterval( this.interval );
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public int getInterval() {
+ return interval;
+ }
+
+ public void setInterval(int interval) {
+ this.interval = interval;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatefulKnowledgeSessionBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatefulKnowledgeSessionBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatefulKnowledgeSessionBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,135 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.Map;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.drools.KnowledgeBaseFactory;
+import org.drools.SessionConfiguration;
+import org.drools.command.Command;
+import org.drools.marshalling.ObjectMarshallingStrategy;
+import org.drools.marshalling.impl.ClassObjectMarshallingStrategyAcceptor;
+import org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy;
+import org.drools.persistence.jpa.JPAKnowledgeService;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.Environment;
+import org.drools.runtime.EnvironmentName;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.WorkItemHandler;
+import org.springframework.transaction.PlatformTransactionManager;
+
+public class StatefulKnowledgeSessionBeanFactory extends AbstractKnowledgeSessionBeanFactory {
+ private StatefulKnowledgeSession ksession;
+
+ private JpaConfiguration jpaConfiguration;
+
+ public Class<StatefulKnowledgeSession> getObjectType() {
+ return StatefulKnowledgeSession.class;
+ }
+
+ public JpaConfiguration getJpaConfiguration() {
+ return jpaConfiguration;
+ }
+
+ public void setJpaConfiguration(JpaConfiguration jpaConfiguration) {
+ this.jpaConfiguration = jpaConfiguration;
+ }
+
+ @Override
+ protected CommandExecutor getCommandExecutor() {
+ return ksession;
+ }
+
+ @Override
+ protected void internalAfterPropertiesSet() {
+ if ( getConf() != null && getWorkItems() != null && !getWorkItems().isEmpty() ) {
+ Map<String, WorkItemHandler> map = ((SessionConfiguration) getConf()).getWorkItemHandlers();
+ map.putAll( getWorkItems() );
+ }
+
+ if ( jpaConfiguration != null ) {
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ jpaConfiguration.getEntityManagerFactory() );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ jpaConfiguration.getPlatformTransactionManager() );
+ env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
+ new ObjectMarshallingStrategy[]{new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
+
+ if ( jpaConfiguration.getId() >= 0 ) {
+ ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( jpaConfiguration.getId(),
+ getKbase(),
+ getConf(),
+ env );
+ } else {
+ ksession = JPAKnowledgeService.newStatefulKnowledgeSession( getKbase(),
+ getConf(),
+ env );
+ }
+ } else {
+ ksession = getKbase().newStatefulKnowledgeSession( getConf(),
+ null );
+ }
+
+ if ( getBatch() != null && !getBatch().isEmpty() ) {
+ for ( Command< ? > cmd : getBatch() ) {
+ ksession.execute( cmd );
+ }
+ }
+
+ if ( getNode() != null ) {
+ getNode().set( getName(),
+ this.ksession );
+ }
+ }
+
+ public static class JpaConfiguration {
+ private EntityManagerFactory emf;
+
+ private PlatformTransactionManager tm;
+
+ private int id = -1;
+
+ public EntityManagerFactory getEntityManagerFactory() {
+ return this.emf;
+ }
+
+ public void setEntityManagerFactory(EntityManagerFactory emf) {
+ this.emf = emf;
+ }
+
+ public PlatformTransactionManager getPlatformTransactionManager() {
+ return this.tm;
+ }
+
+ public void setPlatformTransactionManager(PlatformTransactionManager tm) {
+ this.tm = tm;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatelessKnowledgeSessionBeanFactory.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatelessKnowledgeSessionBeanFactory.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/StatelessKnowledgeSessionBeanFactory.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans;
+
+import java.util.Map;
+
+import org.drools.SessionConfiguration;
+import org.drools.agent.KnowledgeAgent;
+import org.drools.runtime.CommandExecutor;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.process.WorkItemHandler;
+
+public class StatelessKnowledgeSessionBeanFactory extends AbstractKnowledgeSessionBeanFactory {
+ private StatelessKnowledgeSession ksession;
+ private KnowledgeAgent kagent;
+
+ public void setKnowledgeAgent(KnowledgeAgent kagent) {
+ this.kagent = kagent;
+ }
+
+ public KnowledgeAgent getKnowledgeAgent() {
+ return this.kagent;
+ }
+
+ public Class<StatelessKnowledgeSession> getObjectType() {
+ return StatelessKnowledgeSession.class;
+ }
+
+ @Override
+ protected CommandExecutor getCommandExecutor() {
+ return ksession;
+ }
+
+ @Override
+ protected void internalAfterPropertiesSet() {
+ if ( getConf() != null && getWorkItems() != null && !getWorkItems().isEmpty() ) {
+ Map<String, WorkItemHandler> map = ((SessionConfiguration) getConf()).getWorkItemHandlers();
+ map.putAll( getWorkItems() );
+ }
+
+ if ( this.kagent != null ) {
+ ksession = this.kagent.newStatelessKnowledgeSession( getConf() );
+ } else {
+ ksession = getKbase().newStatelessKnowledgeSession( getConf() );
+ }
+
+ if ( getNode() != null ) {
+ getNode().set( getName(),
+ this.ksession );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringJpaManager.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,147 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.drools.persistence.PersistenceContext;
+import org.drools.persistence.jpa.JpaPersistenceContext;
+import org.drools.runtime.Environment;
+import org.drools.runtime.EnvironmentName;
+import org.jbpm.persistence.JpaProcessPersistenceContext;
+import org.jbpm.persistence.ProcessPersistenceContext;
+import org.jbpm.persistence.ProcessPersistenceContextManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.orm.jpa.EntityManagerHolder;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+/**
+ *
+ * @author Mark Proctor
+ * @author Esteban Aliverti
+ */
+public class DroolsSpringJpaManager
+ implements
+ ProcessPersistenceContextManager {
+
+ Logger logger = LoggerFactory.getLogger( getClass() );
+
+ Environment env;
+
+ private EntityManagerFactory emf;
+
+ private EntityManager appScopedEntityManager;
+
+ private boolean internalAppScopedEntityManager;
+
+ public DroolsSpringJpaManager(Environment env) {
+ this.env = env;
+ this.emf = (EntityManagerFactory) env.get( EnvironmentName.ENTITY_MANAGER_FACTORY );
+
+ getApplicationScopedPersistenceContext(); // we create this on initialisation so that we own the EMF reference
+ // otherwise Spring will close it after the transaction finishes
+ }
+
+ public PersistenceContext getApplicationScopedPersistenceContext() {
+ if ( this.appScopedEntityManager == null ) {
+ // Use the App scoped EntityManager if the user has provided it, and it is open.
+ this.appScopedEntityManager = (EntityManager) this.env.get( EnvironmentName.APP_SCOPED_ENTITY_MANAGER );
+ if ( this.appScopedEntityManager != null && !this.appScopedEntityManager.isOpen() ) {
+ throw new RuntimeException( "Provided APP_SCOPED_ENTITY_MANAGER is not open" );
+ }
+
+ if ( this.appScopedEntityManager == null ) {
+ EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( this.emf );
+ if ( emHolder == null ) {
+ this.appScopedEntityManager = this.emf.createEntityManager();
+ emHolder = new EntityManagerHolder( this.appScopedEntityManager );
+ TransactionSynchronizationManager.bindResource( this.emf,
+ emHolder );
+ internalAppScopedEntityManager = true;
+ } else {
+ this.appScopedEntityManager = emHolder.getEntityManager();
+ }
+
+ this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER,
+ emHolder.getEntityManager() );
+ }
+ }
+ if ( TransactionSynchronizationManager.isActualTransactionActive() ) {
+ this.appScopedEntityManager.joinTransaction();
+ }
+ return new JpaPersistenceContext( this.appScopedEntityManager );
+ }
+
+ public PersistenceContext getCommandScopedPersistenceContext() {
+ return new JpaPersistenceContext( (EntityManager) this.env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER ) );
+ }
+
+ public void beginCommandScopedEntityManager() {
+ EntityManager cmdScopedEntityManager = (EntityManager) env.get( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER );
+ if ( cmdScopedEntityManager == null || !cmdScopedEntityManager.isOpen() ) {
+ EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager.getResource( "cmdEM" );
+ EntityManager em = null;
+ if ( emHolder == null ) {
+ em = this.emf.createEntityManager();
+ emHolder = new EntityManagerHolder( em );
+ TransactionSynchronizationManager.bindResource( "cmdEM",
+ emHolder );
+ } else {
+ em = emHolder.getEntityManager();
+ }
+ this.env.set( EnvironmentName.CMD_SCOPED_ENTITY_MANAGER,
+ em );
+ }
+
+ this.getCommandScopedPersistenceContext().joinTransaction();
+ this.appScopedEntityManager.joinTransaction();
+
+ }
+
+ public void endCommandScopedEntityManager() {
+ if ( TransactionSynchronizationManager.hasResource( "cmdEM" ) ) {
+ TransactionSynchronizationManager.unbindResource( "cmdEM" );
+ if ( getCommandScopedPersistenceContext() != null ) {
+ getCommandScopedPersistenceContext().close();
+ }
+
+ }
+ }
+
+ public void dispose() {
+ logger.trace( "Disposing DroolsSpringJpaManager" );
+ if ( internalAppScopedEntityManager ) {
+ //TransactionSynchronizationManager.unbindResource( "appEM" );
+ TransactionSynchronizationManager.unbindResource( this.emf );
+ if ( this.appScopedEntityManager != null && this.appScopedEntityManager.isOpen() ) {
+ this.appScopedEntityManager.close();
+ this.internalAppScopedEntityManager = false;
+ this.env.set( EnvironmentName.APP_SCOPED_ENTITY_MANAGER,
+ null );
+ this.appScopedEntityManager = null;
+ }
+ this.endCommandScopedEntityManager();
+ }
+ }
+
+ public ProcessPersistenceContext getProcessPersistenceContext() {
+ return new JpaProcessPersistenceContext( appScopedEntityManager );
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringTransactionManager.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringTransactionManager.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/DroolsSpringTransactionManager.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,126 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import org.drools.persistence.TransactionManager;
+import org.drools.persistence.TransactionSynchronization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.AbstractPlatformTransactionManager;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+/**
+ *
+ * @author Mark Proctor
+ * @author Esteban Aliverti
+ */
+public class DroolsSpringTransactionManager
+ implements
+ TransactionManager {
+
+ Logger logger = LoggerFactory.getLogger( getClass() );
+ private AbstractPlatformTransactionManager ptm;
+
+ TransactionDefinition td = new DefaultTransactionDefinition();
+ TransactionStatus currentTransaction = null;
+
+ public DroolsSpringTransactionManager(AbstractPlatformTransactionManager ptm) {
+ this.ptm = ptm;
+ }
+
+ private boolean localTransaction;
+
+ public void begin() {
+ if ( getStatus() == TransactionManager.STATUS_NO_TRANSACTION ) {
+ // If there is no transaction then start one, we will commit within the same Command
+ // it seems in spring calling getTransaction is enough to begin a new transaction
+ currentTransaction = this.ptm.getTransaction( td );
+ localTransaction = true;
+ } else {
+ localTransaction = false;
+ }
+ }
+
+ public void commit() {
+ if ( this.localTransaction ) {
+ // if we didn't begin this transaction, then do nothing
+ this.localTransaction = false;
+ this.ptm.commit( currentTransaction );
+ currentTransaction = null;
+ }
+ }
+
+ public void rollback() {
+ if ( this.localTransaction ) {
+ this.localTransaction = false;
+ this.ptm.rollback( currentTransaction );
+ currentTransaction = null;
+ }
+ }
+
+ /**
+ * Borrowed from Seam
+ * @author Michael Youngstrom
+ */
+ public int getStatus() {
+ if ( ptm == null ) {
+ return TransactionManager.STATUS_NO_TRANSACTION;
+ }
+
+ logger.debug( "Current TX name (According to TransactionSynchronizationManager) : " + TransactionSynchronizationManager.getCurrentTransactionName() );
+ if ( TransactionSynchronizationManager.isActualTransactionActive() ) {
+ TransactionStatus transaction = null;
+ try {
+ if ( currentTransaction == null ) {
+ transaction = ptm.getTransaction( td );
+ if ( transaction.isNewTransaction() ) {
+ return TransactionManager.STATUS_COMMITTED;
+ }
+ } else {
+ transaction = currentTransaction;
+ }
+ logger.debug( "Current TX: " + transaction );
+ // If SynchronizationManager thinks it has an active transaction but
+ // our transaction is a new one
+ // then we must be in the middle of committing
+ if ( transaction.isCompleted() ) {
+ if ( transaction.isRollbackOnly() ) {
+ return TransactionManager.STATUS_ROLLEDBACK;
+ }
+ return TransactionManager.STATUS_COMMITTED;
+ } else {
+ if ( transaction.isRollbackOnly() ) {
+ return TransactionManager.STATUS_ROLLEDBACK;
+ }
+ return TransactionManager.STATUS_ACTIVE;
+ }
+ } finally {
+ if ( currentTransaction == null ) {
+ ptm.commit( transaction );
+ }
+ }
+ }
+ return TransactionManager.STATUS_NO_TRANSACTION;
+ }
+
+ public void registerTransactionSynchronization(TransactionSynchronization ts) {
+ TransactionSynchronizationManager.registerSynchronization( new SpringTransactionSynchronizationAdapter( ts ) );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/SpringTransactionSynchronizationAdapter.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/SpringTransactionSynchronizationAdapter.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/beans/persistence/SpringTransactionSynchronizationAdapter.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import org.drools.persistence.TransactionManager;
+import org.springframework.transaction.support.TransactionSynchronization;
+
+public class SpringTransactionSynchronizationAdapter
+ implements
+ TransactionSynchronization {
+ private org.drools.persistence.TransactionSynchronization ts;
+
+ public SpringTransactionSynchronizationAdapter(org.drools.persistence.TransactionSynchronization ts) {
+ this.ts = ts;
+ }
+
+ public void afterCommit() {
+ }
+
+ public void afterCompletion(int status) {
+ switch ( status ) {
+ case TransactionSynchronization.STATUS_COMMITTED : {
+ this.ts.afterCompletion( TransactionManager.STATUS_COMMITTED );
+ break;
+ }
+ case TransactionSynchronization.STATUS_ROLLED_BACK : {
+ this.ts.afterCompletion( TransactionManager.STATUS_ROLLEDBACK );
+ break;
+ }
+ default : {
+ this.ts.afterCompletion( TransactionManager.STATUS_UNKNOWN );
+ }
+ }
+ }
+
+ public void beforeCommit(boolean readOnly) {
+ }
+
+ public void beforeCompletion() {
+ this.ts.beforeCompletion();
+ }
+
+ public void resume() {
+ }
+
+ public void suspend() {
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/DefinitionParserHelper.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/DefinitionParserHelper.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/DefinitionParserHelper.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+public class DefinitionParserHelper {
+
+ public static void emptyAttributeCheck(final String element,
+ final String attributeName,
+ final String attribute) {
+ if ( attribute == null || attribute.trim().length() == 0 ) {
+ throw new IllegalArgumentException( "<" + element + "> requires a '" + attributeName + "' attribute" );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,182 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.container.spring.beans.GridBeanFactory;
+import org.drools.container.spring.beans.GridBeanFactory.SocketServiceConfiguration;
+import org.drools.grid.io.AcceptorFactoryService;
+import org.drools.grid.remote.mina.MinaAcceptorFactoryService;
+import org.drools.grid.service.directory.impl.JpaWhitePages;
+import org.drools.grid.service.directory.impl.WhitePagesImpl;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class GridDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String EMF_ATTRIBUTE = "entity-manager-factory";
+
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( GridBeanFactory.class );
+
+ String id = element.getAttribute( "id" );
+ factory.addPropertyValue( "id",
+ id );
+
+ for ( int i = 0, length = element.getChildNodes().getLength(); i < length; i++ ) {
+ Node n = element.getChildNodes().item( i );
+ if ( n instanceof Element ) {
+ Element e = (Element) n;
+
+ if ( "core-services".equals( e.getLocalName() ) ) {
+ String ref = e.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( e.getChildNodes() );
+
+ if ( StringUtils.hasText( ref ) ) {
+ factory.addPropertyReference( "coreServices",
+ ref );
+ } else if ( nestedElm != null ) {
+ factory.addPropertyValue( "coreServices",
+ parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ throw new IllegalArgumentException( "set-global must either specify a 'ref' attribute or have a nested bean" );
+ }
+ } else if ( "whitepages".equals( e.getLocalName() ) ) {
+ Element persistenceElm = DomUtils.getChildElementByTagName( e,
+ "jpa-persistence" );
+ if ( persistenceElm != null ) {
+ BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( JpaWhitePages.class );
+
+ Element emf = DomUtils.getChildElementByTagName( persistenceElm,
+ EMF_ATTRIBUTE );
+ String ref = emf.getAttribute( "ref" );
+
+ beanBuilder.addConstructorArgReference( ref );
+ factory.addPropertyValue( "whitePages",
+ beanBuilder.getBeanDefinition() );
+ } else {
+ String ref = e.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( e.getChildNodes() );
+
+ if ( StringUtils.hasText( ref ) ) {
+ factory.addPropertyReference( "whitePages",
+ ref );
+ } else if ( nestedElm != null ) {
+ factory.addPropertyValue( "whitePages",
+ parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ factory.addPropertyValue( "whitePages",
+ new WhitePagesImpl() );
+ }
+ }
+ } else if ( "socket-service".equals( e.getLocalName() ) ) {
+ String acceptor = e.getAttribute( "acceptor" );
+ String ip = e.getAttribute( "ip" );
+
+ AcceptorFactoryService acc = null;
+ if ( StringUtils.hasText( acceptor ) ) {
+ if ( "mina".equals( acceptor ) ) {
+ acc = new MinaAcceptorFactoryService();
+ }
+ }
+
+ if ( acc == null ) {
+ acc = new MinaAcceptorFactoryService();
+ }
+
+ if ( !StringUtils.hasText( ip ) ) {
+ try {
+ ip = InetAddress.getLocalHost().getHostAddress();
+ } catch ( UnknownHostException e1 ) {
+ throw new RuntimeException( "socket-service did not specify an ip address and one could not be determined",
+ e1 );
+ }
+ }
+
+ if ( !StringUtils.hasText( ip ) ) {
+ throw new RuntimeException( "socket-service did not specify an ip address and one could not be determined" );
+ }
+
+ BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( SocketServiceConfiguration.class );
+ beanBuilder.addPropertyValue( "ip",
+ ip );
+ beanBuilder.addPropertyValue( "acceptor",
+ acceptor );
+
+ //e.getChildNodes()
+ List<String[]> services = new ArrayList<String[]>();
+ for ( int j = 0, serviceLength = e.getChildNodes().getLength(); j < serviceLength; j++ ) {
+ Node e2 = e.getChildNodes().item( j );
+ if ( e2 instanceof Element && "service".equals( ((Element) e2).getLocalName() ) ) {
+ Element se = (Element) e2;
+ String name = se.getAttribute( "name" );
+ String port = se.getAttribute( "port" );
+ services.add( new String[]{name, port} );
+ }
+ }
+ beanBuilder.addPropertyValue( "services",
+ services );
+ factory.addPropertyValue( "socketServiceConfiguration",
+ beanBuilder.getBeanDefinition() );
+ }
+
+ }
+ }
+
+ return factory.getBeanDefinition();
+ }
+
+ public void emptyAttributeCheck(final String element,
+ final String attributeName,
+ final String attribute) {
+ if ( attribute == null || attribute.trim().length() == 0 ) {
+ throw new IllegalArgumentException( "<" + element + "> requires a '" + attributeName + "' attribute" );
+ }
+ }
+
+ private Element getFirstElement(NodeList list) {
+ for ( int j = 0, lengthj = list.getLength(); j < lengthj; j++ ) {
+ if ( list.item( j ) instanceof Element ) {
+ return (Element) list.item( j );
+ }
+ }
+ return null;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridNodeDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridNodeDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/GridNodeDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,70 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import org.drools.container.spring.beans.GridNodeBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class GridNodeDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String GRID_ATTRIBUTE = "grid";
+ private static final String PORT_ATTRIBUTE = "port";
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( GridNodeBeanFactory.class );
+
+ String id = element.getAttribute( "id" );
+ factory.addPropertyValue( "id",
+ id );
+
+ String connectionRef = element.getAttribute( GRID_ATTRIBUTE );
+ if ( StringUtils.hasText( connectionRef ) ) {
+ factory.addPropertyReference( GRID_ATTRIBUTE,
+ connectionRef );
+ }
+
+ for ( int i = 0, length = element.getChildNodes().getLength(); i < length; i++ ) {
+ Node n = element.getChildNodes().item( i );
+ if ( n instanceof Element ) {
+ Element e = (Element) n;
+
+ if ( "socket-service".equals( e.getLocalName() ) ) {
+ String port = e.getAttribute( PORT_ATTRIBUTE );
+ if ( StringUtils.hasText( port ) ) {
+ factory.addPropertyValue( "port",
+ port );
+ }
+ }
+ }
+ }
+ return factory.getBeanDefinition();
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeAgentDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeAgentDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeAgentDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,90 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import static org.drools.container.spring.namespace.DefinitionParserHelper.emptyAttributeCheck;
+
+import org.drools.container.spring.beans.KnowledgeAgentBeanFactory;
+import org.drools.container.spring.beans.StatelessKnowledgeSessionBeanFactory;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class KnowledgeAgentDefinitionParser extends AbstractBeanDefinitionParser {
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( KnowledgeAgentBeanFactory.class );
+
+ String id = element.getAttribute( "id" );
+ emptyAttributeCheck( element.getLocalName(),
+ "id",
+ id );
+ factory.addPropertyValue( "id",
+ id );
+
+ String kbase = element.getAttribute( "kbase" );
+ if ( StringUtils.hasText( kbase ) ) {
+ factory.addPropertyReference( "kbase",
+ kbase );
+ }
+
+ String newInstance = element.getAttribute( "new-instance" );
+ if ( StringUtils.hasText( newInstance ) ) {
+ factory.addPropertyValue( "newInstance",
+ newInstance );
+ }
+
+ ManagedList resources = KnowledgeBaseDefinitionParser.getResources( element,
+ parserContext,
+ factory );
+
+ if ( resources != null ) {
+ factory.addPropertyValue( "resources",
+ resources );
+ }
+
+ // inject the kagent into any stateless sessions
+ for ( String beanName : parserContext.getRegistry().getBeanDefinitionNames() ) {
+ BeanDefinition def = parserContext.getRegistry().getBeanDefinition( beanName );
+ if ( StatelessKnowledgeSessionBeanFactory.class.getName().equals( def.getBeanClassName() ) ) {
+ PropertyValue pvalue = def.getPropertyValues().getPropertyValue( "kbase" );
+ RuntimeBeanReference tbf = (RuntimeBeanReference) pvalue.getValue();
+ if ( kbase.equals( tbf.getBeanName() ) ) {
+ def.getPropertyValues().addPropertyValue( "knowledgeAgent",
+ new RuntimeBeanReference( id ) );
+ }
+ }
+ }
+
+ return factory.getBeanDefinition();
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeBaseDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeBaseDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeBaseDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,196 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import java.util.List;
+
+import org.drools.RuleBaseConfiguration;
+import org.drools.RuleBaseConfiguration.AssertBehaviour;
+import org.drools.conf.EventProcessingOption;
+import org.drools.container.spring.beans.KnowledgeBaseBeanFactory;
+import org.drools.core.util.StringUtils;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+public class KnowledgeBaseDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String EXECUTION_NODE_ATTRIBUTE = "node";
+
+ private static final String ADVANCED_PROCESS_RULE_INTEGRATED = "advanced-process-rule-integration";
+
+ private static final String MULTITHREADS = "multithread";
+ private static final String MAX_THREADS = "max-threads";
+
+ private static final String MBEABS = "mbeans";
+
+ private static final String EVENT_PROCESSING_MODE = "event-processing-mode";
+
+ private static final String ASSERT_BEHAVIOR = "assert-behavior";
+
+ private static final String ACCUMULATE_FUNCTIONS = "accumulate-functions";
+
+ private static final String ACCUMULATE_FUNCTION = "accumulate-function";
+
+ private static final String EVALUATORS = "evaluators";
+
+ private static final String EVALUATOR = "evaluator";
+
+ private static final String CONSEQUENCE_EXCEPTION_HANDLER = "consequenceExceptionHandler";
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( KnowledgeBaseBeanFactory.class );
+
+ Element kbaseConf = DomUtils.getChildElementByTagName( element,
+ "configuration" );
+ if ( kbaseConf != null ) {
+ BeanDefinitionBuilder rbaseConfBuilder = BeanDefinitionBuilder.rootBeanDefinition( RuleBaseConfiguration.class );
+ Element e = DomUtils.getChildElementByTagName( kbaseConf,
+ ADVANCED_PROCESS_RULE_INTEGRATED );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "enabled" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "advancedProcessRuleIntegration",
+ Boolean.parseBoolean( e.getAttribute( "enabled" ) ) );
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ MULTITHREADS );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "enabled" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "multithreadEvaluation",
+ Boolean.parseBoolean( e.getAttribute( "enabled" ) ) );
+ if ( !StringUtils.isEmpty( e.getAttribute( MAX_THREADS ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "maxThreads",
+ Integer.parseInt( e.getAttribute( MAX_THREADS ) ) );
+ }
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ MBEABS );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "enabled" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "MBeansEnabled",
+ Boolean.parseBoolean( e.getAttribute( "enabled" ) ) );
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ EVENT_PROCESSING_MODE );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "mode" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "eventProcessingMode",
+ EventProcessingOption.valueOf( e.getAttribute( "mode" ) ) );
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ ASSERT_BEHAVIOR );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "mode" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "assertBehaviour",
+ AssertBehaviour.determineAssertBehaviour( e.getAttribute( "mode" ) ) );
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ ACCUMULATE_FUNCTIONS );
+ if ( e != null ) {
+ List<Element> children = DomUtils.getChildElementsByTagName( e,
+ ACCUMULATE_FUNCTION );
+ if ( children != null && !children.isEmpty() ) {
+ ManagedMap functions = new ManagedMap();
+ for ( Element child : children ) {
+ functions.put( child.getAttribute( "name" ),
+ new RuntimeBeanReference( child.getAttribute( "ref" ) ) );
+ }
+ factory.addPropertyValue( "accumulateFunctions",
+ functions );
+ }
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ EVALUATORS );
+ if ( e != null ) {
+ List<Element> children = DomUtils.getChildElementsByTagName( e,
+ EVALUATOR );
+ if ( children != null && !children.isEmpty() ) {
+ ManagedMap evaluators = new ManagedMap();
+ for ( Element child : children ) {
+ evaluators.put( child.getAttribute( "name" ),
+ new RuntimeBeanReference( child.getAttribute( "ref" ) ) );
+ }
+ factory.addPropertyValue( "evaluators",
+ evaluators );
+ }
+ }
+
+ e = DomUtils.getChildElementByTagName( kbaseConf,
+ CONSEQUENCE_EXCEPTION_HANDLER );
+ if ( e != null && !StringUtils.isEmpty( e.getAttribute( "handler" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "consequenceExceptionHandler",
+ e.getAttribute( "handler" ) );
+ }
+
+ factory.addPropertyValue( "conf",
+ rbaseConfBuilder.getBeanDefinition() );
+ }
+
+ String nodeRef = element.getAttribute( EXECUTION_NODE_ATTRIBUTE );
+ if ( nodeRef != null && nodeRef.length() > 0 ) {
+ factory.addPropertyReference( EXECUTION_NODE_ATTRIBUTE,
+ nodeRef );
+ }
+
+ ManagedList resources = getResources( element,
+ parserContext,
+ factory );
+
+ if ( resources != null ) {
+ factory.addPropertyValue( "resources",
+ resources );
+ }
+
+ return factory.getBeanDefinition();
+ }
+
+ @SuppressWarnings("unchecked")
+ public static ManagedList getResources(Element element,
+ ParserContext parserContext,
+ BeanDefinitionBuilder factory) {
+ Element resourcesElm = DomUtils.getChildElementByTagName( element,
+ "resources" );
+ ManagedList resources = null;
+
+ if ( resourcesElm != null ) {
+ List<Element> childElements = DomUtils.getChildElementsByTagName( resourcesElm,
+ "resource" );
+ if ( childElements != null && !childElements.isEmpty() ) {
+ resources = new ManagedList();
+ for ( Element childResource : childElements ) {
+ BeanDefinition resourceDefinition = parserContext.getDelegate().parseCustomElement( childResource,
+ factory.getBeanDefinition() );
+ resources.add( resourceDefinition );
+ }
+ }
+
+ }
+ return resources;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeSessionDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeSessionDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeSessionDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,343 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import static org.drools.container.spring.namespace.DefinitionParserHelper.emptyAttributeCheck;
+
+import java.util.List;
+
+import org.drools.ClockType;
+import org.drools.SessionConfiguration;
+import org.drools.command.runtime.SetGlobalCommand;
+import org.drools.command.runtime.process.SignalEventCommand;
+import org.drools.command.runtime.process.StartProcessCommand;
+import org.drools.command.runtime.rule.FireAllRulesCommand;
+import org.drools.command.runtime.rule.FireUntilHaltCommand;
+import org.drools.command.runtime.rule.InsertObjectCommand;
+import org.drools.container.spring.beans.KnowledgeAgentBeanFactory;
+import org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory;
+import org.drools.container.spring.beans.StatefulKnowledgeSessionBeanFactory.JpaConfiguration;
+import org.drools.container.spring.beans.StatelessKnowledgeSessionBeanFactory;
+import org.springframework.beans.PropertyValue;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.ManagedMap;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class KnowledgeSessionDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String KBASE_ATTRIBUTE = "kbase";
+ private static final String EMF_ATTRIBUTE = "entity-manager-factory";
+ private static final String TX_MANAGER_ATTRIBUTE = "transaction-manager";
+ private static final String FORCLASS_ATTRIBUTE = "for-class";
+ private static final String IMPLEMENTATION_ATTRIBUTE = "implementation";
+
+ private static final String NAME_ATTRIBUTE = "name";
+ private static final String GRID_NODE_ATTRIBUTE = "node";
+ private static final String TYPE_ATTRIBUTE = "type";
+
+ private static final String KEEP_REFERENCE = "keep-reference";
+ private static final String CLOCK_TYPE = "clock-type";
+
+ private static final String WORK_ITEMS = "work-item-handlers";
+
+ private static final String WORK_ITEM = "work-item-handler";
+
+ @SuppressWarnings("unchecked")
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+
+ String id = element.getAttribute( "id" );
+ emptyAttributeCheck( element.getLocalName(),
+ "id",
+ id );
+
+ String kbase = element.getAttribute( KBASE_ATTRIBUTE );
+ emptyAttributeCheck( element.getLocalName(),
+ KBASE_ATTRIBUTE,
+ kbase );
+
+ String sessionType = element.getAttribute( TYPE_ATTRIBUTE );
+ BeanDefinitionBuilder factory;
+
+ if ( "stateful".equals( sessionType ) ) {
+ factory = BeanDefinitionBuilder.rootBeanDefinition( StatefulKnowledgeSessionBeanFactory.class );
+ } else if ( "stateless".equals( sessionType ) ) {
+ factory = BeanDefinitionBuilder.rootBeanDefinition( StatelessKnowledgeSessionBeanFactory.class );
+ } else {
+ throw new IllegalArgumentException( "Invalid value for " + TYPE_ATTRIBUTE + " attribute: " + sessionType );
+ }
+
+ factory.addPropertyReference( "kbase",
+ kbase );
+
+ String node = element.getAttribute( GRID_NODE_ATTRIBUTE );
+ if ( node != null && node.length() > 0 ) {
+ factory.addPropertyReference( "node",
+ node );
+ }
+
+ String name = element.getAttribute( NAME_ATTRIBUTE );
+ if ( StringUtils.hasText( name ) ) {
+ factory.addPropertyValue( "name",
+ name );
+ } else {
+ factory.addPropertyValue( "name",
+ id );
+ }
+
+ Element ksessionConf = DomUtils.getChildElementByTagName( element,
+ "configuration" );
+ if ( ksessionConf != null ) {
+ Element persistenceElm = DomUtils.getChildElementByTagName( ksessionConf,
+ "jpa-persistence" );
+ if ( persistenceElm != null ) {
+ BeanDefinitionBuilder beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( JpaConfiguration.class );
+
+ String loadId = persistenceElm.getAttribute( "load" );
+ if ( StringUtils.hasText( loadId ) ) {
+ beanBuilder.addPropertyValue( "id",
+ Long.parseLong( loadId ) );
+ }
+
+ Element tnxMng = DomUtils.getChildElementByTagName( persistenceElm,
+ TX_MANAGER_ATTRIBUTE );
+ String ref = tnxMng.getAttribute( "ref" );
+
+ beanBuilder.addPropertyReference( "platformTransactionManager",
+ ref );
+
+ Element emf = DomUtils.getChildElementByTagName( persistenceElm,
+ EMF_ATTRIBUTE );
+ ref = emf.getAttribute( "ref" );
+ beanBuilder.addPropertyReference( "entityManagerFactory",
+ ref );
+
+ Element variablePersisters = DomUtils.getChildElementByTagName( persistenceElm,
+ "variable-persisters" );
+ if ( variablePersisters != null && variablePersisters.hasChildNodes() ) {
+ List<Element> childPersisterElems = DomUtils.getChildElementsByTagName( variablePersisters,
+ "persister" );
+ ManagedMap persistors = new ManagedMap( childPersisterElems.size() );
+ for ( Element persisterElem : childPersisterElems ) {
+ String forClass = persisterElem.getAttribute( FORCLASS_ATTRIBUTE );
+ String implementation = persisterElem.getAttribute( IMPLEMENTATION_ATTRIBUTE );
+ if ( !StringUtils.hasText( forClass ) ) {
+ throw new RuntimeException( "persister element must have valid for-class attribute" );
+ }
+ if ( !StringUtils.hasText( implementation ) ) {
+ throw new RuntimeException( "persister element must have valid implementation attribute" );
+ }
+ persistors.put( forClass,
+ implementation );
+ }
+ beanBuilder.addPropertyValue( "variablePersisters",
+ persistors );
+ }
+
+ factory.addPropertyValue( "jpaConfiguration",
+ beanBuilder.getBeanDefinition() );
+ }
+ BeanDefinitionBuilder rbaseConfBuilder = BeanDefinitionBuilder.rootBeanDefinition( SessionConfiguration.class );
+ Element e = DomUtils.getChildElementByTagName( ksessionConf,
+ KEEP_REFERENCE );
+ if ( e != null && StringUtils.hasText( e.getAttribute( "enabled" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "keepReference",
+ Boolean.parseBoolean( e.getAttribute( "enabled" ) ) );
+ }
+
+ e = DomUtils.getChildElementByTagName( ksessionConf,
+ CLOCK_TYPE );
+ if ( e != null && StringUtils.hasText( e.getAttribute( "type" ) ) ) {
+ rbaseConfBuilder.addPropertyValue( "clockType",
+ ClockType.resolveClockType( e.getAttribute( "type" ) ) );
+ }
+ factory.addPropertyValue( "conf",
+ rbaseConfBuilder.getBeanDefinition() );
+
+ e = DomUtils.getChildElementByTagName( ksessionConf,
+ WORK_ITEMS );
+ if ( e != null ) {
+ List<Element> children = DomUtils.getChildElementsByTagName( e,
+ WORK_ITEM );
+ if ( children != null && !children.isEmpty() ) {
+ ManagedMap workDefs = new ManagedMap();
+ for ( Element child : children ) {
+ workDefs.put( child.getAttribute( "name" ),
+ new RuntimeBeanReference( child.getAttribute( "ref" ) ) );
+ }
+ factory.addPropertyValue( "workItems",
+ workDefs );
+ }
+ }
+ }
+
+ Element batch = DomUtils.getChildElementByTagName( element,
+ "batch" );
+ if ( batch == null ) {
+ // just temporary legacy suppport
+ batch = DomUtils.getChildElementByTagName( element,
+ "script" );
+ }
+ if ( batch != null ) {
+ // we know there can only ever be one
+ ManagedList children = new ManagedList();
+
+ for ( int i = 0, length = batch.getChildNodes().getLength(); i < length; i++ ) {
+ Node n = batch.getChildNodes().item( i );
+ if ( n instanceof Element ) {
+ Element e = (Element) n;
+
+ BeanDefinitionBuilder beanBuilder = null;
+ if ( "insert-object".equals( e.getLocalName() ) ) {
+ String ref = e.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( e.getChildNodes() );
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( InsertObjectCommand.class );
+ if ( StringUtils.hasText( ref ) ) {
+ beanBuilder.addConstructorArgReference( ref );
+ } else if ( nestedElm != null ) {
+ beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ throw new IllegalArgumentException( "insert-object must either specify a 'ref' attribute or have a nested bean" );
+ }
+ } else if ( "set-global".equals( e.getLocalName() ) ) {
+ String ref = e.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( e.getChildNodes() );
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( SetGlobalCommand.class );
+ beanBuilder.addConstructorArgValue( e.getAttribute( "identifier" ) );
+ if ( StringUtils.hasText( ref ) ) {
+ beanBuilder.addConstructorArgReference( ref );
+ } else if ( nestedElm != null ) {
+ beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ throw new IllegalArgumentException( "set-global must either specify a 'ref' attribute or have a nested bean" );
+ }
+ } else if ( "fire-until-halt".equals( e.getLocalName() ) ) {
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( FireUntilHaltCommand.class );
+ } else if ( "fire-all-rules".equals( e.getLocalName() ) ) {
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( FireAllRulesCommand.class );
+ String max = e.getAttribute( "max" );
+ if ( StringUtils.hasText( max ) ) {
+ beanBuilder.addPropertyValue( "max",
+ max );
+ }
+ } else if ( "start-process".equals( e.getLocalName() ) ) {
+
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( StartProcessCommand.class );
+ String processId = e.getAttribute( "process-id" );
+ if ( !StringUtils.hasText( processId ) ) {
+ throw new IllegalArgumentException( "start-process must specify a process-id" );
+ }
+ beanBuilder.addConstructorArgValue( processId );
+
+ List<Element> params = DomUtils.getChildElementsByTagName( e,
+ "parameter" );
+ if ( !params.isEmpty() ) {
+ ManagedMap map = new ManagedMap();
+ for ( Element param : params ) {
+ String identifier = param.getAttribute( "identifier" );
+ if ( !StringUtils.hasText( identifier ) ) {
+ throw new IllegalArgumentException( "start-process paramaters must specify an identifier" );
+ }
+
+ String ref = param.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( param.getChildNodes() );
+ if ( StringUtils.hasText( ref ) ) {
+ map.put( identifier,
+ new RuntimeBeanReference( ref ) );
+ } else if ( nestedElm != null ) {
+ map.put( identifier,
+ parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ throw new IllegalArgumentException( "start-process paramaters must either specify a 'ref' attribute or have a nested bean" );
+ }
+ }
+ beanBuilder.addPropertyValue( "parameters",
+ map );
+ }
+ } else if ( "signal-event".equals( e.getLocalName() ) ) {
+ beanBuilder = BeanDefinitionBuilder.genericBeanDefinition( SignalEventCommand.class );
+ String processInstanceId = e.getAttribute( "process-instance-id" );
+ if ( StringUtils.hasText( processInstanceId ) ) {
+ beanBuilder.addConstructorArgValue( processInstanceId );
+ }
+
+ beanBuilder.addConstructorArgValue( e.getAttribute( "event-type" ) );
+
+ String ref = e.getAttribute( "ref" );
+ Element nestedElm = getFirstElement( e.getChildNodes() );
+ if ( StringUtils.hasText( ref ) ) {
+ beanBuilder.addConstructorArgReference( ref );
+ } else if ( nestedElm != null ) {
+ beanBuilder.addConstructorArgValue( parserContext.getDelegate().parsePropertySubElement( nestedElm,
+ null,
+ null ) );
+ } else {
+ throw new IllegalArgumentException( "signal-event must either specify a 'ref' attribute or have a nested bean" );
+ }
+ }
+ if ( beanBuilder == null ) {
+ throw new IllegalStateException( "Unknow element: " + e.getLocalName() );
+ }
+ children.add( beanBuilder.getBeanDefinition() );
+ }
+ }
+ factory.addPropertyValue( "batch",
+ children );
+ }
+
+ // find any kagent's for the current kbase and assign
+ for ( String beanName : parserContext.getRegistry().getBeanDefinitionNames() ) {
+ BeanDefinition def = parserContext.getRegistry().getBeanDefinition( beanName );
+ if ( KnowledgeAgentBeanFactory.class.getName().equals( def.getBeanClassName() ) ) {
+ PropertyValue pvalue = def.getPropertyValues().getPropertyValue( "kbase" );
+ RuntimeBeanReference tbf = (RuntimeBeanReference) pvalue.getValue();
+ if ( kbase.equals( tbf.getBeanName() ) ) {
+ factory.addPropertyValue( "knowledgeAgent",
+ new RuntimeBeanReference( beanName ) );
+ }
+ }
+ }
+
+ return factory.getBeanDefinition();
+ }
+
+ private Element getFirstElement(NodeList list) {
+ for ( int j = 0, lengthj = list.getLength(); j < lengthj; j++ ) {
+ if ( list.item( j ) instanceof Element ) {
+ return (Element) list.item( j );
+ }
+ }
+ return null;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeStoreDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeStoreDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/KnowledgeStoreDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import org.drools.container.spring.beans.KnowledgeStoreBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+public class KnowledgeStoreDefinitionParser extends AbstractBeanDefinitionParser {
+
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( KnowledgeStoreBeanFactory.class );
+
+ return factory.getBeanDefinition();
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceChangeScannerDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceChangeScannerDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceChangeScannerDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import org.drools.container.spring.beans.ResourceChangeScannerBeanFactory;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ *
+ * @author Lucas Amador
+ *
+ */
+public class ResourceChangeScannerDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String INTERVAL = "interval";
+
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( ResourceChangeScannerBeanFactory.class );
+
+ factory.addPropertyValue( INTERVAL,
+ element.getAttribute( INTERVAL ) );
+
+ return factory.getBeanDefinition();
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceDefinitionParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceDefinitionParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/ResourceDefinitionParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,124 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import java.util.List;
+
+import org.drools.builder.DecisionTableInputType;
+import org.drools.builder.ResourceType;
+import org.drools.builder.conf.impl.DecisionTableConfigurationImpl;
+import org.drools.container.spring.beans.DroolsResourceAdapter;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.StringUtils;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+public class ResourceDefinitionParser extends AbstractBeanDefinitionParser {
+
+ private static final String WORKSHEET_NAME_ATTRIBUTE = "worksheet-name";
+ private static final String INPUT_TYPE_ATTRIBUTE = "input-type";
+ private static final String TYPE_ATTRIBUTE = "type";
+ private static final String SOURCE_ATTRIBUTE = "source";
+ private static final String BASIC_AUTHENTICATION_ATTRIBUTE = "basic-authentication";
+ private static final String USERNAME_ATTRIBUTE = "username";
+ private static final String PASSWORD_ATTRIBUTE = "password";
+ private static final String REF = "ref";
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected AbstractBeanDefinition parseInternal(Element element,
+ ParserContext parserContext) {
+ BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition( DroolsResourceAdapter.class );
+
+ if ( StringUtils.hasText( element.getAttribute( REF ) ) ) {
+ String ref = element.getAttribute( REF );
+ emptyAttributeCheck( element.getLocalName(),
+ REF,
+ ref );
+ return (AbstractBeanDefinition) parserContext.getRegistry().getBeanDefinition( ref );
+ }
+
+ String source = element.getAttribute( SOURCE_ATTRIBUTE );
+ emptyAttributeCheck( element.getLocalName(),
+ SOURCE_ATTRIBUTE,
+ source );
+ factory.addPropertyValue( "resource",
+ source );
+
+ String type = element.getAttribute( TYPE_ATTRIBUTE );
+
+ String resourceType = type == null || type.length() == 0 ? ResourceType.DRL.getName() : type;
+
+ factory.addPropertyValue( "resourceType",
+ resourceType );
+
+ boolean basicAuthenticationEnabled = element.getAttribute( BASIC_AUTHENTICATION_ATTRIBUTE ) != null && element.getAttribute( BASIC_AUTHENTICATION_ATTRIBUTE ).equalsIgnoreCase( "enabled" );
+ factory.addPropertyValue( "basicAuthenticationEnabled",
+ basicAuthenticationEnabled );
+
+ if ( basicAuthenticationEnabled ) {
+ String username = element.getAttribute( USERNAME_ATTRIBUTE );
+ factory.addPropertyValue( "basicAuthenticationUsername",
+ username );
+
+ String password = element.getAttribute( PASSWORD_ATTRIBUTE );
+ factory.addPropertyValue( "basicAuthenticationPassword",
+ password );
+ }
+
+ if ( "xsd".equals( resourceType.toLowerCase() ) ) {
+ XsdParser.parse( element,
+ parserContext,
+ factory );
+ } else if ( "dtable".equals( resourceType.toLowerCase() ) ) {
+ List<Element> childElements = DomUtils.getChildElementsByTagName( element,
+ "decisiontable-conf" );
+ if ( !childElements.isEmpty() ) {
+ Element conf = childElements.get( 0 );
+ DecisionTableConfigurationImpl dtableConf = new DecisionTableConfigurationImpl();
+
+ String inputType = conf.getAttribute( INPUT_TYPE_ATTRIBUTE );
+ emptyAttributeCheck( conf.getLocalName(),
+ INPUT_TYPE_ATTRIBUTE,
+ inputType );
+ dtableConf.setInputType( DecisionTableInputType.valueOf( inputType ) );
+
+ String worksheetName = conf.getAttribute( WORKSHEET_NAME_ATTRIBUTE );
+ emptyAttributeCheck( conf.getLocalName(),
+ WORKSHEET_NAME_ATTRIBUTE,
+ worksheetName );
+ dtableConf.setWorksheetName( worksheetName );
+
+ factory.addPropertyValue( "resourceConfiguration",
+ dtableConf );
+ }
+ }
+
+ return factory.getBeanDefinition();
+ }
+
+ public void emptyAttributeCheck(final String element,
+ final String attributeName,
+ final String attribute) {
+ if ( attribute == null || attribute.trim().equals( "" ) ) {
+ throw new IllegalArgumentException( "<" + element + "> requires a '" + attributeName + "' attribute" );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/SpringDroolsHandler.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/SpringDroolsHandler.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/SpringDroolsHandler.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+
+public class SpringDroolsHandler extends NamespaceHandlerSupport {
+
+ public void init() {
+
+ registerBeanDefinitionParser( "resource",
+ new ResourceDefinitionParser() );
+
+ registerBeanDefinitionParser( "resource-change-scanner",
+ new ResourceChangeScannerDefinitionParser() );
+
+ registerBeanDefinitionParser( "model",
+ new ResourceDefinitionParser() );
+
+ registerBeanDefinitionParser( "kbase",
+ new KnowledgeBaseDefinitionParser() );
+
+ registerBeanDefinitionParser( "kagent",
+ new KnowledgeAgentDefinitionParser() );
+
+ registerBeanDefinitionParser( "kstore",
+ new KnowledgeStoreDefinitionParser() );
+
+ registerBeanDefinitionParser( "ksession",
+ new KnowledgeSessionDefinitionParser() );
+
+ registerBeanDefinitionParser( "grid",
+ new GridDefinitionParser() );
+
+ registerBeanDefinitionParser( "grid-node",
+ new GridNodeDefinitionParser() );
+ }
+
+}
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/XsdParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/XsdParser.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/java/org/drools/container/spring/namespace/XsdParser.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.namespace;
+
+import java.util.List;
+
+import org.drools.builder.JaxbConfiguration;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.util.xml.DomUtils;
+import org.w3c.dom.Element;
+
+import com.sun.tools.xjc.Language;
+import com.sun.tools.xjc.Options;
+
+public class XsdParser {
+ private static final String SYSTEM_ID = "system-id";
+ private static final String SCHEMA_LANGUAGE = "schema-language";
+
+ @SuppressWarnings("unchecked")
+ public static void parse(Element element,
+ ParserContext parserContext,
+ BeanDefinitionBuilder factory) {
+
+ List<Element> childElements = DomUtils.getChildElementsByTagName( element,
+ "jaxb-conf" );
+ if ( !childElements.isEmpty() ) {
+ Element conf = childElements.get( 0 );
+
+ String systemId = conf.getAttribute( SYSTEM_ID );
+ systemId = (systemId != null && systemId.trim().length() > 0) ? systemId : "xsd";
+
+ String schemaLanguage = conf.getAttribute( SCHEMA_LANGUAGE );
+ schemaLanguage = (schemaLanguage != null && schemaLanguage.trim().length() > 0) ? schemaLanguage : "XMLSCHEMA";
+
+ Options options = new Options();
+ options.setSchemaLanguage( Language.valueOf( schemaLanguage ) );
+
+ JaxbConfiguration jaxbConf = KnowledgeBuilderFactory.newJaxbConfiguration( new Options(),
+ systemId );
+
+ factory.addPropertyValue( "resourceConfiguration",
+ jaxbConf );
+ } else {
+ JaxbConfiguration jaxbConf = KnowledgeBuilderFactory.newJaxbConfiguration( new Options(),
+ "xsd" );
+
+ factory.addPropertyValue( "resourceConfiguration",
+ jaxbConf );
+ }
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.handlers
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.handlers (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.handlers 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1 @@
+http\://drools.org/schema/drools-spring=org.drools.container.spring.namespace.SpringDroolsHandler
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.schemas
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.schemas (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/META-INF/spring.schemas 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,2 @@
+http\://drools.org/schema/drools-spring.xsd=org/drools/container/spring/drools-spring.xsd
+http\://drools.org/schema/drools-service-spring.xsd=org/drools/container/spring/drools-service-spring.xsd
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,435 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://drools.org/schema/drools-spring"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://drools.org/schema/drools-spring"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:element name="connection">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="type" use="required" type="connectionTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="execution-node">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="connection" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource-change-scanner">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="interval" use="optional" type="xsd:integer"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resources">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="resource" />
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="resourceType">
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="kbase">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="advanced-process-rule-integration" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="multithread" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ <xsd:attribute name="max-threads" type="xsd:positiveInteger"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="mbeans" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="event-processing-mode" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="cloudModeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="assert-behavior" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="assertBehaviorEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="accumulate-functions" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="accumulate-function" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="evaluators" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="evaluator" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="consequenceExceptionHandler" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="handler" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kagent">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="new-instance" use="optional" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kstore" />
+
+ <xsd:element name="ksession">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="batch" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="script" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="persistence" minOccurs="0"/>
+
+ <xsd:element name="keep-reference" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="clock-type" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="type" type="clockTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="work-item-handlers" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="work-item-handler" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+
+ <xsd:attribute name="type" use="required" type="knowledgeSessionTypeEnum"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ <xsd:attribute name="name" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="connectionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="local" />
+ <xsd:enumeration value="remote" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="knowledgeSessionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="stateful" />
+ <xsd:enumeration value="stateless" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="resourceTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DRL" />
+ <xsd:enumeration value="BPMN2" />
+ <xsd:enumeration value="XDRL" />
+ <xsd:enumeration value="DSL" />
+ <xsd:enumeration value="DSLR" />
+ <xsd:enumeration value="DRF" />
+ <xsd:enumeration value="DTABLE" />
+ <xsd:enumeration value="PKG" />
+ <xsd:enumeration value="BRL" />
+ <xsd:enumeration value="CHANGE_SET" />
+ <xsd:enumeration value="XSD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="languageTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DTD" />
+ <xsd:enumeration value="RELAXNG" />
+ <xsd:enumeration value="RELAXNG_COMPACT" />
+ <xsd:enumeration value="WSDL" />
+ <xsd:enumeration value="XMLSCHEMA" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="cloudModeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="STREAM" />
+ <xsd:enumeration value="CLOUD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:simpleType name="assertBehaviorEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="IDENTITY" />
+ <xsd:enumeration value="EQUALITY" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="clockTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="REALTIME" />
+ <xsd:enumeration value="PSEUDO" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="resourceType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element name="decisiontable-conf">
+ <xsd:complexType>
+ <xsd:attribute name="input-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="worksheet-name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="jaxb-conf">
+ <xsd:complexType>
+ <xsd:attribute name="system-id" use="optional" type="xsd:string" />
+ <xsd:attribute name="schema-language" type="languageTypeEnum" use="optional" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ <xsd:attribute name="source" use="optional" type="xsd:string"/>
+ <xsd:attribute name="type" use="optional" type="resourceTypeEnum"/>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="resourceRefType">
+ <xsd:attribute name="id" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="classesType">
+ <xsd:sequence>
+ <xsd:element name="class" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="persisterType">
+ <xsd:attribute name="for-class" use="required" type="xsd:string"/>
+ <xsd:attribute name="implementation" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="variablePersistersType">
+ <xsd:sequence>
+ <xsd:element name="persister" type="persisterType" minOccurs="1" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="jpaSessionServiceFactory">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="variablePersisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="entityManagerFactory" use="required" type="xsd:string"/>
+ <xsd:attribute name="transactionManager" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Persistence -->
+ <xsd:element name="persistence" type="persistenceType" abstract="true"/>
+
+ <xsd:complexType name="persistenceType">
+ </xsd:complexType>
+
+ <xsd:element name="jpa-persistence" substitutionGroup="persistence" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="persistenceType">
+ <xsd:all>
+ <xsd:element name="variable-persisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="transaction-manager" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="entity-manager-factory" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="load" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Commands -->
+ <xsd:element name="command" type="commandType" abstract="true"/>
+
+ <xsd:complexType name="commandType">
+ </xsd:complexType>
+
+ <xsd:element name="insert-object" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set-global" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-all-rules" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:attribute name="max" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-until-halt" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="start-process" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="process-id" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="signal-event" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="event-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="process-instance-id" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.1.0.xsd
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.1.0.xsd (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.1.0.xsd 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,445 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://drools.org/schema/drools-spring"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://drools.org/schema/drools-spring"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:element name="connection">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="type" use="required" type="connectionTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="execution-node">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="connection" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource-change-scanner">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="interval" use="optional" type="xsd:integer"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resources">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="resource" />
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="resourceType">
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="basic-authentication" use="optional" type="enabledDisabledEnum"/>
+ <xsd:attribute name="username" use="optional" type="xsd:string"/>
+ <xsd:attribute name="password" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="kbase">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="advanced-process-rule-integration" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="multithread" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ <xsd:attribute name="max-threads" type="xsd:positiveInteger"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="mbeans" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="event-processing-mode" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="cloudModeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="assert-behavior" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="assertBehaviorEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="accumulate-functions" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="accumulate-function" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="evaluators" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="evaluator" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="consequenceExceptionHandler" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="handler" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kagent">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="new-instance" use="optional" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kstore" />
+
+ <xsd:element name="ksession">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="batch" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="script" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="persistence" minOccurs="0"/>
+
+ <xsd:element name="keep-reference" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="clock-type" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="type" type="clockTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="work-item-handlers" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="work-item-handler" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+
+ <xsd:attribute name="type" use="required" type="knowledgeSessionTypeEnum"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ <xsd:attribute name="name" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="connectionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="local" />
+ <xsd:enumeration value="remote" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="knowledgeSessionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="stateful" />
+ <xsd:enumeration value="stateless" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="resourceTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DRL" />
+ <xsd:enumeration value="BPMN2" />
+ <xsd:enumeration value="XDRL" />
+ <xsd:enumeration value="DSL" />
+ <xsd:enumeration value="DSLR" />
+ <xsd:enumeration value="DRF" />
+ <xsd:enumeration value="DTABLE" />
+ <xsd:enumeration value="PKG" />
+ <xsd:enumeration value="BRL" />
+ <xsd:enumeration value="CHANGE_SET" />
+ <xsd:enumeration value="XSD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="languageTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DTD" />
+ <xsd:enumeration value="RELAXNG" />
+ <xsd:enumeration value="RELAXNG_COMPACT" />
+ <xsd:enumeration value="WSDL" />
+ <xsd:enumeration value="XMLSCHEMA" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="cloudModeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="STREAM" />
+ <xsd:enumeration value="CLOUD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="enabledDisabledEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="enabled" />
+ <xsd:enumeration value="disabled" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:simpleType name="assertBehaviorEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="IDENTITY" />
+ <xsd:enumeration value="EQUALITY" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="clockTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="REALTIME" />
+ <xsd:enumeration value="PSEUDO" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="resourceType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element name="decisiontable-conf">
+ <xsd:complexType>
+ <xsd:attribute name="input-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="worksheet-name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="jaxb-conf">
+ <xsd:complexType>
+ <xsd:attribute name="system-id" use="optional" type="xsd:string" />
+ <xsd:attribute name="schema-language" type="languageTypeEnum" use="optional" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ <xsd:attribute name="source" use="optional" type="xsd:string"/>
+ <xsd:attribute name="type" use="optional" type="resourceTypeEnum"/>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="resourceRefType">
+ <xsd:attribute name="id" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="classesType">
+ <xsd:sequence>
+ <xsd:element name="class" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="persisterType">
+ <xsd:attribute name="for-class" use="required" type="xsd:string"/>
+ <xsd:attribute name="implementation" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="variablePersistersType">
+ <xsd:sequence>
+ <xsd:element name="persister" type="persisterType" minOccurs="1" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="jpaSessionServiceFactory">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="variablePersisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="entityManagerFactory" use="required" type="xsd:string"/>
+ <xsd:attribute name="transactionManager" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Persistence -->
+ <xsd:element name="persistence" type="persistenceType" abstract="true"/>
+
+ <xsd:complexType name="persistenceType">
+ </xsd:complexType>
+
+ <xsd:element name="jpa-persistence" substitutionGroup="persistence" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="persistenceType">
+ <xsd:all>
+ <xsd:element name="variable-persisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="transaction-manager" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="entity-manager-factory" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="load" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Commands -->
+ <xsd:element name="command" type="commandType" abstract="true"/>
+
+ <xsd:complexType name="commandType">
+ </xsd:complexType>
+
+ <xsd:element name="insert-object" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set-global" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-all-rules" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:attribute name="max" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-until-halt" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="start-process" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="process-id" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="signal-event" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="event-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="process-instance-id" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.2.0.xsd
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.2.0.xsd (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.2.0.xsd 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,537 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://drools.org/schema/drools-spring"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:spring="http://www.springframework.org/schema/beans"
+ targetNamespace="http://drools.org/schema/drools-spring"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation=" http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"/>
+
+ <xsd:element name="grid">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="core-services" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="whitepages" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="persistence"/>
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="socket-service" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="service" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="port" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="acceptor" use="optional" type="xsd:string"/>
+ <xsd:attribute name="ip" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="grid-node">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="socket-service" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="port" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="grid" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource-change-scanner">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="interval" use="optional" type="xsd:integer"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resources">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="resource" />
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="resourceType">
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="basic-authentication" use="optional" type="enabledDisabledEnum"/>
+ <xsd:attribute name="username" use="optional" type="xsd:string"/>
+ <xsd:attribute name="password" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="kbase">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="advanced-process-rule-integration" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="multithread" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ <xsd:attribute name="max-threads" type="xsd:positiveInteger"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="mbeans" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="event-processing-mode" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="cloudModeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="assert-behavior" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="assertBehaviorEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="accumulate-functions" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="accumulate-function" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="evaluators" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="evaluator" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="consequenceExceptionHandler" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="handler" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kagent">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="new-instance" use="optional" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kstore" />
+
+ <xsd:element name="ksession">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="batch" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="script" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="persistence" minOccurs="0"/>
+
+ <xsd:element name="keep-reference" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="clock-type" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="type" type="clockTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="work-item-handlers" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="work-item-handler" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+
+ <xsd:attribute name="type" use="required" type="knowledgeSessionTypeEnum"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ <xsd:attribute name="name" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="connectionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="local" />
+ <xsd:enumeration value="remote" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="knowledgeSessionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="stateful" />
+ <xsd:enumeration value="stateless" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="resourceTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DRL" />
+ <xsd:enumeration value="BPMN2" />
+ <xsd:enumeration value="XDRL" />
+ <xsd:enumeration value="DSL" />
+ <xsd:enumeration value="DSLR" />
+ <xsd:enumeration value="DRF" />
+ <xsd:enumeration value="DTABLE" />
+ <xsd:enumeration value="PKG" />
+ <xsd:enumeration value="BRL" />
+ <xsd:enumeration value="CHANGE_SET" />
+ <xsd:enumeration value="XSD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="languageTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DTD" />
+ <xsd:enumeration value="RELAXNG" />
+ <xsd:enumeration value="RELAXNG_COMPACT" />
+ <xsd:enumeration value="WSDL" />
+ <xsd:enumeration value="XMLSCHEMA" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="cloudModeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="STREAM" />
+ <xsd:enumeration value="CLOUD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="enabledDisabledEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="enabled" />
+ <xsd:enumeration value="disabled" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:simpleType name="assertBehaviorEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="IDENTITY" />
+ <xsd:enumeration value="EQUALITY" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="clockTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="REALTIME" />
+ <xsd:enumeration value="PSEUDO" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="resourceType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element name="decisiontable-conf">
+ <xsd:complexType>
+ <xsd:attribute name="input-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="worksheet-name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="jaxb-conf">
+ <xsd:complexType>
+ <xsd:attribute name="system-id" use="optional" type="xsd:string" />
+ <xsd:attribute name="schema-language" type="languageTypeEnum" use="optional" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ <xsd:attribute name="source" use="optional" type="xsd:string"/>
+ <xsd:attribute name="type" use="optional" type="resourceTypeEnum"/>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="resourceRefType">
+ <xsd:attribute name="id" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="classesType">
+ <xsd:sequence>
+ <xsd:element name="class" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="persisterType">
+ <xsd:attribute name="for-class" use="required" type="xsd:string"/>
+ <xsd:attribute name="implementation" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="variablePersistersType">
+ <xsd:sequence>
+ <xsd:element name="persister" type="persisterType" minOccurs="1" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="jpaSessionServiceFactory">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="variablePersisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="entityManagerFactory" use="required" type="xsd:string"/>
+ <xsd:attribute name="transactionManager" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Persistence -->
+ <xsd:element name="persistence" type="persistenceType" abstract="true"/>
+
+ <xsd:complexType name="persistenceType">
+ </xsd:complexType>
+
+ <xsd:element name="jpa-persistence" substitutionGroup="persistence" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="persistenceType">
+ <xsd:all>
+ <xsd:element name="variable-persisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="transaction-manager" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="entity-manager-factory" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="load" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Commands -->
+ <xsd:element name="command" type="commandType" abstract="true"/>
+
+ <xsd:complexType name="commandType">
+ </xsd:complexType>
+
+ <xsd:element name="insert-object" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set-global" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-all-rules" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:attribute name="max" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-until-halt" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="start-process" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="process-id" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="signal-event" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element ref="spring:bean"/>
+ <xsd:element ref="spring:ref"/>
+ <xsd:element ref="spring:idref"/>
+ <xsd:element ref="spring:value"/>
+ <xsd:element ref="spring:null"/>
+ <xsd:element ref="spring:list"/>
+ <xsd:element ref="spring:set"/>
+ <xsd:element ref="spring:map"/>
+ <xsd:element ref="spring:props"/>
+ </xsd:choice>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="event-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="process-instance-id" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring.xsd 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,435 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://drools.org/schema/drools-spring"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://drools.org/schema/drools-spring"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified">
+
+ <xsd:element name="grid">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="grid-node">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="connection" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource-change-scanner">
+ <xsd:complexType>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="interval" use="optional" type="xsd:integer"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resources">
+ <xsd:complexType>
+ <xsd:choice minOccurs="0" maxOccurs="unbounded">
+ <xsd:element ref="resource" />
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="resource">
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="resourceType">
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+
+ <xsd:element name="kbase">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="advanced-process-rule-integration" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="multithread" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ <xsd:attribute name="max-threads" type="xsd:positiveInteger"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="mbeans" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="event-processing-mode" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="cloudModeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="assert-behavior" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="mode" type="assertBehaviorEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="accumulate-functions" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="accumulate-function" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="evaluators" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="evaluator" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="consequenceExceptionHandler" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="handler" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kagent">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element ref="resources" minOccurs="0" maxOccurs="1" />
+ </xsd:all>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="new-instance" use="optional" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="kstore" />
+
+ <xsd:element name="ksession">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element name="batch" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="script" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:all minOccurs="0">
+ <xsd:element ref="persistence" minOccurs="0"/>
+
+ <xsd:element name="keep-reference" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="enabled" type="xsd:boolean"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="clock-type" minOccurs="0">
+ <xsd:complexType>
+ <xsd:attribute name="type" type="clockTypeEnum"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="work-item-handlers" minOccurs="0">
+ <xsd:complexType>
+ <xsd:choice>
+ <xsd:element name="work-item-handler" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" use="required" type="xsd:string"/>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:all>
+
+ <xsd:attribute name="type" use="required" type="knowledgeSessionTypeEnum"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="id" use="required" type="xsd:ID"/>
+ <xsd:attribute name="node" use="optional" type="xsd:string"/>
+ <xsd:attribute name="name" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:simpleType name="connectionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="local" />
+ <xsd:enumeration value="remote" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="knowledgeSessionTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="stateful" />
+ <xsd:enumeration value="stateless" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="resourceTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DRL" />
+ <xsd:enumeration value="BPMN2" />
+ <xsd:enumeration value="XDRL" />
+ <xsd:enumeration value="DSL" />
+ <xsd:enumeration value="DSLR" />
+ <xsd:enumeration value="DRF" />
+ <xsd:enumeration value="DTABLE" />
+ <xsd:enumeration value="PKG" />
+ <xsd:enumeration value="BRL" />
+ <xsd:enumeration value="CHANGE_SET" />
+ <xsd:enumeration value="XSD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="languageTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="DTD" />
+ <xsd:enumeration value="RELAXNG" />
+ <xsd:enumeration value="RELAXNG_COMPACT" />
+ <xsd:enumeration value="WSDL" />
+ <xsd:enumeration value="XMLSCHEMA" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="cloudModeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="STREAM" />
+ <xsd:enumeration value="CLOUD" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:simpleType name="assertBehaviorEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="IDENTITY" />
+ <xsd:enumeration value="EQUALITY" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="clockTypeEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="REALTIME" />
+ <xsd:enumeration value="PSEUDO" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+
+ <xsd:complexType name="resourceType">
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element name="decisiontable-conf">
+ <xsd:complexType>
+ <xsd:attribute name="input-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="worksheet-name" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="jaxb-conf">
+ <xsd:complexType>
+ <xsd:attribute name="system-id" use="optional" type="xsd:string" />
+ <xsd:attribute name="schema-language" type="languageTypeEnum" use="optional" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ <xsd:attribute name="source" use="optional" type="xsd:string"/>
+ <xsd:attribute name="type" use="optional" type="resourceTypeEnum"/>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="resourceRefType">
+ <xsd:attribute name="id" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+
+ <xsd:complexType name="classesType">
+ <xsd:sequence>
+ <xsd:element name="class" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="persisterType">
+ <xsd:attribute name="for-class" use="required" type="xsd:string"/>
+ <xsd:attribute name="implementation" use="required" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="variablePersistersType">
+ <xsd:sequence>
+ <xsd:element name="persister" type="persisterType" minOccurs="1" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="jpaSessionServiceFactory">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="variablePersisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ </xsd:sequence>
+ <xsd:attribute name="id" use="optional" type="xsd:ID"/>
+ <xsd:attribute name="kbase" use="required" type="xsd:string"/>
+ <xsd:attribute name="entityManagerFactory" use="required" type="xsd:string"/>
+ <xsd:attribute name="transactionManager" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Persistence -->
+ <xsd:element name="persistence" type="persistenceType" abstract="true"/>
+
+ <xsd:complexType name="persistenceType">
+ </xsd:complexType>
+
+ <xsd:element name="jpa-persistence" substitutionGroup="persistence" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="persistenceType">
+ <xsd:all>
+ <xsd:element name="variable-persisters" type="variablePersistersType" minOccurs="0" maxOccurs="1"/>
+ <xsd:element name="transaction-manager" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="entity-manager-factory" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:all>
+ <xsd:attribute name="load" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <!-- Commands -->
+ <xsd:element name="command" type="commandType" abstract="true"/>
+
+ <xsd:complexType name="commandType">
+ </xsd:complexType>
+
+ <xsd:element name="insert-object" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="set-global" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-all-rules" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:attribute name="max" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="fire-until-halt" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="start-process" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:element name="parameter" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="identifier" use="required" type="xsd:string"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="process-id" use="required" type="xsd:string"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="signal-event" substitutionGroup="command" >
+ <xsd:complexType>
+ <xsd:complexContent>
+ <xsd:extension base="commandType">
+ <xsd:sequence>
+ <xsd:any minOccurs="0" maxOccurs="1" />
+ </xsd:sequence>
+ <xsd:attribute name="ref" use="optional" type="xsd:string"/>
+ <xsd:attribute name="event-type" use="required" type="xsd:string"/>
+ <xsd:attribute name="process-instance-id" use="optional" type="xsd:integer"/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/Person.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/Person.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,272 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class Person
+ implements
+ Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 510l;
+ 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 boolean happy;
+
+ private String status;
+
+ // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ // name = (String)in.readObject();
+ // likes = (String)in.readObject();
+ // age = in.readInt();
+ // bigDecimal = (BigDecimal)in.readObject();
+ // bigInteger = (BigInteger)in.readObject();
+ // hair = (String)in.readObject();
+ // sex = in.readChar();
+ // alive = in.readBoolean();
+ // status = (String)in.readObject();
+ // cheese = (Cheese)in.readObject();
+ // addresses = (List)in.readObject();
+ // }
+ //
+ // public void writeExternal(ObjectOutput out) throws IOException {
+ // out.writeObject(name);
+ // out.writeObject(likes);
+ // out.writeObject(bigDecimal);
+ // out.writeObject(bigInteger);
+ // out.writeObject(hair);
+ // out.writeChar(sex);
+ // out.writeBoolean(alive);
+ // out.writeObject(status);
+ // out.writeObject(cheese);
+ // out.writeObject(addresses);
+ // }
+
+ public Person() {
+
+ }
+
+ public Person(String name,
+ int age) {
+ super();
+ this.name = name;
+ this.age = age;
+ }
+
+ 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;
+ }
+
+ public boolean isHappy() {
+ return happy;
+ }
+
+ public void setHappy(boolean happy) {
+ this.happy = happy;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockAccumulateFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockAccumulateFunction.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockAccumulateFunction.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,73 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.Serializable;
+
+import org.drools.base.accumulators.AccumulateFunction;
+
+public class MockAccumulateFunction
+ implements
+ AccumulateFunction {
+
+ public void accumulate(Serializable context,
+ Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Serializable createContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getResult(Serializable context) throws Exception {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void init(Serializable context) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void reverse(Serializable context,
+ Object value) throws Exception {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean supportsReverse() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockConsequenceExceptionHandler.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockConsequenceExceptionHandler.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockConsequenceExceptionHandler.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,22 @@
+package org.drools.container.spring;
+
+import org.drools.runtime.rule.Activation;
+import org.drools.runtime.rule.WorkingMemory;
+import org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler;
+
+/**
+ *
+ * @author esteban
+ */
+public class MockConsequenceExceptionHandler extends DefaultConsequenceExceptionHandler {
+
+ @Override
+ public void handleException(Activation activation,
+ WorkingMemory workingMemory,
+ Exception exception) {
+ super.handleException( activation,
+ workingMemory,
+ exception );
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockEvaluatorDefinition.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockEvaluatorDefinition.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/MockEvaluatorDefinition.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,84 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.drools.base.ValueType;
+import org.drools.base.evaluators.EvaluatorDefinition;
+import org.drools.base.evaluators.Operator;
+import org.drools.spi.Evaluator;
+
+public class MockEvaluatorDefinition
+ implements
+ EvaluatorDefinition {
+
+ public Evaluator getEvaluator(ValueType type,
+ String operatorId,
+ boolean isNegated,
+ String parameterText,
+ Target leftTarget,
+ Target rightTarget) {
+ return null;
+ }
+
+ public Evaluator getEvaluator(ValueType type,
+ String operatorId,
+ boolean isNegated,
+ String parameterText) {
+ return null;
+ }
+
+ public Evaluator getEvaluator(ValueType type,
+ Operator operator,
+ String parameterText) {
+ return null;
+ }
+
+ public Evaluator getEvaluator(ValueType type,
+ Operator operator) {
+ return null;
+ }
+
+ public String[] getEvaluatorIds() {
+ return new String[]{"id1", "id2"};
+ }
+
+ public Target getTarget() {
+ return null;
+ }
+
+ public boolean isNegatable() {
+ return false;
+ }
+
+ public boolean supportsType(ValueType type) {
+ return false;
+ }
+
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsGridTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsGridTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsGridTest.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,159 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring;
+
+import java.io.Serializable;
+
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactoryService;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderError;
+import org.drools.builder.KnowledgeBuilderErrors;
+import org.drools.builder.KnowledgeBuilderFactoryService;
+import org.drools.builder.ResourceType;
+import org.drools.grid.ConnectionFactoryService;
+import org.drools.grid.Grid;
+import org.drools.grid.GridConnection;
+import org.drools.grid.GridNode;
+import org.drools.grid.GridServiceDescription;
+import org.drools.grid.SocketService;
+import org.drools.grid.service.directory.WhitePages;
+import org.drools.grid.service.directory.impl.JpaWhitePages;
+import org.drools.grid.service.directory.impl.WhitePagesClient;
+import org.drools.grid.service.directory.impl.WhitePagesImpl;
+import org.drools.io.impl.ByteArrayResource;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.rule.FactHandle;
+import org.junit.Assert;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringDroolsGridTest {
+
+ @Test
+ public void test1() {
+ EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.grid" );
+ WhitePages wp = new JpaWhitePages( emf );
+
+ wp.create( "s1" );
+ wp.create( "s2" );
+ wp.create( "s3" );
+ }
+
+ @Test
+ public void testGrid() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/grid.xml" );
+
+ Grid grid1 = (Grid) context.getBean( "grid1" );
+ assertTrue( grid1.get( WhitePages.class ) instanceof JpaWhitePages );
+
+ Grid grid2 = (Grid) context.getBean( "grid2" );
+ assertTrue( grid2.get( WhitePages.class ) instanceof WhitePagesClient );
+
+ Grid grid3 = (Grid) context.getBean( "grid3" );
+ assertTrue( grid3.get( WhitePages.class ) instanceof WhitePagesImpl );
+
+ GridServiceDescription<GridNode> n1Gsd = grid2.get( WhitePages.class ).lookup( "node1" );
+ GridConnection<GridNode> conn = grid2.get( ConnectionFactoryService.class ).createConnection( n1Gsd );
+ GridNode remoteN1 = conn.connect();
+
+ KnowledgeBuilder kbuilder = remoteN1.get( KnowledgeBuilderFactoryService.class ).newKnowledgeBuilder();
+
+ assertNotNull( kbuilder );
+
+ String rule = "package test\n"
+ + "import org.drools.container.spring.SpringDroolsGridTest.MyObject;\n"
+ + "global MyObject myGlobalObj;\n"
+ + "rule \"test\""
+ + " when"
+ + " $o: MyObject()"
+ + " then"
+ + " System.out.println(\"My Global Object -> \"+myGlobalObj.getName());"
+ + " System.out.println(\"Rule Fired! ->\"+$o.getName());"
+ + " end";
+
+ kbuilder.add( new ByteArrayResource( rule.getBytes() ),
+ ResourceType.DRL );
+
+ KnowledgeBuilderErrors errors = kbuilder.getErrors();
+ if ( errors != null && errors.size() > 0 ) {
+ for ( KnowledgeBuilderError error : errors ) {
+ System.out.println( "Error: " + error.getMessage() );
+
+ }
+ fail( "KnowledgeBase did not build" );
+ }
+
+ KnowledgeBase kbase = remoteN1.get( KnowledgeBaseFactoryService.class ).newKnowledgeBase();
+
+ assertNotNull( kbase );
+
+ kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+
+ StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
+
+ assertNotNull( session );
+ session.setGlobal( "myGlobalObj",
+ new MyObject( "myGlobalObj" ) );
+
+ FactHandle handle = session.insert( new MyObject( "myObj1" ) );
+ assertNotNull( handle );
+
+ int fired = session.fireAllRules();
+ assertEquals( 1,
+ fired );
+
+ session.retract( handle );
+
+ handle = session.insert( new MyObject( "myObj2" ) );
+
+ session.update( handle,
+ new MyObject( "myObj3" ) );
+
+ fired = session.fireAllRules();
+
+ remoteN1.dispose();
+ grid1.get( SocketService.class ).close();
+ }
+
+ public static class MyObject
+ implements
+ Serializable {
+ private String name;
+
+ public MyObject(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/SpringDroolsTest.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,283 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.drools.ClockType;
+import org.drools.Person;
+import org.drools.RuleBaseConfiguration;
+import org.drools.SessionConfiguration;
+import org.drools.RuleBaseConfiguration.AssertBehaviour;
+import org.drools.agent.impl.KnowledgeAgentImpl;
+import org.drools.common.InternalRuleBase;
+import org.drools.conf.EventProcessingOption;
+import org.drools.container.spring.beans.DroolsResourceAdapter;
+import org.drools.grid.GridNode;
+import org.drools.impl.KnowledgeBaseImpl;
+import org.drools.impl.StatefulKnowledgeSessionImpl;
+import org.drools.impl.StatelessKnowledgeSessionImpl;
+import org.drools.io.Resource;
+import org.drools.io.ResourceFactory;
+import org.drools.io.impl.ResourceChangeScannerImpl;
+import org.drools.io.impl.UrlResource;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.drools.runtime.process.WorkItemHandler;
+import org.jbpm.process.instance.impl.humantask.HumanTaskHandler;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringDroolsTest {
+
+ @Test
+ public void testNoConnection() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/beans.xml" );
+
+ GridNode node1 = (GridNode) context.getBean( "node1" );
+ assertNotNull( node1 );
+
+ GridNode node2 = (GridNode) context.getBean( "node2" );
+ assertNotNull( node2 );
+ }
+
+ @Test
+ public void testNoNodeKSessions() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/no-node-beans.xml" );
+
+ List<String> list = new ArrayList<String>();
+ StatelessKnowledgeSession kstateless = (StatelessKnowledgeSession) context.getBean( "ksession1" );
+ kstateless.setGlobal( "list",
+ list );
+ kstateless.execute( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ assertEquals( 1,
+ list.size() );
+
+ list = new ArrayList<String>();
+ StatefulKnowledgeSession kstateful = ((StatefulKnowledgeSession) context.getBean( "ksession2" ));
+ kstateful.setGlobal( "list",
+ list );
+ kstateful.insert( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ kstateful.fireAllRules();
+ assertEquals( 1,
+ list.size() );
+ }
+
+ @Test
+ public void testSimpleKSessions() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/beans.xml" );
+
+ List<String> list = new ArrayList<String>();
+ StatelessKnowledgeSession kstateless = (StatelessKnowledgeSession) context.getBean( "ksession1" );
+ kstateless.setGlobal( "list",
+ list );
+ kstateless.execute( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ assertEquals( 2,
+ list.size() );
+
+ list = new ArrayList<String>();
+ StatefulKnowledgeSession kstateful = ((StatefulKnowledgeSession) context.getBean( "ksession2" ));
+ kstateful.setGlobal( "list",
+ list );
+ kstateful.insert( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ kstateful.fireAllRules();
+ assertEquals( 2,
+ list.size() );
+ }
+
+ @Test
+ public void testAgents() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/kagents-beans.xml" );
+
+ ResourceChangeScannerImpl scanner = (ResourceChangeScannerImpl) ResourceFactory.getResourceChangeScannerService();
+ assertEquals( 5,
+ scanner.getInterval() );
+
+ KnowledgeBaseImpl kbase1 = (KnowledgeBaseImpl) context.getBean( "kbase1" );
+ KnowledgeBaseImpl kbase2 = (KnowledgeBaseImpl) context.getBean( "kbase2" );
+
+ KnowledgeAgentImpl kagent1 = (KnowledgeAgentImpl) context.getBean( "kagent1" );
+ assertSame( kagent1.getKnowledgeBase(),
+ kbase1 );
+ assertEquals( 0,
+ kagent1.getResourceDirectories().size() );
+ assertFalse( kagent1.isNewInstance() );
+
+ KnowledgeAgentImpl kagent2 = (KnowledgeAgentImpl) context.getBean( "kagent2" );
+ assertSame( kagent2.getKnowledgeBase(),
+ kbase2 );
+ assertEquals( 1,
+ kagent2.getResourceDirectories().size() );
+ assertFalse( kagent2.isNewInstance() );
+
+ KnowledgeAgentImpl kagent3 = (KnowledgeAgentImpl) context.getBean( "kagent3" );
+ assertTrue( kagent3.isNewInstance() );
+
+ StatelessKnowledgeSessionImpl ksession1 = (StatelessKnowledgeSessionImpl) context.getBean( "ksession1" );
+ assertSame( kbase1.getRuleBase(),
+ ksession1.getRuleBase() );
+ assertSame( kagent1,
+ ksession1.getKnowledgeAgent() );
+
+ StatefulKnowledgeSessionImpl ksession2 = (StatefulKnowledgeSessionImpl) context.getBean( "ksession2" );
+ assertSame( kbase1.getRuleBase(),
+ ksession2.getRuleBase() );
+
+ StatelessKnowledgeSessionImpl ksession3 = (StatelessKnowledgeSessionImpl) context.getBean( "ksession3" );
+ assertSame( kagent2,
+ ksession3.getKnowledgeAgent() );
+ assertSame( kbase2.getRuleBase(),
+ ksession3.getRuleBase() );
+
+ }
+
+ @Test
+ public void testNode() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/beans.xml" );
+
+ GridNode node = (GridNode) context.getBean( "node1" );
+ List<String> list = new ArrayList<String>();
+ StatelessKnowledgeSession kstateless = node.get( "stateless1",
+ StatelessKnowledgeSession.class );
+ assertNotNull( "can't obtain session named: stateless1",
+ kstateless );
+ kstateless.setGlobal( "list",
+ list );
+ kstateless.execute( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ assertEquals( 2,
+ list.size() );
+
+ list = new ArrayList<String>();
+ StatefulKnowledgeSession kstateful = node.get( "ksession2",
+ StatefulKnowledgeSession.class );
+ kstateful.setGlobal( "list",
+ list );
+ kstateful.insert( new Person( "Darth",
+ "Cheddar",
+ 50 ) );
+ kstateful.fireAllRules();
+ assertEquals( 2,
+ list.size() );
+ }
+
+ @Test
+ public void testConfiguration() {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/session-conf-beans.xml" );
+ KnowledgeBaseImpl kbase1 = (KnowledgeBaseImpl) context.getBean( "kbase1" );
+ RuleBaseConfiguration rconf = ((InternalRuleBase) kbase1.getRuleBase()).getConfiguration();
+ assertTrue( rconf.isAdvancedProcessRuleIntegration() );
+ assertTrue( rconf.isMultithreadEvaluation() );
+ assertEquals( 5,
+ rconf.getMaxThreads() );
+ assertEquals( EventProcessingOption.STREAM,
+ rconf.getEventProcessingMode() );
+ assertEquals( AssertBehaviour.IDENTITY,
+ rconf.getAssertBehaviour() );
+ assertEquals( "org.drools.container.spring.MockConsequenceExceptionHandler",
+ rconf.getConsequenceExceptionHandler() );
+
+ KnowledgeBaseImpl kbase2 = (KnowledgeBaseImpl) context.getBean( "kbase2" );
+ rconf = ((InternalRuleBase) kbase2.getRuleBase()).getConfiguration();
+ assertFalse( rconf.isAdvancedProcessRuleIntegration() );
+ assertFalse( rconf.isMultithreadEvaluation() );
+ assertEquals( 3,
+ rconf.getMaxThreads() );
+ assertEquals( EventProcessingOption.CLOUD,
+ rconf.getEventProcessingMode() );
+ assertEquals( AssertBehaviour.EQUALITY,
+ rconf.getAssertBehaviour() );
+
+ StatefulKnowledgeSessionImpl ksession1 = (StatefulKnowledgeSessionImpl) context.getBean( "ksession1" );
+ SessionConfiguration sconf = ksession1.session.getSessionConfiguration();
+ assertTrue( sconf.isKeepReference() );
+ assertEquals( ClockType.REALTIME_CLOCK,
+ sconf.getClockType() );
+ Map<String, WorkItemHandler> wih = sconf.getWorkItemHandlers();
+ assertEquals( 4,
+ wih.size() );
+ assertTrue( wih.containsKey( "wih1" ) );
+ assertTrue( wih.containsKey( "wih2" ) );
+ assertTrue( wih.containsKey( "Human Task" ) );
+ assertTrue( wih.containsKey( "MyWork" ) );
+ assertNotSame( wih.get( "wih1" ),
+ wih.get( "wih2" ) );
+ assertEquals( HumanTaskHandler.class,
+ wih.get( "wih1" ).getClass() );
+ assertEquals( HumanTaskHandler.class,
+ wih.get( "wih2" ).getClass() );
+
+ StatefulKnowledgeSessionImpl ksession2 = (StatefulKnowledgeSessionImpl) context.getBean( "ksession2" );
+ sconf = ksession2.session.getSessionConfiguration();
+ assertFalse( sconf.isKeepReference() );
+ assertEquals( ClockType.PSEUDO_CLOCK,
+ sconf.getClockType() );
+
+ }
+
+ @Test
+ public void testResourceAuthenication() throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "org/drools/container/spring/beans.xml" );
+
+ //Secure Resource
+ DroolsResourceAdapter resourceAdapter = (DroolsResourceAdapter) context.getBean( "secureResource" );
+ assertNotNull( resourceAdapter );
+
+ Resource resource = resourceAdapter.getDroolsResource();
+ assertTrue( resource instanceof UrlResource );
+
+ UrlResource ur = (UrlResource) resource;
+
+ assertEquals( "enabled",
+ ur.getBasicAuthentication() );
+ assertEquals( "someUser",
+ ur.getUsername() );
+ assertEquals( "somePassword",
+ ur.getPassword() );
+
+ //Insecure Resource
+ resourceAdapter = (DroolsResourceAdapter) context.getBean( "insecureResource" );
+ assertNotNull( resourceAdapter );
+
+ resource = resourceAdapter.getDroolsResource();
+ assertTrue( resource instanceof UrlResource );
+
+ ur = (UrlResource) resource;
+
+ assertEquals( "disabled",
+ ur.getBasicAuthentication() );
+ assertEquals( "",
+ ur.getUsername() );
+ assertEquals( "",
+ ur.getPassword() );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/JPASingleSessionCommandServiceFactoryTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/JPASingleSessionCommandServiceFactoryTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/JPASingleSessionCommandServiceFactoryTest.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,748 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.core.util.DroolsStreamUtils;
+import org.drools.persistence.jpa.KnowledgeStoreService;
+import org.drools.process.core.Work;
+import org.drools.process.core.impl.WorkImpl;
+import org.drools.rule.Package;
+import org.drools.runtime.Environment;
+import org.drools.runtime.EnvironmentName;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.NodeInstance;
+import org.drools.runtime.process.ProcessInstance;
+import org.drools.runtime.process.WorkItem;
+import org.h2.tools.DeleteDbFiles;
+import org.h2.tools.Server;
+import org.jbpm.compiler.ProcessBuilderImpl;
+import org.jbpm.process.core.timer.Timer;
+import org.jbpm.ruleflow.core.RuleFlowProcess;
+import org.jbpm.ruleflow.instance.RuleFlowProcessInstance;
+import org.jbpm.workflow.core.Node;
+import org.jbpm.workflow.core.impl.ConnectionImpl;
+import org.jbpm.workflow.core.impl.DroolsConsequenceAction;
+import org.jbpm.workflow.core.node.ActionNode;
+import org.jbpm.workflow.core.node.EndNode;
+import org.jbpm.workflow.core.node.StartNode;
+import org.jbpm.workflow.core.node.SubProcessNode;
+import org.jbpm.workflow.core.node.TimerNode;
+import org.jbpm.workflow.core.node.WorkItemNode;
+import org.jbpm.workflow.instance.node.SubProcessNodeInstance;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class JPASingleSessionCommandServiceFactoryTest {
+ private static final String TMPDIR = System.getProperty( "java.io.tmpdir" );
+ private static final Logger log = LoggerFactory.getLogger( JPASingleSessionCommandServiceFactoryTest.class );
+ private static Server h2Server;
+
+ private ClassPathXmlApplicationContext ctx;
+
+ @BeforeClass
+ public static void startH2Database() throws Exception {
+ DeleteDbFiles.execute( "",
+ "DroolsFlow",
+ true );
+ h2Server = Server.createTcpServer( new String[0] );
+ h2Server.start();
+ }
+
+ @AfterClass
+ public static void stopH2Database() throws Exception {
+ log.info( "stoping database" );
+ h2Server.stop();
+ DeleteDbFiles.execute( "",
+ "DroolsFlow",
+ true );
+ }
+
+ @BeforeClass
+ public static void generatePackages() {
+ try {
+ log.info( "creating: {}",
+ TMPDIR + "/processWorkItems.pkg" );
+ writePackage( getProcessWorkItems(),
+ new File( TMPDIR + "/processWorkItems.pkg" ) );
+
+ log.info( "creating: {}",
+ TMPDIR + "/processSubProcess.pkg" );
+ writePackage( getProcessSubProcess(),
+ new File( TMPDIR + "/processSubProcess.pkg" ) );
+
+ log.info( "creating: {}",
+ TMPDIR + "/processTimer.pkg" );
+ writePackage( getProcessTimer(),
+ new File( TMPDIR + "/processTimer.pkg" ) );
+
+ log.info( "creating: {}",
+ TMPDIR + "/processTimer2.pkg" );
+ writePackage( getProcessTimer2(),
+ new File( TMPDIR + "/processTimer2.pkg" ) );
+ } catch ( Exception e ) {
+ log.error( "can't create packages!",
+ e );
+ throw new RuntimeException( e );
+ }
+ }
+
+ @Before
+ public void createSpringContext() {
+ try {
+ log.info( "creating spring context" );
+ PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
+ Properties properties = new Properties();
+ properties.setProperty( "temp.dir",
+ TMPDIR );
+ configurer.setProperties( properties );
+ ctx = new ClassPathXmlApplicationContext();
+ ctx.addBeanFactoryPostProcessor( configurer );
+ ctx.setConfigLocation( "org/drools/container/spring/beans/persistence/beans.xml" );
+ ctx.refresh();
+ } catch ( Exception e ) {
+ log.error( "can't create spring context",
+ e );
+ throw new RuntimeException( e );
+ }
+ }
+
+ @After
+ public void destrySpringContext() {
+ log.info( "destroy spring context" );
+ ctx.destroy();
+ }
+
+ @Test
+ public void testPersistenceWorkItems() throws Exception {
+ log.info( "---> get bean jpaSingleSessionCommandService" );
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ log.info( "---> create new SingleSessionCommandService" );
+
+ int sessionId = service.getId();
+ log.info( "---> created SingleSessionCommandService id: " + sessionId );
+
+ ProcessInstance processInstance = service.startProcess( "org.drools.test.TestProcess" );
+ log.info( "Started process instance {}",
+ processInstance.getId() );
+
+ TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ WorkItem workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbProcessWorkItems" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+
+ workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+
+ workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+
+ workItem = handler.getWorkItem();
+ assertNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ service.dispose();
+ }
+
+ @Test
+ public void testPersistenceWorkItemsUserTransaction() throws Exception {
+
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ int sessionId = service.getId();
+ ProcessInstance processInstance = service.startProcess( "org.drools.test.TestProcess" );
+ log.info( "Started process instance {}",
+ processInstance.getId() );
+
+ TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ WorkItem workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbProcessWorkItems" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+
+ workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().abortWorkItem( workItem.getId() );
+
+ workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+ workItem = handler.getWorkItem();
+ assertNull( workItem );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNull( processInstance );
+ service.dispose();
+ }
+
+ @SuppressWarnings("unused")
+ private static Package getProcessWorkItems() {
+ RuleFlowProcess process = new RuleFlowProcess();
+ process.setId( "org.drools.test.TestProcess" );
+ process.setName( "TestProcess" );
+ process.setPackageName( "org.drools.test" );
+ StartNode start = new StartNode();
+ start.setId( 1 );
+ start.setName( "Start" );
+ process.addNode( start );
+ ActionNode actionNode = new ActionNode();
+ actionNode.setId( 2 );
+ actionNode.setName( "Action" );
+ DroolsConsequenceAction action = new DroolsConsequenceAction();
+ action.setDialect( "java" );
+ action.setConsequence( "System.out.println(\"Executed action\");" );
+ actionNode.setAction( action );
+ process.addNode( actionNode );
+ new ConnectionImpl( start,
+ Node.CONNECTION_DEFAULT_TYPE,
+ actionNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ WorkItemNode workItemNode = new WorkItemNode();
+ workItemNode.setId( 3 );
+ workItemNode.setName( "WorkItem1" );
+ Work work = new WorkImpl();
+ work.setName( "MyWork" );
+ workItemNode.setWork( work );
+ process.addNode( workItemNode );
+ new ConnectionImpl( actionNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ workItemNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ WorkItemNode workItemNode2 = new WorkItemNode();
+ workItemNode2.setId( 4 );
+ workItemNode2.setName( "WorkItem2" );
+ work = new WorkImpl();
+ work.setName( "MyWork" );
+ workItemNode2.setWork( work );
+ process.addNode( workItemNode2 );
+ new ConnectionImpl( workItemNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ workItemNode2,
+ Node.CONNECTION_DEFAULT_TYPE );
+ WorkItemNode workItemNode3 = new WorkItemNode();
+ workItemNode3.setId( 5 );
+ workItemNode3.setName( "WorkItem3" );
+ work = new WorkImpl();
+ work.setName( "MyWork" );
+ workItemNode3.setWork( work );
+ process.addNode( workItemNode3 );
+ new ConnectionImpl( workItemNode2,
+ Node.CONNECTION_DEFAULT_TYPE,
+ workItemNode3,
+ Node.CONNECTION_DEFAULT_TYPE );
+ EndNode end = new EndNode();
+ end.setId( 6 );
+ end.setName( "End" );
+ process.addNode( end );
+ new ConnectionImpl( workItemNode3,
+ Node.CONNECTION_DEFAULT_TYPE,
+ end,
+ Node.CONNECTION_DEFAULT_TYPE );
+
+ PackageBuilder packageBuilder = new PackageBuilder();
+ ProcessBuilderImpl processBuilder = new ProcessBuilderImpl( packageBuilder );
+ processBuilder.buildProcess( process,
+ null );
+
+ return packageBuilder.getPackage();
+ }
+
+ public static void writePackage(Package pkg,
+ File dest) {
+ dest.deleteOnExit();
+ OutputStream out = null;
+ try {
+ out = new BufferedOutputStream( new FileOutputStream( dest ) );
+ DroolsStreamUtils.streamOut( out,
+ pkg );
+ } catch ( Exception e ) {
+ throw new RuntimeException( e );
+ } finally {
+ if ( out != null ) {
+ try {
+ out.close();
+ } catch ( IOException e ) {
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testPersistenceSubProcess() {
+
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ int sessionId = service.getId();
+
+ RuleFlowProcessInstance processInstance = (RuleFlowProcessInstance) service.startProcess( "org.drools.test.ProcessSubProcess" );
+ log.info( "Started process instance {}",
+ processInstance.getId() );
+ long processInstanceId = processInstance.getId();
+
+ TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ WorkItem workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbProcessWorkItems" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+
+ processInstance = (RuleFlowProcessInstance) service.getProcessInstance( processInstanceId );
+ assertNotNull( processInstance );
+
+ Collection<NodeInstance> nodeInstances = processInstance.getNodeInstances();
+ assertEquals( 1,
+ nodeInstances.size() );
+ SubProcessNodeInstance subProcessNodeInstance = (SubProcessNodeInstance) nodeInstances.iterator().next();
+ long subProcessInstanceId = subProcessNodeInstance.getProcessInstanceId();
+ RuleFlowProcessInstance subProcessInstance = (RuleFlowProcessInstance) service.getProcessInstance( subProcessInstanceId );
+ assertNotNull( subProcessInstance );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ service.getWorkItemManager().completeWorkItem( workItem.getId(),
+ null );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ subProcessInstance = (RuleFlowProcessInstance) service.getProcessInstance( subProcessInstanceId );
+ assertNull( subProcessInstance );
+
+ processInstance = (RuleFlowProcessInstance) service.getProcessInstance( processInstanceId );
+ assertNull( processInstance );
+ service.dispose();
+ }
+
+ @SuppressWarnings("unused")
+ private static Package getProcessSubProcess() {
+ RuleFlowProcess process = new RuleFlowProcess();
+ process.setId( "org.drools.test.ProcessSubProcess" );
+ process.setName( "ProcessSubProcess" );
+ process.setPackageName( "org.drools.test" );
+ StartNode start = new StartNode();
+ start.setId( 1 );
+ start.setName( "Start" );
+ process.addNode( start );
+ ActionNode actionNode = new ActionNode();
+ actionNode.setId( 2 );
+ actionNode.setName( "Action" );
+ DroolsConsequenceAction action = new DroolsConsequenceAction();
+ action.setDialect( "java" );
+ action.setConsequence( "System.out.println(\"Executed action\");" );
+ actionNode.setAction( action );
+ process.addNode( actionNode );
+ new ConnectionImpl( start,
+ Node.CONNECTION_DEFAULT_TYPE,
+ actionNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ SubProcessNode subProcessNode = new SubProcessNode();
+ subProcessNode.setId( 3 );
+ subProcessNode.setName( "SubProcess" );
+ subProcessNode.setProcessId( "org.drools.test.SubProcess" );
+ process.addNode( subProcessNode );
+ new ConnectionImpl( actionNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ subProcessNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ EndNode end = new EndNode();
+ end.setId( 4 );
+ end.setName( "End" );
+ process.addNode( end );
+ new ConnectionImpl( subProcessNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ end,
+ Node.CONNECTION_DEFAULT_TYPE );
+
+ PackageBuilder packageBuilder = new PackageBuilder();
+ ProcessBuilderImpl processBuilder = new ProcessBuilderImpl( packageBuilder );
+ processBuilder.buildProcess( process,
+ null );
+
+ process = new RuleFlowProcess();
+ process.setId( "org.drools.test.SubProcess" );
+ process.setName( "SubProcess" );
+ process.setPackageName( "org.drools.test" );
+ start = new StartNode();
+ start.setId( 1 );
+ start.setName( "Start" );
+ process.addNode( start );
+ actionNode = new ActionNode();
+ actionNode.setId( 2 );
+ actionNode.setName( "Action" );
+ action = new DroolsConsequenceAction();
+ action.setDialect( "java" );
+ action.setConsequence( "System.out.println(\"Executed action\");" );
+ actionNode.setAction( action );
+ process.addNode( actionNode );
+ new ConnectionImpl( start,
+ Node.CONNECTION_DEFAULT_TYPE,
+ actionNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ WorkItemNode workItemNode = new WorkItemNode();
+ workItemNode.setId( 3 );
+ workItemNode.setName( "WorkItem1" );
+ Work work = new WorkImpl();
+ work.setName( "MyWork" );
+ workItemNode.setWork( work );
+ process.addNode( workItemNode );
+ new ConnectionImpl( actionNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ workItemNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ end = new EndNode();
+ end.setId( 6 );
+ end.setName( "End" );
+ process.addNode( end );
+ new ConnectionImpl( workItemNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ end,
+ Node.CONNECTION_DEFAULT_TYPE );
+
+ processBuilder.buildProcess( process,
+ null );
+ return packageBuilder.getPackage();
+ }
+
+ @Test
+ public void testPersistenceTimer() throws Exception {
+ log.info( "---> get bean jpaSingleSessionCommandService" );
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ int sessionId = service.getId();
+ log.info( "---> created SingleSessionCommandService id: " + sessionId );
+
+ ProcessInstance processInstance = service.startProcess( "org.drools.test.ProcessTimer" );
+ long procId = processInstance.getId();
+ log.info( "---> Started ProcessTimer id: {}",
+ procId );
+ service.dispose();
+ log.info( "---> session disposed" );
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbProcessWorkItems" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+
+ log.info( "---> load session: " + sessionId );
+ processInstance = service.getProcessInstance( procId );
+ log.info( "---> GetProcessInstanceCommand id: " + procId );
+ assertNotNull( processInstance );
+ log.info( "---> session disposed" );
+ service.dispose();
+
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+ log.info( "---> load session: " + sessionId );
+ Thread.sleep( 3000 );
+
+ log.info( "---> GetProcessInstanceCommand id: " + procId );
+ processInstance = service.getProcessInstance( procId );
+ log.info( "---> session disposed" );
+ assertNull( processInstance );
+ }
+
+ @SuppressWarnings("unused")
+ private static Package getProcessTimer() {
+ RuleFlowProcess process = new RuleFlowProcess();
+ process.setId( "org.drools.test.ProcessTimer" );
+ process.setName( "ProcessTimer" );
+ process.setPackageName( "org.drools.test" );
+ StartNode start = new StartNode();
+ start.setId( 1 );
+ start.setName( "Start" );
+ process.addNode( start );
+ TimerNode timerNode = new TimerNode();
+ timerNode.setId( 2 );
+ timerNode.setName( "Timer" );
+ Timer timer = new Timer();
+ timer.setDelay( "2000" );
+ timerNode.setTimer( timer );
+ process.addNode( timerNode );
+ new ConnectionImpl( start,
+ Node.CONNECTION_DEFAULT_TYPE,
+ timerNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ ActionNode actionNode = new ActionNode();
+ actionNode.setId( 3 );
+ actionNode.setName( "Action" );
+ DroolsConsequenceAction action = new DroolsConsequenceAction();
+ action.setDialect( "java" );
+ action.setConsequence( "System.out.println(\"Executed action\");" );
+ actionNode.setAction( action );
+ process.addNode( actionNode );
+ new ConnectionImpl( timerNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ actionNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ EndNode end = new EndNode();
+ end.setId( 6 );
+ end.setName( "End" );
+ process.addNode( end );
+ new ConnectionImpl( actionNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ end,
+ Node.CONNECTION_DEFAULT_TYPE );
+
+ PackageBuilder packageBuilder = new PackageBuilder();
+ ProcessBuilderImpl processBuilder = new ProcessBuilderImpl( packageBuilder );
+ processBuilder.buildProcess( process,
+ null );
+ return packageBuilder.getPackage();
+ }
+
+ @Test
+ public void testPersistenceTimer2() throws Exception {
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ int sessionId = service.getId();
+
+ ProcessInstance processInstance = service.startProcess( "org.drools.test.ProcessTimer2" );
+ log.info( "Started process instance {}",
+ processInstance.getId() );
+
+ Thread.sleep( 2000 );
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbProcessWorkItems" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+
+ processInstance = service.getProcessInstance( processInstance.getId() );
+ assertNull( processInstance );
+ }
+
+ @SuppressWarnings("unused")
+ private static Package getProcessTimer2() {
+ RuleFlowProcess process = new RuleFlowProcess();
+ process.setId( "org.drools.test.ProcessTimer2" );
+ process.setName( "ProcessTimer2" );
+ process.setPackageName( "org.drools.test" );
+ StartNode start = new StartNode();
+ start.setId( 1 );
+ start.setName( "Start" );
+ process.addNode( start );
+ TimerNode timerNode = new TimerNode();
+ timerNode.setId( 2 );
+ timerNode.setName( "Timer" );
+ Timer timer = new Timer();
+ timer.setDelay( "0" );
+ timerNode.setTimer( timer );
+ process.addNode( timerNode );
+ new ConnectionImpl( start,
+ Node.CONNECTION_DEFAULT_TYPE,
+ timerNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ ActionNode actionNode = new ActionNode();
+ actionNode.setId( 3 );
+ actionNode.setName( "Action" );
+ DroolsConsequenceAction action = new DroolsConsequenceAction();
+ action.setDialect( "java" );
+ action.setConsequence( "try { Thread.sleep(1000); } catch (Throwable t) {} System.out.println(\"Executed action\");" );
+ actionNode.setAction( action );
+ process.addNode( actionNode );
+ new ConnectionImpl( timerNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ actionNode,
+ Node.CONNECTION_DEFAULT_TYPE );
+ EndNode end = new EndNode();
+ end.setId( 6 );
+ end.setName( "End" );
+ process.addNode( end );
+ new ConnectionImpl( actionNode,
+ Node.CONNECTION_DEFAULT_TYPE,
+ end,
+ Node.CONNECTION_DEFAULT_TYPE );
+
+ PackageBuilder packageBuilder = new PackageBuilder();
+ ProcessBuilderImpl processBuilder = new ProcessBuilderImpl( packageBuilder );
+ processBuilder.buildProcess( process,
+ null );
+ return packageBuilder.getPackage();
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntity.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntity.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntity.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,107 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ *
+ * @author salaboy
+ */
+ at Entity
+public class MyEntity
+ implements
+ Serializable {
+
+ private static final long serialVersionUID = 510l;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+ private String test;
+
+ public MyEntity() {
+ }
+
+ public MyEntity(String string) {
+ this.test = string;
+ }
+
+ /**
+ * @return the id
+ */
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the test
+ */
+ public String getTest() {
+ return test;
+ }
+
+ /**
+ * @param test the test to set
+ */
+ public void setTest(String test) {
+ this.test = test;
+ }
+
+ public String toString() {
+ return "VARIABLE: " + this.getId() + " - " + this.getTest();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ final MyEntity other = (MyEntity) obj;
+ if ( this.id != other.id && (this.id == null || !this.id.equals( other.id )) ) {
+ return false;
+ }
+ if ( (this.test == null) ? (other.test != null) : !this.test.equals( other.test ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ hash = 41 * hash + (this.test != null ? this.test.hashCode() : 0);
+ return hash;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityMethods.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityMethods.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityMethods.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,106 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ *
+ * @author salaboy
+ */
+ at Entity
+public class MyEntityMethods
+ implements
+ Serializable {
+ private static final long serialVersionUID = 510l;
+
+ private Long id;
+ private String test;
+
+ public MyEntityMethods() {
+ }
+
+ public MyEntityMethods(String string) {
+ this.test = string;
+ }
+
+ /**
+ * @return the id
+ */
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public Long getId() {
+ return id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ /**
+ * @return the test
+ */
+ public String getTest() {
+ return test;
+ }
+
+ /**
+ * @param test the test to set
+ */
+ public void setTest(String test) {
+ this.test = test;
+ }
+
+ public String toString() {
+ return "VARIABLE: " + this.getId() + " - " + this.getTest();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ final MyEntityMethods other = (MyEntityMethods) obj;
+ if ( this.id != other.id && (this.id == null || !this.id.equals( other.id )) ) {
+ return false;
+ }
+ if ( (this.test == null) ? (other.test != null) : !this.test.equals( other.test ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ hash = 41 * hash + (this.test != null ? this.test.hashCode() : 0);
+ return hash;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityOnlyFields.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityOnlyFields.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyEntityOnlyFields.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,79 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+
+/**
+ *
+ * @author salaboy
+ */
+ at Entity
+public class MyEntityOnlyFields
+ implements
+ Serializable {
+
+ private static final long serialVersionUID = 510l;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ public Long id;
+ public String test;
+
+ public MyEntityOnlyFields() {
+ }
+
+ public MyEntityOnlyFields(String string) {
+ this.test = string;
+ }
+
+ public String toString() {
+ return "VARIABLE: " + id + " - " + test;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ final MyEntityOnlyFields other = (MyEntityOnlyFields) obj;
+ if ( this.id != other.id && (this.id == null || !this.id.equals( other.id )) ) {
+ return false;
+ }
+ if ( (this.test == null) ? (other.test != null) : !this.test.equals( other.test ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ hash = 41 * hash + (this.test != null ? this.test.hashCode() : 0);
+ return hash;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyVariableSerializable.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyVariableSerializable.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/MyVariableSerializable.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,77 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @author salaboy
+ */
+public class MyVariableSerializable
+ implements
+ Serializable {
+
+ private static final long serialVersionUID = 510l;
+
+ private String text = "";
+
+ public MyVariableSerializable(String string) {
+ this.text = string;
+ }
+
+ /**
+ * @return the text
+ */
+ public String getText() {
+ return text;
+ }
+
+ /**
+ * @param text the text to set
+ */
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if ( obj == null ) {
+ return false;
+ }
+ if ( getClass() != obj.getClass() ) {
+ return false;
+ }
+ final MyVariableSerializable other = (MyVariableSerializable) obj;
+ if ( (this.text == null) ? (other.text != null) : !this.text.equals( other.text ) ) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 37 * hash + (this.text != null ? this.text.hashCode() : 0);
+ return hash;
+ }
+
+ public String toString() {
+ return "Serializable Variable: " + this.getText();
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/TestWorkItemHandler.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/TestWorkItemHandler.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/TestWorkItemHandler.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
+import org.drools.runtime.process.WorkItemManager;
+
+public class TestWorkItemHandler
+ implements
+ WorkItemHandler {
+
+ private static TestWorkItemHandler INSTANCE = new TestWorkItemHandler();
+
+ private WorkItem workItem;
+
+ private TestWorkItemHandler() {
+ }
+
+ public static TestWorkItemHandler getInstance() {
+ return INSTANCE;
+ }
+
+ public void executeWorkItem(WorkItem workItem,
+ WorkItemManager manager) {
+ this.workItem = workItem;
+ }
+
+ public void abortWorkItem(WorkItem workItem,
+ WorkItemManager manager) {
+ }
+
+ public WorkItem getWorkItem() {
+ WorkItem result = workItem;
+ workItem = null;
+ return result;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyTest.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,512 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.container.spring.beans.persistence;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.base.MapGlobalResolver;
+import org.drools.marshalling.ObjectMarshallingStrategy;
+import org.drools.marshalling.impl.ClassObjectMarshallingStrategyAcceptor;
+import org.drools.marshalling.impl.SerializablePlaceholderResolverStrategy;
+import org.drools.persistence.jpa.JPAKnowledgeService;
+import org.drools.persistence.jpa.KnowledgeStoreService;
+import org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy;
+import org.drools.runtime.Environment;
+import org.drools.runtime.EnvironmentName;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkflowProcessInstance;
+import org.h2.tools.DeleteDbFiles;
+import org.h2.tools.Server;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallback;
+import org.springframework.transaction.support.TransactionTemplate;
+
+public class VariablePersistenceStrategyTest {
+
+ private static final String TMPDIR = System.getProperty( "java.io.tmpdir" );
+ private static final Logger log = LoggerFactory.getLogger( JPASingleSessionCommandServiceFactoryTest.class );
+ private static Server h2Server;
+
+ private ClassPathXmlApplicationContext ctx;
+
+ @BeforeClass
+ public static void startH2Database() throws Exception {
+ DeleteDbFiles.execute( "",
+ "DroolsFlow",
+ true );
+ h2Server = Server.createTcpServer( new String[0] );
+ h2Server.start();
+ }
+
+ @AfterClass
+ public static void stopH2Database() throws Exception {
+ log.info( "stoping database" );
+ h2Server.stop();
+ DeleteDbFiles.execute( "",
+ "DroolsFlow",
+ true );
+ }
+
+ @Before
+ public void createSpringContext() {
+ try {
+ log.info( "creating spring context" );
+ PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
+ Properties properties = new Properties();
+ properties.setProperty( "temp.dir",
+ TMPDIR );
+ configurer.setProperties( properties );
+ ctx = new ClassPathXmlApplicationContext();
+ ctx.addBeanFactoryPostProcessor( configurer );
+ ctx.setConfigLocation( "org/drools/container/spring/beans/persistence/beansVarPersistence.xml" );
+ ctx.refresh();
+ } catch ( Exception e ) {
+ log.error( "can't create spring context",
+ e );
+ throw new RuntimeException( e );
+ }
+ }
+
+ @After
+ public void destrySpringContext() {
+ log.info( "destroy spring context" );
+ ctx.destroy();
+ }
+
+ @Test
+ public void testTransactionsRollback() throws Exception {
+ final List< ? > list = new ArrayList<Object>();
+ PlatformTransactionManager txManager = (PlatformTransactionManager) ctx.getBean( "txManager" );
+
+ final Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ ctx.getBean( "myEmf" ) );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ txManager );
+ env.set( EnvironmentName.GLOBALS,
+ new MapGlobalResolver() );
+ env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
+ new ObjectMarshallingStrategy[]{new JPAPlaceholderResolverStrategy( env ),
+ new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )} );
+
+ final KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ final KnowledgeBase kbRollback = (KnowledgeBase) ctx.getBean( "kbRollback" );
+
+ TransactionTemplate txTemplate = new TransactionTemplate( txManager );
+ final StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ StatefulKnowledgeSession kNewSession = kstore.newStatefulKnowledgeSession( kbRollback,
+ null,
+ env );
+ kNewSession.setGlobal( "list",
+ list );
+ kNewSession.insert( 1 );
+ kNewSession.insert( 2 );
+ return kNewSession;
+ }
+ } );
+
+ final int sessionId = ksession.getId();
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession.insert( 3 );
+ status.setRollbackOnly();
+ return null;
+ }
+ } );
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession.fireAllRules();
+ return null;
+ }
+ } );
+
+ assertEquals( 2,
+ list.size() );
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession.insert( 3 );
+ ksession.insert( 4 );
+ return null;
+ }
+ } );
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession.insert( 5 );
+ ksession.insert( 6 );
+ status.setRollbackOnly();
+ return null;
+ }
+ } );
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession.fireAllRules();
+ return null;
+ }
+ } );
+
+ assertEquals( 4,
+ list.size() );
+
+ ksession.dispose();
+
+ // now load the ksession
+ final StatefulKnowledgeSession ksession2 = JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId,
+ kbRollback,
+ null,
+ env );
+
+ txTemplate = new TransactionTemplate( txManager );
+ txTemplate.execute( new TransactionCallback() {
+
+ public Object doInTransaction(TransactionStatus status) {
+ ksession2.setGlobal( "list",
+ list );
+ ksession2.insert( 7 );
+ ksession2.insert( 8 );
+ return null;
+ }
+ } );
+
+ txTemplate.execute( new TransactionCallback() {
+ public Object doInTransaction(TransactionStatus status) {
+ ksession2.fireAllRules();
+ return null;
+ }
+ } );
+
+ assertEquals( 6,
+ list.size() );
+ }
+
+ @Test
+ public void testPersistenceVariables() throws NamingException,
+ NotSupportedException,
+ SystemException,
+ IllegalStateException,
+ RollbackException,
+ HeuristicMixedException,
+ HeuristicRollbackException {
+ MyEntity myEntity = new MyEntity( "This is a test Entity with annotation in fields" );
+ MyEntityMethods myEntityMethods = new MyEntityMethods( "This is a test Entity with annotations in methods" );
+ MyEntityOnlyFields myEntityOnlyFields = new MyEntityOnlyFields( "This is a test Entity with annotations in fields and without accesors methods" );
+ MyVariableSerializable myVariableSerializable = new MyVariableSerializable( "This is a test SerializableObject" );
+ EntityManager em = ((EntityManagerFactory) ctx.getBean( "myEmf" )).createEntityManager();
+
+ em.getTransaction().begin();
+ em.persist( myEntity );
+ em.persist( myEntityMethods );
+ em.persist( myEntityOnlyFields );
+ em.getTransaction().commit();
+ em.close();
+
+ log.info( "---> get bean jpaSingleSessionCommandService" );
+ StatefulKnowledgeSession service = (StatefulKnowledgeSession) ctx.getBean( "jpaSingleSessionCommandService" );
+
+ int sessionId = service.getId();
+ log.info( "---> created SingleSessionCommandService id: " + sessionId );
+
+ log.info( "### Starting process ###" );
+ Map<String, Object> parameters = new HashMap<String, Object>();
+ parameters.put( "x",
+ "SomeString" );
+ parameters.put( "y",
+ myEntity );
+ parameters.put( "m",
+ myEntityMethods );
+ parameters.put( "f",
+ myEntityOnlyFields );
+ parameters.put( "z",
+ myVariableSerializable );
+ WorkflowProcessInstance processInstance = (WorkflowProcessInstance) service.startProcess( "com.sample.ruleflow",
+ parameters );
+ log.info( "Started process instance {}",
+ processInstance.getId() );
+
+ TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ WorkItem workItem = handler.getWorkItem();
+ assertNotNull( workItem );
+ service.dispose();
+
+ EntityManagerFactory emf = (EntityManagerFactory) ctx.getBean( "myEmf" );
+
+ // List< ? > result = emf.createEntityManager().createQuery( "select i from VariableInstanceInfo i" ).getResultList();
+ // assertEquals( 5,
+ // result.size() );
+ log.info( "### Retrieving process instance ###" );
+
+ Environment env = KnowledgeBaseFactory.newEnvironment();
+ env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ emf );
+ env.set( EnvironmentName.TRANSACTION_MANAGER,
+ ctx.getBean( "txManager" ) );
+ env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
+ new ObjectMarshallingStrategy[]{
+ // new JPAPlaceholderResolverStrategy(env),
+ new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )
+ } );
+
+ KnowledgeStoreService kstore = (KnowledgeStoreService) ctx.getBean( "kstore1" );
+ KnowledgeBase kbase1 = (KnowledgeBase) ctx.getBean( "kbase1" );
+ service = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase1,
+ null,
+ env );
+
+ processInstance = (WorkflowProcessInstance) service.getProcessInstance( processInstance.getId() );
+ assertNotNull( processInstance );
+
+ assertNotNull( processInstance );
+ assertEquals( "SomeString",
+ processInstance.getVariable( "x" ) );
+ assertEquals( "This is a test Entity with annotation in fields",
+ ((MyEntity) processInstance.getVariable( "y" )).getTest() );
+ assertEquals( "This is a test Entity with annotations in methods",
+ ((MyEntityMethods) processInstance.getVariable( "m" )).getTest() );
+ assertEquals( "This is a test Entity with annotations in fields and without accesors methods",
+ ((MyEntityOnlyFields) processInstance.getVariable( "f" )).test );
+ assertEquals( "This is a test SerializableObject",
+ ((MyVariableSerializable) processInstance.getVariable( "z" )).getText() );
+ assertNull( processInstance.getVariable( "a" ) );
+ assertNull( processInstance.getVariable( "b" ) );
+ assertNull( processInstance.getVariable( "c" ) );
+
+ service.dispose();
+
+ // log.info("### Completing first work item ###");
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // log.info("### Retrieving variable instance infos ###");
+ // result = emf.createEntityManager().createQuery("select i from VariableInstanceInfo i").getResultList();
+ // assertEquals(8, result.size());
+ // for (Object o: result) {
+ // assertTrue(VariableInstanceInfo.class.isAssignableFrom(o.getClass()));
+ // log.info(o);
+ // }
+ //
+ // log.info("### Retrieving process instance ###");
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, null, env);
+ // processInstance = (WorkflowProcessInstance)
+ // ksession.getProcessInstance(processInstance.getId());
+ // assertNotNull(processInstance);
+ // assertEquals("SomeString", processInstance.getVariable("x"));
+ // assertEquals("This is a test Entity with annotation in fields", ((MyEntity) processInstance.getVariable("y")).getTest());
+ // assertEquals("This is a test Entity with annotations in methods", ((MyEntityMethods) processInstance.getVariable("m")).getTest());
+ // assertEquals("This is a test Entity with annotations in fields and without accesors methods", ((MyEntityOnlyFields) processInstance.getVariable("f")).test);
+ // assertEquals("This is a test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("z")).getText());
+ // assertEquals("Some new String", processInstance.getVariable("a"));
+ // assertEquals("This is a new test Entity", ((MyEntity) processInstance.getVariable("b")).getTest());
+ // assertEquals("This is a new test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("c")).getText());
+ // log.info("### Completing second work item ###");
+ // ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
+ //
+ // workItem = handler.getWorkItem();
+ // assertNotNull(workItem);
+ //
+ // result = emf.createEntityManager().createQuery("select i from VariableInstanceInfo i").getResultList();
+ // assertEquals(8, result.size());
+ //
+ // log.info("### Retrieving process instance ###");
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, null, env);
+ // processInstance = (WorkflowProcessInstance)
+ // ksession.getProcessInstance(processInstance.getId());
+ // assertNotNull(processInstance);
+ // assertEquals("SomeString", processInstance.getVariable("x"));
+ // assertEquals("This is a test Entity with annotation in fields", ((MyEntity) processInstance.getVariable("y")).getTest());
+ // assertEquals("This is a test Entity with annotations in methods", ((MyEntityMethods) processInstance.getVariable("m")).getTest());
+ // assertEquals("This is a test Entity with annotations in fields and without accesors methods", ((MyEntityOnlyFields) processInstance.getVariable("f")).test);
+ // assertEquals("This is a test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("z")).getText());
+ // assertEquals("Some changed String", processInstance.getVariable("a"));
+ // assertEquals("This is a changed test Entity", ((MyEntity) processInstance.getVariable("b")).getTest());
+ // assertEquals("This is a changed test SerializableObject", ((MyVariableSerializable) processInstance.getVariable("c")).getText());
+ // log.info("### Completing third work item ###");
+ // ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
+ //
+ // workItem = handler.getWorkItem();
+ // assertNull(workItem);
+ //
+ // result = emf.createEntityManager().createQuery("select i from VariableInstanceInfo i").getResultList();
+ // //This was 6.. but I change it to 0 because all the variables will go away with the process instance..
+ // //we need to change that to leave the variables there???
+ // assertEquals(0, result.size());
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(id, kbase, null, env);
+ // processInstance = (WorkflowProcessInstance)
+ // ksession.getProcessInstance(processInstance.getId());
+ // assertNull(processInstance);
+ }
+
+ // public void testPersistenceVariablesWithTypeChange() {
+ // KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ // kbuilder.add( new ClassPathResource( "VariablePersistenceStrategyProcessTypeChange.rf" ), ResourceType.DRF );
+ // for (KnowledgeBuilderError error: kbuilder.getErrors()) {
+ // log.info(error);
+ // }
+ // KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ // kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+ //
+ // EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
+ // Environment env = KnowledgeBaseFactory.newEnvironment();
+ // env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
+ //
+ // env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
+ //
+ // StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
+ // int id = ksession.getId();
+ //
+ // Map<String, Object> parameters = new HashMap<String, Object>();
+ // parameters.put("x", "SomeString");
+ // parameters.put("y", new MyEntity("This is a test Entity with annotation in fields"));
+ // parameters.put("m", new MyEntityMethods("This is a test Entity with annotations in methods"));
+ // parameters.put("f", new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods"));
+ // parameters.put("z", new MyVariableSerializable("This is a test SerializableObject"));
+ // ProcessInstance processInstance = ksession.startProcess( "com.sample.ruleflow", parameters );
+ //
+ // TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ // WorkItem workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNotNull( processInstance );
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNotNull( processInstance );
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNull( processInstance );
+ // }
+ //
+ // public void testPersistenceVariablesSubProcess() {
+ // KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ // kbuilder.add( new ClassPathResource( "VariablePersistenceStrategySubProcess.rf" ), ResourceType.DRF );
+ // for (KnowledgeBuilderError error: kbuilder.getErrors()) {
+ // log.info("{}", error);
+ // }
+ // KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
+ // kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );
+ //
+ // EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" );
+ // Environment env = KnowledgeBaseFactory.newEnvironment();
+ // env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
+ //
+ // env.set( EnvironmentName.GLOBALS, new MapGlobalResolver() );
+ //
+ // StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env );
+ // int id = ksession.getId();
+ //
+ // Map<String, Object> parameters = new HashMap<String, Object>();
+ // parameters.put("x", "SomeString");
+ // parameters.put("y", new MyEntity("This is a test Entity with annotation in fields"));
+ // parameters.put("m", new MyEntityMethods("This is a test Entity with annotations in methods"));
+ // parameters.put("f", new MyEntityOnlyFields("This is a test Entity with annotations in fields and without accesors methods"));
+ // parameters.put("z", new MyVariableSerializable("This is a test SerializableObject"));
+ // ProcessInstance processInstance = ksession.startProcess( "com.sample.ruleflow", parameters );
+ //
+ // TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
+ // WorkItem workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNotNull( processInstance );
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNotNull( processInstance );
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNotNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNotNull( processInstance );
+ // ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
+ //
+ // workItem = handler.getWorkItem();
+ // assertNull( workItem );
+ //
+ // ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );
+ // processInstance = ksession.getProcessInstance( processInstance.getId() );
+ // assertNull( processInstance );
+ // }
+ //
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/MyDroolsBean.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/MyDroolsBean.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/MyDroolsBean.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,123 @@
+package org.drools.container.spring.timer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.base.MapGlobalResolver;
+import org.drools.persistence.jpa.KnowledgeStoreService;
+import org.drools.runtime.Environment;
+import org.drools.runtime.EnvironmentName;
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.orm.jpa.JpaTransactionManager;
+
+public class MyDroolsBean {
+
+ private static int timerTriggerCount;
+ private static int sessionId;
+
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
+ private EntityManagerFactory emf;
+ private KnowledgeBase kbase;
+ private KnowledgeStoreService kstore;
+ private JpaTransactionManager txm;
+
+ private TestWorkItemHandler workItemHandler = new TestWorkItemHandler();
+
+ public void initStartDisposeAndLoadSession() {
+ try {
+ EntityManager em = txm.getEntityManagerFactory().createEntityManager();
+ // create new ksession with kstore
+ StatefulKnowledgeSession ksession = kstore.newStatefulKnowledgeSession( kbase,
+ null,
+ getEnvironment() );
+ sessionId = ksession.getId();
+
+ logger.info( "\n\tSession id: " + sessionId + "\n" );
+
+ ksession.getWorkItemManager().registerWorkItemHandler( "testWorkItemHandler",
+ workItemHandler );
+
+ ksession.startProcess( "timer-flow",
+ null );
+ Thread.sleep( 4000 );
+ ksession.dispose();
+ } catch ( Exception ex ) {
+ throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
+ }
+ }
+
+ /**
+ * Thread safe increment.
+ */
+ public static synchronized void incrementTimerTriggerCount() {
+ timerTriggerCount++;
+ }
+
+ /**
+ * Thread safe getter.
+ * Note that if this method is not synchronized, there is no visibility guarantee,
+ * so the returned value might be a stale cache.
+ * @return >= 0
+ */
+ public static synchronized int getTimerTriggerCount() {
+ return timerTriggerCount;
+ }
+
+ public void endTheProcess() {
+ try {
+ StatefulKnowledgeSession ksession = kstore.loadStatefulKnowledgeSession( sessionId,
+ kbase,
+ null,
+ getEnvironment() );
+
+ //Sleep to check if the timer continues executing.
+ logger.info( "\n\nSleeping to check that the timer is still running" );
+ Thread.sleep( 5000 );
+
+ ksession.getWorkItemManager().completeWorkItem( TestWorkItemHandler.getWorkItem().getId(),
+ null );
+
+ logger.info( "\n\nSleeping to check that the timer is no longer running" );
+ Thread.sleep( 3000 );
+ logger.info( "Ok" );
+
+ ksession.dispose();
+
+ } catch ( InterruptedException ex ) {
+ throw new IllegalStateException("The endTheProcess method has been interrupted", ex);
+ }
+ }
+
+ private Environment getEnvironment() {
+ Environment environment = KnowledgeBaseFactory.newEnvironment();
+ environment.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
+ emf );
+ environment.set( EnvironmentName.TRANSACTION_MANAGER,
+ txm );
+ environment.set( EnvironmentName.GLOBALS,
+ new MapGlobalResolver() );
+
+ return environment;
+ }
+
+ public void setEmf(EntityManagerFactory emf) {
+ this.emf = emf;
+ }
+
+ public void setKbase(KnowledgeBase kbase) {
+ this.kbase = kbase;
+ }
+
+ public void setKstore(KnowledgeStoreService kstore) {
+ this.kstore = kstore;
+ }
+
+ public void setTxm(JpaTransactionManager txm) {
+ this.txm = txm;
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TestWorkItemHandler.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TestWorkItemHandler.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TestWorkItemHandler.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,29 @@
+package org.drools.container.spring.timer;
+
+import org.drools.runtime.process.WorkItem;
+import org.drools.runtime.process.WorkItemHandler;
+import org.drools.runtime.process.WorkItemManager;
+
+public class TestWorkItemHandler
+ implements
+ WorkItemHandler {
+ private static WorkItem workItem = null;
+
+ public void abortWorkItem(WorkItem arg0,
+ WorkItemManager arg1) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void executeWorkItem(WorkItem item,
+ WorkItemManager manager) {
+ // TODO Auto-generated method stub
+ workItem = item;
+ System.out.println( "**** Inside TestWorkItemHandler, suspending.... ****" );
+ }
+
+ public static WorkItem getWorkItem() {
+ return workItem;
+ }
+
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TimerFlowTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TimerFlowTest.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/container/spring/timer/TimerFlowTest.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,60 @@
+package org.drools.container.spring.timer;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class TimerFlowTest {
+
+ private static final Logger log = LoggerFactory.getLogger( TimerFlowTest.class );
+ private static final String TMPDIR = System.getProperty( "java.io.tmpdir" );
+
+ private ClassPathXmlApplicationContext ctx;
+
+ @Before
+ public void createSpringContext() {
+ try {
+ log.info( "creating spring context" );
+ PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
+ Properties properties = new Properties();
+ properties.setProperty( "temp.dir",
+ TMPDIR );
+ configurer.setProperties( properties );
+ ctx = new ClassPathXmlApplicationContext();
+ ctx.addBeanFactoryPostProcessor( configurer );
+ ctx.setConfigLocation( "org/drools/container/spring/timer/conf/spring-conf.xml" );
+ ctx.refresh();
+ } catch ( Exception e ) {
+ log.error( "can't create spring context",
+ e );
+ throw new RuntimeException( e );
+ }
+ }
+
+ @Test @Ignore // test randomly fails on some computer architectures.
+ public void doTest() throws Exception {
+ // TODO do not use Thread.sleep() in MyDroolsBean, but use Object.wait() and Object.notifyAll() or a Latch instead
+
+ MyDroolsBean myDroolsBean = (MyDroolsBean) ctx.getBean( "myDroolsBean" );
+
+ assertEquals( 0,
+ myDroolsBean.getTimerTriggerCount());
+
+ myDroolsBean.initStartDisposeAndLoadSession();
+
+ int n = myDroolsBean.getTimerTriggerCount();
+ assertTrue( n > 0 );
+
+ myDroolsBean.endTheProcess();
+ assertTrue( myDroolsBean.getTimerTriggerCount() > n );
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/helper/FileHelper.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/helper/FileHelper.java (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/java/org/drools/helper/FileHelper.java 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.helper;
+
+import java.io.File;
+
+public class FileHelper {
+ public static void remove(File file) {
+ if ( file.isDirectory() ) {
+ File[] files = file.listFiles();
+ for ( File f : files ) {
+ remove( f );
+ }
+ }
+ file.delete();
+ }
+}
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/MyWorkItemHandlers.conf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/MyWorkItemHandlers.conf (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/MyWorkItemHandlers.conf 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,12 @@
+// We use MVEL to return a List of work definitions
+// The properties of the work definitions are specified as a Map<String, Object>
+// The allowed properties are name, parameters, displayName, icon and customEditor
+// The returned result should thus be of type List<Map<String, Object>>
+import org.drools.container.spring.beans.persistence.TestWorkItemHandler;
+
+[
+
+ "MyWork" : TestWorkItemHandler.getInstance(),
+ "Human Task" : TestWorkItemHandler.getInstance()
+
+]
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/drools.session.conf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/drools.session.conf (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/drools.session.conf 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1 @@
+drools.workItemHandlers = MyWorkItemHandlers.conf
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/orm.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/orm.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/orm.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+ version="1.0">
+ <named-query name="ProcessInstancesWaitingForEvent">
+ <query>
+select
+ processInstanceInfo.processInstanceId
+from
+ ProcessInstanceInfo processInstanceInfo
+where
+ :type in elements(processInstanceInfo.eventTypes)
+ </query>
+ </named-query>
+</entity-mappings>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/persistence.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/persistence.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/META-INF/persistence.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
+ http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
+
+ <persistence-unit name="org.drools.persistence.jpa.local" transaction-type="RESOURCE_LOCAL">
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <!--
+ <jta-data-source>jdbc/testDS1</jta-data-source>
+ -->
+ <class>org.drools.persistence.info.SessionInfo</class>
+ <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
+ <class>org.drools.persistence.info.WorkItemInfo</class>
+
+ <!-- my persistent variables -->
+ <class>org.drools.container.spring.beans.persistence.MyEntity</class>
+ <class>org.drools.container.spring.beans.persistence.MyEntityMethods</class>
+ <class>org.drools.container.spring.beans.persistence.MyEntityOnlyFields</class>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect" />
+ <!--property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/-->
+ <!--property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/-->
+
+ <property name="hibernate.max_fetch_depth" value="3" />
+ <property name="hibernate.hbm2ddl.auto" value="create" />
+ <property name="hibernate.show_sql" value="false" />
+
+ <!--
+ <property name="hibernate.connection.autocommit" value="false" />
+ <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.BTMTransactionManagerLookup" />
+ -->
+ </properties>
+ </persistence-unit>
+</persistence>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/log4j.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/log4j.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/log4j.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-4r %d{dd/MM HH:mm:ss,SSS}[%t] %-5p %c{3}.%M %x- %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- A time/date based rolling appender
+ <appender name="FILE" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="${java.io.tmpdir}/drools.log"/>
+ <param name="Append" value="true"/>
+ <param name="MaxBackupIndex" value="5"/>
+ <param name="MaxFileSize" value="50MB"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-4r %d{dd/MM HH:mm:ss,SSS}[%t] %-5p %c{3}.%M %x- %m%n"/>
+ </layout>
+ </appender>
+ -->
+ <logger name="org.drools">
+ <level value="INFO"/>
+ </logger>
+
+ <!-- logger name="org.hibernate">
+ <level value="INFO"/>
+ </logger -->
+ <root>
+ <priority value="INFO"/>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+</log4j:configuration>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/.~lock.IntegrationExampleTest.xls#
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/.~lock.IntegrationExampleTest.xls# (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/.~lock.IntegrationExampleTest.xls# 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1 @@
+,Daedalus/mproctor,Daedalus,22.10.2009 04:23,file:///C:/Users/mproctor/AppData/Roaming/OpenOffice.org/3;
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/IntegrationExampleTest.xls
===================================================================
(Binary files differ)
Property changes on: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/IntegrationExampleTest.xls
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyProcess.rf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyProcess.rf (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/VariablePersistenceStrategyProcess.rf 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://drools.org/drools-5.0/process"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
+ type="RuleFlow" name="ruleflow" id="com.sample.ruleflow" package-name="com.sample" >
+
+ <header>
+ <imports>
+ <import name="org.drools.container.spring.beans.persistence.MyEntity" />
+ <import name="org.drools.container.spring.beans.persistence.MyVariableSerializable" />
+ <import name="javax.persistence.EntityManager" />
+ <import name="org.drools.runtime.EnvironmentName" />
+ </imports>
+ <variables>
+ <variable name="x" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </variable>
+ <variable name="y" >
+ <type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="org.drools.container.spring.beans.persistence.MyEntity" />
+ </variable>
+ <variable name="z" >
+ <type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="org.drools.container.spring.beans.persistence.MyVariableSerializable" />
+ </variable>
+ <variable name="a" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </variable>
+ <variable name="b" >
+ <type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="org.drools.container.spring.beans.persistence.MyEntity" />
+ </variable>
+ <variable name="c" >
+ <type name="org.drools.process.core.datatype.impl.type.ObjectDataType" className="org.drools.container.spring.beans.persistence.MyVariableSerializable" />
+ </variable>
+ </variables>
+ </header>
+
+ <nodes>
+ <start id="1" name="Start" x="16" y="16" width="48" height="48" />
+ <end id="3" name="End" x="458" y="189" width="48" height="48" />
+ <humanTask id="4" name="Human Task" x="208" y="16" width="93" height="48" >
+ <work name="Human Task" >
+ <parameter name="ActorId" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Comment" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Content" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Priority" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Skippable" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="TaskName" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ </work>
+ </humanTask>
+ <actionNode id="5" name="Action" x="96" y="20" width="80" height="40" >
+ <action type="expression" dialect="java" >System.out.println("x = " + x);
+System.out.println("y = " + y);
+System.out.println("z = " + z);</action>
+ </actionNode>
+ <actionNode id="6" name="Action" x="333" y="20" width="80" height="40" >
+ <action type="expression" dialect="java" >System.out.println("x = " + x);
+System.out.println("y = " + y);
+System.out.println("z = " + z);
+kcontext.setVariable("a", "Some new String");
+
+EntityManager em = (EntityManager) kcontext.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.APP_SCOPED_ENTITY_MANAGER);
+MyEntity myNewEntity = new MyEntity("This is a new test Entity");
+em.persist(myNewEntity);
+
+
+kcontext.setVariable("b", myNewEntity);
+kcontext.setVariable("c", new MyVariableSerializable("This is a new test SerializableObject"));</action>
+ </actionNode>
+ <humanTask id="7" name="Human Task" x="445" y="20" width="80" height="40" >
+ <work name="Human Task" >
+ <parameter name="ActorId" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Comment" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Content" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Priority" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Skippable" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="TaskName" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ </work>
+ </humanTask>
+ <actionNode id="8" name="Action" x="557" y="20" width="80" height="40" >
+ <action type="expression" dialect="java" >System.out.println("x = " + x);
+System.out.println("y = " + y);
+System.out.println("z = " + z);
+System.out.println("a = " + a);
+System.out.println("b = " + b);
+System.out.println("c = " + c);
+kcontext.setVariable("a", "Some changed String");
+EntityManager em = (EntityManager) kcontext.getKnowledgeRuntime().getEnvironment().get(EnvironmentName.APP_SCOPED_ENTITY_MANAGER);
+MyEntity myNewEntity = new MyEntity("This is a changed test Entity");
+em.persist(myNewEntity);
+
+kcontext.setVariable("b", myNewEntity);
+kcontext.setVariable("c", new MyVariableSerializable("This is a changed test SerializableObject"));</action>
+ </actionNode>
+ <humanTask id="9" name="Human Task" x="550" y="94" width="100" height="48" >
+ <work name="Human Task" >
+ <parameter name="ActorId" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Comment" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Content" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Priority" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="Skippable" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ <parameter name="TaskName" >
+ <type name="org.drools.process.core.datatype.impl.type.StringDataType" />
+ </parameter>
+ </work>
+ </humanTask>
+ <actionNode id="10" name="Action" x="562" y="189" width="80" height="48" >
+ <action type="expression" dialect="java" >System.out.println("x = " + x);
+System.out.println("y = " + y);
+System.out.println("z = " + z);
+System.out.println("a = " + a);
+System.out.println("b = " + b);
+System.out.println("c = " + c);</action>
+ </actionNode>
+ </nodes>
+
+ <connections>
+ <connection from="10" to="3" />
+ <connection from="5" to="4" />
+ <connection from="1" to="5" />
+ <connection from="4" to="6" />
+ <connection from="6" to="7" />
+ <connection from="7" to="8" />
+ <connection from="8" to="9" />
+ <connection from="9" to="10" />
+ </connections>
+
+</process>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beans.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beans.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beans.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd">
+
+ <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <!-- org.h2.jdbcx.JdbcDataSource -->
+ <property name="driverClassName" value="org.h2.Driver" />
+ <!-- jdbc:h2:mem:mydb
+ jdbc:h2:tcp://localhost/DroolsFlow-->
+ <property name="url" value="jdbc:h2:tcp://localhost/DroolsFlow" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+ <drools:grid-node id="node1" />
+
+ <drools:kbase id="kbProcessWorkItems" node="node1">
+ <drools:resources>
+ <drools:resource type="PKG" source="file:///${temp.dir}/processWorkItems.pkg" />
+ <drools:resource type="PKG" source="file:///${temp.dir}/processSubProcess.pkg" />
+ <drools:resource type="PKG" source="file:///${temp.dir}/processTimer.pkg" />
+ <drools:resource type="PKG" source="file:///${temp.dir}/processTimer2.pkg" />
+ </drools:resources>
+ </drools:kbase>
+
+ <bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="ds" />
+ <property name="persistenceUnitName" value="org.drools.persistence.jpa.local" />
+ </bean>
+
+ <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="myEmf" />
+ </bean>
+
+ <drools:kstore id="kstore1" />
+
+ <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="kbProcessWorkItems">
+ <drools:configuration>
+ <drools:jpa-persistence>
+ <drools:transaction-manager ref="txManager" />
+ <drools:entity-manager-factory ref="myEmf" />
+ </drools:jpa-persistence>
+ </drools:configuration>
+ </drools:ksession>
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beansVarPersistence.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beansVarPersistence.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/beansVarPersistence.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd">
+
+ <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.h2.Driver" />
+ <property name="url" value="jdbc:h2:tcp://localhost/DroolsFlow" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+ <!-- <drools:connection id="connection1" type="local" />
+ <drools:execution-node id="node1" connection="connection1" /> -->
+
+ <drools:kbase id="kbase1">
+ <drools:resources>
+ <drools:resource type="DRF" source="classpath:org/drools/container/spring/beans/persistence/VariablePersistenceStrategyProcess.rf" />
+ </drools:resources>
+ </drools:kbase>
+
+ <drools:kbase id="kbRollback">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/beans/persistence/rollbackRules.drl" />
+ </drools:resources>
+ </drools:kbase>
+
+ <bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="ds" />
+ <property name="persistenceUnitName" value="org.drools.persistence.jpa.local" />
+ </bean>
+
+ <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="myEmf" />
+ </bean>
+
+ <drools:kstore id="kstore1" />
+
+ <drools:ksession id="jpaSingleSessionCommandService" type="stateful" kbase="kbase1">
+ <drools:configuration>
+ <drools:jpa-persistence>
+ <drools:transaction-manager ref="txManager" />
+ <drools:entity-manager-factory ref="myEmf" />
+
+ </drools:jpa-persistence>
+ </drools:configuration>
+ </drools:ksession>
+
+ <drools:ksession id="jpaSingleSessionCommandServiceRollback" type="stateful" kbase="kbRollback">
+ <drools:configuration>
+ <drools:jpa-persistence>
+ <drools:transaction-manager ref="txManager" />
+ <drools:entity-manager-factory ref="myEmf" />
+ <!-- drools:variable-persisters>
+ <drools:persister for-class="javax.persistence.Entity" implementation="org.drools.persistence.processinstance.persisters.JPAVariablePersister"/>
+ <drools:persister for-class="java.lang.String" implementation="org.drools.container.spring.beans.persistence.StringVariablePersister"/>
+ <drools:persister for-class="java.io.Serializable" implementation="org.drools.persistence.processinstance.persisters.SerializableVariablePersister"/>
+ </drools:variable-persisters -->
+ </drools:jpa-persistence>
+ </drools:configuration>
+ </drools:ksession>
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/rollbackRules.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/rollbackRules.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans/persistence/rollbackRules.drl 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.test;
+
+global java.util.List list;
+
+rule "test rollback"
+when
+ $i : Integer(intValue > 0);
+then
+ list.add( $i );
+end
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/beans.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <drools:grid id="grid1">
+ <drools:whitepages />
+ </drools:grid>
+
+ <drools:grid-node id="node1" grid="grid1" />
+
+ <drools:grid-node id="node2" />
+
+ <drools:resource id="resource1" type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
+
+ <drools:resource id="secureResource" basic-authentication="enabled" username="someUser" password="somePassword" type="DRL" source="http://someHost:1234/someDRLResource.drl"/>
+ <drools:resource id="insecureResource" type="DRL" source="http://someHost:1234/someOtherDRLResource.drl"/>
+
+ <drools:kbase id="kbase1" node="node1">
+ <drools:resources>
+ <drools:resource source="classpath:org/drools/container/spring/IntegrationExampleTest.xls" type="DTABLE">
+ <drools:decisiontable-conf input-type="XLS" worksheet-name="Tables_2" />
+ </drools:resource>
+
+ <drools:resource ref="resource1"/>
+
+ <drools:resource source="classpath:org/drools/container/spring/model.xsd" type="XSD">
+ <drools:jaxb-conf system-id="xsd" />
+ </drools:resource>
+ </drools:resources>
+ </drools:kbase>
+
+
+ <drools:ksession id="ksession1" type="stateless" name="stateless1" kbase="kbase1" node="node1"/>
+
+ <drools:ksession id="ksession2" type="stateful" kbase="kbase1" node="node1"/>
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/drl/testSpring.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/drl/testSpring.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/drl/testSpring.drl 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.springframework
+
+import org.drools.Person
+
+global java.util.List list;
+
+rule "rule 1"
+when
+ $p : Person();
+then
+ list.add( $p );
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/grid.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/grid.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/grid.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <bean id="ds" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <!-- org.h2.jdbcx.JdbcDataSource -->
+ <property name="driverClassName" value="org.h2.Driver" />
+ <property name="url" value="jdbc:h2:mem:mydb" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+ <bean id="myEmf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
+ <property name="persistenceUnitName" value="org.drools.grid"/>
+ </bean>
+
+ <!--bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="dataSource" ref="ds" />
+ <property name="persistenceUnitName" value="org.drools.grid" />
+ <property name="hibernateProperties">
+ <value>
+ hibernate.dialect=org.hibernate.dialect.MySQLDialect
+ hibernate.show_sql=true
+
+ hibernate.dialect=org.hibernate.dialect.H2Dialect
+ hibernate.connection.driver_class="org.h2.Driver
+ hibernate.connection.url=jdbc:h2:mem:mydb
+ hibernate.connection.username=sa
+ hibernate.connection.password=sasa
+ hibernate.connection.autocommit=false
+ hibernate.max_fetch_depth=3
+ hibernate.hbm2ddl.auto=create
+ hibernate.show_sql=true
+ </value>
+ </property>
+ </bean-->
+
+ <bean id="shared-map" class="java.util.HashMap" />
+
+ <bean id="localWhitePages" class="org.drools.grid.service.directory.impl.WhitePagesImpl" />
+
+ <drools:grid id="grid1">
+ <drools:core-services ref="shared-map" />
+
+ <drools:whitepages>
+ <drools:jpa-persistence>
+ <drools:entity-manager-factory ref="myEmf" />
+ </drools:jpa-persistence>
+ </drools:whitepages>
+
+ <drools:socket-service acceptor="mina" ip="127.0.0.1">
+ <drools:service name="org.drools.grid.service.directory.WhitePages" port="8000" />
+ </drools:socket-service>
+ </drools:grid>
+
+
+ <drools:grid id="grid2">
+ <drools:core-services ref="shared-map" />
+ </drools:grid>
+
+
+ <drools:grid id="grid3">
+ <drools:whitepages ref="localWhitePages" />
+ </drools:grid>
+
+
+ <drools:grid-node id="node1" grid="grid1">
+ <drools:socket-service port="8000" />
+ </drools:grid-node>
+
+ <drools:grid-node id="node2" />
+
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/kagents-beans.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/kagents-beans.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/kagents-beans.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <drools:resource-change-scanner id="s1" interval="5" />
+
+ <drools:grid-node id="node1" />
+
+ <drools:ksession id="ksession1" type="stateless" kbase="kbase1"/>
+
+ <drools:ksession id="ksession2" type="stateful" kbase="kbase1"/>
+
+ <drools:kbase id="kbase1" node="node1">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
+ </drools:resources>
+ </drools:kbase>
+
+ <drools:kbase id="kbase2" node="node1">
+ </drools:kbase>
+
+ <drools:kbase id="kbase3" node="node1">
+ </drools:kbase>
+
+ <drools:kagent id="kagent1" kbase="kbase1" new-instance="false" />
+
+ <drools:kagent id="kagent2" kbase="kbase2" new-instance="false">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/drl" />
+ </drools:resources>
+ </drools:kagent>
+
+ <drools:kagent id="kagent3" kbase="kbase3" new-instance="true" />
+
+ <drools:ksession id="ksession3" type="stateless" kbase="kbase2"/>
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/model.xsd
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/model.xsd (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/model.xsd 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,14 @@
+<xsd:schema
+ xmlns:person="http://drools.org/model"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://drools.org/model"
+ elementFormDefault="qualified"
+>
+ <xsd:complexType name="person">
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string" />
+ <xsd:element name="age" type="xsd:integer" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/no-node-beans.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/no-node-beans.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/no-node-beans.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <drools:kbase id="kbase1">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
+ </drools:resources>
+ </drools:kbase>
+
+ <drools:ksession id="ksession1" type="stateless" kbase="kbase1"/>
+
+ <drools:ksession id="ksession2" type="stateful" kbase="kbase1"/>
+
+ <drools:ksession id="ksession3" type="stateful" kbase="kbase1">
+
+ </drools:ksession>
+
+
+ <bean id="person1" class="org.drools.Person" >
+ <property name="name" value="mark" />
+ </bean>
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/session-conf-beans.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/session-conf-beans.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/session-conf-beans.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xmlns:camel="http://camel.apache.org/schema/spring"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
+ http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
+
+ <bean id="rwih1" class="org.jbpm.process.instance.impl.humantask.HumanTaskHandler" />
+
+ <bean id="rwih2" class="org.jbpm.process.instance.impl.humantask.HumanTaskHandler" />
+
+ <bean id="raf1" class="org.drools.container.spring.MockAccumulateFunction" />
+ <bean id="raf2" class="org.drools.container.spring.MockAccumulateFunction" />
+
+ <bean id="red1" class="org.drools.container.spring.MockEvaluatorDefinition" />
+ <bean id="red2" class="org.drools.container.spring.MockEvaluatorDefinition" />
+
+ <drools:kbase id="kbase1">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
+ </drools:resources>
+
+ <drools:configuration>
+ <drools:advanced-process-rule-integration enabled="true" />
+
+ <drools:multithread enabled="true" max-threads="5" />
+
+ <drools:mbeans enabled="true" />
+
+ <drools:event-processing-mode mode="STREAM" />
+
+ <drools:accumulate-functions>
+ <drools:accumulate-function name="af1" ref="raf1" />
+ <drools:accumulate-function name="af2" ref="raf2" />
+ </drools:accumulate-functions>
+
+ <drools:evaluators>
+ <drools:evaluator name="ed1" ref="red1" />
+ <drools:evaluator name="ed2" ref="red2" />
+ </drools:evaluators>
+
+ <drools:assert-behavior mode="IDENTITY" />
+
+ <drools:consequenceExceptionHandler handler="org.drools.container.spring.MockConsequenceExceptionHandler" />
+
+ </drools:configuration>
+ </drools:kbase>
+
+ <drools:kbase id="kbase2">
+ <drools:resources>
+ <drools:resource type="DRL" source="classpath:org/drools/container/spring/testSpring.drl"/>
+ </drools:resources>
+
+ <drools:configuration>
+ <drools:advanced-process-rule-integration enabled="false" />
+
+ <drools:multithread enabled="false" />
+
+ <drools:mbeans enabled="false" />
+
+ <drools:event-processing-mode mode="CLOUD" />
+
+ <drools:assert-behavior mode="EQUALITY" />
+ </drools:configuration>
+ </drools:kbase>
+
+
+ <drools:ksession id="ksession1" type="stateful" kbase="kbase1" >
+ <drools:configuration>
+ <drools:work-item-handlers>
+ <drools:work-item-handler name="wih1" ref="rwih1" />
+ <drools:work-item-handler name="wih2" ref="rwih2" />
+ </drools:work-item-handlers>
+ <drools:keep-reference enabled="true" />
+ <drools:clock-type type="REALTIME" />
+ </drools:configuration>
+ </drools:ksession>
+
+ <drools:ksession id="ksession2" type="stateful" kbase="kbase1" >
+ <drools:configuration>
+ <drools:keep-reference enabled="false" />
+ <drools:clock-type type="PSEUDO" />
+ </drools:configuration>
+ </drools:ksession>
+
+</beans>
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/testSpring.drl
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/testSpring.drl (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/testSpring.drl 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.springframework
+
+import org.drools.Person
+
+global java.util.List list;
+
+rule "rule 1"
+when
+ $p : Person();
+then
+ list.add( $p );
+end
\ No newline at end of file
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/conf/spring-conf.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/conf/spring-conf.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/conf/spring-conf.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:drools="http://drools.org/schema/drools-spring"
+ xmlns:jee="http://www.springframework.org/schema/jee"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
+ http://drools.org/schema/drools-spring http://drools.org/schema/drools-spring.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <bean name="myDroolsBean" class="org.drools.container.spring.timer.MyDroolsBean">
+ <property name="emf" ref="entityManagerFactory" />
+ <property name="kbase" ref="knowledgeBase" />
+ <property name="kstore" ref="knowledgeStore" />
+ <property name="txm" ref="transactionManager" />
+ </bean>
+
+ <context:annotation-config/>
+
+ <drools:kstore id="knowledgeStore"/>
+
+ <drools:kbase id="knowledgeBase">
+ <drools:resources>
+ <drools:resource type="DRF"
+ source="classpath:org/drools/container/spring/timer/flow/timer-flow.rf" />
+ </drools:resources>
+ </drools:kbase>
+
+ <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
+ <property name="entityManagerFactory" ref="entityManagerFactory" />
+ </bean>
+
+ <bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.h2.Driver" />
+ <property name="url" value="jdbc:h2:workflow" />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+ <bean id="entityManagerFactory"
+ class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+ <property name="persistenceUnitName" value="org.drools.persistence.jpa.local" />
+ <property name="dataSource" ref="datasource" />
+ <!--property name="jpaProperties">
+ <props>
+ <prop key="hibernate.connection.autocommit">false</prop>
+ <prop key="hibernate.max_fetch_depth">3</prop>
+ <prop key="hibernate.show_sql">false</prop>
+ <prop key="hibernate.dialect">org.hibernate.dialect.H2Dialect</prop>
+ <prop key="hibernate.hbm2ddl.auto">create-drop</prop>
+ </props>
+ </property-->
+ </bean>
+
+
+ <!--aop:config>
+ <aop:pointcut id="timerFlowManagerMethods"
+ expression="execution(* org.drools.container.spring.timer.MyDroolsBean.*(..))"/>
+
+ <aop:advisor advice-ref="timerFlowManagerTxAdvice"
+ pointcut-ref="timerFlowManagerMethods"/>
+ </aop:config>
+
+ <tx:advice id="timerFlowManagerTxAdvice" transaction-manager="transactionManager">
+ <tx:attributes>
+ <tx:method name="initStartDisposeAndLoadSession" propagation="REQUIRED"/>
+ <tx:method name="endTheProcess" propagation="REQUIRED"/>
+ <tx:method name="*" propagation="REQUIRED" read-only="true"/>
+ </tx:attributes>
+ </tx:advice-->
+
+</beans>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/flow/timer-flow.rf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/flow/timer-flow.rf (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/drools-spring/src/test/resources/org/drools/container/spring/timer/flow/timer-flow.rf 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://drools.org/drools-5.0/process"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
+ type="RuleFlow" name="timer-flow" id="timer-flow" package-name="drools.timer" >
+
+ <header>
+ <imports>
+ <import name="org.drools.container.spring.timer.MyDroolsBean" />
+ </imports>
+ </header>
+
+ <nodes>
+ <start id="1" name="Start" x="16" y="16" width="48" height="48" />
+ <end id="3" name="End" x="377" y="20" width="80" height="40" />
+ <workItem id="4" name="TestWorkItem" x="96" y="20" width="137" height="40" >
+ <work name="testWorkItemHandler" >
+ </work>
+ <onEntry>
+ <action type="expression" dialect="mvel" >System.out.println("**** Entering Test Work Item ****");</action>
+ </onEntry>
+ <onExit>
+ <action type="expression" dialect="mvel" >System.out.println("**** Exiting Test Work Item ****");</action>
+ </onExit>
+ <timers>
+ <timer id="1" delay="1000" period="2000" >
+ <action type="expression" dialect="java" >System.out.println("**** Timer Triggered ****");
+MyDroolsBean.incrementTimerTriggerCount();</action>
+ </timer>
+ </timers>
+ </workItem>
+ </nodes>
+
+ <connections>
+ <connection from="1" to="4" />
+ <connection from="4" to="3" />
+ </connections>
+
+</process>
Added: labs/jbossrules/tags/5.2.0.M1/drools-container/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-container/pom.xml (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-container/pom.xml 2011-02-24 15:34:37 UTC (rev 36698)
@@ -0,0 +1,21 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.drools</groupId>
+ <artifactId>drools</artifactId>
+ <version>5.2.0.M1</version>
+ </parent>
+
+ <artifactId>drools-container</artifactId>
+ <packaging>pom</packaging>
+ <name>Drools :: Container</name>
+
+
+ <modules>
+ <module>drools-seam</module>
+ <module>drools-spring</module>
+ </modules>
+
+</project>
More information about the jboss-svn-commits
mailing list