JBoss JBPM SVN: r4128 - in jbpm3/branches/jbpm-3.2.6.GA/modules/core/src: main/java/org/jbpm/graph/exe and 5 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-03-03 19:46:18 -0500 (Tue, 03 Mar 2009)
New Revision: 4128
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
Log:
JBPM-2043: merge r4126 from branch jbpm-3.2.5.SP
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -217,20 +217,21 @@
}
}
+ public int countDeletableJobsForProcessInstance(ProcessInstance processInstance) {
+ Number jobCount = (Number) session.getNamedQuery("JobSession.countDeletableJobsForProcessInstance")
+ .setParameter("processInstance", processInstance)
+ .uniqueResult();
+ return jobCount.intValue();
+ }
+
public void deleteJobsForProcessInstance(ProcessInstance processInstance) {
try {
- // delete node execution jobs
- int entityCount = session.getNamedQuery("JobSession.deleteExecuteNodeJobsForProcessInstance")
+ // delete unowned node-execute-jobs and timers
+ int entityCount = session.getNamedQuery("JobSession.deleteJobsForProcessInstance")
.setParameter("processInstance", processInstance)
.executeUpdate();
- log.debug("deleted " + entityCount + " execute-node-jobs for " + processInstance);
+ log.debug("deleted " + entityCount + " jobs for " + processInstance);
- // delete unowned timers
- entityCount = session.getNamedQuery("JobSession.deleteTimersForProcessInstance")
- .setParameter("processInstance", processInstance)
- .executeUpdate();
- log.debug("deleted " + entityCount + " timers for " + processInstance);
-
// prevent further repetitions
List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersForProcessInstance")
.setParameter("processInstance", processInstance)
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -29,8 +29,10 @@
import java.util.List;
import java.util.Map;
+import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.db.JobSession;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Identifiable;
import org.jbpm.graph.def.Node;
@@ -44,6 +46,7 @@
import org.jbpm.module.def.ModuleDefinition;
import org.jbpm.module.exe.ModuleInstance;
import org.jbpm.msg.MessageService;
+import org.jbpm.persistence.PersistenceService;
import org.jbpm.svc.Services;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
import org.jbpm.util.Clock;
@@ -359,15 +362,22 @@
superProcessToken.signal(superExecutionContext);
}
- // make sure all the timers for this process instance are canceled after the process end updates are posted to the
- // database
- // NOTE Only timers should be deleted, messages should be kept.
- MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE, false);
- if (messageService != null)
+ // make sure jobs for this process instance are canceled
+ // after the process end updates are posted to the database
+ JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+ if (jbpmContext != null)
{
- CleanUpProcessJob job = new CleanUpProcessJob(this);
- job.setDueDate(new Date());
- messageService.send(job);
+ Services services = jbpmContext.getServices();
+ MessageService messageService = services.getMessageService();
+ PersistenceService persistenceService = services.getPersistenceService();
+ if (messageService != null
+ && persistenceService != null
+ && persistenceService.getJobSession().countDeletableJobsForProcessInstance(this) > 0)
+ {
+ CleanUpProcessJob job = new CleanUpProcessJob(rootToken);
+ job.setDueDate(new Date());
+ messageService.send(job);
+ }
}
}
}
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -22,7 +22,7 @@
package org.jbpm.job;
import org.jbpm.JbpmContext;
-import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
import org.jbpm.scheduler.SchedulerService;
/**
@@ -36,8 +36,8 @@
// default constructor
}
- public CleanUpProcessJob(ProcessInstance processInstance) {
- this.processInstance = processInstance;
+ public CleanUpProcessJob(Token token) {
+ super(token);
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-03-04 00:46:18 UTC (rev 4128)
@@ -345,14 +345,25 @@
]]>
</query>
- <query name="JobSession.deleteTimersForProcessInstance">
+ <query name="JobSession.countDeletableJobsForProcessInstance">
<![CDATA[
- delete from org.jbpm.job.Timer timer
- where timer.processInstance = :processInstance
- and timer.lockOwner is null
+ select count(job.id)
+ from org.jbpm.job.Job job
+ where job.processInstance = :processInstance
+ and job.lockOwner is null
+ and job.class in (org.jbpm.job.ExecuteNodeJob, org.jbpm.job.Timer)
]]>
</query>
+ <query name="JobSession.deleteJobsForProcessInstance">
+ <![CDATA[
+ delete from org.jbpm.job.Job job
+ where job.processInstance = :processInstance
+ and job.lockOwner is null
+ and job.class in (org.jbpm.job.ExecuteNodeJob, org.jbpm.job.Timer)
+ ]]>
+ </query>
+
<query name="JobSession.findRepeatingTimersForProcessInstance">
<![CDATA[
select timer
@@ -362,14 +373,6 @@
]]>
</query>
- <query name="JobSession.deleteExecuteNodeJobsForProcessInstance">
- <![CDATA[
- delete from org.jbpm.job.ExecuteNodeJob job
- where job.processInstance = :processInstance
- and job.lockOwner is null
- ]]>
- </query>
-
<query name="JobSession.findJobsByToken">
<![CDATA[
select job
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/jbpm1798/JBPM1798Test.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -34,7 +34,7 @@
try {
pd.createProcessInstance();
newTransaction();
- assertEquals(2, getNbrOfJobsAvailable());
+ assertEquals(1, getNbrOfJobsAvailable());
processJobs(maxWaitTime);
}
finally {
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -162,7 +162,7 @@
processInstance.signal();
jbpmContext.save(processInstance);
assertEquals(processDefinition.getNode("end"), processInstance.getRootToken().getNode());
- assertEquals(7, getNbrOfJobsAvailable());
+ assertEquals(6, getNbrOfJobsAvailable());
assertEquals(0, recordedActionNumbers.size());
processJobs(5000);
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-03 23:20:30 UTC (rev 4127)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-04 00:46:18 UTC (rev 4128)
@@ -21,10 +21,8 @@
*/
package org.jbpm.perf;
-// $Id$
+import java.util.concurrent.Semaphore;
-import java.text.NumberFormat;
-
import org.jbpm.db.AbstractDbTestCase;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
@@ -32,72 +30,93 @@
import org.jbpm.graph.exe.ProcessInstance;
/**
- * This tests creates a number of process instances.
- * Every instance has a call to an ActionHandler.
+ * This tests creates a number of process instances. Every instance has a call to an ActionHandler.
+ * https://jira.jboss.org/jira/browse/JBPM-2043
*
- * https://jira.jboss.org/jira/browse/JBPM-2043
- *
* @author mvecera(a)redhat.com
* @author pmacik(a)redhat.com
* @author thomas.diesler(a)jboss.com
* @author alex.guizar(a)jboss.com
* @since 18-Feb-2009
*/
-public class SimplePerformanceTest extends AbstractDbTestCase
-{
- private static final int INSTANCES = 1000;
- private static int count;
-
- ProcessDefinition processDefinition;
+public class SimplePerformanceTest extends AbstractDbTestCase {
- public void setUp() throws Exception
- {
+ private static final int WARMUP_INSTANCES = 100;
+ private static final int MEASUREMENT_INSTANCES = 1000;
+
+ private static final Semaphore signalLight = new Semaphore(0);
+
+ private ProcessDefinition processDefinition;
+
+ @Override
+ public void setUp() throws Exception {
super.setUp();
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='perf' xmlns='urn:jbpm.org:jpdl-3.1'>" +
- " <start-state name='start'>" +
- " <transition name='to_state' to='end'>" +
- " <action class='" + PerfActionHandler.class.getName() + "'/>" +
- " </transition>" +
- " </start-state>" +
- " <end-state name='end'/>" +
- "</process-definition>");
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition name='perf'>"
+ + " <event type='process-start'>"
+ + " <action class='"
+ + AsyncSignalAction.class.getName()
+ + "' async='true'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='end'/>"
+ + " </start-state>"
+ + " <end-state name='end'/>"
+ + "</process-definition>");
jbpmContext.deployProcessDefinition(processDefinition);
- newTransaction();
+
+ startJobExecutor();
}
- public void tearDown() throws Exception
- {
+ @Override
+ public void tearDown() throws Exception {
+ stopJobExecutor();
jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
super.tearDown();
}
- public void testAsyncCall()
- {
- long start = System.currentTimeMillis();
+ public void testAsyncCall() {
+ launchProcessInstances(WARMUP_INSTANCES);
- for (count = 1; count <= INSTANCES; count++)
- {
+ long startTime = System.currentTimeMillis();
+ launchProcessInstances(MEASUREMENT_INSTANCES);
+
+ long duration = System.currentTimeMillis() - startTime;
+ System.out.println("=== Test finished processing "
+ + MEASUREMENT_INSTANCES
+ + " instances in "
+ + duration
+ + "ms ===");
+ System.out.println("=== This is "
+ + Math.round(1000f * MEASUREMENT_INSTANCES / duration)
+ + " instances per second ===");
+ }
+
+ private void launchProcessInstances(int count) {
+ for (int i = 0; i < count; i++) {
+ newTransaction();
ProcessInstance pi = new ProcessInstance(processDefinition);
- pi.signal();
jbpmContext.save(pi);
- newTransaction();
}
- long stop = System.currentTimeMillis();
- System.out.println("=== Test finished processing " + INSTANCES + " instances in " + (stop - start) + "ms ===");
- System.out.println("=== This is " + Math.round(1000 * INSTANCES / (stop - start)) + " instances per second ===");
+ commitAndCloseSession();
+ try {
+ signalLight.acquire(count);
+ }
+ catch (InterruptedException e) {
+ fail(getName() + " got interrupted while waiting for process instances to end");
+ }
+ finally {
+ beginSessionTransaction();
+ }
}
- public static class PerfActionHandler implements ActionHandler
- {
- private static final long serialVersionUID = 1L;
+ public static class AsyncSignalAction implements ActionHandler {
+ private static final long serialVersionUID = -8617329370138396271L;
- public void execute(ExecutionContext executionContext) throws Exception
- {
- if (count % (INSTANCES / 4) == 0)
- System.out.println(NumberFormat.getPercentInstance().format((double) count / INSTANCES));
+ public void execute(final ExecutionContext executionContext) throws Exception {
+ signalLight.release();
+ executionContext.leaveNode();
}
}
}
17 years, 2 months
JBoss JBPM SVN: r4127 - jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/perf.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-03-03 18:20:30 -0500 (Tue, 03 Mar 2009)
New Revision: 4127
Modified:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
Log:
JBPM-2043: warm up before measuring job throughput
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-03 23:19:49 UTC (rev 4126)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-03 23:20:30 UTC (rev 4127)
@@ -21,145 +21,104 @@
*/
package org.jbpm.perf;
-// $Id$
-import java.io.File;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmContext;
-import org.jbpm.JbpmException;
-import org.jbpm.command.CommandService;
-import org.jbpm.command.NewProcessInstanceCommand;
-import org.jbpm.command.SignalCommand;
-import org.jbpm.command.impl.CommandServiceImpl;
+import java.util.concurrent.Semaphore;
+
import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.jbpm.instantiation.Delegation;
-import org.jbpm.job.ExecuteActionJob;
-import org.jbpm.msg.MessageService;
-import org.jbpm.svc.Services;
/**
- * This tests creates a number of process instances.
- * Every instance has a call to an ActionHandler.
- *
+ * This tests creates a number of process instances. Every instance has a call to an ActionHandler.
* https://jira.jboss.org/jira/browse/JBPM-2043
- *
+ *
* @author mvecera(a)redhat.com
* @author pmacik(a)redhat.com
* @author thomas.diesler(a)jboss.com
* @since 18-Feb-2009
*/
public class SimplePerformanceTest extends AbstractDbTestCase {
- private static final Log log = LogFactory.getLog(SimplePerformanceTest.class);
- private static final String ESB_ASYNC_SIGNAL_ACTION_NAME = "ESB_ASYNC_SIGNAL_ACTION";
- private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
- private static final int INSTANCES = 10000;
- private static int count = 1;
- private static AtomicInteger signaled = new AtomicInteger(0);
- private Action signalAction;
- ProcessDefinition processDefinition;
- public void setUp() throws Exception {
- super.setUp();
+ private static final int WARMUP_INSTANCES = 100;
+ private static final int MEASUREMENT_INSTANCES = 1000;
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition xmlns='urn:jbpm.org:jpdl-3.1' name='processDefinition1'>" +
- " <start-state name='start'>" +
- " <transition name='to_state' to='end'>" +
- " <action class='" + PerfActionHandler.class.getName() + "'/>" +
- " </transition>" +
- " </start-state>" +
- " <end-state name='end'/>" +
- "</process-definition>");
+ private static final Semaphore signalLight = new Semaphore(0);
- final Delegation delegation = new Delegation(AsyncSignalAction.class.getName());
- delegation.setConfigType("constructor");
- signalAction = new Action(delegation);
- signalAction.setName(ESB_ASYNC_SIGNAL_ACTION_NAME);
- processDefinition.addAction(signalAction);
+ private ProcessDefinition processDefinition;
- saveAndReload(processDefinition);
- }
+ public void setUp() throws Exception {
+ super.setUp();
- public void tearDown() throws Exception {
- beginSessionTransaction();
- jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- super.tearDown();
- }
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition name='perf'>"
+ + " <event type='process-start'>"
+ + " <action class='"
+ + AsyncSignalAction.class.getName()
+ + "' async='true'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='end'/>"
+ + " </start-state>"
+ + " <end-state name='end'/>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
- public void testAsyncCall() {
- long start = System.currentTimeMillis();
+ newTransaction();
+ startJobExecutor();
+ }
- startJobExecutor();
+ public void tearDown() throws Exception {
+ stopJobExecutor();
- commitAndCloseSession();
+ newTransaction();
+ jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- for (int i = 0; i < INSTANCES; i++) {
- beginSessionTransaction();
- NewProcessInstanceCommand startCommand = new NewProcessInstanceCommand();
- startCommand.setProcessId(processDefinition.getId());
- startCommand.setProcessName("processDefinition1");
- ProcessInstance pi = (ProcessInstance) commandService.execute(startCommand);
+ super.tearDown();
+ }
- Token token = pi.getRootToken();
- final ExecuteActionJob signalJob = new ExecuteActionJob(token);
+ public void testAsyncCall() {
+ launchProcessInstances(WARMUP_INSTANCES);
- signalJob.setAction(signalAction);
- signalJob.setDueDate(new Date());
- signalJob.setSuspended(token.isSuspended());
+ long startTime = System.currentTimeMillis();
+ launchProcessInstances(MEASUREMENT_INSTANCES);
+ long duration = System.currentTimeMillis() - startTime;
- final MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE, true);
- messageService.send(signalJob);
+ System.out.println("=== Test finished processing "
+ + MEASUREMENT_INSTANCES
+ + " instances in "
+ + duration
+ + "ms ===");
+ System.out.println("=== This is "
+ + Math.round(1000f * MEASUREMENT_INSTANCES / duration)
+ + " instances per second ===");
+ }
- commitAndCloseSession();
- }
+ private void launchProcessInstances(int count) {
+ for (int i = 0; i < count; i++) {
+ ProcessInstance pi = new ProcessInstance(processDefinition);
+ jbpmContext.save(pi);
+ newTransaction();
+ }
- while (signaled.get() < INSTANCES) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // no problem, computer's fault
- }
- }
+ commitAndCloseSession();
+ try {
+ signalLight.acquire(count);
+ }
+ catch (InterruptedException e) {
+ fail(getName() + " got interrupted while waiting for process instances to end");
+ }
+ finally {
+ beginSessionTransaction();
+ }
+ }
- stopJobExecutor();
+ public static class AsyncSignalAction implements ActionHandler {
+ private static final long serialVersionUID = -8617329370138396271L;
- long stop = System.currentTimeMillis();
- System.out.println("=== Test finished processing " + INSTANCES + " instances in " + (stop - start) + "ms ===");
- System.out.println("=== This is " + Math.round(1000f * INSTANCES / (stop - start)) + " instances per second ===");
- }
-
- public static class PerfActionHandler implements ActionHandler {
- private static final long serialVersionUID = -2171981067863454024L;
- public void execute(ExecutionContext executionContext) throws Exception {
- //System.out.println(count);
- count++;
- }
- }
-
- private static class AsyncSignalAction implements ActionHandler {
- private static final long serialVersionUID = -8617329370138396271L;
-
- AsyncSignalAction(final String configuration) throws JbpmException {
- }
-
- public void execute(final ExecutionContext executionContext)
- throws Exception {
- final Token token = executionContext.getToken();
- final long tokenId = token.getId();
- final JbpmContext jbpmContext = executionContext.getJbpmContext();
-
- final SignalCommand signalCommand = new SignalCommand(tokenId, null);
- signalCommand.execute(jbpmContext);
-
- signaled.incrementAndGet();
- }
- }
+ public void execute(final ExecutionContext executionContext) throws Exception {
+ executionContext.leaveNode();
+ signalLight.release();
+ }
+ }
}
+
17 years, 2 months
JBoss JBPM SVN: r4126 - in jbpm3/branches/jbpm-3.2.5.SP/modules/core/src: main/java/org/jbpm/graph/exe and 4 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-03-03 18:19:49 -0500 (Tue, 03 Mar 2009)
New Revision: 4126
Modified:
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
Log:
JBPM-2043: prevent cleanup job from being created if there are no deletable jobs
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-03-03 23:19:49 UTC (rev 4126)
@@ -217,20 +217,21 @@
}
}
+ public int countDeletableJobsForProcessInstance(ProcessInstance processInstance) {
+ Number jobCount = (Number) session.getNamedQuery("JobSession.countDeletableJobsForProcessInstance")
+ .setParameter("processInstance", processInstance)
+ .uniqueResult();
+ return jobCount.intValue();
+ }
+
public void deleteJobsForProcessInstance(ProcessInstance processInstance) {
try {
- // delete node execution jobs
- int entityCount = session.getNamedQuery("JobSession.deleteExecuteNodeJobsForProcessInstance")
+ // delete unowned node-execute-jobs and timers
+ int entityCount = session.getNamedQuery("JobSession.deleteJobsForProcessInstance")
.setParameter("processInstance", processInstance)
.executeUpdate();
- log.debug("deleted " + entityCount + " execute-node-jobs for " + processInstance);
+ log.debug("deleted " + entityCount + " jobs for " + processInstance);
- // delete unowned timers
- entityCount = session.getNamedQuery("JobSession.deleteTimersForProcessInstance")
- .setParameter("processInstance", processInstance)
- .executeUpdate();
- log.debug("deleted " + entityCount + " timers for " + processInstance);
-
// prevent further repetitions
List<?> timers = session.getNamedQuery("JobSession.findRepeatingTimersForProcessInstance")
.setParameter("processInstance", processInstance)
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/graph/exe/ProcessInstance.java 2009-03-03 23:19:49 UTC (rev 4126)
@@ -30,8 +30,10 @@
import java.util.List;
import java.util.Map;
+import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.context.exe.ContextInstance;
+import org.jbpm.db.JobSession;
import org.jbpm.graph.def.Event;
import org.jbpm.graph.def.Identifiable;
import org.jbpm.graph.def.Node;
@@ -45,6 +47,7 @@
import org.jbpm.module.def.ModuleDefinition;
import org.jbpm.module.exe.ModuleInstance;
import org.jbpm.msg.MessageService;
+import org.jbpm.persistence.PersistenceService;
import org.jbpm.svc.Services;
import org.jbpm.taskmgmt.exe.TaskMgmtInstance;
import org.jbpm.util.Clock;
@@ -363,15 +366,22 @@
superProcessToken.signal(superExecutionContext);
}
- // make sure all the timers for this process instance are canceled after the process end updates are posted to the
- // database
- // NOTE Only timers should be deleted, messages should be kept.
- MessageService messageService = (MessageService)Services.getCurrentService(Services.SERVICENAME_MESSAGE, false);
- if (messageService != null)
+ // make sure jobs for this process instance are canceled
+ // after the process end updates are posted to the database
+ JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
+ if (jbpmContext != null)
{
- CleanUpProcessJob job = new CleanUpProcessJob(this);
- job.setDueDate(new Date());
- messageService.send(job);
+ Services services = jbpmContext.getServices();
+ MessageService messageService = services.getMessageService();
+ PersistenceService persistenceService = services.getPersistenceService();
+ if (messageService != null
+ && persistenceService != null
+ && persistenceService.getJobSession().countDeletableJobsForProcessInstance(this) > 0)
+ {
+ CleanUpProcessJob job = new CleanUpProcessJob(rootToken);
+ job.setDueDate(new Date());
+ messageService.send(job);
+ }
}
}
}
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/java/org/jbpm/job/CleanUpProcessJob.java 2009-03-03 23:19:49 UTC (rev 4126)
@@ -22,7 +22,7 @@
package org.jbpm.job;
import org.jbpm.JbpmContext;
-import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
import org.jbpm.scheduler.SchedulerService;
/**
@@ -36,8 +36,8 @@
// default constructor
}
- public CleanUpProcessJob(ProcessInstance processInstance) {
- this.processInstance = processInstance;
+ public CleanUpProcessJob(Token token) {
+ super(token);
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/main/resources/org/jbpm/db/hibernate.queries.hbm.xml 2009-03-03 23:19:49 UTC (rev 4126)
@@ -345,14 +345,25 @@
]]>
</query>
- <query name="JobSession.deleteTimersForProcessInstance">
+ <query name="JobSession.countDeletableJobsForProcessInstance">
<![CDATA[
- delete from org.jbpm.job.Timer timer
- where timer.processInstance = :processInstance
- and timer.lockOwner is null
+ select count(job.id)
+ from org.jbpm.job.Job job
+ where job.processInstance = :processInstance
+ and job.lockOwner is null
+ and job.class in (org.jbpm.job.ExecuteNodeJob, org.jbpm.job.Timer)
]]>
</query>
+ <query name="JobSession.deleteJobsForProcessInstance">
+ <![CDATA[
+ delete from org.jbpm.job.Job job
+ where job.processInstance = :processInstance
+ and job.lockOwner is null
+ and job.class in (org.jbpm.job.ExecuteNodeJob, org.jbpm.job.Timer)
+ ]]>
+ </query>
+
<query name="JobSession.findRepeatingTimersForProcessInstance">
<![CDATA[
select timer
@@ -362,14 +373,6 @@
]]>
</query>
- <query name="JobSession.deleteExecuteNodeJobsForProcessInstance">
- <![CDATA[
- delete from org.jbpm.job.ExecuteNodeJob job
- where job.processInstance = :processInstance
- and job.lockOwner is null
- ]]>
- </query>
-
<query name="JobSession.findJobsByToken">
<![CDATA[
select job
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/msg/command/AsyncExecutionDbTest.java 2009-03-03 23:19:49 UTC (rev 4126)
@@ -162,7 +162,7 @@
processInstance.signal();
jbpmContext.save(processInstance);
assertEquals(processDefinition.getNode("end"), processInstance.getRootToken().getNode());
- assertEquals(7, getNbrOfJobsAvailable());
+ assertEquals(6, getNbrOfJobsAvailable());
assertEquals(0, recordedActionNumbers.size());
processJobs(5000);
Modified: jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-03 19:52:32 UTC (rev 4125)
+++ jbpm3/branches/jbpm-3.2.5.SP/modules/core/src/test/java/org/jbpm/perf/SimplePerformanceTest.java 2009-03-03 23:19:49 UTC (rev 4126)
@@ -21,146 +21,105 @@
*/
package org.jbpm.perf;
-// $Id$
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jbpm.JbpmContext;
-import org.jbpm.JbpmException;
-import org.jbpm.command.CommandService;
-import org.jbpm.command.NewProcessInstanceCommand;
-import org.jbpm.command.SignalCommand;
-import org.jbpm.command.impl.CommandServiceImpl;
+import java.util.concurrent.Semaphore;
+
import org.jbpm.db.AbstractDbTestCase;
-import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.graph.exe.ProcessInstance;
-import org.jbpm.graph.exe.Token;
-import org.jbpm.instantiation.Delegation;
-import org.jbpm.job.ExecuteActionJob;
-import org.jbpm.msg.MessageService;
-import org.jbpm.svc.Services;
/**
- * This tests creates a number of process instances.
- * Every instance has a call to an ActionHandler.
- *
+ * This tests creates a number of process instances. Every instance has a call to an ActionHandler.
* https://jira.jboss.org/jira/browse/JBPM-2043
- *
+ *
* @author mvecera(a)redhat.com
* @author pmacik(a)redhat.com
* @author thomas.diesler(a)jboss.com
* @since 18-Feb-2009
*/
public class SimplePerformanceTest extends AbstractDbTestCase {
- private static final Log log = LogFactory.getLog(SimplePerformanceTest.class);
- private static final String ESB_ASYNC_SIGNAL_ACTION_NAME = "ESB_ASYNC_SIGNAL_ACTION";
- private CommandService commandService = new CommandServiceImpl(getJbpmConfiguration());
- private static final int INSTANCES = 10000;
- private static int count = 1;
- private static AtomicInteger signaled = new AtomicInteger(0);
- private Action signalAction;
- ProcessDefinition processDefinition;
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ private static final int WARMUP_INSTANCES = 100;
+ private static final int MEASUREMENT_INSTANCES = 1000;
- processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition xmlns='urn:jbpm.org:jpdl-3.1' name='processDefinition1'>" +
- " <start-state name='start'>" +
- " <transition name='to_state' to='end'>" +
- " <action class='" + PerfActionHandler.class.getName() + "'/>" +
- " </transition>" +
- " </start-state>" +
- " <end-state name='end'/>" +
- "</process-definition>");
+ private static final Semaphore signalLight = new Semaphore(0);
- final Delegation delegation = new Delegation(AsyncSignalAction.class.getName());
- delegation.setConfigType("constructor");
- signalAction = new Action(delegation);
- signalAction.setName(ESB_ASYNC_SIGNAL_ACTION_NAME);
- processDefinition.addAction(signalAction);
+ private ProcessDefinition processDefinition;
- saveAndReload(processDefinition);
- }
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
- @Override
- public void tearDown() throws Exception {
- beginSessionTransaction();
- jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- super.tearDown();
- }
+ processDefinition = ProcessDefinition.parseXmlString("<process-definition name='perf'>"
+ + " <event type='process-start'>"
+ + " <action class='"
+ + AsyncSignalAction.class.getName()
+ + "' async='true'/>"
+ + " </event>"
+ + " <start-state name='start'>"
+ + " <transition to='end'/>"
+ + " </start-state>"
+ + " <end-state name='end'/>"
+ + "</process-definition>");
+ jbpmContext.deployProcessDefinition(processDefinition);
- public void testAsyncCall() {
- long start = System.currentTimeMillis();
+ newTransaction();
+ startJobExecutor();
+ }
- startJobExecutor();
+ @Override
+ public void tearDown() throws Exception {
+ stopJobExecutor();
- commitAndCloseSession();
+ newTransaction();
+ jbpmContext.getGraphSession().deleteProcessDefinition(processDefinition.getId());
- for (int i = 0; i < INSTANCES; i++) {
- beginSessionTransaction();
- NewProcessInstanceCommand startCommand = new NewProcessInstanceCommand();
- startCommand.setProcessDefinitionId(processDefinition.getId());
- startCommand.setProcessDefinitionName("processDefinition1");
- ProcessInstance pi = (ProcessInstance) commandService.execute(startCommand);
+ super.tearDown();
+ }
- Token token = pi.getRootToken();
- final ExecuteActionJob signalJob = new ExecuteActionJob(token);
+ public void testAsyncCall() {
+ launchProcessInstances(WARMUP_INSTANCES);
- signalJob.setAction(signalAction);
- signalJob.setDueDate(new Date());
- signalJob.setSuspended(token.isSuspended());
+ long startTime = System.currentTimeMillis();
+ launchProcessInstances(MEASUREMENT_INSTANCES);
+ long duration = System.currentTimeMillis() - startTime;
- final MessageService messageService = (MessageService) Services.getCurrentService(Services.SERVICENAME_MESSAGE, true);
- messageService.send(signalJob);
+ System.out.println("=== Test finished processing "
+ + MEASUREMENT_INSTANCES
+ + " instances in "
+ + duration
+ + "ms ===");
+ System.out.println("=== This is "
+ + Math.round(1000f * MEASUREMENT_INSTANCES / duration)
+ + " instances per second ===");
+ }
- commitAndCloseSession();
- }
+ private void launchProcessInstances(int count) {
+ for (int i = 0; i < count; i++) {
+ ProcessInstance pi = new ProcessInstance(processDefinition);
+ jbpmContext.save(pi);
+ newTransaction();
+ }
- while (signaled.get() < INSTANCES) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // no problem, computer's fault
- }
- }
+ commitAndCloseSession();
+ try {
+ signalLight.acquire(count);
+ }
+ catch (InterruptedException e) {
+ fail(getName() + " got interrupted while waiting for process instances to end");
+ }
+ finally {
+ beginSessionTransaction();
+ }
+ }
- stopJobExecutor();
+ public static class AsyncSignalAction implements ActionHandler {
+ private static final long serialVersionUID = -8617329370138396271L;
- long stop = System.currentTimeMillis();
- System.out.println("=== Test finished processing " + INSTANCES + " instances in " + (stop - start) + "ms ===");
- System.out.println("=== This is " + Math.round(1000f * INSTANCES / (stop - start)) + " instances per second ===");
- }
-
- public static class PerfActionHandler implements ActionHandler {
- private static final long serialVersionUID = -2171981067863454024L;
- public void execute(ExecutionContext executionContext) throws Exception {
- //System.out.println(count);
- count++;
- }
- }
-
- private static class AsyncSignalAction implements ActionHandler {
- private static final long serialVersionUID = -8617329370138396271L;
-
- AsyncSignalAction(final String configuration) throws JbpmException {
- }
-
- public void execute(final ExecutionContext executionContext)
- throws Exception {
- final Token token = executionContext.getToken();
- final long tokenId = token.getId();
- final JbpmContext jbpmContext = executionContext.getJbpmContext();
-
- final SignalCommand signalCommand = new SignalCommand(tokenId, null);
- signalCommand.execute(jbpmContext);
-
- signaled.incrementAndGet();
- }
- }
+ public void execute(final ExecutionContext executionContext) throws Exception {
+ executionContext.leaveNode();
+ signalLight.release();
+ }
+ }
}
17 years, 2 months
JBoss JBPM SVN: r4125 - in jbpm3: tags and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-03-03 14:52:32 -0500 (Tue, 03 Mar 2009)
New Revision: 4125
Added:
jbpm3/branches/jbpm-3.2.6.GA/
Removed:
jbpm3/tags/jbpm-3.2.6.GA/
Log:
Reopen jbpm-3.2.6.GA
Copied: jbpm3/branches/jbpm-3.2.6.GA (from rev 4124, jbpm3/tags/jbpm-3.2.6.GA)
17 years, 2 months
JBoss JBPM SVN: r4124 - in jbpm3: tags and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-03-03 14:50:05 -0500 (Tue, 03 Mar 2009)
New Revision: 4124
Added:
jbpm3/tags/jbpm-3.2.6.GA/
Removed:
jbpm3/branches/jbpm-3.2.6.GA/
Log:
Release jbpm-3.2.6.GA
Copied: jbpm3/tags/jbpm-3.2.6.GA (from rev 4123, jbpm3/branches/jbpm-3.2.6.GA)
17 years, 2 months
JBoss JBPM SVN: r4123 - in projects/jsf-console/tags/jsf-console-3.2.6.SP1: console and 2 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-03-03 07:42:04 -0500 (Tue, 03 Mar 2009)
New Revision: 4123
Modified:
projects/jsf-console/tags/jsf-console-3.2.6.SP1/console/pom.xml
projects/jsf-console/tags/jsf-console-3.2.6.SP1/jbpm4jsf/pom.xml
projects/jsf-console/tags/jsf-console-3.2.6.SP1/pom.xml
projects/jsf-console/tags/jsf-console-3.2.6.SP1/soa/pom.xml
Log:
Version 3.2.6.SP1
Modified: projects/jsf-console/tags/jsf-console-3.2.6.SP1/console/pom.xml
===================================================================
--- projects/jsf-console/tags/jsf-console-3.2.6.SP1/console/pom.xml 2009-03-03 12:32:25 UTC (rev 4122)
+++ projects/jsf-console/tags/jsf-console-3.2.6.SP1/console/pom.xml 2009-03-03 12:42:04 UTC (rev 4123)
@@ -21,7 +21,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jsf-console-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.2.6.SP1</version>
<relativePath>../pom.xml</relativePath>
</parent>
Modified: projects/jsf-console/tags/jsf-console-3.2.6.SP1/jbpm4jsf/pom.xml
===================================================================
--- projects/jsf-console/tags/jsf-console-3.2.6.SP1/jbpm4jsf/pom.xml 2009-03-03 12:32:25 UTC (rev 4122)
+++ projects/jsf-console/tags/jsf-console-3.2.6.SP1/jbpm4jsf/pom.xml 2009-03-03 12:42:04 UTC (rev 4123)
@@ -24,7 +24,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jsf-console-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.2.6.SP1</version>
<relativePath>../pom.xml</relativePath>
</parent>
Modified: projects/jsf-console/tags/jsf-console-3.2.6.SP1/pom.xml
===================================================================
--- projects/jsf-console/tags/jsf-console-3.2.6.SP1/pom.xml 2009-03-03 12:32:25 UTC (rev 4122)
+++ projects/jsf-console/tags/jsf-console-3.2.6.SP1/pom.xml 2009-03-03 12:42:04 UTC (rev 4123)
@@ -16,7 +16,7 @@
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jsf-console-parent</artifactId>
<packaging>pom</packaging>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.2.6.SP1</version>
<!-- Parent -->
<parent>
Modified: projects/jsf-console/tags/jsf-console-3.2.6.SP1/soa/pom.xml
===================================================================
--- projects/jsf-console/tags/jsf-console-3.2.6.SP1/soa/pom.xml 2009-03-03 12:32:25 UTC (rev 4122)
+++ projects/jsf-console/tags/jsf-console-3.2.6.SP1/soa/pom.xml 2009-03-03 12:42:04 UTC (rev 4123)
@@ -21,7 +21,7 @@
<parent>
<groupId>org.jbpm.jbpm3</groupId>
<artifactId>jsf-console-parent</artifactId>
- <version>3.2.7-SNAPSHOT</version>
+ <version>3.2.6.SP1</version>
<relativePath>../pom.xml</relativePath>
</parent>
17 years, 2 months
JBoss JBPM SVN: r4122 - jbpm3/branches/jbpm-3.2.6.GA.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-03-03 07:32:25 -0500 (Tue, 03 Mar 2009)
New Revision: 4122
Modified:
jbpm3/branches/jbpm-3.2.6.GA/pom.xml
Log:
JSF Console 3.2.6.SP1
Modified: jbpm3/branches/jbpm-3.2.6.GA/pom.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/pom.xml 2009-03-03 12:22:57 UTC (rev 4121)
+++ jbpm3/branches/jbpm-3.2.6.GA/pom.xml 2009-03-03 12:32:25 UTC (rev 4122)
@@ -73,7 +73,7 @@
<javax.jaxb.version>2.1</javax.jaxb.version>
<jaxen.version>1.1.1</jaxen.version>
<jbpm.designer.version>3.1.7</jbpm.designer.version>
- <jbpm.jsf-console.version>3.2.6.GA</jbpm.jsf-console.version>
+ <jbpm.jsf-console.version>3.2.6.SP1</jbpm.jsf-console.version>
<jboss.client.version>4.2.2.GA</jboss.client.version>
<jboss.gravel.version>1.0.0.GA</jboss.gravel.version>
<jboss.seam.version>2.0.2.GA</jboss.seam.version>
17 years, 2 months
JBoss JBPM SVN: r4121 - in jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise: console and 1 other directory.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-03-03 07:22:57 -0500 (Tue, 03 Mar 2009)
New Revision: 4121
Added:
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java
Removed:
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java
Log:
svn merge -r4085:HEAD https://svn.jboss.org/repos/jbpm/jbpm3/trunk
Copied: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console (from rev 4119, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console)
Deleted: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java 2009-03-03 11:59:23 UTC (rev 4119)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -1,147 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
-
-/**
- * A Base64 Encoder/Decoder.
- */
-public class Base64Coder
-{
-
- // Mapping table from 6-bit nibbles to Base64 characters.
- private static char[] map1 = new char[64];
- static {
- int i=0;
- for (char c='A'; c<='Z'; c++) map1[i++] = c;
- for (char c='a'; c<='z'; c++) map1[i++] = c;
- for (char c='0'; c<='9'; c++) map1[i++] = c;
- map1[i++] = '+'; map1[i++] = '/'; }
-
- // Mapping table from Base64 characters to 6-bit nibbles.
- private static byte[] map2 = new byte[128];
- static {
- for (int i=0; i<map2.length; i++) map2[i] = -1;
- for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
-
- /**
- * Encodes a string into Base64 format.
- * No blanks or line breaks are inserted.
- * @param s a String to be encoded.
- * @return A String with the Base64 encoded data.
- */
- public static String encodeString (String s) {
- return new String(encode(s.getBytes())); }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- * @param in an array containing the data bytes to be encoded.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode (byte[] in) {
- return encode(in,in.length); }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- * @param in an array containing the data bytes to be encoded.
- * @param iLen number of bytes to process in <code>in</code>.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode (byte[] in, int iLen) {
- int oDataLen = (iLen*4+2)/3; // output length without padding
- int oLen = ((iLen+2)/3)*4; // output length including padding
- char[] out = new char[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++] & 0xff;
- int i1 = ip < iLen ? in[ip++] & 0xff : 0;
- int i2 = ip < iLen ? in[ip++] & 0xff : 0;
- int o0 = i0 >>> 2;
- int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
- int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
- int o3 = i2 & 0x3F;
- out[op++] = map1[o0];
- out[op++] = map1[o1];
- out[op] = op < oDataLen ? map1[o2] : '='; op++;
- out[op] = op < oDataLen ? map1[o3] : '='; op++; }
- return out; }
-
- /**
- * Decodes a string from Base64 format.
- * @param s a Base64 String to be decoded.
- * @return A String containing the decoded data.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static String decodeString (String s) {
- return new String(decode(s)); }
-
- /**
- * Decodes a byte array from Base64 format.
- * @param s a Base64 String to be decoded.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode (String s) {
- return decode(s.toCharArray()); }
-
- /**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded data.
- * @param in a character array containing the Base64 encoded data.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode (char[] in) {
- int iLen = in.length;
- if (iLen%4 != 0) throw new IllegalArgumentException ("Length of Base64 encoded input string is not a multiple of 4.");
- while (iLen > 0 && in[iLen-1] == '=') iLen--;
- int oLen = (iLen*3) / 4;
- byte[] out = new byte[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++];
- int i1 = in[ip++];
- int i2 = ip < iLen ? in[ip++] : 'A';
- int i3 = ip < iLen ? in[ip++] : 'A';
- if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
- throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
- int b0 = map2[i0];
- int b1 = map2[i1];
- int b2 = map2[i2];
- int b3 = map2[i3];
- if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
- throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
- int o0 = ( b0 <<2) | (b1>>>4);
- int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
- int o2 = ((b2 & 3)<<6) | b3;
- out[op++] = (byte)o0;
- if (op<oLen) out[op++] = (byte)o1;
- if (op<oLen) out[op++] = (byte)o2; }
- return out; }
-
- // Dummy constructor.
- private Base64Coder() {}
-
-} // end class Base64Coder
Copied: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java (from rev 4119, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/Base64Coder.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
+
+/**
+ * A Base64 Encoder/Decoder.
+ */
+public class Base64Coder
+{
+
+ // Mapping table from 6-bit nibbles to Base64 characters.
+ private static char[] map1 = new char[64];
+ static {
+ int i=0;
+ for (char c='A'; c<='Z'; c++) map1[i++] = c;
+ for (char c='a'; c<='z'; c++) map1[i++] = c;
+ for (char c='0'; c<='9'; c++) map1[i++] = c;
+ map1[i++] = '+'; map1[i++] = '/'; }
+
+ // Mapping table from Base64 characters to 6-bit nibbles.
+ private static byte[] map2 = new byte[128];
+ static {
+ for (int i=0; i<map2.length; i++) map2[i] = -1;
+ for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
+
+ /**
+ * Encodes a string into Base64 format.
+ * No blanks or line breaks are inserted.
+ * @param s a String to be encoded.
+ * @return A String with the Base64 encoded data.
+ */
+ public static String encodeString (String s) {
+ return new String(encode(s.getBytes())); }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ * @param in an array containing the data bytes to be encoded.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode (byte[] in) {
+ return encode(in,in.length); }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ * @param in an array containing the data bytes to be encoded.
+ * @param iLen number of bytes to process in <code>in</code>.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode (byte[] in, int iLen) {
+ int oDataLen = (iLen*4+2)/3; // output length without padding
+ int oLen = ((iLen+2)/3)*4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iLen ? in[ip++] & 0xff : 0;
+ int i2 = ip < iLen ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '='; op++;
+ out[op] = op < oDataLen ? map1[o3] : '='; op++; }
+ return out; }
+
+ /**
+ * Decodes a string from Base64 format.
+ * @param s a Base64 String to be decoded.
+ * @return A String containing the decoded data.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static String decodeString (String s) {
+ return new String(decode(s)); }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ * @param s a Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode (String s) {
+ return decode(s.toCharArray()); }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ * No blanks or line breaks are allowed within the Base64 encoded data.
+ * @param in a character array containing the Base64 encoded data.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode (char[] in) {
+ int iLen = in.length;
+ if (iLen%4 != 0) throw new IllegalArgumentException ("Length of Base64 encoded input string is not a multiple of 4.");
+ while (iLen > 0 && in[iLen-1] == '=') iLen--;
+ int oLen = (iLen*3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iLen ? in[ip++] : 'A';
+ int i3 = ip < iLen ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+ throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+ throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
+ int o0 = ( b0 <<2) | (b1>>>4);
+ int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
+ int o2 = ((b2 & 3)<<6) | b3;
+ out[op++] = (byte)o0;
+ if (op<oLen) out[op++] = (byte)o1;
+ if (op<oLen) out[op++] = (byte)o2; }
+ return out; }
+
+ // Dummy constructor.
+ private Base64Coder() {}
+
+} // end class Base64Coder
Deleted: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-03-03 11:59:23 UTC (rev 4119)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
-
-import junit.framework.TestCase;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class ConsoleAvailabilityTest extends TestCase
-{
-
- /**
- * Verify if the console has been deployed successfully
- * @throws Exception
- */
- public void testConsoleDeployment()
- throws Exception
- {
- String bindAddress = System.getProperty("jboss.bind.address");
- String host = bindAddress !=null ? bindAddress : "localhost:8080";
- if(host.indexOf(":")==-1) host = (host+":8080"); // default port
-
- System.out.println("Console URL: " + host);
- String response = HTTP.get("http://"+host +"/jbpm-console", null, true); // no auth
- }
-
-}
Copied: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java (from rev 4119, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class ConsoleAvailabilityTest extends TestCase
+{
+
+ /**
+ * Verify if the console has been deployed successfully
+ * @throws Exception
+ */
+ public void testConsoleDeployment()
+ throws Exception
+ {
+ String bindAddress = System.getProperty("jboss.bind.address");
+ String host = bindAddress !=null ? bindAddress : "localhost:8080";
+ if(host.indexOf(":")==-1) host = (host+":8080"); // default port
+
+ System.out.println("Console URL: " + host);
+ String response = HTTP.get("http://"+host +"/jbpm-console", null, true); // no auth
+ }
+
+}
Deleted: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java 2009-03-03 11:59:23 UTC (rev 4119)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -1,214 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
-
-import java.io.*;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.UUID;
-
-/**
- * @author Heiko.Braun <heiko.braun(a)jboss.com>
- */
-public class HTTP
-{
- public static String post(String urlString, InputStream inputStream, String[] credentials)
- throws Exception
- {
-
- HttpURLConnection conn = null;
- BufferedReader br = null;
- DataOutputStream dos = null;
- DataInputStream inStream = null;
-
- InputStream is = null;
- OutputStream os = null;
- boolean ret = false;
- String StrMessage = "";
-
-
- String lineEnd = "\r\n";
- String twoHyphens = "--";
- String boundary = "*****";
-
-
- int bytesRead, bytesAvailable, bufferSize;
-
- byte[] buffer;
-
- int maxBufferSize = 1*1024*1024;
-
- String responseFromServer = "";
-
- try
- {
- //------------------ CLIENT REQUEST
-
- // open a URL connection to the Servlet
-
- URL url = new URL(urlString);
-
-
- // Open a HTTP connection to the URL
-
- conn = (HttpURLConnection) url.openConnection();
-
- if(credentials!=null)
- applyCredentials(credentials, conn);
-
- // Allow Inputs
- conn.setDoInput(true);
-
- // Allow Outputs
- conn.setDoOutput(true);
-
- // Don't use a cached copy.
- conn.setUseCaches(false);
-
- // Use a post method.
- conn.setRequestMethod("POST");
-
- conn.setRequestProperty("Connection", "Keep-Alive");
-
- conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
-
- dos = new DataOutputStream( conn.getOutputStream() );
-
- dos.writeBytes(twoHyphens + boundary + lineEnd);
- dos.writeBytes("Content-Disposition: form-data; name=\"upload\";"
- + " filename=\"" + UUID.randomUUID().toString() +"\"" + lineEnd);
- dos.writeBytes(lineEnd);
-
- // create a buffer of maximum size
- bytesAvailable = inputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- buffer = new byte[bufferSize];
-
- // read file and write it into form...
- bytesRead = inputStream.read(buffer, 0, bufferSize);
-
- while (bytesRead > 0)
- {
- dos.write(buffer, 0, bufferSize);
- bytesAvailable = inputStream.available();
- bufferSize = Math.min(bytesAvailable, maxBufferSize);
- bytesRead = inputStream.read(buffer, 0, bufferSize);
- }
-
- // send multipart form data necesssary after file data...
-
- dos.writeBytes(lineEnd);
- dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
-
- // close streams
-
- inputStream.close();
- dos.flush();
- dos.close();
-
- }
- catch (MalformedURLException ex)
- {
- throw ex;
- }
-
- catch (IOException ioe)
- {
- throw ioe;
- }
-
-
- //------------------ read the SERVER RESPONSE
-
- StringBuffer sb = new StringBuffer();
-
- try
- {
- inStream = new DataInputStream ( conn.getInputStream() );
- String str;
- while (( str = inStream.readLine()) != null)
- {
- sb.append(str).append("");
- }
- inStream.close();
-
- }
- catch (IOException ioex)
- {
- System.out.println("From (ServerResponse): "+ioex);
-
- }
-
-
- return sb.toString();
-
- }
-
- private static void applyCredentials(String[] credentials, HttpURLConnection conn)
- {
- String userPassword = credentials[0]+":"+credentials[1];
- String encoding = new String(Base64Coder.encode (userPassword.getBytes()));
- conn.setRequestProperty ("Authorization", "Basic " + encoding);
- }
-
- public static String get(String urlString, String[] credentials, boolean throwServerError)
- {
- StringBuffer sb = new StringBuffer();
- try
- {
- URL url = new URL(urlString);
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- if(credentials!=null)
- applyCredentials(credentials, conn);
-
-
- if(throwServerError && conn.getResponseCode()!=200)
- {
- throw new RuntimeException("Server response " + conn.getResponseCode());
- }
-
- BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String str;
-
-
- while ((str = in.readLine()) != null)
- {
- sb.append(str);
- }
-
- in.close();
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
-
- return sb.toString();
- }
-}
-
-
Copied: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java (from rev 4119, jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java)
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java (rev 0)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/test/java/org/jbpm/enterprise/console/HTTP.java 2009-03-03 12:22:57 UTC (rev 4121)
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.enterprise.console;
+
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.UUID;
+
+/**
+ * @author Heiko.Braun <heiko.braun(a)jboss.com>
+ */
+public class HTTP
+{
+ public static String post(String urlString, InputStream inputStream, String[] credentials)
+ throws Exception
+ {
+
+ HttpURLConnection conn = null;
+ BufferedReader br = null;
+ DataOutputStream dos = null;
+ DataInputStream inStream = null;
+
+ InputStream is = null;
+ OutputStream os = null;
+ boolean ret = false;
+ String StrMessage = "";
+
+
+ String lineEnd = "\r\n";
+ String twoHyphens = "--";
+ String boundary = "*****";
+
+
+ int bytesRead, bytesAvailable, bufferSize;
+
+ byte[] buffer;
+
+ int maxBufferSize = 1*1024*1024;
+
+ String responseFromServer = "";
+
+ try
+ {
+ //------------------ CLIENT REQUEST
+
+ // open a URL connection to the Servlet
+
+ URL url = new URL(urlString);
+
+
+ // Open a HTTP connection to the URL
+
+ conn = (HttpURLConnection) url.openConnection();
+
+ if(credentials!=null)
+ applyCredentials(credentials, conn);
+
+ // Allow Inputs
+ conn.setDoInput(true);
+
+ // Allow Outputs
+ conn.setDoOutput(true);
+
+ // Don't use a cached copy.
+ conn.setUseCaches(false);
+
+ // Use a post method.
+ conn.setRequestMethod("POST");
+
+ conn.setRequestProperty("Connection", "Keep-Alive");
+
+ conn.setRequestProperty("Content-Type", "multipart/form-data;boundary="+boundary);
+
+ dos = new DataOutputStream( conn.getOutputStream() );
+
+ dos.writeBytes(twoHyphens + boundary + lineEnd);
+ dos.writeBytes("Content-Disposition: form-data; name=\"upload\";"
+ + " filename=\"" + UUID.randomUUID().toString() +"\"" + lineEnd);
+ dos.writeBytes(lineEnd);
+
+ // create a buffer of maximum size
+ bytesAvailable = inputStream.available();
+ bufferSize = Math.min(bytesAvailable, maxBufferSize);
+ buffer = new byte[bufferSize];
+
+ // read file and write it into form...
+ bytesRead = inputStream.read(buffer, 0, bufferSize);
+
+ while (bytesRead > 0)
+ {
+ dos.write(buffer, 0, bufferSize);
+ bytesAvailable = inputStream.available();
+ bufferSize = Math.min(bytesAvailable, maxBufferSize);
+ bytesRead = inputStream.read(buffer, 0, bufferSize);
+ }
+
+ // send multipart form data necesssary after file data...
+
+ dos.writeBytes(lineEnd);
+ dos.writeBytes(twoHyphens + boundary + twoHyphens + lineEnd);
+
+ // close streams
+
+ inputStream.close();
+ dos.flush();
+ dos.close();
+
+ }
+ catch (MalformedURLException ex)
+ {
+ throw ex;
+ }
+
+ catch (IOException ioe)
+ {
+ throw ioe;
+ }
+
+
+ //------------------ read the SERVER RESPONSE
+
+ StringBuffer sb = new StringBuffer();
+
+ try
+ {
+ inStream = new DataInputStream ( conn.getInputStream() );
+ String str;
+ while (( str = inStream.readLine()) != null)
+ {
+ sb.append(str).append("");
+ }
+ inStream.close();
+
+ }
+ catch (IOException ioex)
+ {
+ System.out.println("From (ServerResponse): "+ioex);
+
+ }
+
+
+ return sb.toString();
+
+ }
+
+ private static void applyCredentials(String[] credentials, HttpURLConnection conn)
+ {
+ String userPassword = credentials[0]+":"+credentials[1];
+ String encoding = new String(Base64Coder.encode (userPassword.getBytes()));
+ conn.setRequestProperty ("Authorization", "Basic " + encoding);
+ }
+
+ public static String get(String urlString, String[] credentials, boolean throwServerError)
+ {
+ StringBuffer sb = new StringBuffer();
+ try
+ {
+ URL url = new URL(urlString);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ if(credentials!=null)
+ applyCredentials(credentials, conn);
+
+
+ if(throwServerError && conn.getResponseCode()!=200)
+ {
+ throw new RuntimeException("Server response " + conn.getResponseCode());
+ }
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ String str;
+
+
+ while ((str = in.readLine()) != null)
+ {
+ sb.append(str);
+ }
+
+ in.close();
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+
+ return sb.toString();
+ }
+}
+
+
17 years, 2 months
JBoss JBPM SVN: r4120 - projects/jsf-console/tags.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-03-03 07:08:44 -0500 (Tue, 03 Mar 2009)
New Revision: 4120
Added:
projects/jsf-console/tags/jsf-console-3.2.6.SP1/
Log:
Create 3.2.6.SP1 tag
Copied: projects/jsf-console/tags/jsf-console-3.2.6.SP1 (from rev 4119, projects/jsf-console/trunk)
17 years, 2 months
JBoss JBPM SVN: r4119 - jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-03-03 06:59:23 -0500 (Tue, 03 Mar 2009)
New Revision: 4119
Modified:
jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
Log:
Fix ConsoleAvailabilityTest
Modified: jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java
===================================================================
--- jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-03-03 11:51:27 UTC (rev 4118)
+++ jbpm3/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/console/ConsoleAvailabilityTest.java 2009-03-03 11:59:23 UTC (rev 4119)
@@ -41,7 +41,7 @@
if(host.indexOf(":")==-1) host = (host+":8080"); // default port
System.out.println("Console URL: " + host);
- String response = HTTP.get("http://"+host +"/jbpm-consol2e", null, true); // no auth
+ String response = HTTP.get("http://"+host +"/jbpm-console", null, true); // no auth
}
}
17 years, 2 months