JBoss JBPM SVN: r5653 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-17 08:05:43 -0400 (Thu, 17 Sep 2009)
New Revision: 5653
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java
Log:
Test for deployment through zip file
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentResourceTest.java 2009-09-17 12:05:43 UTC (rev 5653)
@@ -0,0 +1,77 @@
+/*
+ * 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.test.deploy;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.zip.ZipInputStream;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * Test case for the various ways of setting a process, image, etc as input
+ * of a deployment.
+ *
+ * @author Joram Barrez
+ */
+public class DeploymentResourceTest extends JbpmTestCase {
+
+
+ public void testZippedResourceDeployment() {
+ FileInputStream fip = null;
+ try {
+
+ fip = new FileInputStream("src/test/resources/org/jbpm/test/deploy/process.zip");
+ ZipInputStream zis = new ZipInputStream(fip);
+
+ NewDeployment newDeployment = repositoryService.createDeployment();
+ newDeployment.addResourcesFromZipInputStream(zis);
+ String deployId = newDeployment.deploy();
+
+ ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery()
+ .deploymentId(deployId)
+ .uniqueResult();
+ assertNotNull(procDef);
+ assertEquals("ImageTest", procDef.getName());
+ repositoryService.deleteDeploymentCascade(deployId);
+
+ } catch (IOException e) {
+ fail(e.getMessage());
+ } finally {
+ if (fip != null) {
+ try {
+ fip.close();
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ }
+
+}
14 years, 7 months
JBoss JBPM SVN: r5652 - in jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test: query and 1 other directory.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-17 08:04:55 -0400 (Thu, 17 Sep 2009)
New Revision: 5652
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryDetailQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessDefinitionQueryTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java
Log:
Added test cases for orderBy of query API
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java (from rev 5433, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/deploy/DeploymentQueryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/DeploymentQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,187 @@
+/*
+ * 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.test.query;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.Deployment;
+import org.jbpm.api.DeploymentQuery;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DeploymentQueryTest extends JbpmTestCase {
+
+ public void testSuspendDeployment() {
+ List<String> deploymentIds = deployTestProcesses();
+
+ repositoryService.suspendDeployment(deploymentIds.get(2));
+
+ // find all deployments
+
+ List<Deployment> deployments = repositoryService
+ .createDeploymentQuery()
+ .list();
+
+ Set<String> expectedDeploymentNames = new HashSet<String>();
+ expectedDeploymentNames.add("Claim");
+ expectedDeploymentNames.add("Hire");
+ expectedDeploymentNames.add("Fire");
+
+ assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
+
+ // find suspended deployments
+
+ deployments = repositoryService
+ .createDeploymentQuery()
+ .suspended()
+ .list();
+
+ expectedDeploymentNames = new HashSet<String>();
+ expectedDeploymentNames.add("Hire");
+
+ assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
+
+ // find active deployments
+
+ deployments = repositoryService
+ .createDeploymentQuery()
+ .notSuspended()
+ .list();
+
+ expectedDeploymentNames = new HashSet<String>();
+ expectedDeploymentNames.add("Claim");
+ expectedDeploymentNames.add("Fire");
+
+ assertEquals(expectedDeploymentNames, getDeploymentNames(deployments));
+
+ deleteCascade(deploymentIds);
+ }
+
+ private Set<String> getDeploymentNames(List<Deployment> deployments) {
+ Set<String> deploymentNames = new HashSet<String>();
+ for (Deployment deployment: deployments) {
+ deploymentNames.add(deployment.getName());
+ }
+ return deploymentNames;
+ }
+
+ private List<String> deployTestProcesses() {
+ List<String> processIds = new ArrayList<String>();
+
+ String deploymentClaimId = repositoryService
+ .createDeployment()
+ .setName("Claim")
+ .addResourceFromString("process.jpdl.xml",
+ "<process name='claim'>" +
+ " <start>" +
+ " <transition to='c' />" +
+ " </start>" +
+ " <state name='c' />" +
+ "</process>"
+ )
+ .deploy();
+
+ String deploymentHireId = repositoryService
+ .createDeployment()
+ .setName("Hire")
+ .addResourceFromString("process.jpdl.xml",
+ "<process name='hire'>" +
+ " <start>" +
+ " <transition to='h' />" +
+ " </start>" +
+ " <state name='h' />" +
+ "</process>"
+ )
+ .deploy();
+
+ String deploymentFireId = repositoryService
+ .createDeployment()
+ .setName("Fire")
+ .addResourceFromString("process.jpdl.xml",
+ "<process name='fire'>" +
+ " <start>" +
+ " <transition to='f' />" +
+ " </start>" +
+ " <state name='f' />" +
+ "</process>"
+ )
+ .deploy();
+
+ processIds.add(deploymentClaimId);
+ processIds.add(deploymentFireId);
+ processIds.add(deploymentHireId);
+
+ return processIds;
+ }
+
+ private void deleteCascade(List<String> deploymentIds) {
+ for (String deploymentId : deploymentIds) {
+ repositoryService.deleteDeploymentCascade(deploymentId);
+ }
+ }
+
+ public void testOrderByName() {
+ testOrderBy(DeploymentQuery.PROPERTY_NAME, Arrays.asList("Claim", "Fire", "Hire"));
+ }
+
+ public void testOrderByTimeStamp() {
+ testOrderByNaturalOrdening(DeploymentQuery.PROPERTY_TIMESTAMP, 3);
+ }
+
+ private void testOrderBy(String property, List expectedValues) {
+ testOrderBy(property, expectedValues, null, false);
+ }
+
+ private void testOrderByNaturalOrdening(String property, int expectedNrOfResults) {
+ testOrderBy(property, null, expectedNrOfResults, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void testOrderBy(String property, List expectedValues,
+ Integer expectedNrOfResults, boolean naturalOrderCheck) {
+
+ List<String> deploymentIds = deployTestProcesses();
+
+ List<Deployment> deploymentsAsc =
+ repositoryService.createDeploymentQuery().orderAsc(property).list();
+
+ List<Deployment> deploymentsDesc =
+ repositoryService.createDeploymentQuery().orderDesc(property).list();
+
+ if (naturalOrderCheck) {
+ QueryAssertions.assertOrderIsNatural(Deployment.class, property, deploymentsAsc, deploymentsDesc, 3);
+ } else {
+ QueryAssertions.assertOrderOnProperty(Deployment.class, property, deploymentsAsc, deploymentsDesc, expectedValues);
+ }
+
+ deleteCascade(deploymentIds);
+ }
+
+}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java (from rev 5433, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryActivityInstanceQeuryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryActivityInstanceQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,153 @@
+/*
+ * 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.test.query;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryActivityInstance;
+import org.jbpm.api.history.HistoryActivityInstanceQuery;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryActivityInstanceQueryTest extends JbpmTestCase {
+
+ public void testSimpleQuery() {
+ startAndSignalTestProcesses();
+
+ List<HistoryActivityInstance> histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("a")
+ .list();
+
+ assertEquals(4, histActInsts.size());
+
+ histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("b")
+ .list();
+
+ assertEquals(3, histActInsts.size());
+
+ histActInsts = historyService.createHistoryActivityInstanceQuery()
+ .activityName("c")
+ .list();
+
+ assertEquals(2, histActInsts.size());
+ }
+
+ public void testOrderByActivityName() {
+ testOrderBy(HistoryActivityInstanceQuery.PROPERTY_ACTIVITYNAME, Arrays.asList("a", "a", "a", "a", "b", "b", "b", "c", "c"));
+ }
+
+ public void testOrderByStartTime() {
+ testOrderByNaturalOrdening(HistoryActivityInstanceQuery.PROPERTY_STARTTIME, 9);
+ }
+
+ public void testOrderByEndTime() {
+ testOrderByNaturalOrdening(HistoryActivityInstanceQuery.PROPERTY_ENDTIME, 9);
+ }
+
+ public void testOrderByDuration() {
+ testOrderByNaturalOrdening(HistoryActivityInstanceQuery.PROPERTY_DURATION, 9);
+ }
+
+ public void testOrderByExecutionId() {
+ testOrderByNaturalOrdening(HistoryActivityInstanceQuery.PROPERTY_EXECUTIONID, 9);
+ }
+
+ private List<String> startAndSignalTestProcesses() {
+ deployJpdlXmlString(
+ "<process name='abc'>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <transition to ='b' />" +
+ " </state>" +
+ " <state name='b'>" +
+ " <transition to ='c' />" +
+ " </state>" +
+ " <state name='c'>" +
+ " <transition to ='end' />" +
+ " </state>" +
+ " <end name='end' />" +
+ "</process>"
+ );
+
+ List<String> ids = new ArrayList<String>();
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+ ids.add(processInstance.getId());
+
+ processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+ executionService.signalExecutionById(processInstance.getId());
+ ids.add(processInstance.getId());
+
+ processInstance = executionService.startProcessInstanceByKey("abc");
+ executionService.signalExecutionById(processInstance.getId());
+ ids.add(processInstance.getId());
+
+ processInstance = executionService.startProcessInstanceByKey("abc");
+ ids.add(processInstance.getId());
+
+ return ids;
+ }
+
+ private void testOrderBy(String property, List expectedValues) {
+ testOrderBy(property, expectedValues, null, false);
+ }
+
+ private void testOrderByNaturalOrdening(String property, int expectedNrOfResults) {
+ testOrderBy(property, null, expectedNrOfResults, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void testOrderBy(String property, List expectedValues,
+ Integer expectedNrOfResults, boolean naturalOrderCheck) {
+
+ startAndSignalTestProcesses();
+
+ List<HistoryActivityInstance> listAsc =
+ historyService.createHistoryActivityInstanceQuery().orderAsc(property).list();
+
+ List<HistoryActivityInstance> listDesc =
+ historyService.createHistoryActivityInstanceQuery().orderDesc(property).list();
+
+ if (naturalOrderCheck) {
+ QueryAssertions.assertOrderIsNatural(HistoryActivityInstance.class, property, listAsc, listDesc, expectedNrOfResults);
+ } else {
+ QueryAssertions.assertOrderOnProperty(HistoryActivityInstance.class, property, listAsc, listDesc, expectedValues);
+ }
+
+ }
+
+}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryDetailQueryTest.java (from rev 5433, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/history/HistoryDetailQueryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryDetailQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryDetailQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,127 @@
+/*
+ * 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.test.query;
+
+import java.util.List;
+
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.api.history.HistoryComment;
+import org.jbpm.api.history.HistoryDetail;
+import org.jbpm.api.history.HistoryDetailQuery;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.api.task.Task;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistoryDetailQueryTest extends JbpmTestCase {
+
+ public void testTaskCommentDetail() {
+ deployJpdlXmlString(
+ "<process name='TaskCommentDetail'>" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <task name='t' assignee='johndoe'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("TaskCommentDetail");
+
+ String taskId = taskService.createTaskQuery().uniqueResult().getId();
+
+ taskService.addTaskComment(taskId, "hello");
+
+ List<HistoryDetail> historyDetails = historyService.createHistoryDetailQuery().list();
+ assertEquals(historyDetails.toString(), 1, historyDetails.size());
+
+ historyDetails = historyService
+ .createHistoryDetailQuery()
+ .comments()
+ .list();
+
+ assertEquals(historyDetails.toString(), 1, historyDetails.size());
+
+ HistoryComment historyComment = (HistoryComment) historyDetails.get(0);
+ assertEquals("hello", historyComment.getMessage());
+ }
+
+ public void testTaskCommentRepliesDetail() {
+ deployJpdlXmlString(
+ "<process name='TaskCommentRepliesDetail'>" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <task name='t' assignee='johndoe'/>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("TaskCommentRepliesDetail");
+
+ String taskId = taskService.createTaskQuery().uniqueResult().getId();
+
+ processEngine.setAuthenticatedUserId("johndoe");
+ String helloCommentId = taskService.addTaskComment(taskId, "hi, how are you guys?").getId();
+
+ processEngine.setAuthenticatedUserId("joesmoe");
+ taskService.addReplyComment(helloCommentId, "i'm doing fine, thanks");
+
+ processEngine.setAuthenticatedUserId("jackblack");
+ taskService.addReplyComment(helloCommentId, "i got a hangover");
+
+ List<HistoryDetail> historyDetails = historyService.createHistoryDetailQuery().list();
+ assertEquals(historyDetails.toString(), 3, historyDetails.size());
+
+ historyDetails = historyService
+ .createHistoryDetailQuery()
+ .comments()
+ .list();
+ }
+
+
+ public void testOrderBy() {
+
+ Task task = taskService.newTask();
+ taskService.saveTask(task);
+
+ // add some comments
+ taskService.addTaskComment(task.getId(), "aaaaaaa");
+ taskService.addTaskComment(task.getId(), "xxxxxxx");
+ String commentId = taskService.addTaskComment(task.getId(), "ggggggg").getId();
+ taskService.addReplyComment(commentId, "jjjjjj");
+
+ List<HistoryDetail> listAsc =
+ historyService.createHistoryDetailQuery().orderAsc(HistoryDetailQuery.PROPERTY_TIME).list();
+
+ List<HistoryDetail> listDesc =
+ historyService.createHistoryDetailQuery().orderDesc(HistoryDetailQuery.PROPERTY_TIME).list();
+
+ QueryAssertions.assertOrderIsNatural(HistoryDetail.class, HistoryDetailQuery.PROPERTY_TIME, listAsc, listDesc, 4);
+
+ taskService.deleteTaskCascade(task.getId());
+ }
+
+}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryProcessInstanceQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,105 @@
+/*
+ * 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.test.query;
+
+import java.util.List;
+
+import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.api.history.HistoryProcessInstanceQuery;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class HistoryProcessInstanceQueryTest extends JbpmTestCase {
+
+ public void testOrderByStartTime() {
+ testOrderByNaturalOrdening(HistoryProcessInstanceQuery.PROPERTY_STARTTIME, 4);
+ }
+
+ public void testOrderByEndTime() {
+ testOrderByNaturalOrdening(HistoryProcessInstanceQuery.PROPERTY_ENDTIME, 4);
+ }
+
+ public void testOrderByDuration() {
+ testOrderByNaturalOrdening(HistoryProcessInstanceQuery.PROPERTY_DURATION, 4);
+ }
+
+
+ /* -------------------------------------------------------------
+ * HELPER METHODS
+ * ------------------------------------------------------------- */
+
+ // Don't delete because it isn't used. Could be handy in the future!
+ private void testOrderBy(String property, List<Object> expectedValues) {
+ createTestHistoryProcessInstances();
+
+ List<HistoryProcessInstance> histProcListAsc =
+ historyService.createHistoryProcessInstanceQuery()
+ .orderAsc(property)
+ .list();
+
+ List<HistoryProcessInstance> histProcListDesc =
+ historyService.createHistoryProcessInstanceQuery()
+ .orderDesc(property)
+ .list();
+
+ QueryAssertions.assertOrderOnProperty(HistoryProcessInstance.class, property, histProcListAsc, histProcListDesc, expectedValues);
+ }
+
+ private void testOrderByNaturalOrdening(String property, int expectedNrOfResults) {
+ createTestHistoryProcessInstances();
+
+ List<HistoryProcessInstance> histProcListAsc =
+ historyService.createHistoryProcessInstanceQuery()
+ .orderAsc(property)
+ .list();
+
+ List<HistoryProcessInstance> histProcListDesc =
+ historyService.createHistoryProcessInstanceQuery()
+ .orderDesc(property)
+ .list();
+
+ QueryAssertions.assertOrderIsNatural(HistoryProcessInstance.class, property, histProcListAsc, histProcListDesc, expectedNrOfResults);
+ }
+
+ private void createTestHistoryProcessInstances() {
+ deployJpdlXmlString(
+ "<process name='theProcess'>" +
+ " <start>" +
+ " <transition to='end' />" +
+ " </start>" +
+ " <end name='end' />" +
+ "</process>");
+
+ for (int i = 0; i < 4; i++) {
+ executionService.startProcessInstanceByKey("theProcess");
+ }
+
+ }
+
+}
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/HistoryTaskQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,141 @@
+/*
+ * 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.test.query;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.api.history.HistoryTaskQuery;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class HistoryTaskQueryTest extends JbpmTestCase {
+
+ public void testOrderByName() {
+ testOrderBy(HistoryTaskQuery.PROPERTY_ASSIGNEE, Arrays.asList("Alex", "Joram", "Tom"));
+ }
+
+ public void testOrderByStartTime() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_CREATETIME, 3);
+ }
+
+ public void testOrderByEndTime() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_ENDTIME, 3);
+ }
+
+ public void testOrderByDuration() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_DURATION, 3);
+ }
+
+ public void testOrderByexecutionId() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_EXECUTIONID, 3);
+ }
+
+ public void testOrderByOutcome() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_OUTCOME, 3);
+ }
+
+ public void testOrderByState() {
+ testOrderByNaturalOrdening(HistoryTaskQuery.PROPERTY_STATE, 3);
+ }
+
+ private void createTestHistoryTasks() {
+ String processXml1 =
+ "<process name='theProcess1'>" +
+ " <start>" +
+ " <transition to='theTask' />" +
+ " </start>" +
+ " <task name='theTask' assignee='Alex'>" +
+ " <transition to='theEnd' />" +
+ " </task>" +
+ " <end name='theEnd' />" +
+ "</process>";
+
+ String processXml3 = processXml1.replace("1", "2").replace("Alex", "Tom");
+ String processXml2 = processXml1.replace("1", "3").replace("Alex", "Joram");
+
+ deployJpdlXmlString(processXml1);
+ deployJpdlXmlString(processXml2);
+ deployJpdlXmlString(processXml3);
+
+ executionService.startProcessInstanceByKey("theProcess1");
+ executionService.startProcessInstanceByKey("theProcess2");
+ executionService.startProcessInstanceByKey("theProcess3");
+
+ taskService.completeTask(taskService.findPersonalTasks("Alex").get(0).getId());
+ taskService.completeTask(taskService.findPersonalTasks("Joram").get(0).getId());
+ taskService.completeTask(taskService.findPersonalTasks("Tom").get(0).getId());
+
+ taskService.findPersonalTasks("Alex");
+ }
+
+ private void testOrderBy(String property, List expectedValues) {
+ testOrderBy(property, expectedValues, null, false);
+ }
+
+ private void testOrderByNaturalOrdening(String property, int expectedNrOfResults) {
+ testOrderBy(property, null, expectedNrOfResults, true);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void testOrderBy(String property, List expectedValues,
+ Integer expectedNrOfResults, boolean naturalOrderCheck) {
+
+ createTestHistoryTasks();
+
+ List<HistoryTask> historyTasksAsc =
+ historyService.createHistoryTaskQuery().orderAsc(property).list();
+
+ List<HistoryTask> historyTasksDesc =
+ historyService.createHistoryTaskQuery().orderDesc(property).list();
+
+ if (naturalOrderCheck) {
+ QueryAssertions.assertOrderIsNatural(HistoryTask.class, property, historyTasksAsc, historyTasksDesc, expectedNrOfResults);
+ } else {
+ QueryAssertions.assertOrderOnProperty(HistoryTask.class, property, historyTasksAsc, historyTasksDesc, expectedValues);
+ }
+
+ }
+
+ private Date stringToDate(String dateString) {
+ DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
+ try {
+ return dateFormat.parse(dateString);
+ } catch (ParseException e) {
+ throw new RuntimeException("Couldn't convert " + dateString);
+ }
+ }
+
+
+}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java (from rev 5433, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/JobQueryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/JobQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,126 @@
+package org.jbpm.test.query;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.jbpm.api.JobQuery;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+public class JobQueryTest extends JbpmTestCase {
+
+ public void testQueryOutstandingTimers() {
+ startTestProcessInstances();
+
+ List<Job> timers = managementService.createJobQuery()
+ .timers()
+ .list();
+
+ assertEquals(4, timers.size());
+ }
+
+ public void testQueryBacklogMessages() {
+ deployJpdlXmlString(
+ "<process name='MessagesQueryTest' >" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <state name='t' continue='async' />" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("MessagesQueryTest");
+ executionService.startProcessInstanceByKey("MessagesQueryTest");
+ executionService.startProcessInstanceByKey("MessagesQueryTest");
+ executionService.startProcessInstanceByKey("MessagesQueryTest");
+
+ List<Job> jobs = managementService.createJobQuery()
+ .messages()
+ .list();
+
+ assertEquals(4, jobs.size());
+ }
+
+ private void startTestProcessInstances() {
+ deployJpdlXmlString(
+ "<process name='TimerQueryTest' >" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <state name='t'>" +
+ " <transition name='timeout' to='t'>" +
+ " <timer duedate='20 seconds' />" +
+ " </transition>" +
+ " </state>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("TimerQueryTest");
+ executionService.startProcessInstanceByKey("TimerQueryTest");
+ executionService.startProcessInstanceByKey("TimerQueryTest");
+ executionService.startProcessInstanceByKey("TimerQueryTest");
+ }
+
+
+ public static class Dog implements Serializable {
+ private static final long serialVersionUID = 1L;
+ public void bark() {
+ throw new RuntimeException("wooof");
+ }
+ }
+
+ public void testErrorMessages() {
+ deployJpdlXmlString(
+ "<process name='ErrorMsgQueryTest' >" +
+ " <start>" +
+ " <transition to='t' />" +
+ " </start>" +
+ " <java name='t' " +
+ " continue='async' " +
+ " class='"+Dog.class.getName()+"'" +
+ " method='bark'>" +
+ " </java>" +
+ "</process>"
+ );
+
+ executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
+ executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
+ executionService.startProcessInstanceByKey("ErrorMsgQueryTest");
+
+
+ List<Job> messages = managementService.createJobQuery()
+ .messages()
+ .list();
+
+ assertEquals(3, messages.size());
+
+ managementService.executeJob(messages.get(0).getId());
+ managementService.executeJob(messages.get(0).getId());
+ managementService.executeJob(messages.get(0).getId());
+
+ List<Job> errorJobs = managementService.createJobQuery()
+ .exception(true)
+ .list();
+
+ assertEquals(1, errorJobs.size());
+
+ assertTextPresent("wooof", errorJobs.get(0).getException());
+
+ messages = managementService.createJobQuery()
+ .messages()
+ .exception(false)
+ .list();
+
+ assertEquals(2, messages.size());
+ }
+
+ public void testOrderByDueDate() {
+ startTestProcessInstances();
+ List<Job> jobsAsc = managementService.createJobQuery().orderAsc(JobQuery.PROPERTY_DUEDATE).list();
+ List<Job> jobsDesc = managementService.createJobQuery().orderDesc(JobQuery.PROPERTY_DUEDATE).list();
+ QueryAssertions.assertOrderIsNatural(Job.class, JobQuery.PROPERTY_DUEDATE, jobsAsc, jobsDesc, 4);
+ }
+
+}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessDefinitionQueryTest.java (from rev 5433, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/process/ProcessDefinitionQueryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessDefinitionQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/ProcessDefinitionQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,138 @@
+/*
+ * 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.test.query;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.api.ProcessDefinitionQuery;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ProcessDefinitionQueryTest extends JbpmTestCase {
+
+ public void testQueryProcessDefinitionsEmpty() {
+ List<ProcessDefinition> processDefinitions = repositoryService
+ .createProcessDefinitionQuery()
+ .list();
+
+ assertEquals(0, processDefinitions.size());
+ }
+
+ public void testQueryProcessDefinitionsNameLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionNameLike("%make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
+ .list();
+
+ assertEquals("fix coffeemaker", processDefinitions.get(0).getName());
+ assertEquals("make friends", processDefinitions.get(1).getName());
+ assertEquals("make print", processDefinitions.get(2).getName());
+ }
+
+ public void testQueryProcessDefinitionsKeyLike() {
+ deployJpdlXmlString(
+ "<process name='make print'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='use phone'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='make friends'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='clean whiteboard'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ deployJpdlXmlString(
+ "<process name='fix coffeemaker'>" +
+ " <start />" +
+ "</process>"
+ );
+
+ List<ProcessDefinition> processDefinitions = repositoryService.createProcessDefinitionQuery()
+ .processDefinitionNameLike("make%")
+ .orderAsc(ProcessDefinitionQuery.PROPERTY_ID)
+ .list();
+
+ assertEquals("make_friends-1", processDefinitions.get(0).getId());
+ assertEquals("make_friends-2", processDefinitions.get(1).getId());
+ assertEquals("make_friends-3", processDefinitions.get(2).getId());
+ assertEquals("make_print-1", processDefinitions.get(3).getId());
+ }
+}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java (from rev 5627, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/task/TaskQueryTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/query/TaskQueryTest.java 2009-09-17 12:04:55 UTC (rev 5652)
@@ -0,0 +1,190 @@
+/*
+ * 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.test.query;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.jbpm.api.TaskQuery;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+import org.jbpm.test.assertion.QueryAssertions;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskQueryTest extends JbpmTestCase {
+
+ public void testPropertyNames() {
+ Task task = taskService.newTask();
+ task.setName("write task query test");
+ task.setAssignee("koen");
+ task.setPriority(Integer.MAX_VALUE);
+ task.setDescription("make sure the test fails if property names are incorrect");
+ task.setDuedate(new Date());
+ String taskId = taskService.saveTask(task);
+
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_ASSIGNEE);
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_CREATEDATE);
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_DUEDATE);
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_NAME);
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PRIORITY);
+ checkProperty(taskService.createTaskQuery(), task, TaskQuery.PROPERTY_PROGRESS);
+
+ taskService.deleteTaskCascade(taskId);
+ }
+
+ private void checkProperty(TaskQuery taskQuery, Task task, String propertyName) {
+ List<Task> taskList = taskQuery.orderAsc(propertyName).list();
+ assertNotNull(taskList);
+ assertContainsTask(taskList, task.getName());
+ assertEquals(1, taskList.size());
+ }
+
+ public void testSimplestTaskQuery() {
+ List<Task> tasks = createTestTasks();
+
+ List<Task> taskList = taskService
+ .createTaskQuery()
+ .list();
+ assertNotNull(taskList);
+
+ assertContainsTask(taskList, "do laundry");
+ assertContainsTask(taskList, "change dyper");
+ assertContainsTask(taskList, "start new business");
+ assertContainsTask(taskList, "find venture capital");
+
+ assertEquals(4, taskList.size());
+
+ deleteTasks(tasks);
+ }
+
+ public void testOrderByName() {
+ testOrderBy(TaskQuery.PROPERTY_NAME,
+ new String[] {"change dyper", "do laundry", "find venture capital", "start new business"});
+ }
+
+ public void testOrderByAssignee() {
+ testOrderBy(TaskQuery.PROPERTY_ASSIGNEE, new String[] {null, "Joram", "Koen", "Tom"});
+ }
+
+ public void testOrderByCreateTime() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_CREATEDATE, 4);
+ }
+
+ public void testOrderByDueDate() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_DUEDATE, 4);
+ }
+
+ public void testOrderByPriority() {
+ testOrderByResultsInNaturalOrdening(TaskQuery.PROPERTY_PRIORITY, 4);
+ }
+
+ public void testOrderByProgress() {
+ testOrderBy(TaskQuery.PROPERTY_PROGRESS, new Integer[] {2, 15, 75, 99});
+ }
+
+
+ /* -------------------------------------------------------------------
+ * HELPER METHODS
+ * ------------------------------------------------------------------- */
+
+ private List<Task> createTestTasks() {
+ List<Task> result = new ArrayList<Task>();
+
+ Task task1 = taskService.newTask();
+ task1.setName("do laundry");
+ task1.setAssignee("Tom");
+ task1.setPriority(3);
+ task1.setDuedate(stringToDate("10/10/1985"));
+ task1.setProgress(15);
+
+ Task task2 = taskService.newTask();
+ task2.setName("change dyper");
+ task2.setAssignee("Koen");
+ task2.setPriority(1);
+ task2.setDuedate(stringToDate("28/06/1989"));
+ task2.setProgress(2);
+
+ Task task3 = taskService.newTask();
+ task3.setName("start new business");
+ task3.setAssignee("Joram");
+ task3.setPriority(4);
+ task3.setProgress(75);
+
+ Task task4 = taskService.newTask();
+ task4.setName("find venture capital");
+ task4.setPriority(7);
+ task4.setDuedate(stringToDate("09/09/2009"));
+ task4.setProgress(99);
+
+ for (Task t : new Task[] {task1, task2, task3, task4}) {
+ taskService.saveTask(t);
+ result.add(t);
+ }
+
+ return result;
+ }
+
+ private void testOrderBy(String property, Object[] expectedValues) {
+ List<Task> tasks = createTestTasks();
+
+ List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
+ List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
+
+ QueryAssertions.assertOrderOnProperty(Task.class, property, taskListAsc, taskListDesc, Arrays.asList(expectedValues));
+
+ deleteTasks(tasks);
+ }
+
+ private void testOrderByResultsInNaturalOrdening(String property, int expectedNrOfResults) {
+ List<Task> tasks = createTestTasks();
+ List<Task> taskListAsc = taskService.createTaskQuery().orderAsc(property).list();
+ List<Task> taskListDesc = taskService.createTaskQuery().orderDesc(property).list();
+
+ QueryAssertions.assertOrderIsNatural(Task.class, property, taskListAsc, taskListDesc, expectedNrOfResults);
+
+ deleteTasks(tasks);
+ }
+
+ private void deleteTasks(List<Task> tasks) {
+ for (Task t : tasks) {
+ taskService.deleteTaskCascade(t.getId());
+ }
+ }
+
+ private Date stringToDate(String dateString) {
+ DateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy");
+ try {
+ return dateFormat.parse(dateString);
+ } catch (ParseException e) {
+ throw new RuntimeException("Couldn't convert " + dateString);
+ }
+ }
+
+}
14 years, 7 months
JBoss JBPM SVN: r5651 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/hibernate and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-09-16 10:31:51 -0400 (Wed, 16 Sep 2009)
New Revision: 5651
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/MembershipImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.history.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
Log:
JBPM-2526 switched the other persistent entities over to jbpm dbid generation
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/NewDeployment.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -66,4 +66,5 @@
* @return the generated deploymentId identification for this deployment
* in the {@link RepositoryService repository}. */
String deploy();
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/DbSessionImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -40,6 +40,7 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.model.HistoryCommentImpl;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.query.DeploymentQueryImpl;
@@ -364,6 +365,8 @@
protected TaskImpl newTask() {
TaskImpl task = new TaskImpl();
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ task.setDbid(dbid);
task.setNew(true);
return task;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryActivityInstanceImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -30,6 +30,7 @@
import org.jbpm.api.history.HistoryActivityInstance;
import org.jbpm.api.history.HistoryProcessInstance;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -71,6 +72,7 @@
this.executionId = execution.getId();
this.activityName = activity.getName();
this.startTime = execution.getHistoryActivityStart();
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
}
// details //////////////////////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/model/HistoryDetailImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -25,6 +25,7 @@
import java.util.Date;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.internal.util.EqualsUtil;
@@ -55,6 +56,7 @@
// dummy string constructor to differentiate from
// the default constructor which is used by hibernate
protected HistoryDetailImpl(String dummy) {
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
this.time = Clock.getCurrentTime();
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/GroupImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -73,4 +73,7 @@
public void setType(String type) {
this.type = type;
}
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -30,6 +30,8 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.identity.Group;
import org.jbpm.api.identity.User;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.identity.spi.IdentitySession;
/**
@@ -39,10 +41,13 @@
protected Session session;
- public String createUser(String userName, String givenName, String familyName,
- String businessEmail) {
+ public String createUser(String userName, String givenName, String familyName, String businessEmail) {
UserImpl user = new UserImpl(userName, givenName, familyName);
user.setBusinessEmail(businessEmail);
+
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ user.setDbid(dbid);
+
session.save(user);
return user.getId();
@@ -90,6 +95,10 @@
GroupImpl group = new GroupImpl();
String groupId = groupType != null ? groupType + "." + groupName : groupName;
group.setId(groupId);
+
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ group.setDbid(dbid);
+
group.setName(groupName);
group.setType(groupType);
@@ -97,7 +106,7 @@
GroupImpl parentGroup = findGroupById(parentGroupId);
group.setParent(parentGroup);
}
-
+
session.save(group);
return group.getId();
@@ -172,6 +181,9 @@
membership.setGroup(group);
membership.setRole(role);
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ membership.setDbid(dbid);
+
session.save(membership);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/MembershipImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/MembershipImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/MembershipImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -60,4 +60,8 @@
public void setRole(String role) {
this.role = role;
}
+
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -94,4 +94,8 @@
public void setPassword(String password) {
this.password = password;
}
+
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/MessageImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -22,6 +22,7 @@
package org.jbpm.pvm.internal.job;
import org.jbpm.api.job.Message;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.model.ExecutionImpl;
/**
@@ -41,5 +42,6 @@
public MessageImpl(ExecutionImpl execution) {
this.execution = execution;
this.processInstance = execution.getProcessInstance();
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -31,6 +31,7 @@
import org.jbpm.pvm.internal.cal.BusinessCalendar;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.Transaction;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.jobexecutor.JobAddedNotification;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.model.ObservableElement;
@@ -65,6 +66,7 @@
}
public void schedule() {
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
TimerSession timerSession = EnvironmentImpl.getFromCurrent(TimerSession.class);
timerSession.schedule(this);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/lob/Lob.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -26,6 +26,7 @@
import java.util.List;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
/**
@@ -65,11 +66,13 @@
public Lob(byte[] bytes) {
cachedBytes = bytes;
getBlobStrategy().set(bytes, this);
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
}
public Lob(char[] text) {
cachedChars = text;
getClobStrategy().set(text, this);
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -802,6 +802,8 @@
public SwimlaneImpl createSwimlane(String swimlaneName) {
SwimlaneImpl swimlane = new SwimlaneImpl();
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ swimlane.setDbid(dbid);
swimlane.setName(swimlaneName);
swimlane.setExecution(this);
swimlanes.put(swimlaneName, swimlane);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -35,6 +35,7 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.VariableCreate;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.pvm.internal.type.Converter;
@@ -135,8 +136,11 @@
variable.setExecution(getExecution());
variable.setTask(getTask());
variable.setHistoryEnabled(isHistoryEnabled);
-
+
variable.setValue(value);
+
+ long dbid = DbidGenerator.getDbidGenerator().getNextId();
+ variable.setDbid(dbid);
if (isHistoryEnabled) {
HistoryEvent.fire(new VariableCreate(variable));
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -315,4 +315,7 @@
public String getState() {
return state;
}
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/DeploymentProperty.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -24,6 +24,8 @@
import java.io.Serializable;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
/**
@@ -44,6 +46,7 @@
}
public DeploymentProperty(DeploymentImpl deployment, String objectName, String key) {
+ this.dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
this.deployment = deployment;
this.objectName = objectName;
this.key = key;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/repository/RepositorySessionImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -32,6 +32,8 @@
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.query.ProcessDefinitionQueryImpl;
@@ -51,6 +53,8 @@
public String deploy(NewDeployment deployment) {
DeploymentImpl deploymentImpl = (DeploymentImpl) deployment;
+ long dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
+ deploymentImpl.setDbid(dbid);
session.save(deploymentImpl);
deployerManager.deploy(deploymentImpl);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/ParticipationImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -24,6 +24,8 @@
import java.io.Serializable;
import org.jbpm.api.task.Participation;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.id.DbidGenerator;
/** the relation between a task and a person.
@@ -47,6 +49,7 @@
}
public ParticipationImpl(String userId, String groupId, String type) {
+ this.dbid = EnvironmentImpl.getFromCurrent(DbidGenerator.class).getNextId();
this.userId = userId;
this.groupId = groupId;
this.type = type;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/SwimlaneImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -22,7 +22,6 @@
package org.jbpm.pvm.internal.task;
import java.io.Serializable;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -148,4 +147,7 @@
public void setExecution(ExecutionImpl execution) {
this.execution = execution;
}
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -487,4 +487,8 @@
public void setNew(boolean isNew) {
this.isNew = isNew;
}
+
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/Variable.java 2009-09-16 14:31:51 UTC (rev 5651)
@@ -28,6 +28,7 @@
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.HistorySession;
import org.jbpm.pvm.internal.history.events.VariableUpdate;
+import org.jbpm.pvm.internal.id.DbidGenerator;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
@@ -124,7 +125,7 @@
}
// getters and setters //////////////////////////////////////////////////////
-
+
public String getKey() {
return key;
}
@@ -161,4 +162,7 @@
public void setHistoryEnabled(boolean isHistoryEnabled) {
this.isHistoryEnabled = isHistoryEnabled;
}
+ public void setDbid(long dbid) {
+ this.dbid = dbid;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-09-16 14:31:51 UTC (rev 5651)
@@ -120,7 +120,7 @@
-->
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator column="CLASS_"/>
<version name="dbversion" column="DBVERSION_" />
@@ -188,7 +188,7 @@
<!-- ### LOB ############################################################ -->
<class name="org.jbpm.pvm.internal.lob.Lob" table="JBPM4_LOB">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
<property name="blob" type="blob"><column name="BLOB_VALUE_" /></property>
@@ -202,7 +202,7 @@
<class name="org.jbpm.pvm.internal.job.JobImpl" table="JBPM4_JOB" discriminator-value="Job">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator column="CLASS_" />
<version name="dbversion" column="DBVERSION_" />
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.history.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.history.hbm.xml 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.history.hbm.xml 2009-09-16 14:31:51 UTC (rev 5651)
@@ -50,7 +50,7 @@
<!-- ### HISTORY ACTIVITY INSTANCE ####################################### -->
<class name="HistoryActivityInstanceImpl" table="JBPM4_HIST_ACTINST" discriminator-value="act">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator column="CLASS_" />
<version name="dbversion" column="DBVERSION_" />
@@ -169,7 +169,7 @@
<!-- ### HISTORY COMMENTS ################################################# -->
<class name="HistoryDetailImpl" table="JBPM4_HIST_DETAIL">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator column="CLASS_" />
<version name="dbversion" column="DBVERSION_" />
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.identity.hbm.xml 2009-09-16 14:31:51 UTC (rev 5651)
@@ -6,7 +6,7 @@
<!-- ### USER ########################################################### -->
<class name="UserImpl" table="JBPM4_ID_USER">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
@@ -20,7 +20,7 @@
<!-- ### MEMBERSHIP ##################################################### -->
<class name="MembershipImpl" table="JBPM4_ID_MEMBERSHIP">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
@@ -42,7 +42,7 @@
<!-- ### GROUP ########################################################### -->
<class name="GroupImpl" table="JBPM4_ID_GROUP">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.repository.hbm.xml 2009-09-16 14:31:51 UTC (rev 5651)
@@ -9,7 +9,7 @@
<!-- ProcessElementImpl part ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<property name="name" type="text" column="NAME_" />
@@ -35,7 +35,7 @@
<class name="org.jbpm.pvm.internal.repository.DeploymentProperty" table="JBPM4_DEPLOYPROP">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<many-to-one name="deployment"
class="org.jbpm.pvm.internal.repository.DeploymentImpl"
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml 2009-09-16 13:15:55 UTC (rev 5650)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.task.hbm.xml 2009-09-16 14:31:51 UTC (rev 5651)
@@ -9,7 +9,7 @@
table="JBPM4_TASK"
discriminator-value="T">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator type="char" column="CLASS_"/>
<version name="dbversion" column="DBVERSION_" />
@@ -78,7 +78,7 @@
<!-- ### PARTICIPANT #################################################### -->
<class name="ParticipationImpl" table="JBPM4_PARTICIPATION">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
@@ -102,7 +102,7 @@
<!-- ### SWIMLANE ####################################################### -->
<class name="SwimlaneImpl" table="JBPM4_SWIMLANE">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<version name="dbversion" column="DBVERSION_" />
14 years, 7 months
JBoss JBPM SVN: r5650 - jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-16 09:15:55 -0400 (Wed, 16 Sep 2009)
New Revision: 5650
Modified:
jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
Log:
Small enhancements in how the current activitities are displayed
Modified: jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java
===================================================================
--- jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-09-16 12:52:34 UTC (rev 5649)
+++ jbpm4/trunk/modules/integration/console/src/main/java/org/jbpm/integration/console/ModelAdaptor.java 2009-09-16 13:15:55 UTC (rev 5650)
@@ -113,20 +113,24 @@
if (currentActivities.size() == 1) {
tok.setCurrentNodeName(currentActivities.iterator().next());
}
- else
- {
- tok.setCurrentNodeName(executionId);
+ else if (currentActivities.size() > 1){
+ StringBuilder strb = new StringBuilder();
+ for (String activeActivity : currentActivities) {
+ strb.append(activeActivity + ",");
+ }
+ tok.setCurrentNodeName(strb.deleteCharAt(strb.length() - 1).toString());
+ } else {
+ tok.setCurrentNodeName(executionId);
}
// transitions
List<String> availableSignals = new ArrayList<String>();
- /* TODO: FIX THIS
+ /* TODO: in jBPM4, executions don't have outgoing transitions. verifiy if this is needed.
ExecutionImpl openTopLevelExecution = (ExecutionImpl) execution;
List<Transition> outTransitions = openTopLevelExecution.getActivity().getOutgoingTransitions();
if (outTransitions != null) {
for (Transition t : outTransitions) {
- // TODO: Fix when https://jira.jboss.org/jira/browse/JBPM-2220 is done
String transitionName = t.getName() != null ? t.getName() : "to_" + t.getDestination().getName();
availableSignals.add(transitionName);
}
14 years, 7 months
JBoss JBPM SVN: r5649 - in jbpm4/trunk/modules: jpdl/src/main/java/org/jbpm/jpdl/internal/activity and 19 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-09-16 08:52:34 -0400 (Wed, 16 Sep 2009)
New Revision: 5649
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdComposer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdComposer.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdComposer.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/IdGenerator.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/AntHelper.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java
jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
Log:
JBPM-2526 switched executions over to jbpm dbid generation
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -70,7 +70,7 @@
if (implementationClassNames==null) {
implementationClassNames = new HashMap<String, String>();
// null represents the default configuration (== the JbpmConfiguration)
- implementationClassNames.put(null, "org.jbpm.pvm.internal.cfg.JbpmConfiguration");
+ implementationClassNames.put(null, "org.jbpm.pvm.internal.cfg.ProcessEngineImpl");
implementationClassNames.put("spring-test", "org.jbpm.pvm.internal.cfg.SpringConfiguration");
// TODO
// implementationClasses.put("mc", "org.jbpm.pvm.internal.cfg.McConfiguration");
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -32,6 +32,7 @@
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.task.SwimlaneImpl;
@@ -84,6 +85,12 @@
executionImpl.historyActivityStart();
subProcessInstance.start();
+
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
+ if (dbSession!=null) {
+ dbSession.save(subProcessInstance);
+ }
+
execution.waitForSignal();
}
Modified: jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java
===================================================================
--- jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/Jpdl3ConverterReaderTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -27,7 +27,7 @@
import org.dom4j.Document;
import org.dom4j.Element;
import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.xml.Problem;
import org.junit.Assert;
@@ -177,7 +177,7 @@
}
private void setUpEnviroment() throws Exception {
- EnvironmentFactory environmentFactory = JbpmConfiguration
+ EnvironmentFactory environmentFactory = ProcessEngineImpl
.parseXmlString("<jbpm-configuration>"
+ " <process-engine-context>"
+ " <script-manager default-expression-language='juel'"
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/AntHelper.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/AntHelper.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/AntHelper.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -28,7 +28,7 @@
import org.apache.commons.logging.LogFactory;
import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
/**
* common strategy for jbpm ant tasks to obtain a hibernate SessionFactory.
@@ -40,7 +40,7 @@
private static final Log log = LogFactory.getLog(AntHelper.class);
public static ProcessEngine getProcessEngine(String jbpmCfgXml) {
- ProcessEngine processEngine = (JbpmConfiguration) processEngines.get(jbpmCfgXml);
+ ProcessEngine processEngine = (ProcessEngineImpl) processEngines.get(jbpmCfgXml);
if (processEngine == null) {
Configuration configuration = new Configuration();
if (jbpmCfgXml!=null) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/ant/JbpmDeployTask.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -52,7 +52,7 @@
ClassLoader originalClassLoader = currentThread.getContextClassLoader();
currentThread.setContextClassLoader(JbpmDeployTask.class.getClassLoader());
try {
- // get the JbpmConfiguration
+ // get the ProcessEngineImpl
ProcessEngine processEngine = AntHelper.getProcessEngine(jbpmCfg);
// if attribute process is set, deploy that process file
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,336 +0,0 @@
-/*
- * 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.cfg;
-
-import java.io.File;
-import java.io.InputStream;
-import java.net.URL;
-import java.sql.Connection;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ExecutionService;
-import org.jbpm.api.HistoryService;
-import org.jbpm.api.IdentityService;
-import org.jbpm.api.JbpmException;
-import org.jbpm.api.ManagementService;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.RepositoryService;
-import org.jbpm.api.TaskService;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cmd.CommandService;
-import org.jbpm.pvm.internal.env.Context;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.JbpmConfigurationParser;
-import org.jbpm.pvm.internal.env.PvmEnvironment;
-import org.jbpm.pvm.internal.env.UserProvidedEnvironmentObject;
-import org.jbpm.pvm.internal.stream.FileStreamInput;
-import org.jbpm.pvm.internal.stream.InputStreamInput;
-import org.jbpm.pvm.internal.stream.ResourceStreamInput;
-import org.jbpm.pvm.internal.stream.StreamInput;
-import org.jbpm.pvm.internal.stream.StringStreamInput;
-import org.jbpm.pvm.internal.stream.UrlStreamInput;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireDefinition;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-
-/**
- * an environment factory that also is the process-engine context.
- *
- * <p>
- * This environment factory will produce environments with 2 contexts: the
- * process-engine context and the block context.
- * </p>
- *
- * <p>
- * An process-engine context is build from two wire definitions: the
- * process-engine wire definition and the environment wire definition.
- * </p>
- *
- * <p>
- * The process-engine context itself is build from the process-engine
- * wire definition. So all objects that are created in this context remain
- * cached for the lifetime of this process-engine context object.
- * </p>
- *
- * <p>
- * This process-engine context is also a environment factory. The produced
- * environments contain 2 contexts: the process-engine context itself and a
- * new environment context, build from the environment wire definition. For each
- * created environment, a new environment context will be created from the same
- * environment wire definition. Objects in the environment context will live for
- * as long as the environment.
- * </p>
- *
- * @author Tom Baeyens
- */
-public class JbpmConfiguration extends Configuration implements Context, ProcessEngine, EnvironmentFactory {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(JbpmConfiguration.class.getName());
-
- protected boolean isConfigured = false;
- protected WireContext processEngineWireContext = new WireContext(new WireDefinition(), Context.CONTEXTNAME_PROCESS_ENGINE, true);
- protected WireDefinition transactionWireDefinition = new WireDefinition();
-
- protected ThreadLocal<List<UserProvidedEnvironmentObject>> userProvidedEnvironmentObjectsThreadLocal = new ThreadLocal<List<UserProvidedEnvironmentObject>>();
- protected ThreadLocal<String> authenticatedUserIdThreadLocal = new ThreadLocal<String>();
-
- protected CommandService userCommandService = null;
-
- public JbpmConfiguration() {
- super((Configuration)null);
- }
-
- public ProcessEngine buildProcessEngine() {
- if (!isConfigured) {
- setResource("jbpm.cfg.xml");
- }
- if (log.isTraceEnabled()) {
- log.trace("created ProcessEngine "+System.identityHashCode(this));
- if ( (processEngineWireContext!=null)
- && (processEngineWireContext.getWireDefinition()!=null)
- && (processEngineWireContext.getWireDefinition().getDescriptorTypes()!=null)
- ) {
- log.trace(" process-engine-context "+System.identityHashCode(processEngineWireContext));
- for (Class<?> descriptorType: processEngineWireContext.getWireDefinition().getDescriptorTypes()) {
- log.trace(" "+descriptorType.getName());
- }
- }
- if ( (transactionWireDefinition!=null)
- && (transactionWireDefinition.getDescriptorTypes()!=null)
- ) {
- log.trace(" transaction-context:");
- for (Class<?> descriptorType: transactionWireDefinition.getDescriptorTypes()) {
- log.trace(" "+descriptorType.getName());
- }
- }
- }
- processEngineWireContext.create();
- userCommandService = (CommandService) processEngineWireContext.get("user.command.service");
- return this;
- }
-
- public Configuration setHibernateSessionFactory(Object hibernateSessionFactory) {
- processEngineWireContext
- .getWireDefinition()
- .addDescriptor(new ProvidedObjectDescriptor(hibernateSessionFactory, true));
- return this;
- }
-
- public Configuration setInputStream(InputStream inputStream) {
- parse(new InputStreamInput(inputStream));
- return this;
- }
-
- public Configuration setResource(String resource) {
- parse(new ResourceStreamInput(resource, getClassLoader()));
- return this;
- }
-
- public Configuration setUrl(URL url) {
- parse(new UrlStreamInput(url));
- return this;
- }
-
- public Configuration setFile(File file) {
- parse(new FileStreamInput(file));
- return this;
- }
-
- public Configuration setXmlString(String xmlString) {
- parse(new StringStreamInput(xmlString));
- return this;
- }
-
-
- public static EnvironmentFactory parseXmlString(String xmlString) {
- JbpmConfiguration jbpmConfiguration = new JbpmConfiguration();
- jbpmConfiguration.setXmlString(xmlString);
- return jbpmConfiguration;
- }
-
- protected void parse(StreamInput streamSource) {
- isConfigured = true;
- JbpmConfigurationParser.getInstance()
- .createParse()
- .pushObject(this)
- .setStreamSource(streamSource)
- .execute()
- .checkErrors("jbpm configuration " + streamSource);
- }
-
- public ExecutionService getExecutionService() {
- return processEngineWireContext.get(ExecutionService.class);
- }
- public HistoryService getHistoryService() {
- return processEngineWireContext.get(HistoryService.class);
- }
- public ManagementService getManagementService() {
- return processEngineWireContext.get(ManagementService.class);
- }
- public TaskService getTaskService() {
- return processEngineWireContext.get(TaskService.class);
- }
- public IdentityService getIdentityService() {
- return processEngineWireContext.get(IdentityService.class);
- }
- public RepositoryService getRepositoryService() {
- return processEngineWireContext.get(RepositoryService.class);
- }
-
- public EnvironmentImpl openEnvironment() {
- PvmEnvironment environment = new PvmEnvironment(this);
-
- if (log.isTraceEnabled()) log.trace("opening " + environment);
-
- installAuthenticatedUserId(environment);
- installProcessEngineContext(environment);
- installTransactionContext(environment);
-
- return environment;
- }
-
- protected void installAuthenticatedUserId(EnvironmentImpl environment) {
- String authenticatedUserId = authenticatedUserIdThreadLocal.get();
- if (authenticatedUserId!=null) {
- environment.setAuthenticatedUserId(authenticatedUserId);
- authenticatedUserIdThreadLocal.set(null);
- }
- }
-
- protected void installTransactionContext(PvmEnvironment environment) {
- WireContext transactionContext = new WireContext(transactionWireDefinition, Context.CONTEXTNAME_TRANSACTION, true);
- // add the environment block context to the environment
- environment.setContext(transactionContext);
-
- EnvironmentImpl.pushEnvironment(environment);
- try {
- // finish the creation of the environment wire context
- transactionContext.create();
-
- } catch (RuntimeException e) {
- EnvironmentImpl.popEnvironment();
- throw e;
- }
- }
-
- protected void installProcessEngineContext(PvmEnvironment environment) {
- // add the process-engine context
- environment.setContext(processEngineWireContext);
- }
-
- public void close() {
- processEngineWireContext.fire(WireContext.EVENT_CLOSE, null);
- }
-
- // process-engine context delegation methods
- // ///////////////////////////////////
-
- public Object get(String key) {
- return processEngineWireContext.get(key);
- }
-
- public <T> T get(Class<T> type) {
- return processEngineWireContext.get(type);
- }
-
- public String getName() {
- return processEngineWireContext.getName();
- }
-
- public boolean has(String key) {
- return processEngineWireContext.has(key);
- }
-
- public Set<String> keys() {
- return processEngineWireContext.keys();
- }
-
- public Object set(String key, Object value) {
- return processEngineWireContext.set(key, value);
- }
-
- public void addProcessEngineWireDefinition(WireDefinition wireDefinition) {
- processEngineWireContext.getWireDefinition().addWireDefinition(wireDefinition);
- }
-
- public void addTransactionWireDefinition(WireDefinition wireDefinition) {
- transactionWireDefinition.addWireDefinition(wireDefinition);
- }
-
- // getters and setters //////////////////////////////////////////////////////
-
- public void setTransactionWireDefinition(WireDefinition transactionWireDefinition) {
- this.transactionWireDefinition = transactionWireDefinition;
- }
- public WireContext getProcessEngineWireContext() {
- return processEngineWireContext;
- }
- public void setProcessEngineWireContext(WireContext processEngineWireContext) {
- this.processEngineWireContext = processEngineWireContext;
- }
- public WireDefinition getTransactionWireDefinition() {
- return transactionWireDefinition;
- }
-
- public ProcessEngine setAuthenticatedUserId(String authenticatedUserId) {
- authenticatedUserIdThreadLocal.set(authenticatedUserId);
- return this;
- }
-
- public ProcessEngine setHibernateSession(Object hibernateSession) {
- addUserProvidedEnvironmentObject(new UserProvidedEnvironmentObject(hibernateSession, null, true));
- return this;
- }
-
- public ProcessEngine setJdbcConnection(Connection jdbcConnection) {
- addUserProvidedEnvironmentObject(new UserProvidedEnvironmentObject(jdbcConnection, null, true));
- return this;
- }
-
- protected synchronized void addUserProvidedEnvironmentObject(UserProvidedEnvironmentObject userProvidedEnvironmentObject) {
- List<UserProvidedEnvironmentObject> environmentObjects = userProvidedEnvironmentObjectsThreadLocal.get();
- if (environmentObjects==null) {
- environmentObjects = new ArrayList<UserProvidedEnvironmentObject>();
- userProvidedEnvironmentObjectsThreadLocal.set(environmentObjects);
- }
- environmentObjects.add(userProvidedEnvironmentObject);
- }
-
- public <T> T execute(Command<T> command) {
- EnvironmentImpl environment = openEnvironment();
- try {
- return userCommandService.execute(command);
- } catch (RuntimeException e) {
- throw e;
- } catch (Exception e) {
- throw new JbpmException(e.getMessage(), e);
- } finally {
- environment.close();
- }
- }
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/JbpmConfiguration.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,338 @@
+/*
+ * 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.cfg;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URL;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.HistoryService;
+import org.jbpm.api.IdentityService;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.ManagementService;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.api.TaskService;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.CommandService;
+import org.jbpm.pvm.internal.env.Context;
+import org.jbpm.pvm.internal.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.env.JbpmConfigurationParser;
+import org.jbpm.pvm.internal.env.PvmEnvironment;
+import org.jbpm.pvm.internal.env.UserProvidedEnvironmentObject;
+import org.jbpm.pvm.internal.stream.FileStreamInput;
+import org.jbpm.pvm.internal.stream.InputStreamInput;
+import org.jbpm.pvm.internal.stream.ResourceStreamInput;
+import org.jbpm.pvm.internal.stream.StreamInput;
+import org.jbpm.pvm.internal.stream.StringStreamInput;
+import org.jbpm.pvm.internal.stream.UrlStreamInput;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+
+/**
+ * an environment factory that also is the process-engine context.
+ *
+ * <p>
+ * This environment factory will produce environments with 2 contexts: the
+ * process-engine context and the block context.
+ * </p>
+ *
+ * <p>
+ * An process-engine context is build from two wire definitions: the
+ * process-engine wire definition and the environment wire definition.
+ * </p>
+ *
+ * <p>
+ * The process-engine context itself is build from the process-engine
+ * wire definition. So all objects that are created in this context remain
+ * cached for the lifetime of this process-engine context object.
+ * </p>
+ *
+ * <p>
+ * This process-engine context is also a environment factory. The produced
+ * environments contain 2 contexts: the process-engine context itself and a
+ * new environment context, build from the environment wire definition. For each
+ * created environment, a new environment context will be created from the same
+ * environment wire definition. Objects in the environment context will live for
+ * as long as the environment.
+ * </p>
+ *
+ * @author Tom Baeyens
+ */
+public class ProcessEngineImpl extends Configuration implements Context, ProcessEngine, EnvironmentFactory {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(ProcessEngineImpl.class.getName());
+
+ public static final String JBPM_LIBRARY_VERSION = "4.1-SNAPSHOT";
+
+ protected boolean isConfigured = false;
+ protected WireContext processEngineWireContext = new WireContext(new WireDefinition(), Context.CONTEXTNAME_PROCESS_ENGINE, true);
+ protected WireDefinition transactionWireDefinition = new WireDefinition();
+
+ protected ThreadLocal<List<UserProvidedEnvironmentObject>> userProvidedEnvironmentObjectsThreadLocal = new ThreadLocal<List<UserProvidedEnvironmentObject>>();
+ protected ThreadLocal<String> authenticatedUserIdThreadLocal = new ThreadLocal<String>();
+
+ protected CommandService userCommandService = null;
+
+ public ProcessEngineImpl() {
+ super((Configuration)null);
+ }
+
+ public ProcessEngine buildProcessEngine() {
+ if (!isConfigured) {
+ setResource("jbpm.cfg.xml");
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("created ProcessEngine "+System.identityHashCode(this));
+ if ( (processEngineWireContext!=null)
+ && (processEngineWireContext.getWireDefinition()!=null)
+ && (processEngineWireContext.getWireDefinition().getDescriptorTypes()!=null)
+ ) {
+ log.trace(" process-engine-context "+System.identityHashCode(processEngineWireContext));
+ for (Class<?> descriptorType: processEngineWireContext.getWireDefinition().getDescriptorTypes()) {
+ log.trace(" "+descriptorType.getName());
+ }
+ }
+ if ( (transactionWireDefinition!=null)
+ && (transactionWireDefinition.getDescriptorTypes()!=null)
+ ) {
+ log.trace(" transaction-context:");
+ for (Class<?> descriptorType: transactionWireDefinition.getDescriptorTypes()) {
+ log.trace(" "+descriptorType.getName());
+ }
+ }
+ }
+ processEngineWireContext.create();
+ userCommandService = (CommandService) processEngineWireContext.get("user.command.service");
+ return this;
+ }
+
+ public Configuration setHibernateSessionFactory(Object hibernateSessionFactory) {
+ processEngineWireContext
+ .getWireDefinition()
+ .addDescriptor(new ProvidedObjectDescriptor(hibernateSessionFactory, true));
+ return this;
+ }
+
+ public Configuration setInputStream(InputStream inputStream) {
+ parse(new InputStreamInput(inputStream));
+ return this;
+ }
+
+ public Configuration setResource(String resource) {
+ parse(new ResourceStreamInput(resource, getClassLoader()));
+ return this;
+ }
+
+ public Configuration setUrl(URL url) {
+ parse(new UrlStreamInput(url));
+ return this;
+ }
+
+ public Configuration setFile(File file) {
+ parse(new FileStreamInput(file));
+ return this;
+ }
+
+ public Configuration setXmlString(String xmlString) {
+ parse(new StringStreamInput(xmlString));
+ return this;
+ }
+
+
+ public static EnvironmentFactory parseXmlString(String xmlString) {
+ ProcessEngineImpl processEngineImpl = new ProcessEngineImpl();
+ processEngineImpl.setXmlString(xmlString);
+ return processEngineImpl;
+ }
+
+ protected void parse(StreamInput streamSource) {
+ isConfigured = true;
+ JbpmConfigurationParser.getInstance()
+ .createParse()
+ .pushObject(this)
+ .setStreamSource(streamSource)
+ .execute()
+ .checkErrors("jbpm configuration " + streamSource);
+ }
+
+ public ExecutionService getExecutionService() {
+ return processEngineWireContext.get(ExecutionService.class);
+ }
+ public HistoryService getHistoryService() {
+ return processEngineWireContext.get(HistoryService.class);
+ }
+ public ManagementService getManagementService() {
+ return processEngineWireContext.get(ManagementService.class);
+ }
+ public TaskService getTaskService() {
+ return processEngineWireContext.get(TaskService.class);
+ }
+ public IdentityService getIdentityService() {
+ return processEngineWireContext.get(IdentityService.class);
+ }
+ public RepositoryService getRepositoryService() {
+ return processEngineWireContext.get(RepositoryService.class);
+ }
+
+ public EnvironmentImpl openEnvironment() {
+ PvmEnvironment environment = new PvmEnvironment(this);
+
+ if (log.isTraceEnabled()) log.trace("opening " + environment);
+
+ installAuthenticatedUserId(environment);
+ installProcessEngineContext(environment);
+ installTransactionContext(environment);
+
+ return environment;
+ }
+
+ protected void installAuthenticatedUserId(EnvironmentImpl environment) {
+ String authenticatedUserId = authenticatedUserIdThreadLocal.get();
+ if (authenticatedUserId!=null) {
+ environment.setAuthenticatedUserId(authenticatedUserId);
+ authenticatedUserIdThreadLocal.set(null);
+ }
+ }
+
+ protected void installTransactionContext(PvmEnvironment environment) {
+ WireContext transactionContext = new WireContext(transactionWireDefinition, Context.CONTEXTNAME_TRANSACTION, true);
+ // add the environment block context to the environment
+ environment.setContext(transactionContext);
+
+ EnvironmentImpl.pushEnvironment(environment);
+ try {
+ // finish the creation of the environment wire context
+ transactionContext.create();
+
+ } catch (RuntimeException e) {
+ EnvironmentImpl.popEnvironment();
+ throw e;
+ }
+ }
+
+ protected void installProcessEngineContext(PvmEnvironment environment) {
+ // add the process-engine context
+ environment.setContext(processEngineWireContext);
+ }
+
+ public void close() {
+ processEngineWireContext.fire(WireContext.EVENT_CLOSE, null);
+ }
+
+ // process-engine context delegation methods
+ // ///////////////////////////////////
+
+ public Object get(String key) {
+ return processEngineWireContext.get(key);
+ }
+
+ public <T> T get(Class<T> type) {
+ return processEngineWireContext.get(type);
+ }
+
+ public String getName() {
+ return processEngineWireContext.getName();
+ }
+
+ public boolean has(String key) {
+ return processEngineWireContext.has(key);
+ }
+
+ public Set<String> keys() {
+ return processEngineWireContext.keys();
+ }
+
+ public Object set(String key, Object value) {
+ return processEngineWireContext.set(key, value);
+ }
+
+ public void addProcessEngineWireDefinition(WireDefinition wireDefinition) {
+ processEngineWireContext.getWireDefinition().addWireDefinition(wireDefinition);
+ }
+
+ public void addTransactionWireDefinition(WireDefinition wireDefinition) {
+ transactionWireDefinition.addWireDefinition(wireDefinition);
+ }
+
+ // getters and setters //////////////////////////////////////////////////////
+
+ public void setTransactionWireDefinition(WireDefinition transactionWireDefinition) {
+ this.transactionWireDefinition = transactionWireDefinition;
+ }
+ public WireContext getProcessEngineWireContext() {
+ return processEngineWireContext;
+ }
+ public void setProcessEngineWireContext(WireContext processEngineWireContext) {
+ this.processEngineWireContext = processEngineWireContext;
+ }
+ public WireDefinition getTransactionWireDefinition() {
+ return transactionWireDefinition;
+ }
+
+ public ProcessEngine setAuthenticatedUserId(String authenticatedUserId) {
+ authenticatedUserIdThreadLocal.set(authenticatedUserId);
+ return this;
+ }
+
+ public ProcessEngine setHibernateSession(Object hibernateSession) {
+ addUserProvidedEnvironmentObject(new UserProvidedEnvironmentObject(hibernateSession, null, true));
+ return this;
+ }
+
+ public ProcessEngine setJdbcConnection(Connection jdbcConnection) {
+ addUserProvidedEnvironmentObject(new UserProvidedEnvironmentObject(jdbcConnection, null, true));
+ return this;
+ }
+
+ protected synchronized void addUserProvidedEnvironmentObject(UserProvidedEnvironmentObject userProvidedEnvironmentObject) {
+ List<UserProvidedEnvironmentObject> environmentObjects = userProvidedEnvironmentObjectsThreadLocal.get();
+ if (environmentObjects==null) {
+ environmentObjects = new ArrayList<UserProvidedEnvironmentObject>();
+ userProvidedEnvironmentObjectsThreadLocal.set(environmentObjects);
+ }
+ environmentObjects.add(userProvidedEnvironmentObject);
+ }
+
+ public <T> T execute(Command<T> command) {
+ EnvironmentImpl environment = openEnvironment();
+ try {
+ return userCommandService.execute(command);
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new JbpmException(e.getMessage(), e);
+ } finally {
+ environment.close();
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -47,7 +47,7 @@
*
* @author Andries Inze
*/
-public class SpringConfiguration extends JbpmConfiguration implements EnvironmentFactory, ProcessEngine, ApplicationContextAware {
+public class SpringConfiguration extends ProcessEngineImpl implements EnvironmentFactory, ProcessEngine, ApplicationContextAware {
private static final Log log = Log.getLog(SpringConfiguration.class.getName());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -64,11 +64,6 @@
processInstance.setVariables(variables);
processInstance.start();
- if (!processInstance.isEnded()) {
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
- session.save(processInstance);
- }
-
return processInstance;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/JbpmConfigurationParser.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.internal.env;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -57,9 +57,9 @@
Element documentElement = document.getDocumentElement();
// if the default environment factory was already set in the parse
- JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) parse.findObject(JbpmConfiguration.class);
- if (jbpmConfiguration==null) {
- jbpmConfiguration = new JbpmConfiguration();
+ ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) parse.findObject(ProcessEngineImpl.class);
+ if (processEngineImpl==null) {
+ processEngineImpl = new ProcessEngineImpl();
}
for (Element importElement : XmlUtil.elements(documentElement, "import")) {
@@ -67,7 +67,7 @@
String resource = importElement.getAttribute("resource");
Parse importParse = createParse()
.setResource(resource)
- .pushObject(jbpmConfiguration)
+ .pushObject(processEngineImpl)
.execute();
parse.addProblems(importParse.getProblems());
@@ -76,7 +76,7 @@
Element processEngineElement = XmlUtil.element(documentElement, "process-engine-context");
if (processEngineElement != null) {
- WireDefinition processEngineContextDefinition = jbpmConfiguration.getProcessEngineWireContext().getWireDefinition();
+ WireDefinition processEngineContextDefinition = processEngineImpl.getProcessEngineWireContext().getWireDefinition();
parse.pushObject(processEngineContextDefinition);
try {
processEngineContextParser.parseDocumentElement(processEngineElement, parse);
@@ -87,7 +87,7 @@
Element txCtxElement = XmlUtil.element(documentElement, "transaction-context");
if (txCtxElement != null) {
- WireDefinition transactionContextDefinition = jbpmConfiguration.getTransactionWireDefinition();
+ WireDefinition transactionContextDefinition = processEngineImpl.getTransactionWireDefinition();
parse.pushObject(transactionContextDefinition);
try {
transactionContextParser.parseDocumentElement(txCtxElement, parse);
@@ -96,9 +96,9 @@
}
}
- parse.setDocumentObject(jbpmConfiguration);
+ parse.setDocumentObject(processEngineImpl);
- return jbpmConfiguration;
+ return processEngineImpl;
}
public Parser getProcessEngineContextParser() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/PvmEnvironment.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.env;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.util.Closable;
@@ -35,10 +35,10 @@
private static final Log log = Log.getLog(PvmEnvironment.class.getName());
- protected JbpmConfiguration jbpmConfiguration;
+ protected ProcessEngineImpl processEngineImpl;
- public PvmEnvironment(JbpmConfiguration jbpmConfiguration) {
- this.jbpmConfiguration = jbpmConfiguration;
+ public PvmEnvironment(ProcessEngineImpl processEngineImpl) {
+ this.processEngineImpl = processEngineImpl;
}
public String toString() {
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,39 @@
+package org.jbpm.pvm.internal.id;
+
+import org.hibernate.Session;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AcquireDbidBlockCmd implements Command<Long> {
+
+ private static final long serialVersionUID = 1L;
+
+ long blocksize;
+
+ public AcquireDbidBlockCmd(long blocksize) {
+ this.blocksize = blocksize;
+ }
+
+ public Long execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+
+ PropertyImpl property = (PropertyImpl) session.createQuery(
+ "select property " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
+ ).uniqueResult();
+
+ String nextIdText = property.getValue();
+ Long nextId = new Long(nextIdText);
+
+ property.setValue(Long.toString(nextId.longValue()+blocksize));
+
+ session.update(property);
+ session.flush();
+
+ return nextId;
+ }
+}
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireDbidBlockCmd.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/AcquireIdBlockCmd.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,39 +0,0 @@
-package org.jbpm.pvm.internal.id;
-
-import org.hibernate.Session;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-
-/**
- * @author Tom Baeyens
- */
-public class AcquireIdBlockCmd implements Command<Long> {
-
- private static final long serialVersionUID = 1L;
-
- long blocksize;
-
- public AcquireIdBlockCmd(long blocksize) {
- this.blocksize = blocksize;
- }
-
- public Long execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
-
- PropertyImpl property = (PropertyImpl) session.createQuery(
- "select property " +
- "from "+PropertyImpl.class.getName()+" as property " +
- "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'"
- ).uniqueResult();
-
- String nextIdText = property.getValue();
- Long nextId = new Long(nextIdText);
-
- property.setValue(Long.toString(nextId.longValue()+blocksize));
-
- session.update(property);
- session.flush();
-
- return nextId;
- }
-}
\ No newline at end of file
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,103 @@
+/*
+ * 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.id;
+
+import java.util.Random;
+
+import org.hibernate.StaleStateException;
+import org.jbpm.api.JbpmException;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.CommandService;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DatabaseDbidGenerator extends DbidGenerator {
+
+ private static Log log = Log.getLog(DatabaseDbidGenerator.class.getName());
+
+ static Random random = new Random();
+
+ // configuration
+ CommandService commandService;
+ long blocksize = 10000;
+ int maxAttempts = 3;
+
+ // runtime state
+ long lastId = -2;
+ long nextId = -1;
+
+ public synchronized long getNextId() {
+ // if no more ids available
+ if (lastId<nextId) {
+ // acquire a next block of ids
+
+ // reset the id block
+ lastId = -2;
+ nextId = -1;
+
+ // try couple of times
+ try {
+ for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
+ try {
+ // acquire block
+ nextId = commandService.execute(new AcquireDbidBlockCmd(blocksize));
+ lastId = nextId + blocksize - 1;
+
+ log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
+
+ } catch (StaleStateException e) {
+ // optimistic locking exception indicating another thread tried to
+ // acquire a block of ids concurrently
+ attempts--;
+
+ // if no attempts left
+ if (attempts==0) {
+ // fail the surrounding transaction
+ throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
+ }
+
+ // if there are still attempts left, first wait a bit
+ int millis = 20 + random.nextInt(200);
+ log.debug("optimistic locking failure while trying to acquire id block. retrying in "+millis+" millis");
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException e1) {
+ log.debug("waiting after id block locking failure got interrupted");
+ }
+ }
+ }
+ } catch (Exception e) {
+ throw new JbpmException("couldn't acquire block of ids", e);
+ }
+ }
+
+ return nextId++;
+ }
+
+ public void initialize() {
+ nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
+ lastId = nextId + blocksize - 1;
+ log.debug("initial id block ["+nextId+"-"+lastId+"]");
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseDbidGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdComposer.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdComposer.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdComposer.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,67 @@
+/*
+ * 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.id;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DatabaseIdComposer extends IdComposer {
+
+ private static Log log = Log.getLog(DatabaseIdComposer.class.getName());
+
+ public String createId(ProcessDefinition processDefinition, Execution parent, ExecutionImpl execution) {
+
+ String base = null;
+ if (parent!=null) {
+ base = parent.getId();
+ } else if (processDefinition.getKey()!=null){
+ base = processDefinition.getKey();
+ } else {
+ base = processDefinition.getId();
+ }
+
+ String executionPart = null;
+ if ( (parent==null)
+ && (execution.getKey()!=null)
+ ) {
+ executionPart = execution.getKey();
+
+ } else if (execution.getName()!=null) {
+ executionPart = execution.getName();
+
+ } else {
+ executionPart = Long.toString(execution.getDbid());
+ }
+
+ String executionId = base+"."+executionPart;
+
+ if (log.isDebugEnabled()) log.debug("generated execution id "+executionId);
+
+ return executionId;
+ }
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DatabaseIdGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,103 +0,0 @@
-/*
- * 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.id;
-
-import java.util.Random;
-
-import org.hibernate.StaleStateException;
-import org.jbpm.api.JbpmException;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cmd.CommandService;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DatabaseIdGenerator extends IdGenerator {
-
- private static Log log = Log.getLog(DatabaseIdGenerator.class.getName());
-
- static Random random = new Random();
-
- // configuration
- CommandService commandService;
- long blocksize = 10000;
- int maxAttempts = 3;
-
- // runtime state
- long lastId = -2;
- long nextId = -1;
-
- public synchronized long getNextId() {
- // if no more ids available
- if (lastId<nextId) {
- // acquire a next block of ids
-
- // reset the id block
- lastId = -2;
- nextId = -1;
-
- // try couple of times
- try {
- for ( int attempts = maxAttempts; (attempts>0) && (nextId==-1) ; attempts-- ) {
- try {
- // acquire block
- nextId = commandService.execute(new AcquireIdBlockCmd(blocksize));
- lastId = nextId + blocksize - 1;
-
- log.debug("acquired new id block ["+nextId+"-"+lastId+"]");
-
- } catch (StaleStateException e) {
- // optimistic locking exception indicating another thread tried to
- // acquire a block of ids concurrently
- attempts--;
-
- // if no attempts left
- if (attempts==0) {
- // fail the surrounding transaction
- throw new JbpmException("couldn't acquire block of ids, tried "+maxAttempts+" times");
- }
-
- // if there are still attempts left, first wait a bit
- int millis = 20 + random.nextInt(200);
- log.debug("optimistic locking failure while trying to acquire id block. retrying in "+millis+" millis");
- try {
- Thread.sleep(millis);
- } catch (InterruptedException e1) {
- log.debug("waiting after id block locking failure got interrupted");
- }
- }
- }
- } catch (Exception e) {
- throw new JbpmException("couldn't acquire block of ids", e);
- }
- }
-
- return nextId++;
- }
-
- public void initialize() {
- nextId = commandService.execute(new InitializePropertiesCmd(blocksize));
- lastId = nextId + blocksize - 1;
- log.debug("initial id block ["+nextId+"-"+lastId+"]");
- }
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,47 @@
+/*
+ * 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.id;
+
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class DbidGenerator {
+
+ static DbidGenerator defaultIdGenerator = new MemoryDbidGenerator();
+
+ public static DbidGenerator getDbidGenerator() {
+ DbidGenerator dbidGenerator = EnvironmentImpl.getFromCurrent(DbidGenerator.class, false);
+ if (dbidGenerator!=null) {
+ return dbidGenerator;
+ }
+ return getDefaultIdGenerator();
+ }
+
+ public static DbidGenerator getDefaultIdGenerator() {
+ return defaultIdGenerator;
+ }
+
+ public abstract long getNextId();
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/DbidGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdComposer.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/IdGenerator.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdComposer.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdComposer.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,51 @@
+/*
+ * 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.id;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class IdComposer {
+
+ private static IdComposer defaultIdComposer = new MemoryIdComposer();
+
+ public static IdComposer getIdComposer() {
+ IdComposer idComposer = EnvironmentImpl.getFromCurrent(IdComposer.class, false);
+ if (idComposer!=null) {
+ return idComposer;
+ }
+ return getDefaultIdComposer();
+ }
+
+ public static IdComposer getDefaultIdComposer() {
+ return defaultIdComposer;
+ }
+
+ /** generates a unique id for the given execution. */
+ public abstract String createId(ProcessDefinition processDefinition, Execution parent, ExecutionImpl execution);
+}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/IdGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,47 +0,0 @@
-/*
- * 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.id;
-
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public abstract class IdGenerator {
-
- static IdGenerator defaultIdGenerator = new MemoryIdGenerator();
-
- public static IdGenerator getIdGenerator() {
- IdGenerator idGenerator = EnvironmentImpl.getFromCurrent(IdGenerator.class, false);
- if (idGenerator!=null) {
- return idGenerator;
- }
- return getDefaultIdGenerator();
- }
-
- public static IdGenerator getDefaultIdGenerator() {
- return defaultIdGenerator;
- }
-
- public abstract long getNextId();
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/InitializePropertiesCmd.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -26,6 +26,7 @@
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
/**
@@ -61,19 +62,16 @@
"where property.key = '"+PropertyImpl.SCHEMA_VERSION_KEY+"'"
).uniqueResult();
- String jbpmVersion = "4.1-SNAPSHOT";
-
+ log.debug("version of jbpm library: "+ProcessEngineImpl.JBPM_LIBRARY_VERSION);
+
if (property==null) {
- log.debug("initializing db schema version to "+jbpmVersion);
- property = new PropertyImpl(PropertyImpl.SCHEMA_VERSION_KEY, jbpmVersion);
- session.save(property);
+ log.debug("version of jbpm db schema: none");
} else {
String dbSchemaVersion = property.getValue();
- if (!jbpmVersion.equals(dbSchemaVersion)) {
- throw new JbpmException("jBPM runtime version "+jbpmVersion+" doesn't match with DB schema, which is version ");
- } else {
- log.debug("runtime and db schema version both "+jbpmVersion);
+ log.debug("version of jbpm db schema: "+dbSchemaVersion);
+ if (!ProcessEngineImpl.JBPM_LIBRARY_VERSION.equals(dbSchemaVersion)) {
+ throw new JbpmException("jBPM runtime version "+ProcessEngineImpl.JBPM_LIBRARY_VERSION+" doesn't match with DB schema, which is version ");
}
}
}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java (from rev 5640, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,35 @@
+/*
+ * 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.id;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MemoryDbidGenerator extends DbidGenerator {
+
+ static long nextId = 1;
+
+ public synchronized long getNextId() {
+ return nextId++;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryDbidGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdComposer.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdComposer.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdComposer.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,37 @@
+/*
+ * 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.id;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessDefinition;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MemoryIdComposer extends IdComposer {
+
+ public String createId(ProcessDefinition processDefinition, Execution parent, ExecutionImpl execution) {
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdComposer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/id/MemoryIdGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,36 +0,0 @@
-/*
- * 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.id;
-
-
-/**
- * @author Tom Baeyens
- */
-public class MemoryIdGenerator extends IdGenerator {
-
- static long nextId = 1;
-
- public synchronized long getNextId() {
- return nextId++;
- }
-
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorServlet.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -31,7 +31,7 @@
import org.jbpm.api.Configuration;
import org.jbpm.api.JbpmException;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
/**
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/DefaultIdGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,84 +0,0 @@
-/*
- * 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.model;
-
-import org.hibernate.Session;
-import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessDefinition;
-import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DefaultIdGenerator implements IdGenerator {
-
- private static Log log = Log.getLog(DefaultIdGenerator.class.getName());
-
- public String createId(ProcessDefinition processDefinition, Execution parent, ExecutionImpl execution) {
-
- Session session = EnvironmentImpl.getFromCurrent(Session.class);
- session.save(execution);
- // the next flush is introduced because of the following situation:
- // for hsqldb: id generation is done by inserting and then reading the id value
- // for db's that have separate id generators (postgres, oracle, mysql), the previous
- // save will only make hibernate generate a new id, but the insert is not yet done
- // Then the following scenario might happen:
- // * the new execution is added to collection of the parent execution
- // * the parent execution ends, causing the new child to be removed from the collection
- // * the child executions collection's cascade is set to all-delete-orphan so
- // we expect hibernate to delete it
- // * for some reason, then hibernate gets confused and still inserts the
- // execution afterwards.
- session.flush();
-
-
- String base = null;
- if (parent!=null) {
- base = parent.getId();
- } else if (processDefinition.getKey()!=null){
- base = processDefinition.getKey();
- } else {
- base = processDefinition.getId();
- }
-
- String executionPart = null;
- if ( (parent==null)
- && (execution.getKey()!=null)
- ) {
- executionPart = execution.getKey();
-
- } else if (execution.getName()!=null) {
- executionPart = execution.getName();
-
- } else {
- executionPart = Long.toString(execution.getDbid());
- }
-
- String executionId = base+"."+executionPart;
-
- if (log.isDebugEnabled()) log.debug("generated execution id "+executionId);
-
- return executionId;
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -57,6 +57,8 @@
import org.jbpm.pvm.internal.history.events.DecisionEnd;
import org.jbpm.pvm.internal.history.events.ProcessInstanceCreate;
import org.jbpm.pvm.internal.history.events.ProcessInstanceEnd;
+import org.jbpm.pvm.internal.id.DbidGenerator;
+import org.jbpm.pvm.internal.id.IdComposer;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.model.op.AtomicOperation;
@@ -179,14 +181,25 @@
this.state = STATE_CREATED;
this.key = key;
- IdGenerator idGenerator = processDefinition.getIdGenerator();
- if (idGenerator!=null) {
- this.id = idGenerator.createId(processDefinition, null, this);
- }
+ save();
+ composeIds();
HistoryEvent.fire(new ProcessInstanceCreate(), this);
}
+ protected void save() {
+ this.dbid = DbidGenerator.getDbidGenerator().getNextId();
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
+ if (dbSession!=null) {
+ dbSession.save(this);
+ }
+ }
+
+ protected void composeIds() {
+ this.id = IdComposer.getIdComposer().createId(processDefinition, parent, this);
+ }
+
+
// execution method : start /////////////////////////////////////////////////
public void start() {
@@ -346,8 +359,13 @@
this.propagation = Propagation.EXPLICIT;
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
+
if (parent!=null) {
parent.removeExecution(this);
+ if (dbSession!=null) {
+ dbSession.delete(this);
+ }
} else { // this is a process instance
HistoryEvent.fire(new ProcessInstanceEnd(), this);
@@ -358,7 +376,6 @@
superProcessExecution.signal();
}
- DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
if (dbSession!=null) {
dbSession.deleteProcessInstance(id, false);
}
@@ -798,24 +815,25 @@
}
public ExecutionImpl createExecution(String name) {
- // ?!
+ // when an activity calls createExecution, propagation is explicit.
+ // this means that the default propagation (proceed()) will not be called
propagation = Propagation.EXPLICIT;
- // create child execution
+ // create new execution
ExecutionImpl childExecution = newChildExecution();
- addExecution(childExecution);
-
- // initialize new concurrent execution
+ // initialize child execution
childExecution.setProcessDefinition(getProcessDefinition());
childExecution.processInstance = this.processInstance;
childExecution.name = name;
+
+ childExecution.save();
+ // make sure that child execution are saved before added to a persistent collection
+ // cause of the 'assigned' id strategy, adding the childExecution to the persistent collection
+ // before the dbid is assigned will result in identifier of an instance of ExecutionImpl altered from 0 to x
+ addExecution(childExecution);
+ // composeIds uses the parent so the childExecution has to be added before the ids are composed
+ childExecution.composeIds();
- // id generation (after initialization)
- IdGenerator keyGenerator = EnvironmentImpl.getFromCurrent(IdGenerator.class, false);
- if (keyGenerator!=null) {
- childExecution.id = keyGenerator.createId(getProcessDefinition(), this, childExecution);
- }
-
log.debug("created "+childExecution);
return childExecution;
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/IdGenerator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/IdGenerator.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/IdGenerator.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,36 +0,0 @@
-/*
- * 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.model;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessDefinition;
-
-
-/**
- * @author Tom Baeyens
- */
-public interface IdGenerator {
-
- /** generates a unique id for the given execution. */
- String createId(ProcessDefinition processDefinition, Execution parent, ExecutionImpl execution);
-
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ProcessDefinitionImpl.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -124,15 +124,6 @@
return new ExecutionImpl();
}
- /** by default, during initialization, an id will be generated when
- * an IdGenerator is present in the environment. By default,
- * this makes the execution persistent. So in case the process definition
- * is not persistent and there is an environment present (like in the case
- * of task lifecycle for jpdl processes), this method needs to be overwritten. */
- public IdGenerator getIdGenerator() {
- return EnvironmentImpl.getFromCurrent(IdGenerator.class, false);
- }
-
// task definitions /////////////////////////////////////////////////////////
public void addTaskDefinitionImpl(TaskDefinitionImpl taskDefinition) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/EnvironmentInterceptor.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -42,7 +42,7 @@
environment = environmentFactory.openEnvironment();
try {
- injectEnvironmentObjects(environment);
+ // injectEnvironmentObjects(environment);
return next.execute(command);
} finally {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycle.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -25,10 +25,10 @@
import java.util.Map;
import org.jbpm.api.JbpmException;
+import org.jbpm.pvm.internal.id.IdComposer;
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.IdGenerator;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
/**
@@ -85,7 +85,7 @@
task.setState(lifeCycleExecution.getActivity().getName());
}
- public IdGenerator getIdGenerator() {
+ public IdComposer getIdGenerator() {
// overrides the default ProcessDefinitionImpl behaviour that will end up
// in the execution being persisted
return null;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -36,7 +36,9 @@
public HibernateSessionResource(Session session) {
this.session = session;
- if (log.isTraceEnabled()) log.trace("beginning transaction on hibernate session "+System.identityHashCode(session));
+ if (log.isDebugEnabled()) {
+ log.debug("----- beginning hibernate tx "+System.identityHashCode(session)+" --------------------------------------------------------");
+ }
try {
this.transaction = session.beginTransaction();
@@ -46,7 +48,7 @@
throw e;
}
- if (log.isTraceEnabled()) log.trace("begun hibernate transaction "+System.identityHashCode(transaction)+" on hibernate session "+System.identityHashCode(session));
+ if (log.isTraceEnabled()) log.trace("begun hibernate tx "+System.identityHashCode(transaction)+" on hibernate session "+System.identityHashCode(session));
}
public void prepare() {
@@ -55,7 +57,9 @@
}
public void commit() {
- if (log.isTraceEnabled()) log.trace("committing hibernate transaction "+System.identityHashCode(transaction));
+ if (log.isDebugEnabled()) {
+ log.debug("----- committing hibernate tx "+System.identityHashCode(transaction)+" -------------------------------------------------------");
+ }
try {
transaction.commit();
} finally {
@@ -69,7 +73,9 @@
}
public void rollback() {
- if (log.isTraceEnabled()) log.trace("rolling back hibernate transaction "+System.identityHashCode(transaction));
+ if (log.isDebugEnabled()) {
+ log.debug("----- rolling back hibernate tx "+System.identityHashCode(transaction)+" -----------------------------------------------------");
+ }
try {
transaction.rollback();
} finally {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -31,7 +31,7 @@
import org.jbpm.api.activity.ActivityBehaviour;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -66,7 +66,7 @@
*
* <p>A WireContext is used often in combination with {@link EnvironmentImpl} to
* decouple the processDefinition virtual machine from its environment. In the
- * {@link JbpmConfiguration}, both the process-engine context and
+ * {@link ProcessEngineImpl}, both the process-engine context and
* the environment contexts are WireContexts. The PVM will use the persistence service,
* asynchronous message service, timer service and other services through specified
* abstractions in the environment.
@@ -244,7 +244,7 @@
* set to true, the {@link #createTime()} method needs to be called explicitly by the client after
* construction is complete. The use case is creation of environment where the transactionName needs to be
* set and the scope needs to be added to the environment before the creation of this wire scope is done.
- * @see JbpmConfiguration#openEnvironment()
+ * @see ProcessEngineImpl#openEnvironment()
*/
public WireContext(WireDefinition wireDefinition, String name, boolean delayCreate) {
this.wireDefinition = wireDefinition;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/EnvironmentInterceptorBinding.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.internal.wire.binding;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.wire.descriptor.EnvironmentInterceptorDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
@@ -38,7 +38,7 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- EnvironmentFactory environmentFactory = (EnvironmentFactory) parse.findObject(JbpmConfiguration.class);
+ EnvironmentFactory environmentFactory = (EnvironmentFactory) parse.findObject(ProcessEngineImpl.class);
return new EnvironmentInterceptorDescriptor(environmentFactory);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/IdGeneratorBinding.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.internal.wire.binding;
-import org.jbpm.pvm.internal.model.DefaultIdGenerator;
+import org.jbpm.pvm.internal.id.DatabaseIdComposer;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -38,7 +38,7 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new ObjectDescriptor(DefaultIdGenerator.class);
+ return new ObjectDescriptor(DatabaseIdComposer.class);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-09-16 12:52:34 UTC (rev 5649)
@@ -18,11 +18,13 @@
<hibernate-session-factory />
- <object class="org.jbpm.pvm.internal.id.DatabaseIdGenerator" init="eager">
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
<field name="commandService"><ref type="org.jbpm.pvm.internal.cmd.CommandService" /></field>
<invoke method="initialize" />
</object>
+ <object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
+
<script-manager default-expression-language="juel"
default-script-language="juel">
<script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-09-16 12:52:34 UTC (rev 5649)
@@ -23,7 +23,7 @@
table="JBPM4_EXECUTION"
discriminator-value="pvm">
<id name="dbid" column="DBID_">
- <generator class="native" />
+ <generator class="assigned" />
</id>
<discriminator><column name="CLASS_" /></discriminator>
<version name="dbversion" column="DBVERSION_" />
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.env;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -34,7 +34,7 @@
public class BasicEnvironmentTest extends BaseJbpmTestCase {
public void testBasicEnvironmentOperation() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object name='a' class='"+Object.class.getName()+"' />" +
@@ -77,7 +77,7 @@
}
public void testCurrentEnvironment(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine/>" +
" <environment/>" +
@@ -107,7 +107,7 @@
public void testUnexistingElement() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object name='a' class='"+Object.class.getName()+"' />" +
@@ -128,7 +128,7 @@
}
public void testNoBlockEnvironment(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine/>" +
"</jbpm-configuration>"
@@ -149,7 +149,7 @@
}
public void testNoApplicationEnvironment(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <environment/>" +
"</jbpm-configuration>"
@@ -171,7 +171,7 @@
}
public void testEmptyEnvironment(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment/>"
);
assertNotNull(environmentFactory);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.env;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -36,7 +36,7 @@
{
public void testEnvironmentDefaultSearchOrder() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='process-engine-a' />" +
@@ -58,7 +58,7 @@
}
public void testEnvironmentGivenSearchOrder() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='process-engine-a' />" +
@@ -82,7 +82,7 @@
}
public void testEnvironmentGivenSearchOrderUnexistingObject() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='process-engine-a' />" +
@@ -108,7 +108,7 @@
public void testEnvironmentDefaultSearchOrderWithAddedContext() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='process-engine-a' />" +
@@ -142,7 +142,7 @@
}
public void testEnvironmentGivenSearchOrderWithAddedContext() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='process-engine-a' />" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.env;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.test.BaseJbpmTestCase;
@@ -35,7 +35,7 @@
}
public void testApplicationTypeLookup() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object class='"+A.class.getName()+"' />" +
@@ -59,7 +59,7 @@
public void testBlockTypeLookup() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='distraction' />" +
@@ -83,7 +83,7 @@
public void testNonExistingTypeLookup() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <string name='a' value='A' />" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.env;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.test.BaseJbpmTestCase;
@@ -32,7 +32,7 @@
public class NestedEnvironmentTest extends BaseJbpmTestCase {
public void testNestedEnvironments() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object name='a' class='"+Object.class.getName()+"' />" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/GroovyExpressionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -23,7 +23,7 @@
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.client.ClientExecution;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -42,7 +42,7 @@
}
public void dontTestGroovyExpression() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <script-manager default-expression-language='juel'" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/expr/JuelExpressionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -23,7 +23,7 @@
import org.jbpm.pvm.activities.WaitState;
import org.jbpm.pvm.internal.builder.ProcessDefinitionBuilder;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.client.ClientExecution;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -39,7 +39,7 @@
public class JuelExpressionTest extends BaseJbpmTestCase {
public void testJuelExpression() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <script-manager default-expression-language='juel'" +
Copied: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java (from rev 5640, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -0,0 +1,67 @@
+/*
+ * 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.id;
+
+import junit.framework.TestCase;
+
+import org.hibernate.Session;
+import org.jbpm.api.Configuration;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.cmd.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.cmd.CommandService;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DbidGeneratorTest extends TestCase {
+
+ private static Log log = Log.getLog(DbidGeneratorTest.class.getName());
+
+ public void testIdGenerator() {
+ ProcessEngine processEngine = new Configuration().buildProcessEngine();
+
+ CommandService commandService = processEngine.get(CommandService.class);
+ commandService.execute(new Command<Void>() {
+ private static final long serialVersionUID = 1L;
+ public Void execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ assertEquals("10001", session.createQuery(
+ "select property.value " +
+ "from "+PropertyImpl.class.getName()+" as property " +
+ "where property.key = '"+PropertyImpl.NEXT_ID_KEY+"'").uniqueResult());
+ return null;
+ }
+ });
+
+ DbidGenerator dbidGenerator = processEngine.get(DbidGenerator.class);
+
+ for (int i=1; i<10020; i++) {
+ assertEquals(i, dbidGenerator.getNextId());
+ if ((i%1000) == 0) {
+ log.debug("just got dbid "+i+"...");
+ }
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/DbidGeneratorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/id/IdGeneratorTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,61 +0,0 @@
-/*
- * 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.id;
-
-import junit.framework.TestCase;
-
-import org.hibernate.Session;
-import org.jbpm.api.Configuration;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.Environment;
-import org.jbpm.pvm.internal.cmd.CommandService;
-
-
-/**
- * @author Tom Baeyens
- */
-public class IdGeneratorTest extends TestCase {
-
- public void testIdGenerator() {
- ProcessEngine processEngine = new Configuration().buildProcessEngine();
-
- CommandService commandService = processEngine.get(CommandService.class);
- commandService.execute(new Command<Void>() {
- private static final long serialVersionUID = 1L;
- public Void execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- assertEquals(2, session.createQuery("select property from "+PropertyImpl.class.getName()+" as property").list().size());
- return null;
- }
- });
-
- IdGenerator idGenerator = processEngine.get(IdGenerator.class);
-
- for (int i=1; i<10020; i++) {
- assertEquals(i, idGenerator.getNextId());
- if ((i%100) == 0) {
- System.err.println(i);
- }
- }
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextBlockSubscriptionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -76,7 +76,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is no eager initialization
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -126,7 +126,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -160,7 +160,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -201,7 +201,7 @@
// <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -237,7 +237,7 @@
// <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -284,7 +284,7 @@
// <subscribe event='...' /> will use the scope as the observable and only notify on the specified event
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -320,7 +320,7 @@
}
public void testOtherWireScope() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object name='factory' class='"+Object.class.getName()+"' />" +
@@ -363,14 +363,14 @@
index++;
assertEquals("close", events.get(index).eventName);
- JbpmConfiguration jbpmConfiguration = (JbpmConfiguration) environmentFactory;
- WireContext applicationWireContext = jbpmConfiguration.getProcessEngineWireContext();
+ ProcessEngineImpl processEngineImpl = (ProcessEngineImpl) environmentFactory;
+ WireContext applicationWireContext = processEngineImpl.getProcessEngineWireContext();
assertEquals(applicationWireContext, events.get(index).source);
assertNull(events.get(index).info);
}
public void testOtherWireScopeWithEventFiltering() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <object name='factory' class='"+Object.class.getName()+"' />" +
@@ -408,7 +408,7 @@
}
public void testUnexistingScope() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -437,7 +437,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is no eager initialization
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -491,7 +491,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is no eager initialization
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ContextTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -16,7 +16,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -149,7 +149,7 @@
}
public void testHasOnEmptyEnv(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes/>"
);
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/EnvWireTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,6 +1,6 @@
package org.jbpm.pvm.internal.wire;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.wire.WireContext;
@@ -12,7 +12,7 @@
public class EnvWireTest extends WireTestCase {
public void testEnvironmentWire(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context /> " +
" <transaction-context>" +
@@ -36,7 +36,7 @@
}
public void testEnvironmentFactoryWire(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -59,7 +59,7 @@
}
public void testContextRefEnvironmentWire(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -83,7 +83,7 @@
}
public void testContextRefEnvironmentFactoryWire(){
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context>" +
" <context-ref name='c' />" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MethodSubscriptionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,6 +1,6 @@
package org.jbpm.pvm.internal.wire;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.util.DefaultObservable;
@@ -44,7 +44,7 @@
* The recorder is eagerly initialized.
*/
public void testMethodWithNoArg() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -86,7 +86,7 @@
* The recorder is eagerly initialized.
*/
public void testMethodWithBadName() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -123,7 +123,7 @@
* The recorder is eagerly initialized.
*/
public void testMethodWithOneArg() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -170,7 +170,7 @@
* The recorder is eagerly initialized.
*/
public void testMethodWithTwoArgs() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context /> "+
" <transaction-context>" +
@@ -230,7 +230,7 @@
* The recorder is eagerly initialized.
*/
public void testMethodWithThreeArgs() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<jbpm-configuration>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -282,7 +282,7 @@
* Test subscription using a specified method and two objects.
*/
public void testMethodWithArgsAndMultipleObjectsSubcription() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -373,7 +373,7 @@
}
public void testMethodAndOverLoading() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -428,7 +428,7 @@
}
public void testMethodAndBadArg() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/ObjectSubscriptionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.internal.wire;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.util.DefaultObservable;
@@ -38,7 +38,7 @@
// <subscribe object='...' /> will use the object as the observable
// In this test, there is no eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -80,7 +80,7 @@
// <subscribe object='...' /> will use the object as the observable
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -126,7 +126,7 @@
// <subscribe objects='...' /> will use the object as the observable
// In this test, there is eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -193,7 +193,7 @@
}
public void testUnexistingObject() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -216,7 +216,7 @@
// <subscribe object='...' /> will use the object as the observable
// In this test, there is eager initialization
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -266,7 +266,7 @@
}
public void testNotObservableObject() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -288,7 +288,7 @@
}
public void testNotListener() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireEventsSubscriptionTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -21,7 +21,7 @@
*/
package org.jbpm.pvm.internal.wire;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.util.DefaultObservable;
@@ -40,7 +40,7 @@
// class Descriptor
public void testRegisterToAllDescriptors() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -82,7 +82,7 @@
}
public void testOneObjectDescriptor() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -139,7 +139,7 @@
}
public void testMultipleObjectDescriptors() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -215,7 +215,7 @@
}
public void testOneObjectDescriptorWithEventFilter() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
@@ -256,7 +256,7 @@
}
public void testMultipleObjectDescriptorsWithEventFilter() {
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/WireObservableTest.java 2009-09-16 12:52:34 UTC (rev 5649)
@@ -23,7 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
+import org.jbpm.pvm.internal.cfg.ProcessEngineImpl;
import org.jbpm.pvm.internal.env.Context;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.EnvironmentFactory;
@@ -46,7 +46,7 @@
// <subscribe /> will use the scope as the observable
// In this test, there is no eager initialisation
- EnvironmentFactory environmentFactory = JbpmConfiguration.parseXmlString(
+ EnvironmentFactory environmentFactory = ProcessEngineImpl.parseXmlString(
"<environment-scopes>" +
" <process-engine-context />" +
" <transaction-context>" +
Modified: jbpm4/trunk/modules/test-db/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2009-09-16 11:34:14 UTC (rev 5648)
+++ jbpm4/trunk/modules/test-db/src/test/resources/logging.properties 2009-09-16 12:52:34 UTC (rev 5649)
@@ -1,7 +1,7 @@
handlers= java.util.logging.ConsoleHandler
redirect.commons.logging = enabled
-java.util.logging.ConsoleHandler.level = FINE
+java.util.logging.ConsoleHandler.level = FINEST
java.util.logging.ConsoleHandler.formatter = org.jbpm.internal.log.LogFormatter
org.jbpm.level=FINE
@@ -12,7 +12,7 @@
org.hibernate.level=INFO
org.hibernate.cfg.SettingsFactory.level=SEVERE
org.hibernate.cfg.HbmBinder.level=SEVERE
-# org.hibernate.SQL.level=FINEST
-# org.hibernate.type.level=FINEST
+org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST
# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
# org.hibernate.transaction.level=FINEST
\ No newline at end of file
14 years, 7 months
JBoss JBPM SVN: r5648 - jbpm4/trunk.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-09-16 07:34:14 -0400 (Wed, 16 Sep 2009)
New Revision: 5648
Modified:
jbpm4/trunk/pom.xml
Log:
Update to console 1.2.0-SNAPSHOT
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2009-09-16 11:24:16 UTC (rev 5647)
+++ jbpm4/trunk/pom.xml 2009-09-16 11:34:14 UTC (rev 5648)
@@ -49,7 +49,7 @@
<cactus.version>1.8.1</cactus.version>
<aspectjrt.version>1.5.3</aspectjrt.version>
<freemarker.version>2.3.15</freemarker.version>
- <gwt.console.version>1.1.2</gwt.console.version>
+ <gwt.console.version>1.2.0-SNAPSHOT</gwt.console.version>
<jbpm.gpd.version>4.1</jbpm.gpd.version>
<hibernate.version>3.3.1.GA</hibernate.version>
<slf4j.version>1.5.2</slf4j.version>
14 years, 7 months
JBoss JBPM SVN: r5647 - jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-16 07:24:16 -0400 (Wed, 16 Sep 2009)
New Revision: 5647
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java
Log:
Added testcase for JBPM-2537
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/timer/TaskTimerTaskTest.java 2009-09-16 11:24:16 UTC (rev 5647)
@@ -0,0 +1,90 @@
+/*
+ * 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.test.timer;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Joram Barrez
+ */
+public class TaskTimerTaskTest extends JbpmTestCase {
+
+ // Test case for JBPM-2537
+ public void testTaskClosedWhenTimerFires() {
+ deployJpdlXmlString(
+ "<process name='test1' xmlns='http://jbpm.org/4.0/jpdl'>" +
+ " <start g='-9,192,48,48' name='start1'>" +
+ " <transition g='-44,-18' name='to task3' to='task3' />" +
+ " </start>" +
+ " <task g='272,189,92,52' name='task1'>" +
+ " <transition g='-42,-18' name='to end1' to='end1' />" +
+ " <transition g='-45,-18' name='to wait' to='waitHere'>" +
+ " <timer duedate='10 seconds' />" +
+ " </transition>" +
+ " </task>" +
+ " <task g='454,316,92,52' name='task2'>" +
+ " <transition g='-42,-18' name='to end2' to='end2' />" +
+ " </task>" +
+ " <task g='113,189,92,52' name='task3'>" +
+ " <transition g='-44,-18' to='task1' name='to end1' />" +
+ " </task>" +
+ " <state name='waitHere'>" +
+ " <transition to='end1' />" +
+ " </state>" +
+ " <end g='490,192,48,48' name='end1' />" +
+ " <end g='626,319,48,48' name='end2' />" +
+ "</process>");
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("test1");
+
+ Task currentTask = taskService.createTaskQuery().uniqueResult();
+ assertEquals("task3", currentTask.getName());
+ taskService.completeTask(currentTask.getId());
+
+ currentTask = taskService.createTaskQuery().uniqueResult();
+ assertEquals("task1", currentTask.getName());
+
+ Job timeout = managementService.createJobQuery().timers().uniqueResult();
+ managementService.executeJob(timeout.getId());
+
+ assertActivityActive(processInstance.getId(), "waitHere");
+
+ // Task1 should be completed now
+ List<Task> currentTasks = taskService.createTaskQuery().list();
+
+ // TODO: Uncomment when fixing issue!
+ // assertTrue("Error: there are still tasks active: "
+ // + listAllOpenTasks(processInstance.getId()), currentTasks.isEmpty());
+
+ }
+
+
+}
14 years, 7 months
JBoss JBPM SVN: r5646 - in projects/demos/trainticket-demo/user_registration/trunk: src/main/org/jbpm/trainticketdemo/userregistration/entity and 2 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-15 16:50:39 -0400 (Tue, 15 Sep 2009)
New Revision: 5646
Added:
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsActionImpl.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterActionImpl.java
projects/demos/trainticket-demo/user_registration/trunk/view/img/header.jpg
Removed:
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCredits.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/Register.java
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java
Modified:
projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AuthenticatorBean.java
projects/demos/trainticket-demo/user_registration/trunk/src/main/org/jbpm/trainticketdemo/userregistration/entity/User.java
projects/demos/trainticket-demo/user_registration/trunk/view/login.xhtml
projects/demos/trainticket-demo/user_registration/trunk/view/user_details.xhtml
Log:
Small enhancements to demo
Deleted: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCredits.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCredits.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCredits.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -1,40 +0,0 @@
-/*
- * 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.trainticketdemo.userregistration.sessionbeans;
-
-import javax.ejb.Local;
-
-/**
- * @author Joram Barrez
- */
-@Local
-public interface AddCredits {
-
- public void addCredits();
-
- public String getCreditsToAdd();
-
- public void setCreditsToAdd(String creditsToAdd);
-
- public void reloadDetails();
-
-}
Deleted: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -1,78 +0,0 @@
-/*
- * 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.trainticketdemo.userregistration.sessionbeans;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.log.Log;
-import org.jbpm.trainticketdemo.userregistration.entity.User;
-
-/**
- * @author Joram Barrez
- */
-@Stateless
-@Name("addCreditsAction")
-public class AddCreditsAction implements AddCredits {
-
- @In
- @Out
- private User user;
-
- @PersistenceContext
- private EntityManager em;
-
- @Logger
- private Log log;
-
- private String creditsToAdd = "";
-
- public void addCredits() {
- try {
- Double credits = Double.parseDouble(creditsToAdd);
- user.setCurrentCredit(user.getCurrentCredit() + credits);
- em.merge(user);
- FacesMessages.instance().add(credits + " added to balance");
- } catch (NumberFormatException e) {
- FacesMessages.instance().add("Invalid amount of credits.");
- }
- }
-
- public void reloadDetails() {
- this.user = em.find(User.class, user.getId());
- }
-
- public String getCreditsToAdd() {
- return creditsToAdd;
- }
-
- public void setCreditsToAdd(String creditsToAdd) {
- this.creditsToAdd = creditsToAdd;
- }
-
-}
Copied: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java (from rev 5554, projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCredits.java)
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java (rev 0)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -0,0 +1,40 @@
+/*
+ * 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.trainticketdemo.userregistration.sessionbeans;
+
+import javax.ejb.Local;
+
+/**
+ * @author Joram Barrez
+ */
+@Local
+public interface AddCreditsAction {
+
+ public void addCredits();
+
+ public String getCreditsToAdd();
+
+ public void setCreditsToAdd(String creditsToAdd);
+
+ public void reloadDetails();
+
+}
Copied: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsActionImpl.java (from rev 5554, projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsAction.java)
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsActionImpl.java (rev 0)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AddCreditsActionImpl.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -0,0 +1,88 @@
+/*
+ * 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.trainticketdemo.userregistration.sessionbeans;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.intercept.PostConstruct;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+import org.jbpm.trainticketdemo.userregistration.entity.User;
+
+/**
+ * @author Joram Barrez
+ */
+@Stateless
+@Name("addCreditsAction")
+public class AddCreditsActionImpl implements AddCreditsAction {
+
+ @In
+ @Out
+ private User user;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Logger
+ private Log log;
+
+ private String creditsToAdd = "";
+
+ public void addCredits() {
+ try {
+ Double credits = Double.parseDouble(creditsToAdd);
+ user.setCurrentCredit(user.getCurrentCredit() + credits);
+ em.merge(user);
+ FacesMessages.instance().add(credits + " added to balance");
+ } catch (NumberFormatException e) {
+ FacesMessages.instance().add("Invalid amount of credits.");
+ }
+ }
+
+ public void reloadDetails() {
+ this.user = em.find(User.class, user.getId());
+ }
+
+ public String getCreditsToAdd() {
+ return creditsToAdd;
+ }
+
+ public void setCreditsToAdd(String creditsToAdd) {
+ this.creditsToAdd = creditsToAdd;
+ }
+
+ public User getUser() {
+ reloadDetails();
+ return user;
+ }
+
+ public void setUser(User user) {
+ this.user = user;
+ }
+
+}
Modified: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AuthenticatorBean.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AuthenticatorBean.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/AuthenticatorBean.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -34,6 +34,8 @@
@Out(required = false)
private User user;
+ private Long userId;
+
@SuppressWarnings("unchecked")
public boolean authenticate() {
@@ -42,7 +44,7 @@
log.info("authenticating {0}", credentials.getUsername());
List<User> users = new ArrayList<User>();
- if (credentials.getUsername().equalsIgnoreCase("emulator")) {
+ if (credentials.getUsername().equalsIgnoreCase("123456789")) { // emulator
users = em.createQuery("select user from User user where user.name='jBPMPhone' ").getResultList();
} else {
users = em.createQuery(
Deleted: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/Register.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/Register.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/Register.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -1,34 +0,0 @@
-/*
- * 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.trainticketdemo.userregistration.sessionbeans;
-
-import javax.ejb.Local;
-
-/**
- * @author Joram Barrez
- */
-@Local
-public interface Register {
-
- String register();
-
-}
Deleted: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -1,71 +0,0 @@
-/*
- * 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.trainticketdemo.userregistration.sessionbeans;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.log.Log;
-import org.jbpm.trainticketdemo.userregistration.entity.User;
-
-/**
- * @author Joram Barrez
- */
-@Stateless
-@Name("registerAction")
-public class RegisterAction implements Register {
-
- @In
- private User user;
-
- @PersistenceContext
- private EntityManager em;
-
- @Logger
- private Log log;
-
- public String register() {
-
- List existingCellPhone = em.createQuery(
- "select name from User where cellPhoneNr = #{user.cellPhoneNr}")
- .getResultList();
-
- if (existingCellPhone.size() == 0) {
- user.setCurrentCredit(0.0);
- em.persist(user);
- log.info("Registered new cellphone nr #{user.cellPhoneNr} for #{user.name}");
- return "/registered.xhtml";
- } else {
- FacesMessages.instance().add("Cellphone number #{user.cellPhoneNr} already registered");
- return null;
- }
-
- }
-
-}
Copied: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java (from rev 5554, projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/Register.java)
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java (rev 0)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -0,0 +1,34 @@
+/*
+ * 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.trainticketdemo.userregistration.sessionbeans;
+
+import javax.ejb.Local;
+
+/**
+ * @author Joram Barrez
+ */
+@Local
+public interface RegisterAction {
+
+ String register();
+
+}
Copied: projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterActionImpl.java (from rev 5554, projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterAction.java)
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterActionImpl.java (rev 0)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/hot/org/jbpm/trainticketdemo/userregistration/sessionbeans/RegisterActionImpl.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -0,0 +1,80 @@
+/*
+ * 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.trainticketdemo.userregistration.sessionbeans;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Logger;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.faces.FacesMessages;
+import org.jboss.seam.log.Log;
+import org.jbpm.trainticketdemo.userregistration.entity.User;
+
+/**
+ * @author Joram Barrez
+ */
+@Stateless
+@Name("registerAction")
+public class RegisterActionImpl implements RegisterAction {
+
+ @In
+ @Out
+ private User user;
+
+ @PersistenceContext
+ private EntityManager em;
+
+ @Logger
+ private Log log;
+
+ public String register() {
+
+ List<User> existingCellPhone = em.createQuery(
+ "select u from User u where u.cellPhoneNr = #{user.cellPhoneNr}")
+ .getResultList();
+
+ // If using the demo cellphone nr, we fake registration and use the already stored user.
+ if (user.getCellPhoneNr().equals("123456789")) {
+ user = (User) em.createQuery("select user from User user where user.name='jBPMPhone' ").getResultList().get(0);
+ return "/registered.xhtml";
+ }
+
+ if (existingCellPhone.size() == 0) {
+ user.setCurrentCredit(0.0);
+ em.persist(user);
+ log.info("Registered new cellphone nr #{user.cellPhoneNr} for #{user.name}");
+ return "/registered.xhtml";
+ } else {
+
+ FacesMessages.instance().add("Cellphone number #{user.cellPhoneNr} already registered");
+ return null;
+ }
+
+ }
+
+}
Modified: projects/demos/trainticket-demo/user_registration/trunk/src/main/org/jbpm/trainticketdemo/userregistration/entity/User.java
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/src/main/org/jbpm/trainticketdemo/userregistration/entity/User.java 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/src/main/org/jbpm/trainticketdemo/userregistration/entity/User.java 2009-09-15 20:50:39 UTC (rev 5646)
@@ -35,6 +35,8 @@
import org.jboss.seam.annotations.Scope;
/**
+ * Basic entity for storing user information: a cellphone nr, password and credit.
+ *
* @author Joram Barrez
*/
@Entity
Added: projects/demos/trainticket-demo/user_registration/trunk/view/img/header.jpg
===================================================================
(Binary files differ)
Property changes on: projects/demos/trainticket-demo/user_registration/trunk/view/img/header.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: projects/demos/trainticket-demo/user_registration/trunk/view/login.xhtml
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/view/login.xhtml 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/view/login.xhtml 2009-09-15 20:50:39 UTC (rev 5646)
@@ -15,6 +15,8 @@
<rich:panel>
<f:facet name="header">Login</f:facet>
+ <h:graphicImage value="/img/header.jpg" alt="jBPM Demo Header" style="float:right"/>
+
<p>Please login here</p>
<div class="dialog">
Modified: projects/demos/trainticket-demo/user_registration/trunk/view/user_details.xhtml
===================================================================
--- projects/demos/trainticket-demo/user_registration/trunk/view/user_details.xhtml 2009-09-15 20:49:13 UTC (rev 5645)
+++ projects/demos/trainticket-demo/user_registration/trunk/view/user_details.xhtml 2009-09-15 20:50:39 UTC (rev 5646)
@@ -13,15 +13,11 @@
template="layout/template.xhtml">
<ui:define name="body">
-
- <a4j:region>
- <h:form>
- <a4j:poll id="poll" interval="3000" reRender="poll,currentBalance" actionListener="#{addCreditsAction.reloadDetails}" />
- </h:form>
- </a4j:region>
<rich:panel id="userDetails">
<f:facet name="header">User details</f:facet>
+
+ <h:graphicImage value="/img/header.jpg" alt="jBPM Demo Header" style="float:right"/>
<f:view>
<h:form>
@@ -32,12 +28,16 @@
<b>Current balance: <h:outputText id="currentBalance" value="#{user.currentCredit}" /></b>
</h:panelGrid>
<br/>
- <h:panelGrid columns="2">
- Add credits to balance: <h:inputText value="#{addCreditsAction.creditsToAdd}" />
+ <h:panelGrid columns="3">
+ <h:outputText value="Add credits to balance:" />
+ <h:inputText value="#{addCreditsAction.creditsToAdd}" />
+ <h:commandButton value="OK" action="#{addCreditsAction.addCredits}" />
</h:panelGrid>
</s:validateAll>
<h:messages />
- <h:commandButton value="OK" action="#{addCreditsAction.addCredits}" />
+ <br/>
+ <br/>
+ <h:commandButton value="Refresh" action="#{addCreditsAction.reloadDetails}" />
</h:form>
</f:view>
</rich:panel>
14 years, 7 months
JBoss JBPM SVN: r5645 - in projects/demos/trainticket-demo/jbpm-phone/trunk: src/main/java and 6 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-15 16:49:13 -0400 (Tue, 15 Sep 2009)
New Revision: 5645
Removed:
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/message/
Modified:
projects/demos/trainticket-demo/jbpm-phone/trunk/pom.xml
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/LoadTest.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/Demo.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/InboxPanel.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/PhonePanel.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/SendSmsPanel.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/fancy/AePlayWave.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/http/HttpListener.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/model/Inbox.java
projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/service/SmsService.java
Log:
Small enhancements to demo
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/pom.xml
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/pom.xml 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/pom.xml 2009-09-15 20:49:13 UTC (rev 5645)
@@ -5,6 +5,16 @@
<artifactId>jBPM-Phone</artifactId>
<version>1.0</version>
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.org/maven2</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
<dependencies>
<dependency>
<groupId>net.java.dev.timingframework</groupId>
@@ -16,6 +26,12 @@
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>3.1.2.GA</version>
+ </dependency>
+
</dependencies>
<build>
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/LoadTest.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/LoadTest.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/LoadTest.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -1,7 +1,4 @@
-import java.io.DataOutputStream;
import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -12,6 +9,8 @@
import org.apache.commons.httpclient.methods.PostMethod;
import org.jbpm.trainticketdemo.http.HttpListener;
import org.jbpm.trainticketdemo.model.Inbox;
+import org.jbpm.trainticketdemo.model.SmsMessage;
+import org.jbpm.trainticketdemo.service.SmsService;
/*
* JBoss, Home of Professional Open Source
@@ -36,12 +35,17 @@
*/
/**
+ *
* @author Joram Barrez
*/
public class LoadTest {
-private static final String POST_URL = "http://localhost:8080/jbpm-on-rails/receive_sms";
+ private static Inbox inbox;
+ private static CustomerAcceptanceThread customerThread;
+
+ private static final String POST_URL = "http://localhost:8080/jbpm-on-rails/receive_sms";
+
private static final String PARAM_SEND_DATE = "sendDate";
private static final String PARAM_MSG_CONTENT = "msgContent";
@@ -53,26 +57,29 @@
public static void main(String[] args) throws Exception {
//Need http server for sms response
- Inbox inbox = new Inbox();
- HttpListener listener = new HttpListener(inbox);
- listener.start();
+ inbox = new Inbox();
+ new HttpListener(inbox);
+
+ customerThread = new CustomerAcceptanceThread();
+ customerThread.start();
+ int nrOfTicketRequests = 50;
+
+ final ExecutorService threadPool = Executors.newFixedThreadPool(25);
+
+
long start = System.currentTimeMillis();
- int max = 50;
-
- ExecutorService threadPool = Executors.newFixedThreadPool(5);
- //ArrayBlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>(max);
- //ThreadPoolExecutor threadPool = new ThreadPoolExecutor(10,25,10, TimeUnit.SECONDS, queue);
- for (int i=0; i < max; i++) {
+ for (int i=0; i < nrOfTicketRequests; i++) {
threadPool.execute(new Runnable() {
public void run() {
PostMethod post = new PostMethod(POST_URL);
post.addParameter(PARAM_SEND_DATE, new Date().toString());
post.addParameter(PARAM_MSG_CONTENT, "TICKET brussel antwerpen");
post.addParameter(PARAM_SENDER_NR, VALUE_SENDER_NR);
- HttpClient httpClient = new HttpClient();
+ final HttpClient httpClient = new HttpClient();
try {
httpClient.executeMethod(post);
+ post.releaseConnection();
} catch (HttpException e) {
e.printStackTrace();
} catch (IOException e) {
@@ -80,16 +87,90 @@
}
}
});
+
+ // After a while the OS can't close the sockets fast enough
+ // So we wait a bit for the OS to follow us
+ if (i % 50 == 0 ) {
+ Thread.sleep(5000);
+ }
+
}
// waits until all threads are executed
threadPool.shutdown();
- threadPool.awaitTermination(5, TimeUnit.HOURS);
+ threadPool.awaitTermination(1, TimeUnit.HOURS);
- long end = System.currentTimeMillis();
- System.out.println("TIME until all threads finished = " + (end-start));
+ System.out.println("TIME (ms) until all ticket requests have finished finished = " + (System.currentTimeMillis()-start));
+
- //listener.stop();
+ while (inbox.getNrOfMessages() > customerThread.getNrOfProcessedMessages() + 1) {
+ System.out.println("All msgs not yet processed. Sleeping for 2.5s");
+ Thread.sleep(2500);
+ }
+ System.out.println("TIME (ms) until all acceptance msgs have been processed = " + (System.currentTimeMillis()-start));
+
+ Thread.sleep(5000); // Let everything cool down
+ System.exit(0);
}
+ private static class CustomerAcceptanceThread extends Thread {
+
+ private int index = 0;
+
+ public int getNrOfProcessedMessages() {
+ return index;
+ }
+
+ public void run() {
+
+ // Wait until a few tasks are finished
+ try {
+ System.out.println("Customer acceptance thread sleeping for 5000ms ");
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ final ExecutorService acceptThreadPool = Executors.newFixedThreadPool(10);
+
+ while(true) {
+
+ while (inbox.getNrOfMessages() > index + 1) {
+
+ final String msg = getAcceptanceMessage();
+
+ if (msg != null) {
+
+ acceptThreadPool.execute(new Runnable() {
+
+ public void run() {
+ try {
+ SmsService.sendSms(msg);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ }
+
+ }
+ }
+ }
+
+ private String getAcceptanceMessage() {
+ SmsMessage msg = inbox.get(index++);
+ String content = msg.getContent();
+
+ // ACCEPT msg
+ int acceptIndexStart = content.indexOf("'");
+ if (acceptIndexStart > 0) {
+ int acceptIndexEnd = content.indexOf("'", acceptIndexStart + 1);
+ return content.substring(acceptIndexStart + 1, acceptIndexEnd);
+ }
+ return null;
+ }
+
+ }
+
}
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/Demo.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/Demo.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/Demo.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -41,9 +41,8 @@
// Set up SMS inbox for cellphone
final Inbox inbox = new Inbox();
- // Set up Http Listener
+ // Set up Http Listener which will update inbox with incoming msgs
final HttpListener httpListener = new HttpListener(inbox);
- httpListener.start();
// Set up GUI
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/InboxPanel.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/InboxPanel.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/InboxPanel.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -43,6 +43,8 @@
import org.jbpm.trainticketdemo.model.SmsMessage;
/**
+ * Screen showing the inbox of the cellphone
+ *
* @author Joram Barrez
*/
public class InboxPanel extends JPanel {
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/PhonePanel.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/PhonePanel.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/PhonePanel.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -41,6 +41,9 @@
import org.jbpm.trainticketdemo.model.Inbox;
/**
+ * General panel when the phone is started.
+ * Has buttons to to go to other screens.
+ *
* @author Joram Barrez
*/
public class PhonePanel extends JPanel implements MouseMotionListener, MouseListener, ChangeListener {
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/SendSmsPanel.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/SendSmsPanel.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/SendSmsPanel.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -41,6 +41,8 @@
import org.jbpm.trainticketdemo.service.SmsService;
/**
+ * Screen used when sending a SMS.
+ *
* @author Joram Barrez
*/
public class SendSmsPanel extends JPanel {
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/fancy/AePlayWave.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/fancy/AePlayWave.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/gui/fancy/AePlayWave.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -12,7 +12,7 @@
import javax.sound.sampled.UnsupportedAudioFileException;
/**
- * Borrowed from http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml
+ * Inspired by http://www.anyexample.com/programming/java/java_play_wav_sound_file.xml
* @jbarrez (small adaptations)
*/
public class AePlayWave {
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/http/HttpListener.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/http/HttpListener.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/http/HttpListener.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -21,98 +21,118 @@
*/
package org.jbpm.trainticketdemo.http;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.InetSocketAddress;
import java.net.URLDecoder;
import java.util.concurrent.Executors;
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineCoverage;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelUpstreamHandler;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jbpm.trainticketdemo.model.Inbox;
import org.jbpm.trainticketdemo.model.SmsMessage;
-import com.sun.net.httpserver.HttpExchange;
-import com.sun.net.httpserver.HttpHandler;
-import com.sun.net.httpserver.HttpServer;
-
/**
+ * Listens to incoming HTTP messages and forwards SMS messages to cellphone
+ * inbox when receiving a SMS through HTTP.
+ *
* @author Joram Barrez
*/
public class HttpListener {
-
+
+ private Inbox inbox;
+
public static final int HTTP_PORT = 4321;
-
+
public static final String URL = "/cellphone_sms_listener";
-
- private HttpServer server;
-
- private Inbox inbox;
-
+
public HttpListener(Inbox inbox) throws Exception {
this.inbox = inbox;
- InetSocketAddress address = new InetSocketAddress(HTTP_PORT);
- server = HttpServer.create(address, 0);
- server.createContext(URL, new SmsHandler());
- server.setExecutor(Executors.newCachedThreadPool());
+
+ ServerBootstrap bootstrap = new ServerBootstrap(
+ new NioServerSocketChannelFactory(Executors
+ .newCachedThreadPool(), Executors.newCachedThreadPool()));
+ bootstrap.setPipelineFactory(new HttpServerPipelineFactory());
+ bootstrap.bind(new InetSocketAddress(HTTP_PORT));
}
-
- public void start() {
- server.start();
+
+ private class HttpServerPipelineFactory implements ChannelPipelineFactory {
+
+ public ChannelPipeline getPipeline() throws Exception {
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("decoder", new HttpRequestDecoder());
+ pipeline.addLast("encoder", new HttpResponseEncoder());
+ pipeline.addLast("handler", new HttpRequestHandler());
+ return pipeline;
+ }
+
}
-
- public void stop() {
- server.stop(0);
- }
-
- private class SmsHandler implements HttpHandler {
- public void handle(HttpExchange httpExchange) throws IOException {
- if (httpExchange.getRequestMethod().equalsIgnoreCase("POST")) {
+ @ChannelPipelineCoverage("one")
+ private class HttpRequestHandler extends SimpleChannelUpstreamHandler {
+
+ @Override
+ public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
+ throws Exception {
+ final HttpRequest request = (HttpRequest) e.getMessage();
+
+ if (request.getUri().equalsIgnoreCase(URL)) {
+
+ // Get HTTP content
+ //ChannelBuffer contentBuffer = request.getContent();
+ String content = request.getContent().toString("UTF-8");
- // Read the raw content of the message
- StringBuilder strb = new StringBuilder();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(httpExchange.getRequestBody()));
- String line = br.readLine();
- while (line != null) {
- strb.append(line);
- line = br.readLine();
- }
- } finally {
- if (br != null) {
- br.close();
- }
- }
- httpExchange.sendResponseHeaders(200, 0);
- httpExchange.close();
-
- // add the parsed message to the cellphone inbox
- SmsMessage smsMessage = parseRawMessage(strb.toString());
- inbox.addMessage(smsMessage);
+ // Send HTTP response
+ HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
+ ChannelFuture channelFuture = e.getChannel().write(response);
+ channelFuture.addListener(ChannelFutureListener.CLOSE);
+
+ // Decode SMS message and add to cellphone inbox
+ SmsMessage msg = parseRawMessage(content);
+ inbox.addMessage(msg);
+
+ } else {
+ System.err.println("Discarded msg for URI " + request.getUri());
}
+
}
-
- private SmsMessage parseRawMessage(String message) {
-
+
+ private SmsMessage parseRawMessage(String message) {
+
SmsMessage result = new SmsMessage();
-
+
String decoded = "";
try {
decoded = URLDecoder.decode(message, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
+
+ // parse string of form 'date=Tue+18+2009¶m2=1+a'
+ String[] splitOnParamChar = decoded.split("&");
- // parse string of form 'date=Tue+18+2009¶m2=1+a'
- String[] splitOnParamChar = decoded.split("&");
for (String s : splitOnParamChar) {
-
+
String[] splitOnKeyValue = s.split("=");
String key = splitOnKeyValue[0];
String value = splitOnKeyValue[1];
-
+
if (key.equalsIgnoreCase("sendDate")) {
result.setDate(value);
} else if (key.equalsIgnoreCase("msgContent")) {
@@ -120,12 +140,12 @@
} else if (key.equalsIgnoreCase("senderNr")) {
result.setSender(value);
}
-
+
}
-
+
return result;
}
-
+
}
}
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/model/Inbox.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/model/Inbox.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/model/Inbox.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -30,6 +30,9 @@
import javax.swing.event.EventListenerList;
/**
+ * Class representing the inbox of a cellphone.
+ * In reality, nothing more than an arraylist of SmsMessages.
+ *
* @author Joram Barrez
*/
public class Inbox {
@@ -41,8 +44,17 @@
public Inbox() {
this.messages = new ArrayList<SmsMessage>();
}
+
+ public synchronized int getNrOfMessages() {
+ return messages.size();
+ }
+
+ // Doesn't need to be syncrhonized, since we're only adding
+ public SmsMessage get(int index) {
+ return messages.get(index);
+ }
- public void addMessage(SmsMessage smsMessage) {
+ public synchronized void addMessage(SmsMessage smsMessage) {
messages.add(smsMessage);
fireStateChanged();
}
Modified: projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/service/SmsService.java
===================================================================
--- projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/service/SmsService.java 2009-09-15 20:48:19 UTC (rev 5644)
+++ projects/demos/trainticket-demo/jbpm-phone/trunk/src/main/java/org/jbpm/trainticketdemo/service/SmsService.java 2009-09-15 20:49:13 UTC (rev 5645)
@@ -28,6 +28,8 @@
import org.jbpm.trainticketdemo.http.HttpListener;
/**
+ * Service (or Util) to send an SMS to the server on localhost.
+ *
* @author Joram Barrez
*/
public class SmsService {
14 years, 7 months
JBoss JBPM SVN: r5644 - in projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk: src/hot/org/jbpm/trainticketdemo/bam/util and 2 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-09-15 16:48:19 -0400 (Tue, 15 Sep 2009)
New Revision: 5644
Modified:
projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/session/GraphProducerBean.java
projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/util/JdbcTemplate.java
projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/Metric.java
projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/TicketSale.java
projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/view/home.xhtml
Log:
Small enhancements to demo
Modified: projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/session/GraphProducerBean.java
===================================================================
--- projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/session/GraphProducerBean.java 2009-09-15 20:47:18 UTC (rev 5643)
+++ projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/session/GraphProducerBean.java 2009-09-15 20:48:19 UTC (rev 5644)
@@ -38,6 +38,10 @@
import org.jbpm.trainticketdemo.bam.util.JdbcTemplate;
/**
+ *
+ * Implementation that will produce the graphs (or charts, whatever you call them),
+ * using good old plain JDBC.
+ *
* @author Joram Barrez
*/
@Stateless
@@ -173,7 +177,7 @@
"WHEN DURATION_ > 10000 AND DURATION_ <= 20000 THEN '10s>time>=20s' " +
"WHEN DURATION_ > 20000 AND DURATION_ <= 30000 THEN '20s>time>=30s' " +
"ELSE '>30s' END) as reactionTime FROM JBPM4_HIST_ACTINST " +
- "WHERE ACTIVITY_NAME_ = 'Accept quote') " +
+ "WHERE ACTIVITY_NAME_ = 'Accept quote' AND DURATION_ > 0) " +
"GROUP BY reactionTime");
ResultSet rs = stm.executeQuery();
while (rs.next()) {
Modified: projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/util/JdbcTemplate.java
===================================================================
--- projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/util/JdbcTemplate.java 2009-09-15 20:47:18 UTC (rev 5643)
+++ projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/hot/org/jbpm/trainticketdemo/bam/util/JdbcTemplate.java 2009-09-15 20:48:19 UTC (rev 5644)
@@ -25,6 +25,8 @@
import java.sql.SQLException;
/**
+ * Inspired by the Spring template for doing JDBC operations.
+ *
* @author Joram Barrez
*/
public class JdbcTemplate {
Modified: projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/Metric.java
===================================================================
--- projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/Metric.java 2009-09-15 20:47:18 UTC (rev 5643)
+++ projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/Metric.java 2009-09-15 20:48:19 UTC (rev 5644)
@@ -22,6 +22,8 @@
package org.jbpm.trainticketdemo.bam.entity;
/**
+ * Wrapper class for a category and a value, to be used for displaying metrics in a chart.
+ *
* @author Joram Barrez
*/
public class Metric {
Modified: projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/TicketSale.java
===================================================================
--- projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/TicketSale.java 2009-09-15 20:47:18 UTC (rev 5643)
+++ projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/src/main/org/jbpm/trainticketdemo/bam/entity/TicketSale.java 2009-09-15 20:48:19 UTC (rev 5644)
@@ -21,9 +21,10 @@
*/
package org.jbpm.trainticketdemo.bam.entity;
-import java.util.Date;
/**
+ * Class representing the sale of one train ticket in a given period.
+ *
* @author Joram Barrez
*/
public class TicketSale {
Modified: projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/view/home.xhtml
===================================================================
--- projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/view/home.xhtml 2009-09-15 20:47:18 UTC (rev 5643)
+++ projects/demos/trainticket-demo/jbpm_on_rails_bam/trunk/view/home.xhtml 2009-09-15 20:48:19 UTC (rev 5644)
@@ -32,7 +32,7 @@
var barChartStyle =
{
color: 0xB0C4DE,
- size: 60
+ size: 30
};
</script>
14 years, 7 months