[jbpm-commits] JBoss JBPM SVN: r5918 - in jbpm4/trunk: modules/devguide/src/main/docbook/en/modules and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Dec 4 11:12:01 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-12-04 11:12:00 -0500 (Fri, 04 Dec 2009)
New Revision: 5918
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/ExecutionGlobals.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/Outcome.java
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
jbpm4/trunk/modules/examples/pom.xml
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.cfg.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java
jbpm4/trunk/pom.xml
Log:
JBPM-2006 drools integration
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -317,7 +317,7 @@
<!-- ### GROUP ########################################################## -->
<section id="group">
- <title><literal>group</literal></title>
+ <title><literal>group</literal> activity</title>
<para>A <literal>group</literal> groups a set of activities in a process. Contained groups must
be hierarchically nested. A group corresponds to a BPMN expanded sub process.
@@ -615,8 +615,110 @@
Don't tell anyone cause this is not BPMN compliant.
</para>
</section>
-
</section>
+
+
+ <!-- ### RULES DEPLOYER ####################################################### -->
+ <section id="rulesdeployer">
+ <title>Rules deployer</title>
+ <para>The rules deployer is a convenience integration between jBPM and
+ <ulink url="http://drools.org">Drools</ulink>. It creates a KownledgeBase based
+ on all .drl files that are included in a business archive deployment.
+ That KnowledgeBase is then stored in the repository cache. So one
+ KnowledgeBase is maintained in memory the process-engine-context. Activities
+ like the <link linkend="rulesdecision">rules decision</link> leverage
+ this KnowledgeBase.
+ </para>
+ </section>
+
+ <!-- ### RULES DECISION ####################################################### -->
+ <section id="rulesdecision">
+ <title><literal>rules-decision</literal> activity</title>
+ <para>A rules-decision is an automatic activity that will select a single outgoing
+ transition based on the evaluation of rules.
+ </para>
+ <para>Rules for a rules decision are to be deployed as part of the business
+ archive. Those rules can use all process variables as globals in rule definitions.
+ The <literal>rule-decision</literal> activity will use a stateless knowledge
+ session on the knowledgebase. The execution arriving in the <literal>rules-decision</literal>
+ is executed on the stateless drools knowledge session.
+ </para>
+ <para>Let's look at the next example how that works in practice. We'll start
+ with the <literal>RulesDecision</literal> process</para>
+ <programlisting><process name="RulesDecision">
+
+ <start>
+ <transition to="isImportant" />
+ </start>
+
+ <emphasis role="bold"><rules-decision name="isImportant">
+ <transition name="dunno" to="analyseManually" />
+ <transition name="important" to="processWithPriority" />
+ <transition name="irrelevant" to="processWhenResourcesAvailable" />
+ </rules-decision></emphasis>
+
+ <state name="analyseManually" />
+ <state name="processWithPriority" />
+ <state name="processWhenResourcesAvailable" />
+
+</process></programlisting>
+ <para>The following <literal>isImportant.drl</literal> is included in the
+ business archive deployment.
+ </para>
+ <programlisting>global java.lang.Integer amount;
+global java.lang.String product;
+global org.jbpm.jpdl.internal.rules.Outcome outcome;
+
+rule "LessThen3IsIrrelevant"
+ when
+ eval(amount < 3)
+ then
+ outcome.set("irrelevant");
+end
+
+rule "MoreThen24IsImportant"
+ when
+ eval(amount > 24)
+ then
+ outcome.set("important");
+end
+
+rule "TwelveTempranillosIsImportant"
+ when
+ eval(product == "Tempranillo")
+ eval(amount > 12)
+ then
+ outcome.set("important");
+end</programlisting>
+ <para>First you see that amount and product are defined as globals.
+ Those will resolve by the <literal>rules-decision</literal> to the
+ process variables with those respective names.
+ </para>
+ <para><literal>outcome</literal> is a special global variable that is
+ used to indicate the transition to take in the consequence. Also,
+ if no outcome is specified by the rules, the default transition will be taken.
+ </para>
+ <para>So let's start a new process instance and set 2 variables
+ <literal>product</literal> and <literal>amount</literal> with respective
+ values <literal>shoe</literal> and <literal>32</literal>:</para>
+ <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
+variables.put("amount", 32);
+variables.put("product", "shoe");
+
+ProcessInstance processInstance =
+ executionService.startProcessInstanceByKey("RulesDecision", variables);</programlisting>
+ <para>After starting the process instance method returns, the process instance
+ will have arrived in the activity <literal>processWithPriority</literal> </para>
+ <para>In similar style, a new RulesDecision process instance with
+ <literal>2 missiles</literal> will go to
+ activity <literal>processWhenResourcesAvailable</literal> </para>
+ <para>A RulesDecision process instance with
+ <literal>15 shoes</literal> will go to
+ activity <literal>analyseManually</literal> </para>
+ <para>And a RulesDecision process instance with
+ <literal>13 Tempranillo</literal>s will go to
+ activity <literal>analyseManually</literal> </para>
+ </section>
<section>
<title>Creating identity groups</title>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -210,16 +210,24 @@
<fileset dir="${jbpm.home}/lib">
<include name="activation.jar" />
<include name="antlr.jar" />
+ <include name="antlr-runtime.jar" />
<include name="commons-collections.jar" />
+ <include name="core.jar" />
<include name="dom4j.jar" />
+ <include name="drools-api.jar" />
+ <include name="drools-core.jar" />
+ <include name="drools-compiler.jar" />
<include name="freemarker.jar" />
<include name="hibernate-core.jar" />
<include name="hibernate-cglib-repack.jar" />
+ <include name="janino.jar" />
<include name="javassist.jar" />
<include name="jta.jar" />
<include name="juel*.jar" />
<include name="livetribe-jsr223.jar" />
<include name="mail.jar" />
+ <include name="joda-time.jar" />
+ <include name="mvel2.jar" />
<include name="slf4j-api.jar" />
<include name="slf4j-jdk14.jar" />
</fileset>
@@ -453,22 +461,30 @@
<fileset dir="${jbpm.home}/lib">
<include name="activation.jar" />
<include name="antlr.jar" />
+ <include name="antlr-runtime.jar" />
<include name="bsh.jar" />
<include name="commons-collections.jar" />
<include name="commons-logging.jar" />
+ <include name="core.jar" />
<include name="dom4j.jar" />
+ <include name="drools-api.jar" />
+ <include name="drools-core.jar" />
+ <include name="drools-compiler.jar" />
<include name="freemarker.jar" />
<include name="groovy-all.jar" />
<include name="hibernate-core.jar" />
<include name="hibernate-cglib-repack.jar" />
+ <include name="janino.jar" />
<include name="javassist.jar" />
<include name="jbpm-spi.jar" />
<include name="jbpm-tomcat6.jar" />
+ <include name="joda-time.jar" />
<include name="jta.jar" />
<include name="juel*.jar" />
<include name="livetribe-jsr223.jar" />
<include name="log4j.jar" />
<include name="mail.jar" />
+ <include name="mvel2.jar" />
<include name="slf4j-api.jar" />
<include name="slf4j-jdk14.jar" />
<include name="gwt-console-server-integration.jar" />
Modified: jbpm4/trunk/modules/examples/pom.xml
===================================================================
--- jbpm4/trunk/modules/examples/pom.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/examples/pom.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -60,12 +60,18 @@
<artifactId>wstx-lgpl</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
</dependency>
-
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.rulesdecision;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesDecisionTest extends JbpmTestCase {
+
+ String deploymentId;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/rulesdecision/process.jpdl.xml")
+ .addResourceFromClasspath("org/jbpm/examples/rulesdecision/isImportant.drl")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+
+ super.tearDown();
+ }
+
+
+ public void testImportantOrder() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("amount", 32);
+ variables.put("product", "shoe");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("RulesDecision", variables);
+
+ assertTrue(processInstance.isActive("processWithPriority"));
+ }
+
+ public void testIrrelevantOrder() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("amount", 2);
+ variables.put("product", "missiles");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("RulesDecision", variables);
+
+ assertTrue(processInstance.isActive("processWhenResourcesAvailable"));
+ }
+
+ public void testUndefinedImportance() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("amount", 15);
+ variables.put("product", "shoe");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("RulesDecision", variables);
+
+ assertTrue(processInstance.isActive("analyseManually"));
+ }
+
+ public void test13TempranillosIsImportant() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("amount", 13);
+ variables.put("product", "Tempranillo");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("RulesDecision", variables);
+
+ assertTrue(processInstance.isActive("processWithPriority"));
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/rulesdecision/RulesDecisionTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/isImportant.drl 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,25 @@
+global java.lang.Integer amount;
+global java.lang.String product;
+global org.jbpm.jpdl.internal.rules.Outcome outcome;
+
+rule "LessThen3IsIrrelevant"
+ when
+ eval(amount < 3)
+ then
+ outcome.set("irrelevant");
+end
+
+rule "MoreThen24IsImportant"
+ when
+ eval(amount > 24)
+ then
+ outcome.set("important");
+end
+
+rule "TwelveTempranillosIsImportant"
+ when
+ eval(product == "Tempranillo")
+ eval(amount > 12)
+ then
+ outcome.set("important");
+end
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/process.jpdl.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="RulesDecision">
+
+ <start>
+ <transition to="isImportant" />
+ </start>
+
+ <rules-decision name="isImportant">
+ <transition name="dunno" to="analyseManually" />
+ <transition name="important" to="processWithPriority" />
+ <transition name="irrelevant" to="processWhenResourcesAvailable" />
+ </rules-decision>
+
+ <state name="analyseManually" />
+ <state name="processWithPriority" />
+ <state name="processWhenResourcesAvailable" />
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/rulesdecision/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionActivity.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionActivity.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.drools.KnowledgeBase;
+import org.drools.runtime.StatelessKnowledgeSession;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.jpdl.internal.rules.ExecutionGlobals;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.repository.RulesDeployer;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesDecisionActivity extends JpdlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ String deploymentId = ((ExecutionImpl)execution).getProcessDefinition().getDeploymentId();
+ KnowledgeBase knowledgeBase = RulesDeployer.getKnowledgeBase(deploymentId);
+
+ StatelessKnowledgeSession knowledgeSession =
+ knowledgeBase.newStatelessKnowledgeSession();
+
+ ExecutionGlobals executionGlobals = new ExecutionGlobals(execution);
+ knowledgeSession.getGlobals().setDelegate(executionGlobals);
+ knowledgeSession.execute(execution);
+ if (!executionGlobals.getOutcome().isDefined()) {
+ execution.takeDefaultTransition();
+ } else {
+ execution.take(executionGlobals.getOutcome().get());
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionActivity.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionBinding.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionBinding.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.w3c.dom.Element;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesDecisionBinding extends JpdlBinding {
+
+ public RulesDecisionBinding() {
+ super("rules-decision");
+ }
+
+ public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
+ return new RulesDecisionActivity();
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/RulesDecisionBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/ExecutionGlobals.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/ExecutionGlobals.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/ExecutionGlobals.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,43 @@
+package org.jbpm.jpdl.internal.rules;
+
+import org.drools.runtime.Globals;
+import org.jbpm.api.Execution;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+public class ExecutionGlobals implements Globals {
+
+ private static final Log log = Log.getLog(ExecutionGlobals.class.getName());
+
+ ExecutionImpl execution;
+ Outcome outcome = new Outcome();
+
+ public ExecutionGlobals(Execution execution) {
+ this.execution = (ExecutionImpl) execution;
+ }
+
+ public Object get(String variableName) {
+ if ("execution".equals(variableName)) {
+ log.info("returning execution");
+ return execution;
+ }
+ if ("outcome".equals(variableName)) {
+ log.info("returning outcome");
+ return outcome;
+ }
+ Object variableValue = execution.getVariable(variableName);
+ log.info("returning variable "+variableName+": "+variableValue);
+ return variableValue;
+ }
+
+ public void set(String variableName, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setDelegate(Globals globals) {
+ throw new UnsupportedOperationException();
+ }
+ public Outcome getOutcome() {
+ return outcome;
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/ExecutionGlobals.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/Outcome.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/Outcome.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/Outcome.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -0,0 +1,24 @@
+package org.jbpm.jpdl.internal.rules;
+
+import org.jbpm.internal.log.Log;
+
+public class Outcome {
+
+ private static final Log log = Log.getLog(Outcome.class.getName());
+
+ String outcome = null;
+
+ public void set(String outcome) {
+ log.info("outcome is being set to "+outcome);
+ this.outcome = outcome;
+ }
+
+ public boolean isDefined() {
+ return (outcome!=null);
+ }
+
+ public String get() {
+ log.info("outcome "+outcome+" is being fetched");
+ return outcome;
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/rules/Outcome.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.bindings.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -19,6 +19,7 @@
<activity binding="org.jbpm.jpdl.internal.activity.CustomBinding" />
<activity binding="org.jbpm.jpdl.internal.activity.AssignBinding" />
<activity binding="org.jbpm.jpdl.internal.activity.PassthroughBinding" />
+ <activity binding="org.jbpm.jpdl.internal.activity.RulesDecisionBinding" />
<eventlistener binding="org.jbpm.jpdl.internal.activity.EventListenerBinding" />
<eventlistener binding="org.jbpm.jpdl.internal.activity.JavaBinding" />
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.cfg.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.cfg.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.cfg.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -6,6 +6,7 @@
<deployer-manager>
<jpdl-deployer />
+ <object class="org.jbpm.pvm.internal.repository.RulesDeployer" />
</deployer-manager>
</process-engine-context>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java 2009-12-04 16:12:00 UTC (rev 5918)
@@ -24,6 +24,7 @@
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.io.ResourceFactory;
@@ -38,9 +39,9 @@
public static final String CACHEKEY_KNOWLEDGEBASE = "KnowledgeBase";
public void deploy(DeploymentImpl deployment) {
+ KnowledgeBuilder knowledgeBuilder = null;
+
for (String resourceName: deployment.getResourceNames()) {
-
- KnowledgeBuilder knowledgeBuilder = null;
if (resourceName.endsWith(".drl")) {
if (knowledgeBuilder==null) {
knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
@@ -50,21 +51,32 @@
knowledgeBuilder.add(ResourceFactory.newByteArrayResource(drlBytes), ResourceType.DRL);
}
-
- if (knowledgeBuilder!=null) {
- if (knowledgeBuilder.hasErrors()) {
-
- } else {
- KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
- knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
-
- RepositoryCache repositoryCache = EnvironmentImpl.getFromCurrent(RepositoryCache.class);
- repositoryCache.set(deployment.getId(), CACHEKEY_KNOWLEDGEBASE, knowledgeBase);
+ }
+
+ if (knowledgeBuilder!=null) {
+ if (knowledgeBuilder.hasErrors()) {
+ for (KnowledgeBuilderError error: knowledgeBuilder.getErrors()) {
+ deployment.addProblem("drl problem: "+error.getMessage());
}
+ } else {
+ KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
+ knowledgeBase.addKnowledgePackages(knowledgeBuilder.getKnowledgePackages());
+
+ RepositoryCache repositoryCache = EnvironmentImpl.getFromCurrent(RepositoryCache.class);
+ repositoryCache.set(deployment.getId(), CACHEKEY_KNOWLEDGEBASE, knowledgeBase);
}
}
}
+
+ public static KnowledgeBase getKnowledgeBase(String deploymentId) {
+ return getKnowledgeBase(deploymentId, CACHEKEY_KNOWLEDGEBASE);
+ }
+ public static KnowledgeBase getKnowledgeBase(String deploymentId, String knowledgeBaseName) {
+ RepositoryCache repositoryCache = EnvironmentImpl.getFromCurrent(RepositoryCache.class);
+ return (KnowledgeBase) repositoryCache.get(deploymentId, knowledgeBaseName);
+ }
+
public void updateResource(DeploymentImpl deployment, String resourceName, byte[] bytes) {
if (resourceName.endsWith(".drl")) {
throw new UnsupportedOperationException("drl resource updates is not implemented yet. please contribute :-)");
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2009-12-04 15:36:10 UTC (rev 5917)
+++ jbpm4/trunk/pom.xml 2009-12-04 16:12:00 UTC (rev 5918)
@@ -284,6 +284,11 @@
<version>${drools.version}</version>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-compiler</artifactId>
+ <version>${drools.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>report-engine</artifactId>
<type>zip</type>
More information about the jbpm-commits
mailing list