JBoss JBPM SVN: r4092 - in jbpm3/branches/jbpm-3.2.6.GA/modules/core/src: test/java/org/jbpm and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 18:38:45 -0500 (Sat, 28 Feb 2009)
New Revision: 4092
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
Log:
[JBPM-2074] Removed invalid usage of finalize
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 23:11:26 UTC (rev 4091)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 23:38:45 UTC (rev 4092)
@@ -619,12 +619,6 @@
}
}
- @Override
- protected void finalize() throws Throwable
- {
- close();
- }
-
static JbpmConfiguration getCurrentJbpmConfiguration()
{
JbpmConfiguration currentJbpmConfiguration = null;
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 23:11:26 UTC (rev 4091)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 23:38:45 UTC (rev 4092)
@@ -21,7 +21,6 @@
*/
package org.jbpm;
-import java.io.PrintStream;
import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;
@@ -111,17 +110,10 @@
public JbpmContext(Services services, ObjectFactory objectFactory)
{
log.debug("creating " + toString());
-
- if (logCreateStackTrace)
- new RuntimeException().printStackTrace(new PrintStream(System.out));
-
this.services = services;
this.objectFactory = objectFactory;
}
- // [JBPM-2074] Fix intermittent problem with JbpmConfigurationTest.testDomainModelConfigsWithoutJbpmContext
- public static boolean logCreateStackTrace;
-
/**
* make sure you close your JbpmContext in a finally block.
*/
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 23:11:26 UTC (rev 4091)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 23:38:45 UTC (rev 4092)
@@ -128,19 +128,11 @@
// 'jbpm.cfg.xml' or the static method JbpmConfiguration.Configs.setDefaultObjectFactory
// to specify the configuration information.
- JbpmContext.logCreateStackTrace = true;
- try
- {
- JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='myproperty'>myvalue</string>" +
- "</jbpm-configuration>"));
- assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
- }
- finally
- {
- JbpmContext.logCreateStackTrace = false;
- }
+ JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString(
+ "<jbpm-configuration>" +
+ " <string name='myproperty'>myvalue</string>" +
+ "</jbpm-configuration>"));
+ assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
}
public static class CustomObjectFactory implements ObjectFactory
15 years, 2 months
JBoss JBPM SVN: r4091 - jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 18:11:26 -0500 (Sat, 28 Feb 2009)
New Revision: 4091
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
Log:
[JBPM-2074] document what I am doing
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 22:57:08 UTC (rev 4090)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 23:11:26 UTC (rev 4091)
@@ -119,6 +119,7 @@
this.objectFactory = objectFactory;
}
+ // [JBPM-2074] Fix intermittent problem with JbpmConfigurationTest.testDomainModelConfigsWithoutJbpmContext
public static boolean logCreateStackTrace;
/**
15 years, 2 months
JBoss JBPM SVN: r4090 - jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 17:57:08 -0500 (Sat, 28 Feb 2009)
New Revision: 4090
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
Log:
[JBPM-2074] Try to catch the creator ot the JbpmContext
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 22:42:36 UTC (rev 4089)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 22:57:08 UTC (rev 4090)
@@ -128,11 +128,19 @@
// 'jbpm.cfg.xml' or the static method JbpmConfiguration.Configs.setDefaultObjectFactory
// to specify the configuration information.
- JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='myproperty'>myvalue</string>" +
- "</jbpm-configuration>"));
- assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
+ JbpmContext.logCreateStackTrace = true;
+ try
+ {
+ JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString(
+ "<jbpm-configuration>" +
+ " <string name='myproperty'>myvalue</string>" +
+ "</jbpm-configuration>"));
+ assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
+ }
+ finally
+ {
+ JbpmContext.logCreateStackTrace = false;
+ }
}
public static class CustomObjectFactory implements ObjectFactory
@@ -163,28 +171,20 @@
public void testDomainModelConfigsWithJbpmContext()
{
- JbpmContext.logCreateStackTrace = true;
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context name='default.jbpm.context' />" +
+ " <string name='myproperty'>myvalueinacontext</string>" +
+ "</jbpm-configuration>");
+
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
try
{
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>");
-
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try
- {
- assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
- }
- finally
- {
- jbpmContext.close();
- }
+ assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
}
finally
{
- JbpmContext.logCreateStackTrace = false;
+ jbpmContext.close();
}
}
15 years, 2 months
JBoss JBPM SVN: r4089 - in jbpm3/branches/jbpm-3.2.6.GA/modules/core/src: test/java/org/jbpm and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 17:42:36 -0500 (Sat, 28 Feb 2009)
New Revision: 4089
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
Log:
[JBPM-2074] Try to catch the creator ot the JbpmContext
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 21:26:56 UTC (rev 4088)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmContext.java 2009-02-28 22:42:36 UTC (rev 4089)
@@ -21,6 +21,7 @@
*/
package org.jbpm;
+import java.io.PrintStream;
import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;
@@ -110,9 +111,15 @@
public JbpmContext(Services services, ObjectFactory objectFactory)
{
log.debug("creating " + toString());
+
+ if (logCreateStackTrace)
+ new RuntimeException().printStackTrace(new PrintStream(System.out));
+
this.services = services;
this.objectFactory = objectFactory;
}
+
+ public static boolean logCreateStackTrace;
/**
* make sure you close your JbpmContext in a finally block.
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 21:26:56 UTC (rev 4088)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 22:42:36 UTC (rev 4089)
@@ -163,20 +163,28 @@
public void testDomainModelConfigsWithJbpmContext()
{
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>");
-
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ JbpmContext.logCreateStackTrace = true;
try
{
- assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context name='default.jbpm.context' />" +
+ " <string name='myproperty'>myvalueinacontext</string>" +
+ "</jbpm-configuration>");
+
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
}
finally
{
- jbpmContext.close();
+ JbpmContext.logCreateStackTrace = false;
}
}
15 years, 2 months
JBoss JBPM SVN: r4088 - in jbpm3/branches/jbpm-3.2.6.GA/modules: core/src/main/java/org/jbpm/job/executor and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-02-28 16:26:56 -0500 (Sat, 28 Feb 2009)
New Revision: 4088
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/Timer.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
Log:
move addAutoSaveProcessInstance calls back to each job, as in the JBPM-1015 resolution
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4213963
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java 2009-02-28 16:55:18 UTC (rev 4087)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteActionJob.java 2009-02-28 21:26:56 UTC (rev 4088)
@@ -13,25 +13,32 @@
private static final long serialVersionUID = 1L;
Action action;
-
+
public ExecuteActionJob() {
}
-
+
public ExecuteActionJob(Token token) {
super(token);
}
-
+
public boolean execute(JbpmContext jbpmContext) throws Exception {
- log.debug("job["+id+"] executes "+action);
-
+ log.debug("job[" + id + "] executes " + action);
+
+ // register process instance for automatic save
+ // see https://jira.jboss.org/jira/browse/JBPM-1015
+ jbpmContext.addAutoSaveProcessInstance(processInstance);
+
+ // prepare execution context
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setAction(action);
executionContext.setEvent(action.getEvent());
-
- Node node = (token!=null ? token.getNode() : null);
- if (node!=null) {
+
+ // then execute the action
+ Node node = token != null ? token.getNode() : null;
+ if (node != null) {
node.executeAction(action, executionContext);
- } else {
+ }
+ else {
action.execute(executionContext);
}
@@ -41,9 +48,10 @@
public Action getAction() {
return action;
}
+
public void setAction(Action action) {
this.action = action;
}
-
+
private static Log log = LogFactory.getLog(ExecuteActionJob.class);
}
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java 2009-02-28 16:55:18 UTC (rev 4087)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/ExecuteNodeJob.java 2009-02-28 21:26:56 UTC (rev 4088)
@@ -10,7 +10,7 @@
public class ExecuteNodeJob extends Job {
private static final long serialVersionUID = 1L;
-
+
Node node;
public ExecuteNodeJob() {
@@ -19,20 +19,28 @@
public ExecuteNodeJob(Token token) {
super(token);
}
-
- public boolean execute(JbpmContext jbpmContext) throws Exception {
- log.debug("job["+id+"] executes "+node);
+ public boolean execute(JbpmContext jbpmContext) throws Exception {
+ log.debug("job[" + id + "] executes " + node);
+
+ // register process instance for automatic save
+ // see https://jira.jboss.org/jira/browse/JBPM-1015
+ jbpmContext.addAutoSaveProcessInstance(processInstance);
+
+ // unlock token in case it leaves the node
token.unlock(this.toString());
+ // prepare execution context
ExecutionContext executionContext = new ExecutionContext(token);
+ // then execute the node
node.execute(executionContext);
return true;
}
-
+
public Node getNode() {
return node;
}
+
public void setNode(Node node) {
this.node = node;
}
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/Timer.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-02-28 16:55:18 UTC (rev 4087)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/Timer.java 2009-02-28 21:26:56 UTC (rev 4088)
@@ -20,13 +20,13 @@
private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
static BusinessCalendar businessCalendar = new BusinessCalendar();
-
+
String name;
String repeat;
String transitionName = null;
Action action = null;
GraphElement graphElement = null;
-
+
public Timer() {
}
@@ -35,57 +35,62 @@
}
public boolean execute(JbpmContext jbpmContext) throws Exception {
+ // register process instance for automatic save
+ // see https://jira.jboss.org/jira/browse/JBPM-1015
+ jbpmContext.addAutoSaveProcessInstance(processInstance);
+
+ // prepare execution context
ExecutionContext executionContext = new ExecutionContext(token);
executionContext.setTimer(this);
+ if (taskInstance != null) executionContext.setTaskInstance(taskInstance);
- if (taskInstance!=null) {
- executionContext.setTaskInstance(taskInstance);
- }
-
// first fire the event if there is a graph element specified
- if (graphElement!=null) {
+ if (graphElement != null) {
graphElement.fireAndPropagateEvent(Event.EVENTTYPE_TIMER, executionContext);
}
// then execute the action if there is one
- if (action!=null) {
+ if (action != null) {
try {
- log.debug("executing '"+this+"'");
- if (graphElement!=null) {
+ log.debug("executing " + this);
+ if (graphElement != null) {
graphElement.executeAction(action, executionContext);
- } else {
+ }
+ else {
action.execute(executionContext);
}
- } catch (Exception actionException) {
+ }
+ catch (Exception actionException) {
// NOTE that Error's are not caught because that might halt the JVM and mask the original Error.
log.warn("timer action threw exception", actionException);
// if there is a graphElement connected to this timer...
if (graphElement != null) {
try {
- // we give that graphElement a chance to catch the exception
+ // give that graphElement a chance to catch the exception
graphElement.raiseException(actionException, executionContext);
- log.debug("timer exception got handled by '"+graphElement+"'");
- } catch (Exception handlerException) {
+ log.debug("timer exception got handled by '" + graphElement + "'");
+ }
+ catch (Exception handlerException) {
// if the exception handler rethrows or the original exception results in a DelegationException...
throw handlerException;
}
- } else {
+ }
+ else {
throw actionException;
}
}
}
// then take a transition if one is specified
- if ( (transitionName!=null)
- && (exception==null) // and if no unhandled exception occurred during the action
- ) {
+ // and if no unhandled exception occurred during the action
+ if (transitionName != null && exception == null) {
if (token.getNode().hasLeavingTransition(transitionName)) {
token.signal(transitionName);
}
}
// if repeat is specified, reschedule the job
- if (repeat!=null) {
+ if (repeat != null) {
// suppose that it took the timer runner thread a
// very long time to execute the timers.
// then the repeat action dueDate could already have passed.
@@ -108,26 +113,22 @@
return false;
}
-
+
return true;
}
-
+
public String toString() {
StringBuilder text = new StringBuilder("Timer");
if (name != null || dueDate != null) {
text.append('(');
- if (name!=null)
- text.append(name).append(",");
- if (dueDate!=null)
- text.append(formatDueDate(dueDate)).append(",");
- if (taskInstance!=null)
- text.append(taskInstance).append(",");
+ if (name != null) text.append(name).append(",");
+ if (dueDate != null) text.append(formatDueDate(dueDate)).append(",");
+ if (taskInstance != null) text.append(taskInstance).append(",");
- if (token!=null)
+ if (token != null)
text.append(token);
- else if (processInstance!=null)
- text.append(processInstance);
+ else if (processInstance != null) text.append(processInstance);
text.append(')');
}
@@ -141,33 +142,42 @@
public String getRepeat() {
return repeat;
}
+
public void setRepeat(String repeat) {
this.repeat = repeat;
}
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
+
public String getTransitionName() {
return transitionName;
}
+
public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
}
+
public GraphElement getGraphElement() {
return graphElement;
}
+
public void setGraphElement(GraphElement graphElement) {
this.graphElement = graphElement;
}
+
public Action getAction() {
return action;
}
+
public void setAction(Action action) {
this.action = action;
}
-
+
private static Log log = LogFactory.getLog(Timer.class);
}
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-02-28 16:55:18 UTC (rev 4087)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-02-28 21:26:56 UTC (rev 4088)
@@ -164,10 +164,6 @@
JobSession jobSession = jbpmContext.getJobSession();
job = jobSession.loadJob(job.getId());
- // register process instance for automatic save
- // see https://jira.jboss.org/jira/browse/JBPM-1015
- jbpmContext.addAutoSaveProcessInstance(job.getProcessInstance());
-
log.debug("executing " + job);
try {
if (job.execute(jbpmContext)) {
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-02-28 16:55:18 UTC (rev 4087)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-02-28 21:26:56 UTC (rev 4088)
@@ -29,7 +29,6 @@
import org.jbpm.JbpmContext;
import org.jbpm.JbpmException;
import org.jbpm.command.Command;
-import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.job.Job;
import org.jbpm.persistence.db.DbPersistenceService;
@@ -57,14 +56,9 @@
private Job acquireJob(JbpmContext jbpmContext) {
Job job = jbpmContext.getJobSession().loadJob(jobId);
- // register process instance for automatic save
- // see https://jira.jboss.org/jira/browse/JBPM-1015
- ProcessInstance processInstance = job.getProcessInstance();
- jbpmContext.addAutoSaveProcessInstance(processInstance);
-
// if job is exclusive, lock process instance
if (job.isExclusive()) {
- jbpmContext.getGraphSession().lockProcessInstance(processInstance);
+ jbpmContext.getGraphSession().lockProcessInstance(job.getProcessInstance());
}
// mark job as locked to prevent other parts of the engine from deleting it
15 years, 2 months
JBoss JBPM SVN: r4087 - jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 11:55:18 -0500 (Sat, 28 Feb 2009)
New Revision: 4087
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
Log:
Clear the real list, not the copy
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 15:52:35 UTC (rev 4086)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 16:55:18 UTC (rev 4087)
@@ -643,15 +643,15 @@
static void clearJbpmConfigurationStack()
{
- List<JbpmConfiguration> configStack = new ArrayList<JbpmConfiguration>(getJbpmConfigurationStack());
+ List<JbpmConfiguration> configStack = getJbpmConfigurationStack();
if (configStack != null)
{
- for (JbpmConfiguration config : configStack)
+ for (JbpmConfiguration config : new ArrayList<JbpmConfiguration>(configStack))
{
- List<JbpmContext> contextStack = new ArrayList<JbpmContext>(config.getJbpmContextStack());
+ List<JbpmContext> contextStack = config.getJbpmContextStack();
if (contextStack != null)
{
- for (JbpmContext context : contextStack)
+ for (JbpmContext context : new ArrayList<JbpmContext>(contextStack))
{
context.close();
}
15 years, 2 months
JBoss JBPM SVN: r4086 - in jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs: jBPM3-Database-Matrix and 2 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 10:52:35 -0500 (Sat, 28 Feb 2009)
New Revision: 4086
Modified:
jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml
jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml
jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.5/config.xml
jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.6/config.xml
Log:
Remove dependency on $HUDSON_BASE
Modified: jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml 2009-02-28 15:48:09 UTC (rev 4085)
+++ jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Container-Matrix/config.xml 2009-02-28 15:52:35 UTC (rev 4086)
@@ -62,7 +62,6 @@
export CONTAINER=$container
export DATABASE=$database
-export HUDSON_BASE=(a)hudson.base@
export JBPM_VERSION=(a)version.id@
export JBOSS_SERVER=(a)jboss.server.instance@
export JBOSS_BINDADDR=(a)jboss.bind.address@
Modified: jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml 2009-02-28 15:48:09 UTC (rev 4085)
+++ jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-Database-Matrix/config.xml 2009-02-28 15:52:35 UTC (rev 4086)
@@ -63,7 +63,6 @@
export CONTAINER=$container
export DATABASE=$database
-export HUDSON_BASE=(a)hudson.base@
export JBPM_VERSION=(a)version.id@
export JBOSS_SERVER=(a)jboss.server.instance@
export JBOSS_BINDADDR=(a)jboss.bind.address@
Modified: jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.5/config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.5/config.xml 2009-02-28 15:48:09 UTC (rev 4085)
+++ jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.5/config.xml 2009-02-28 15:52:35 UTC (rev 4086)
@@ -47,7 +47,6 @@
WORKSPACE=`pwd`
JBPMDIR=$WORKSPACE/jbpm
-export HUDSON_BASE=(a)hudson.base@
export JBPM_VERSION=(a)version.id@
export JBOSS_SERVER=(a)jboss.server.instance@
export JBOSS_BINDADDR=(a)jboss.bind.address@
Modified: jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.6/config.xml
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.6/config.xml 2009-02-28 15:48:09 UTC (rev 4085)
+++ jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/jobs/jBPM3-JDK1.6/config.xml 2009-02-28 15:52:35 UTC (rev 4086)
@@ -47,7 +47,6 @@
WORKSPACE=`pwd`
JBPMDIR=$WORKSPACE/jbpm
-export HUDSON_BASE=(a)hudson.base@
export JBPM_VERSION=(a)version.id@
export JBOSS_SERVER=(a)jboss.server.instance@
export JBOSS_BINDADDR=(a)jboss.bind.address@
15 years, 2 months
JBoss JBPM SVN: r4085 - jbpm3/trunk/hudson/hudson-home.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 10:48:09 -0500 (Sat, 28 Feb 2009)
New Revision: 4085
Modified:
jbpm3/trunk/hudson/hudson-home/command.sh
Log:
Remove dependency on
Modified: jbpm3/trunk/hudson/hudson-home/command.sh
===================================================================
--- jbpm3/trunk/hudson/hudson-home/command.sh 2009-02-28 15:27:56 UTC (rev 4084)
+++ jbpm3/trunk/hudson/hudson-home/command.sh 2009-02-28 15:48:09 UTC (rev 4085)
@@ -27,7 +27,7 @@
# Unzip the JBoss build
#
rm -rf $JBOSS_BUILD
-unzip -q $HUDSON_BASE/jboss/$JBOSS_BUILD.zip
+unzip -q $HUDSON_HOME/../jboss/$JBOSS_BUILD.zip
JBOSS_HOME=$WORKSPACE/$JBOSS_BUILD
ENVIRONMENT="-Ddatabase=$DATABASE -Djbpm.target.container=$CONTAINER -Djboss.home=$JBOSS_HOME -Djboss.bind.address=$JBOSS_BINDADDR"
15 years, 2 months
JBoss JBPM SVN: r4084 - jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 10:27:56 -0500 (Sat, 28 Feb 2009)
New Revision: 4084
Modified:
jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/command.sh
Log:
Try out dependency on $HUDSON_HOME
Modified: jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/command.sh
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/command.sh 2009-02-28 14:56:34 UTC (rev 4083)
+++ jbpm3/branches/jbpm-3.2.6.GA/hudson/hudson-home/command.sh 2009-02-28 15:27:56 UTC (rev 4084)
@@ -27,7 +27,7 @@
# Unzip the JBoss build
#
rm -rf $JBOSS_BUILD
-unzip -q $HUDSON_BASE/jboss/$JBOSS_BUILD.zip
+unzip -q $HUDSON_HOME/../jboss/$JBOSS_BUILD.zip
JBOSS_HOME=$WORKSPACE/$JBOSS_BUILD
ENVIRONMENT="-Ddatabase=$DATABASE -Djbpm.target.container=$CONTAINER -Djboss.home=$JBOSS_HOME -Djboss.bind.address=$JBOSS_BINDADDR"
15 years, 2 months
JBoss JBPM SVN: r4083 - in jbpm3/branches/jbpm-3.2.6.GA/modules/core/src: test/java/org/jbpm and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-02-28 09:56:34 -0500 (Sat, 28 Feb 2009)
New Revision: 4083
Modified:
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
Log:
Add clearJbpmConfigurationStack to enable more explicit cleanup
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 12:06:41 UTC (rev 4082)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2009-02-28 14:56:34 UTC (rev 4083)
@@ -26,8 +26,8 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -248,7 +248,8 @@
* </tr>
* </table>
*/
-public class JbpmConfiguration implements Serializable {
+public class JbpmConfiguration implements Serializable
+{
private static final long serialVersionUID = 1L;
@@ -261,45 +262,55 @@
private JobExecutor jobExecutor;
private boolean isClosed;
- static class StackThreadLocal<E> extends ThreadLocal<List<E>> {
+ static class StackThreadLocal<E> extends ThreadLocal<List<E>>
+ {
@Override
- protected List<E> initialValue() {
+ protected List<E> initialValue()
+ {
return new ArrayList<E>();
}
}
- public JbpmConfiguration(ObjectFactory objectFactory) {
+ public JbpmConfiguration(ObjectFactory objectFactory)
+ {
this.objectFactory = objectFactory;
}
- public static JbpmConfiguration getInstance() {
+ public static JbpmConfiguration getInstance()
+ {
return getInstance(null);
}
- public static JbpmConfiguration getInstance(String resource) {
- if (resource == null) {
+ public static JbpmConfiguration getInstance(String resource)
+ {
+ if (resource == null)
+ {
resource = "jbpm.cfg.xml";
}
JbpmConfiguration instance;
- synchronized (instances) {
+ synchronized (instances)
+ {
// look for configuration in cache
instance = instances.get(resource);
- if (instance == null) {
+ if (instance == null)
+ {
// configuration does not exist or was evicted, construct it
- if (defaultObjectFactory != null) {
+ if (defaultObjectFactory != null)
+ {
log.debug("creating configuration from default object factory: " + defaultObjectFactory);
instance = new JbpmConfiguration(defaultObjectFactory);
}
- else {
+ else
+ {
log.info("using configuration resource: " + resource);
InputStream jbpmCfgXmlStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
/*
- * if a custom resource is specified, but not found in the classpath, log a warning;
- * otherwise, users who want to load custom stuff will not receive any feedback when their
- * resource cannot be found
+ * if a custom resource is specified, but not found in the classpath, log a warning; otherwise, users who want to load custom stuff will not receive any
+ * feedback when their resource cannot be found
*/
- if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource)) {
+ if (jbpmCfgXmlStream == null && !"jbpm.cfg.xml".equals(resource))
+ {
log.warn("configuration resource '" + resource + "' could not be found");
}
ObjectFactory objectFactory = parseObjectFactory(jbpmCfgXmlStream);
@@ -312,18 +323,20 @@
return instance;
}
- public static boolean hasInstance(String resource) {
+ public static boolean hasInstance(String resource)
+ {
return instances.containsKey(resource != null ? resource : "jbpm.cfg.xml");
}
- protected static ObjectFactory parseObjectFactory(InputStream inputStream) {
+ protected static ObjectFactory parseObjectFactory(InputStream inputStream)
+ {
log.debug("loading defaults in jbpm configuration");
ObjectFactoryParser objectFactoryParser = new ObjectFactoryParser();
ObjectFactoryImpl objectFactoryImpl = new ObjectFactoryImpl();
- objectFactoryParser.parseElementsFromResource("org/jbpm/default.jbpm.cfg.xml",
- objectFactoryImpl);
+ objectFactoryParser.parseElementsFromResource("org/jbpm/default.jbpm.cfg.xml", objectFactoryImpl);
- if (inputStream != null) {
+ if (inputStream != null)
+ {
log.debug("loading specific configuration...");
objectFactoryParser.parseElementsStream(inputStream, objectFactoryImpl);
}
@@ -331,26 +344,31 @@
return objectFactoryImpl;
}
- public static JbpmConfiguration parseXmlString(String xml) {
+ public static JbpmConfiguration parseXmlString(String xml)
+ {
log.debug("creating jbpm configuration from xml string");
InputStream inputStream = null;
- if (xml != null) {
+ if (xml != null)
+ {
inputStream = new ByteArrayInputStream(xml.getBytes());
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory) {
+ protected static JbpmConfiguration createJbpmConfiguration(ObjectFactory objectFactory)
+ {
JbpmConfiguration jbpmConfiguration = new JbpmConfiguration(objectFactory);
// make the bean jbpm.configuration always available
- if (objectFactory instanceof ObjectFactoryImpl) {
- ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl) objectFactory;
+ if (objectFactory instanceof ObjectFactoryImpl)
+ {
+ ObjectFactoryImpl objectFactoryImpl = (ObjectFactoryImpl)objectFactory;
ObjectInfo jbpmConfigurationInfo = new ValueInfo("jbpmConfiguration", jbpmConfiguration);
objectFactoryImpl.addObjectInfo(jbpmConfigurationInfo);
- if (getHideStaleObjectExceptions(objectFactory)) {
+ if (getHideStaleObjectExceptions(objectFactory))
+ {
StaleObjectLogConfigurer.hideStaleObjectExceptions();
}
}
@@ -358,184 +376,226 @@
return jbpmConfiguration;
}
- private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory) {
- if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions")) return true;
+ private static boolean getHideStaleObjectExceptions(ObjectFactory objectFactory)
+ {
+ if (!objectFactory.hasObject("jbpm.hide.stale.object.exceptions"))
+ return true;
Object object = objectFactory.createObject("jbpm.hide.stale.object.exceptions");
- return object instanceof Boolean ? (Boolean) object : true;
+ return object instanceof Boolean ? (Boolean)object : true;
}
- public static JbpmConfiguration parseInputStream(InputStream inputStream) {
+ public static JbpmConfiguration parseInputStream(InputStream inputStream)
+ {
log.debug("creating jbpm configuration from input stream");
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- public static JbpmConfiguration parseResource(String resource) {
+ public static JbpmConfiguration parseResource(String resource)
+ {
log.debug("creating jbpm configuration from resource: " + resource);
InputStream inputStream = null;
- if (resource != null) {
+ if (resource != null)
+ {
inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
}
- public JbpmContext createJbpmContext() {
+ public JbpmContext createJbpmContext()
+ {
return createJbpmContext(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public JbpmContext createJbpmContext(String name) {
+ public JbpmContext createJbpmContext(String name)
+ {
ensureOpen();
- JbpmContext jbpmContext = (JbpmContext) objectFactory.createObject(name);
+ JbpmContext jbpmContext = (JbpmContext)objectFactory.createObject(name);
jbpmContext.jbpmConfiguration = this;
jbpmContextCreated(jbpmContext);
return jbpmContext;
}
- private void ensureOpen() {
- if (isClosed) throw new JbpmException("configuration closed");
+ private void ensureOpen()
+ {
+ if (isClosed)
+ throw new JbpmException("configuration closed");
}
- public ServiceFactory getServiceFactory(String serviceName) {
+ public ServiceFactory getServiceFactory(String serviceName)
+ {
return getServiceFactory(serviceName, JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName) {
+ public ServiceFactory getServiceFactory(String serviceName, String jbpmContextName)
+ {
ServiceFactory serviceFactory = null;
JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try {
+ try
+ {
serviceFactory = jbpmContext.getServices().getServiceFactory(serviceName);
}
- finally {
+ finally
+ {
jbpmContext.close();
}
return serviceFactory;
}
- public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition)
+ {
ProcessClassLoaderFactory factory = null;
- if (Configs.hasObject("jbpm.processClassLoader")) {
- factory = (ProcessClassLoaderFactory) Configs.getObject("jbpm.processClassLoader");
+ if (Configs.hasObject("jbpm.processClassLoader"))
+ {
+ factory = (ProcessClassLoaderFactory)Configs.getObject("jbpm.processClassLoader");
}
- else {
+ else
+ {
factory = new DefaultProcessClassLoaderFactory();
}
return factory.getProcessClassLoader(processDefinition);
}
- /**
+ /*
* gives the jbpm domain model access to configuration information via the current JbpmContext.
*/
- public static class Configs {
+ public static class Configs
+ {
- private Configs() {
+ private Configs()
+ {
// hide default constructor to prevent instantiation
}
- public static ObjectFactory getObjectFactory() {
+ public static ObjectFactory getObjectFactory()
+ {
ObjectFactory objectFactory = null;
JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
- if (jbpmContext != null) {
+ if (jbpmContext != null)
+ {
objectFactory = jbpmContext.objectFactory;
}
- else {
+ else
+ {
objectFactory = getInstance().objectFactory;
}
return objectFactory;
}
- public static void setDefaultObjectFactory(ObjectFactory objectFactory) {
+ public static void setDefaultObjectFactory(ObjectFactory objectFactory)
+ {
defaultObjectFactory = objectFactory;
}
- public static boolean hasObject(String name) {
+ public static boolean hasObject(String name)
+ {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.hasObject(name);
}
- public static synchronized Object getObject(String name) {
+ public static synchronized Object getObject(String name)
+ {
ObjectFactory objectFactory = getObjectFactory();
return objectFactory.createObject(name);
}
- public static String getString(String name) {
- return (String) getObject(name);
+ public static String getString(String name)
+ {
+ return (String)getObject(name);
}
- public static long getLong(String name) {
- return ((Long) getObject(name)).longValue();
+ public static long getLong(String name)
+ {
+ return ((Long)getObject(name)).longValue();
}
- public static int getInt(String name) {
- return ((Integer) getObject(name)).intValue();
+ public static int getInt(String name)
+ {
+ return ((Integer)getObject(name)).intValue();
}
- public static boolean getBoolean(String name) {
- return ((Boolean) getObject(name)).booleanValue();
+ public static boolean getBoolean(String name)
+ {
+ return ((Boolean)getObject(name)).booleanValue();
}
}
- public void cleanSchema() {
+ public void cleanSchema()
+ {
cleanSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void cleanSchema(String jbpmContextName) {
+ public void cleanSchema(String jbpmContextName)
+ {
getPersistenceServiceFactory(jbpmContextName).cleanSchema();
}
- public void createSchema() {
+ public void createSchema()
+ {
createSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void createSchema(String jbpmContextName) {
+ public void createSchema(String jbpmContextName)
+ {
getPersistenceServiceFactory(jbpmContextName).createSchema();
}
- public void dropSchema() {
+ public void dropSchema()
+ {
dropSchema(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void dropSchema(String jbpmContextName) {
+ public void dropSchema(String jbpmContextName)
+ {
getPersistenceServiceFactory(jbpmContextName).dropSchema();
}
- private DbPersistenceServiceFactory getPersistenceServiceFactory(String jbpmContextName) {
- return (DbPersistenceServiceFactory) getServiceFactory(Services.SERVICENAME_PERSISTENCE,
- jbpmContextName);
+ private DbPersistenceServiceFactory getPersistenceServiceFactory(String jbpmContextName)
+ {
+ return (DbPersistenceServiceFactory)getServiceFactory(Services.SERVICENAME_PERSISTENCE, jbpmContextName);
}
- public boolean isClosed() {
+ public boolean isClosed()
+ {
return isClosed;
}
- public void close() {
+ public void close()
+ {
close(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME);
}
- public void close(String jbpmContextName) {
+ public void close(String jbpmContextName)
+ {
// prevent configuration from being closed more than once
- if (isClosed) return;
+ if (isClosed)
+ return;
// stop job executor
- if (jobExecutor != null) {
+ if (jobExecutor != null)
+ {
jobExecutor.stop();
jobExecutor = null;
}
// close service factories
JbpmContext jbpmContext = createJbpmContext(jbpmContextName);
- try {
- Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices()
- .getServiceFactories();
- if (serviceFactories != null) {
- for (ServiceFactory serviceFactory : serviceFactories.values()) {
+ try
+ {
+ Map<String, ServiceFactory> serviceFactories = jbpmContext.getServices().getServiceFactories();
+ if (serviceFactories != null)
+ {
+ for (ServiceFactory serviceFactory : serviceFactories.values())
+ {
serviceFactory.close();
}
}
}
- finally {
+ finally
+ {
jbpmContext.close();
}
@@ -546,9 +606,12 @@
jbpmContextStacks.remove();
// remove from configuration cache
- synchronized (instances) {
- for (java.util.Iterator<JbpmConfiguration> i = instances.values().iterator(); i.hasNext();) {
- if (this == i.next()) {
+ synchronized (instances)
+ {
+ for (java.util.Iterator<JbpmConfiguration> i = instances.values().iterator(); i.hasNext();)
+ {
+ if (this == i.next())
+ {
i.remove();
break;
}
@@ -557,89 +620,127 @@
}
@Override
- protected void finalize() throws Throwable {
+ protected void finalize() throws Throwable
+ {
close();
}
- static JbpmConfiguration getCurrentJbpmConfiguration() {
+ static JbpmConfiguration getCurrentJbpmConfiguration()
+ {
JbpmConfiguration currentJbpmConfiguration = null;
List<JbpmConfiguration> stack = getJbpmConfigurationStack();
- if (!stack.isEmpty()) {
+ if (!stack.isEmpty())
+ {
currentJbpmConfiguration = stack.get(stack.size() - 1);
}
return currentJbpmConfiguration;
}
- static List<JbpmConfiguration> getJbpmConfigurationStack() {
+ static List<JbpmConfiguration> getJbpmConfigurationStack()
+ {
return jbpmConfigurationStacks.get();
}
- synchronized void pushJbpmConfiguration() {
+ static void clearJbpmConfigurationStack()
+ {
+ List<JbpmConfiguration> configStack = new ArrayList<JbpmConfiguration>(getJbpmConfigurationStack());
+ if (configStack != null)
+ {
+ for (JbpmConfiguration config : configStack)
+ {
+ List<JbpmContext> contextStack = new ArrayList<JbpmContext>(config.getJbpmContextStack());
+ if (contextStack != null)
+ {
+ for (JbpmContext context : contextStack)
+ {
+ context.close();
+ }
+ }
+ contextStack.clear();
+ }
+ configStack.clear();
+ }
+ }
+
+ synchronized void pushJbpmConfiguration()
+ {
getJbpmConfigurationStack().add(this);
}
- synchronized void popJbpmConfiguration() {
+ synchronized void popJbpmConfiguration()
+ {
getJbpmConfigurationStack().remove(this);
}
- public JbpmContext getCurrentJbpmContext() {
+ public JbpmContext getCurrentJbpmContext()
+ {
ensureOpen();
JbpmContext currentJbpmContext = null;
List<JbpmContext> stack = getJbpmContextStack();
- if (!stack.isEmpty()) {
+ if (!stack.isEmpty())
+ {
currentJbpmContext = stack.get(stack.size() - 1);
}
return currentJbpmContext;
}
- List<JbpmContext> getJbpmContextStack() {
+ List<JbpmContext> getJbpmContextStack()
+ {
return jbpmContextStacks.get();
}
- void pushJbpmContext(JbpmContext jbpmContext) {
+ void pushJbpmContext(JbpmContext jbpmContext)
+ {
getJbpmContextStack().add(jbpmContext);
}
- void popJbpmContext(JbpmContext jbpmContext) {
+ void popJbpmContext(JbpmContext jbpmContext)
+ {
List<JbpmContext> stack = getJbpmContextStack();
int size = stack.size();
- if (size == 0) {
- log.warn("closed JbpmContext more than once... "
- + "check your try-finally clauses around JbpmContext blocks");
+ if (size == 0)
+ {
+ log.warn("closed JbpmContext more than once... " + "check your try-finally clauses around JbpmContext blocks");
}
- else if (jbpmContext != stack.remove(size - 1)) {
+ else if (jbpmContext != stack.remove(size - 1))
+ {
stack.remove(jbpmContext); // prevent context from remaining in the stack
- log.warn("closed JbpmContext in some order that differs from creation... "
- + "check your try-finally clauses around JbpmContext blocks");
+ log.warn("closed JbpmContext in some order that differs from creation... " + "check your try-finally clauses around JbpmContext blocks");
}
}
- void jbpmContextCreated(JbpmContext jbpmContext) {
+ void jbpmContextCreated(JbpmContext jbpmContext)
+ {
pushJbpmConfiguration();
pushJbpmContext(jbpmContext);
}
- void jbpmContextClosed(JbpmContext jbpmContext) {
+ void jbpmContextClosed(JbpmContext jbpmContext)
+ {
popJbpmContext(jbpmContext);
popJbpmConfiguration();
}
- public void startJobExecutor() {
+ public void startJobExecutor()
+ {
getJobExecutor().start();
}
- public synchronized JobExecutor getJobExecutor() {
+ public synchronized JobExecutor getJobExecutor()
+ {
ensureOpen();
- if (jobExecutor == null) {
+ if (jobExecutor == null)
+ {
Object object = objectFactory.createObject("jbpm.job.executor");
- if (object instanceof JobExecutor) {
- jobExecutor = (JobExecutor) object;
+ if (object instanceof JobExecutor)
+ {
+ jobExecutor = (JobExecutor)object;
}
- else if (object != null) {
- throw new JbpmException("configuration object named 'jbpm.job.executor' is not a "
- + JobExecutor.class.getSimpleName());
+ else if (object != null)
+ {
+ throw new JbpmException("configuration object named 'jbpm.job.executor' is not a " + JobExecutor.class.getSimpleName());
}
}
return jobExecutor;
Modified: jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 12:06:41 UTC (rev 4082)
+++ jbpm3/branches/jbpm-3.2.6.GA/modules/core/src/test/java/org/jbpm/JbpmConfigurationTest.java 2009-02-28 14:56:34 UTC (rev 4083)
@@ -28,17 +28,19 @@
import org.jbpm.configuration.ObjectFactoryParser;
import org.jbpm.util.XmlException;
-public class JbpmConfigurationTest extends AbstractJbpmTestCase {
+public class JbpmConfigurationTest extends AbstractJbpmTestCase
+{
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
+ JbpmConfiguration.clearJbpmConfigurationStack();
+ JbpmConfiguration.defaultObjectFactory = null;
JbpmConfiguration.instances.clear();
- JbpmConfiguration.defaultObjectFactory = null;
- JbpmConfiguration.jbpmConfigurationStacks.remove();
}
-
- public void testSingleton() {
+
+ public void testSingleton()
+ {
JbpmConfiguration.defaultObjectFactory = new ObjectFactoryImpl(null, null);
JbpmConfiguration instance = JbpmConfiguration.getInstance();
assertNotNull(instance);
@@ -47,36 +49,38 @@
assertSame(instance, JbpmConfiguration.getInstance());
}
- public void testDefaultContextCreation() {
+ public void testDefaultContextCreation()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='"+JbpmContext.DEFAULT_JBPM_CONTEXT_NAME+"' />" +
- "</jbpm-configuration>"
- );
+ "<jbpm-configuration>" +
+ " <jbpm-context name='" + JbpmContext.DEFAULT_JBPM_CONTEXT_NAME + "' />" +
+ "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
assertNotNull(jbpmConfiguration.createJbpmContext());
}
- public void testNonExistingContext() {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration />"
- );
+ public void testNonExistingContext()
+ {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString("<jbpm-configuration />");
assertNotNull(jbpmConfiguration);
- try {
+ try
+ {
jbpmConfiguration.createJbpmContext("non-existing-context");
fail("expected exception");
- } catch (ConfigurationException e) {
- //OK
}
+ catch (ConfigurationException e)
+ {
+ // OK
+ }
}
- public void testParseXmlStringConfiguration() {
+ public void testParseXmlStringConfiguration()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- " <jbpm-context name='b' />" +
- "</jbpm-configuration>"
- );
+ "<jbpm-configuration>" +
+ " <jbpm-context name='a' />" +
+ " <jbpm-context name='b' />" +
+ "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
JbpmContext a = jbpmConfiguration.createJbpmContext("a");
assertNotNull(a);
@@ -85,12 +89,12 @@
assertNotSame(a, b);
}
- public void testNonSingletonContextCreation() {
+ public void testNonSingletonContextCreation()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='a' />" +
- "</jbpm-configuration>"
- );
+ "<jbpm-configuration>" +
+ " <jbpm-context name='a' />" +
+ "</jbpm-configuration>");
assertNotNull(jbpmConfiguration);
JbpmContext a = jbpmConfiguration.createJbpmContext("a");
assertNotNull(a);
@@ -99,111 +103,131 @@
assertNotSame(a, a2);
}
- public void testParseXmlFault() {
- try {
+ public void testParseXmlFault()
+ {
+ try
+ {
JbpmConfiguration.parseXmlString("< problematic // <</> <x>M/L");
fail("expected exception");
- } catch (XmlException e) {
+ }
+ catch (XmlException e)
+ {
// OK
}
}
- public void testDomainModelConfigsWithoutJbpmContext() {
- // Without a current JbpmContext, the jbpm domain model objects that
- // need configuration information fetch it from the object factory of
- // the singleton instance. The singleton instance object factory is
- // by default initialized with the jbpm.cfg.xml resource unless, a
+ public void testDomainModelConfigsWithoutJbpmContext()
+ {
+ // Without a current JbpmContext, the jbpm domain model objects that
+ // need configuration information fetch it from the object factory of
+ // the singleton instance. The singleton instance object factory is
+ // by default initialized with the jbpm.cfg.xml resource unless, a
// custom default object factory is specified.
//
- // So to use jBPM without a JbpmContext, you can only use the resource with name
+ // So to use jBPM without a JbpmContext, you can only use the resource with name
// 'jbpm.cfg.xml' or the static method JbpmConfiguration.Configs.setDefaultObjectFactory
// to specify the configuration information.
- JbpmConfiguration.Configs.setDefaultObjectFactory(
- ObjectFactoryParser.parseXmlString(
- "<jbpm-configuration>" +
- " <string name='myproperty'>myvalue</string>" +
- "</jbpm-configuration>"
- )
- );
+ JbpmConfiguration.Configs.setDefaultObjectFactory(ObjectFactoryParser.parseXmlString(
+ "<jbpm-configuration>" +
+ " <string name='myproperty'>myvalue</string>" +
+ "</jbpm-configuration>"));
assertEquals("myvalue", JbpmConfiguration.Configs.getString("myproperty"));
}
- public static class CustomObjectFactory implements ObjectFactory {
+ public static class CustomObjectFactory implements ObjectFactory
+ {
private static final long serialVersionUID = 1L;
- public Object createObject(String name) {
+
+ public Object createObject(String name)
+ {
Object o = null;
- if ("myproperty".equals(name)) {
+ if ("myproperty".equals(name))
+ {
o = "mycustomfactoriedvalue";
}
return o;
}
- public boolean hasObject(String name) {
+
+ public boolean hasObject(String name)
+ {
return "myproperty".equals(name);
}
}
- public void testDomainModelConfigsWithCustomObjectFactory() {
- JbpmConfiguration.Configs.setDefaultObjectFactory(
- new CustomObjectFactory()
- );
+ public void testDomainModelConfigsWithCustomObjectFactory()
+ {
+ JbpmConfiguration.Configs.setDefaultObjectFactory(new CustomObjectFactory());
assertEquals("mycustomfactoriedvalue", JbpmConfiguration.Configs.getString("myproperty"));
}
- public void testDomainModelConfigsWithJbpmContext() {
+ public void testDomainModelConfigsWithJbpmContext()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>"
- );
+ "<jbpm-configuration>" +
+ " <jbpm-context name='default.jbpm.context' />" +
+ " <string name='myproperty'>myvalueinacontext</string>" +
+ "</jbpm-configuration>");
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+ try
+ {
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally
+ {
jbpmContext.close();
}
}
- public void testDomainModelConfigsWithNestedJbpmContext() {
+ public void testDomainModelConfigsWithNestedJbpmContext()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinacontext</string>" +
- "</jbpm-configuration>"
- );
+ "<jbpm-configuration>" +
+ " <jbpm-context name='default.jbpm.context' />" +
+ " <string name='myproperty'>myvalueinacontext</string>" +
+ "</jbpm-configuration>");
+
JbpmConfiguration nestedJbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <jbpm-context name='default.jbpm.context' />" +
- " <string name='myproperty'>myvalueinanestedcontext</string>" +
- "</jbpm-configuration>"
- );
-
+ "<jbpm-configuration>" +
+ " <jbpm-context name='default.jbpm.context' />" +
+ " <string name='myproperty'>myvalueinanestedcontext</string>" +
+ "</jbpm-configuration>");
+
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
+ try
+ {
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
JbpmContext nestedJbpmContext = nestedJbpmConfiguration.createJbpmContext();
- try {
+ try
+ {
assertEquals("myvalueinanestedcontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally
+ {
nestedJbpmContext.close();
}
-
+
assertEquals("myvalueinacontext", JbpmConfiguration.Configs.getString("myproperty"));
- } finally {
+ }
+ finally
+ {
jbpmContext.close();
}
}
- public void testJbpmConfigurationClose() {
+ public void testJbpmConfigurationClose()
+ {
JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
SessionFactory sessionFactory;
- try {
+ try
+ {
sessionFactory = jbpmContext.getSessionFactory();
- } finally {
+ }
+ finally
+ {
jbpmContext.close();
}
jbpmConfiguration.close();
15 years, 2 months