[jbpm-commits] JBoss JBPM SVN: r5911 - in jbpm4/trunk: modules/pvm and 1 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Dec 3 11:03:24 EST 2009
Author: tom.baeyens at jboss.com
Date: 2009-12-03 11:03:23 -0500 (Thu, 03 Dec 2009)
New Revision: 5911
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java
Modified:
jbpm4/trunk/modules/pvm/pom.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCache.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java
jbpm4/trunk/pom.xml
Log:
JBPM-2006 drools integration
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2009-12-03 12:08:42 UTC (rev 5910)
+++ jbpm4/trunk/modules/pvm/pom.xml 2009-12-03 16:03:23 UTC (rev 5911)
@@ -97,6 +97,10 @@
<artifactId>idm-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jboss.identity.idm</groupId>
<artifactId>idm-hibernate</artifactId>
<exclusions>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCache.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCache.java 2009-12-03 12:08:42 UTC (rev 5910)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCache.java 2009-12-03 16:03:23 UTC (rev 5911)
@@ -31,6 +31,7 @@
public interface RepositoryCache {
void set(String deploymentId, Map<String, Object> deployedObjects);
+ void set(String deploymentId, String key, Object cachedObject);
Object get(String deploymentId, String objectName);
Set<String> getCachedDeploymentIds();
void remove(String deploymentId);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java 2009-12-03 12:08:42 UTC (rev 5910)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositoryCacheImpl.java 2009-12-03 16:03:23 UTC (rev 5911)
@@ -45,6 +45,12 @@
return deploymentObjects.get(objectName);
}
+ public void set(String deploymentId, String key, Object cachedObject) {
+ Map<String, Object> objects = new HashMap<String, Object>();
+ objects.put(key, cachedObject);
+ set(deploymentId, objects);
+ }
+
public void set(String deploymentId, Map<String, Object> objects) {
if (objects==null) {
deployments.put(deploymentId, null);
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java 2009-12-03 16:03:23 UTC (rev 5911)
@@ -0,0 +1,73 @@
+/*
+ * 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.pvm.internal.repository;
+
+import org.drools.KnowledgeBase;
+import org.drools.KnowledgeBaseFactory;
+import org.drools.builder.KnowledgeBuilder;
+import org.drools.builder.KnowledgeBuilderFactory;
+import org.drools.builder.ResourceType;
+import org.drools.io.ResourceFactory;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class RulesDeployer implements Deployer {
+
+ public static final String CACHEKEY_KNOWLEDGEBASE = "KnowledgeBase";
+
+ public void deploy(DeploymentImpl deployment) {
+ for (String resourceName: deployment.getResourceNames()) {
+
+ KnowledgeBuilder knowledgeBuilder = null;
+ if (resourceName.endsWith(".drl")) {
+ if (knowledgeBuilder==null) {
+ knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ }
+
+ byte[] drlBytes = deployment.getBytes(resourceName);
+
+ 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);
+ }
+ }
+ }
+ }
+
+ 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 :-)");
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RulesDeployer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2009-12-03 12:08:42 UTC (rev 5910)
+++ jbpm4/trunk/pom.xml 2009-12-03 16:03:23 UTC (rev 5911)
@@ -50,6 +50,7 @@
<beanshell.version>2.0b5</beanshell.version>
<groovy.version>1.5.6</groovy.version>
<cactus.version>1.8.1</cactus.version>
+ <drools.version>5.0.1</drools.version>
<aspectjrt.version>1.5.3</aspectjrt.version>
<freemarker.version>2.3.15</freemarker.version>
<gwt.console.version>1.2.1</gwt.console.version>
@@ -278,6 +279,11 @@
<version>${groovy.version}</version>
</dependency>
<dependency>
+ <groupId>org.drools</groupId>
+ <artifactId>drools-core</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