JBoss JBPM SVN: r1861 - in jbpm4/pvm/trunk/modules/core/src/main: java/org/jbpm/pvm/internal/wire/binding and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-08-11 05:59:19 -0400 (Mon, 11 Aug 2008)
New Revision: 1861
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
Log:
renamed transition.guardCondition to transition.condition: JBPM-1461
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2008-08-11 09:59:19 UTC (rev 1861)
@@ -23,6 +23,8 @@
import java.util.List;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.model.Condition;
import org.jbpm.pvm.model.Event;
import org.jbpm.pvm.model.Transition;
@@ -37,8 +39,8 @@
protected NodeImpl source;
protected NodeImpl destination;
- protected ObjectReference<Condition> guardConditionReference;
- protected ObjectReference<Condition> waitConditionReference;
+ protected Descriptor conditionDescriptor;
+ protected Descriptor waitConditionDescriptor;
protected boolean isTakeAsync;
/* Use one of the NodeImpl.createOutgoingTransition methods instead. */
@@ -118,12 +120,18 @@
}
}
- public Condition getGuardCondition() {
- return ( guardConditionReference!=null ? guardConditionReference.get() : null );
+ public Condition getCondition() {
+ if (conditionDescriptor==null) {
+ return null;
+ }
+ return (Condition) WireContext.create(conditionDescriptor);
}
public Condition getWaitCondition() {
- return ( waitConditionReference!=null ? waitConditionReference.get() : null );
+ if (waitConditionDescriptor==null) {
+ return null;
+ }
+ return (Condition) WireContext.create(waitConditionDescriptor);
}
public EventImpl getEvent() {
@@ -141,21 +149,21 @@
public void setDestination(NodeImpl destination) {
this.destination = destination;
}
- /** see <a href="#guardconditions">Guard conditions</a> */
- public ObjectReference<Condition> getGuardConditionReference() {
- return guardConditionReference;
+ /** see <a href="#conditions">Conditions</a> */
+ public Descriptor getConditionDescriptor() {
+ return conditionDescriptor;
}
- /** see <a href="#guardconditions">Guard conditions</a> */
- public void setGuardConditionReference(ObjectReference<Condition> guardConditionReference) {
- this.guardConditionReference = guardConditionReference;
+ /** see <a href="#conditions">Conditions</a> */
+ public void setConditionDescriptor(Descriptor conditionDescriptor) {
+ this.conditionDescriptor = conditionDescriptor;
}
/** see <a href="#waitconditions">Wait conditions</a> */
- public ObjectReference<Condition> getWaitConditionReference() {
- return waitConditionReference;
+ public Descriptor getWaitConditionDescriptor() {
+ return waitConditionDescriptor;
}
/** see <a href="#waitconditions">Wait conditions</a> */
- public void setWaitConditionReferenceConditionReference(ObjectReference<Condition> waitConditionReference) {
- this.waitConditionReference = waitConditionReference;
+ public void setWaitConditionDescriptor(Descriptor waitConditionDescriptor) {
+ this.waitConditionDescriptor = waitConditionDescriptor;
}
public boolean isTakeAsync() {
return isTakeAsync;
@@ -163,7 +171,4 @@
public void setTakeAsync(boolean isTakeAsync) {
this.isTakeAsync = isTakeAsync;
}
- public void setWaitConditionReference(ObjectReference<Condition> waitConditionReference) {
- this.waitConditionReference = waitConditionReference;
- }
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/ObjectBinding.java 2008-08-11 09:59:19 UTC (rev 1861)
@@ -47,6 +47,20 @@
super("object");
}
+
+ public static boolean isObjectDescriptor(Element element) {
+ if (XmlUtil.attribute(element, "class")!=null) {
+ return true;
+ }
+ if (XmlUtil.attribute(element, "factory")!=null) {
+ return true;
+ }
+ if (XmlUtil.element(element, "factory")!=null) {
+ return true;
+ }
+ return false;
+ }
+
public Object parse(Element element, Parse parse, Parser parser) {
ObjectDescriptor descriptor = new ObjectDescriptor();
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java 2008-08-11 09:59:19 UTC (rev 1861)
@@ -26,7 +26,7 @@
import org.jbpm.pvm.listener.EventListenerExecution;
/** user code that reflects a runtime calculation of a boolean value.
- * Used for {@link Transition#getGuardCondition() transition guard conditions} and
+ * Used for {@link Transition#getCondition() transition guard conditions} and
* {@link Transition#getWaitCondition() transition wait states}.
*
* @see Transition
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-08-11 09:59:19 UTC (rev 1861)
@@ -43,6 +43,7 @@
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
import org.jbpm.pvm.listener.EventListener;
@@ -457,8 +458,8 @@
if (transition==null) {
throw new PvmException("no current transition");
}
- ObjectReference<Condition> waitConditionReference = new ObjectReference<Condition>(condition);
- transition.setWaitConditionReference(waitConditionReference);
+ Descriptor conditionDescriptor= new ProvidedObjectDescriptor(condition);
+ transition.setWaitConditionDescriptor(conditionDescriptor);
return this;
}
@@ -471,8 +472,8 @@
if (transition==null) {
throw new PvmException("no current transition");
}
- ObjectReference<Condition> guardConditionReference = new ObjectReference<Condition>(condition);
- transition.setGuardConditionReference(guardConditionReference);
+ Descriptor conditionDescriptor= new ProvidedObjectDescriptor(condition);
+ transition.setConditionDescriptor(conditionDescriptor);
return this;
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java 2008-08-11 09:59:19 UTC (rev 1861)
@@ -62,6 +62,7 @@
/** the node in which this transition arrives. */
Node getDestination();
- /** the guard condition */
- Condition getGuardCondition();
+ /** the general purpose condition that can be used in various ways by the
+ * activities. */
+ Condition getCondition();
}
\ No newline at end of file
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml 2008-08-11 09:03:59 UTC (rev 1860)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml 2008-08-11 09:59:19 UTC (rev 1861)
@@ -232,32 +232,22 @@
foreign-key="FK_TRANS_DST"
index="IDX_TRANS_DST" />
- <component name="guardConditionReference">
- <many-to-one name="descriptor"
- column="GUARD_DESCR_"
- class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
- cascade="all"
- foreign-key="FK_TRANS_GUARD"
- index="IDX_TRANS_GUARD" />
- <any name="object" id-type="long" cascade="all">
- <!-- TODO: Specify names for classes -->
- <column name="GUARD_CLASS_" />
- <column name="GUARD_ID_" />
- </any>
- </component>
- <component name="waitConditionReference">
- <many-to-one name="descriptor"
- column="WAIT_DESCR_"
- class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
- cascade="all"
- foreign-key="FK_TRANS_WAIT_DESCR"
- index="IDX_TRANS_WAIT_DESCR" />
- <any name="object" id-type="long" cascade="all">
- <!-- TODO: Specify names for classes -->
- <column name="WAIT_CLASS_" />
- <column name="WAIT_ID_" />
- </any>
- </component>
+ <many-to-one name="conditionDescriptor"
+ column="COND_DESCR_"
+ class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+ cascade="all"
+ foreign-key="FK_TRANS_COND"
+ index="IDX_TRANS_COND" />
+
+ <!--
+ <many-to-one name="waitConditionDescriptor"
+ column="WAIT_DESCR_"
+ class="org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor"
+ cascade="all"
+ foreign-key="FK_TRANS_WAIT_DESCR"
+ index="IDX_TRANS_WAIT_DESCR" />
+ -->
+
<property name="isTakeAsync" column="TAKEASYNC_" />
</class>
17 years, 8 months
JBoss JBPM SVN: r1860 - in jbpm4/pvm/trunk/modules/core/src/main: java/org/jbpm/pvm/internal/wire/binding and 1 other directories.
by do-not-reply@jboss.org
Author: porcherg
Date: 2008-08-11 05:03:59 -0400 (Mon, 11 Aug 2008)
New Revision: 1860
Removed:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestMessageSession.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd
Log:
remove JobTestMessageSession and JobTestTimerSession
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestMessageSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestMessageSession.java 2008-08-11 07:14:47 UTC (rev 1859)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestMessageSession.java 2008-08-11 09:03:59 UTC (rev 1860)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.jobexecutor;
-
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.job.JobTestHelper;
-import org.jbpm.pvm.session.DbSession;
-import org.jbpm.pvm.session.MessageSession;
-
-/**
- * @author Tom Baeyens
- */
-public class JobTestMessageSession implements MessageSession {
-
- private static final Log log = Log.getLog(JobTestMessageSession.class.getName());
-
- /* injected */
- DbSession dbSession;
-
- public void send(MessageImpl<?> message) {
- log.debug("sending "+message+" for target "+ReflectUtil.getUnqualifiedClassName(JobTestHelper.class));
- dbSession.save(message);
- }
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java 2008-08-11 07:14:47 UTC (rev 1859)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java 2008-08-11 09:03:59 UTC (rev 1860)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.jobexecutor;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.job.Timer;
-import org.jbpm.pvm.session.TimerSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class JobTestTimerSession implements TimerSession {
-
- /* injected */
- Session session;
-
- public void schedule(Timer timer) {
- session.save(timer);
- }
-
- public void cancel(Timer timer) {
- session.delete(timer);
- }
-
-}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java 2008-08-11 07:14:47 UTC (rev 1859)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/MessageSessionBinding.java 2008-08-11 09:03:59 UTC (rev 1860)
@@ -23,7 +23,6 @@
import org.jbpm.pvm.internal.jms.JmsMessageSession;
import org.jbpm.pvm.internal.jobexecutor.JobExecutorMessageSession;
-import org.jbpm.pvm.internal.jobexecutor.JobTestMessageSession;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.JndiDescriptor;
@@ -71,10 +70,6 @@
parse.addProblem("attribute <"+XmlUtil.getTagLocalName(element)+" destination-jndi=\"...\" is required when target=\"jms\"");
}
- } else if ("test".equals(target)) {
- objectDescriptor.setClassName(JobTestMessageSession.class.getName());
- objectDescriptor.addInjection("dbSession", new ContextTypeRefDescriptor(DbSession.class));
-
} else {
objectDescriptor.setClassName(JobExecutorMessageSession.class.getName());
objectDescriptor.addInjection("transaction", new TransactionRefDescriptor());
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java 2008-08-11 07:14:47 UTC (rev 1859)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java 2008-08-11 09:03:59 UTC (rev 1860)
@@ -13,12 +13,10 @@
**/
package org.jbpm.pvm.internal.wire.binding;
-import org.hibernate.Session;
import org.jbpm.pvm.internal.ejb.EnterpriseTimerSession;
import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.jobexecutor.JobExecutorTimerSession;
-import org.jbpm.pvm.internal.jobexecutor.JobTestTimerSession;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ContextTypeRefDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.EnvironmentTypeRefDescriptor;
@@ -49,11 +47,6 @@
if ((target!=null) && ("ejb".equalsIgnoreCase(target))) {
objectDescriptor.setClassName(EnterpriseTimerSession.class.getName());
- } else if ((target!=null) && ("test".equalsIgnoreCase(target))) {
- // wire the JobTestTimerSession
- objectDescriptor.setClassName(JobTestTimerSession.class.getName());
- objectDescriptor.addInjection("session", new ContextTypeRefDescriptor(Session.class));
-
} else {
// wire the JobExecutorTimerSession
objectDescriptor.setClassName(JobExecutorTimerSession.class.getName());
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd 2008-08-11 07:14:47 UTC (rev 1859)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd 2008-08-11 09:03:59 UTC (rev 1860)
@@ -784,7 +784,6 @@
<restriction base="string">
<enumeration value="job-executor" />
<enumeration value="ejb" />
- <enumeration value="test" />
</restriction>
</simpleType>
</attribute>
17 years, 8 months
JBoss JBPM SVN: r1859 - in jbossbpm/spec/branches/tdiesler/modules: ri/src/main/java/org/jboss/bpm/model/internal and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-08-11 03:14:47 -0400 (Mon, 11 Aug 2008)
New Revision: 1859
Removed:
jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/NoneEventDetail.java
jbossbpm/spec/branches/tdiesler/modules/ri/src/main/java/org/jboss/bpm/model/internal/NoneEventDetailImpl.java
Modified:
jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/EventDetail.java
Log:
Remove None event detail
Modified: jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/EventDetail.java
===================================================================
--- jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/EventDetail.java 2008-08-09 14:09:16 UTC (rev 1858)
+++ jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/EventDetail.java 2008-08-11 07:14:47 UTC (rev 1859)
@@ -36,7 +36,7 @@
*/
public enum EventDetailType
{
- None, Message, Timer, Error, Conditional, Link, Signal, Compensate, Cancel, Terminate
+ Message, Timer, Error, Conditional, Link, Signal, Compensate, Cancel, Terminate
};
/**
Deleted: jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/NoneEventDetail.java
===================================================================
--- jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/NoneEventDetail.java 2008-08-09 14:09:16 UTC (rev 1858)
+++ jbossbpm/spec/branches/tdiesler/modules/api/src/main/java/org/jboss/bpm/model/NoneEventDetail.java 2008-08-11 07:14:47 UTC (rev 1859)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model;
-
-//$Id$
-
-/**
- * The Cancel event detail
- *
- * @author thomas.diesler(a)jboss.com
- * @since 21-Jul-2008
- */
-public interface NoneEventDetail extends EventDetail
-{
-
-}
Deleted: jbossbpm/spec/branches/tdiesler/modules/ri/src/main/java/org/jboss/bpm/model/internal/NoneEventDetailImpl.java
===================================================================
--- jbossbpm/spec/branches/tdiesler/modules/ri/src/main/java/org/jboss/bpm/model/internal/NoneEventDetailImpl.java 2008-08-09 14:09:16 UTC (rev 1858)
+++ jbossbpm/spec/branches/tdiesler/modules/ri/src/main/java/org/jboss/bpm/model/internal/NoneEventDetailImpl.java 2008-08-11 07:14:47 UTC (rev 1859)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.bpm.model.internal;
-
-//$Id$
-
-import org.jboss.bpm.model.NoneEventDetail;
-
-/**
- * The None event detail.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 08-Jul-2008
- */
-@SuppressWarnings("serial")
-public class NoneEventDetailImpl extends EventDetailImpl implements NoneEventDetail
-{
- public EventDetailType getEventDetailType()
- {
- return EventDetailType.None;
- }
-}
\ No newline at end of file
17 years, 8 months
JBoss JBPM SVN: r1858 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/internal/model/op and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-08-09 10:09:16 -0400 (Sat, 09 Aug 2008)
New Revision: 1858
Added:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java
Removed:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/Condition.java
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java
Log:
updates needed for jpdl decision impl
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -23,7 +23,7 @@
import java.util.List;
-import org.jbpm.pvm.listener.Condition;
+import org.jbpm.pvm.model.Condition;
import org.jbpm.pvm.model.Event;
import org.jbpm.pvm.model.Transition;
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/op/TakeTransition.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -30,7 +30,7 @@
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.model.ObservableElementImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
-import org.jbpm.pvm.listener.Condition;
+import org.jbpm.pvm.model.Condition;
import org.jbpm.pvm.model.Event;
public class TakeTransition implements AtomicOperation {
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/Condition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/Condition.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/Condition.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.listener;
-
-import java.io.Serializable;
-
-import org.jbpm.pvm.model.Transition;
-
-/** user code that reflects a runtime calculation of a boolean value.
- * Used for {@link Transition#getGuardCondition() transition guard conditions} and
- * {@link Transition#getWaitCondition() transition wait states}.
- *
- * @see Transition
- *
- * @author Tom Baeyens
- */
-public interface Condition extends Serializable {
-
- /** evaluates this condition in the context of the given execution. */
- boolean evaluate(EventListenerExecution execution);
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java (from rev 1850, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/Condition.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.model;
+
+import java.io.Serializable;
+
+import org.jbpm.pvm.listener.EventListenerExecution;
+
+/** user code that reflects a runtime calculation of a boolean value.
+ * Used for {@link Transition#getGuardCondition() transition guard conditions} and
+ * {@link Transition#getWaitCondition() transition wait states}.
+ *
+ * @see Transition
+ *
+ * @author Tom Baeyens
+ */
+public interface Condition extends Serializable {
+
+ /** evaluates this condition in the context of the given execution. */
+ boolean evaluate(EventListenerExecution execution);
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Condition.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -44,7 +44,6 @@
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
-import org.jbpm.pvm.listener.Condition;
import org.jbpm.pvm.listener.EventListener;
/** factory for process definitions.
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/Transition.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -23,6 +23,7 @@
import java.util.Set;
+
/**
* a transition in a {@link ProcessDefinition} graph.
*
@@ -60,4 +61,7 @@
/** the node in which this transition arrives. */
Node getDestination();
+
+ /** the guard condition */
+ Condition getGuardCondition();
}
\ No newline at end of file
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java 2008-08-09 14:08:19 UTC (rev 1857)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionAsWaitStateTest.java 2008-08-09 14:09:16 UTC (rev 1858)
@@ -29,8 +29,8 @@
import org.jbpm.pvm.activity.ExternalActivity;
import org.jbpm.pvm.client.ClientProcessDefinition;
import org.jbpm.pvm.client.ClientProcessInstance;
-import org.jbpm.pvm.listener.Condition;
import org.jbpm.pvm.listener.EventListenerExecution;
+import org.jbpm.pvm.model.Condition;
import org.jbpm.pvm.model.ProcessFactory;
/** this test shows how to implement a transition that behaves as a
17 years, 8 months
JBoss JBPM SVN: r1857 - in jbpm4/jpdl/trunk/modules/core/src: main/java/org/jbpm/jpdl/activity and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-08-09 10:08:19 -0400 (Sat, 09 Aug 2008)
New Revision: 1857
Added:
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
Removed:
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
Modified:
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java
Log:
added more decision implementations
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/DecisionHandler.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface DecisionHandler {
+
+ /** the name of the selected outgoing transition */
+ String decide(JpdlExecution execution);
+}
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionConditionActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.activity;
+
+import java.util.List;
+
+import org.jbpm.jpdl.JpdlException;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.pvm.model.Condition;
+import org.jbpm.pvm.model.Node;
+import org.jbpm.pvm.model.Transition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionConditionActivity extends JpdlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(JpdlExecution execution) throws Exception {
+ Transition transition = findTransition(execution);
+ if (transition==null) {
+ throw new JpdlException("no outgoing transition condition evaluated to true for decision "+execution.getNode());
+ }
+ execution.take(transition);
+ }
+
+ private Transition findTransition(JpdlExecution execution) {
+ Node node = execution.getNode();
+ List<Transition> outgoingTransitions = node.getOutgoingTransitions();
+ for (Transition transition : outgoingTransitions) {
+ Condition condition = transition.getGuardCondition();
+ if ( (condition==null)
+ || (condition.evaluate(execution))
+ ) {
+ return transition;
+ }
+ }
+ return null;
+ }
+}
Modified: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionExpressionActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -23,10 +23,10 @@
import org.jbpm.jpdl.JpdlExecution;
import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.model.Transition;
import org.jbpm.pvm.env.EnvironmentHelper;
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.model.Transition;
/**
* @author Tom Baeyens
@@ -37,21 +37,25 @@
protected String expr;
protected String lang;
-
+
public void execute(JpdlExecution execution) throws Exception {
+ NodeImpl node = execution.getNode();
+ String transitionName = null;
+
ScriptManager scriptManager = EnvironmentHelper.get(ScriptManager.class);
Object result = scriptManager.evaluateExpression(expr, execution, lang);
if ( (result!=null)
&& (! (result instanceof String))
) {
- throw new PvmException("decision expression '"+expr+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
+ throw new PvmException("expression '"+expr+"' in decision '"+node.getName()+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
}
- String transitionName = (String) result;
- NodeImpl node = execution.getNode();
- Transition transition = node.findOutgoingTransition(transitionName);
+ transitionName = (String) result;
+
+ Transition transition = node.getOutgoingTransition(transitionName);
if (transition==null) {
- throw new PvmException("decision expression '"+expr+"' returned unexisting outgoing transition name: "+transitionName);
+ throw new PvmException("expression '"+expr+"' in decision '"+node.getName()+"' returned unexisting outgoing transition name: "+transitionName);
}
+
execution.take(transition);
}
Added: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/activity/DecisionHandlerActivity.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.activity;
+
+import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.JpdlException;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.EnvironmentHelper;
+import org.jbpm.pvm.internal.model.NodeImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.model.Transition;
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionHandlerActivity extends JpdlActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String decisionHandlerName;
+ protected Descriptor decisionHandlerDescriptor;
+
+ public void execute(JpdlExecution execution) throws Exception {
+ NodeImpl node = execution.getNode();
+ String transitionName = null;
+
+ Object object = null;
+ if (decisionHandlerDescriptor!=null) {
+ object = WireContext.create(decisionHandlerDescriptor);
+ } else if (decisionHandlerName!=null) {
+ Environment environment = Environment.getCurrent();
+ object = environment.get(decisionHandlerName);
+ }
+
+ if (object==null) {
+ throw new JpdlException("decision handler for "+node+" is null");
+ }
+ if (! (object instanceof DecisionHandler)) {
+ throw new JpdlException("handler for decision is not a "+DecisionHandler.class.getName()+": "+object.getClass().getName());
+ }
+ DecisionHandler decisionHandler = (DecisionHandler) object;
+ transitionName = decisionHandler.decide(execution);
+
+ Transition transition = node.getOutgoingTransition(transitionName);
+ if (transition==null) {
+ throw new PvmException("handler in decision '"+node.getName()+"' returned unexisting outgoing transition name: "+transitionName);
+ }
+
+ execution.take(transition);
+ }
+
+}
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/JpdlTestCase.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -21,52 +21,20 @@
*/
package org.jbpm.jpdl;
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
-
import org.jbpm.jpdl.xml.JpdlParser;
import org.jbpm.pvm.client.ClientProcessDefinition;
import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.test.base.JbpmTestCase;
/**
* @author Tom Baeyens
*/
-public class JpdlTestCase extends TestCase {
+public class JpdlTestCase extends JbpmTestCase {
static protected Log log = Log.getLog(JpdlTestCase.class.getName());
- public void setUp() throws Exception {
- log.info("=== starting "+getName()+" =============================");
- }
-
- public void tearDown() throws Exception {
- log.info("=== ending "+getName()+" =============================\n");
- }
-
- public void assertTextPresent(String expected, String value) {
- if ( (value==null)
- || (value.indexOf(expected)==-1)
- ) {
- throw new AssertionFailedError("expected presence of '"+expected+"' but was '"+value+"'");
- }
- }
-
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- } catch (AssertionFailedError e) {
- log.error("");
- log.error("ASSERTION FAILURE: "+e.getMessage());
- log.error("");
- throw e;
- } catch (Throwable t) {
- t.printStackTrace();
- throw t;
- }
- }
-
- public ClientProcessDefinition parseProcess(String xmlString) {
+ public ClientProcessDefinition parseJpdl(String xmlString) {
JpdlParser jpdlParser = new JpdlParser();
return (ClientProcessDefinition) jpdlParser.createParse()
.setString(xmlString)
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/ControlFlowTests.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -33,7 +33,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jbpm.jpdl.controlflow");
//$JUnit-BEGIN$
- suite.addTestSuite(DecisionTest.class);
+ suite.addTestSuite(DecisionExpressionTest.class);
suite.addTestSuite(StateTest.class);
//$JUnit-END$
return suite;
Copied: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java (from rev 1852, jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java)
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.controlflow;
+
+import org.jbpm.jpdl.JpdlTestCase;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionExpressionTest extends JpdlTestCase {
+
+ public void testDecisionOutgoingTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition name='right' to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "left");
+ execution.signal();
+ assertEquals("c", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "right");
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("expression '#{theWayToGo}' in decision 'b' returned unexisting outgoing transition name: null", e.getMessage());
+ }
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "up");
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("expression '#{theWayToGo}' in decision 'b' returned unexisting outgoing transition name: up", e.getMessage());
+ }
+ }
+
+ public void testDecisionOutgoingUnnamedTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+ }
+}
Property changes on: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionExpressionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionHandlerTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.controlflow;
+
+import org.jbpm.jpdl.DecisionHandler;
+import org.jbpm.jpdl.JpdlExecution;
+import org.jbpm.jpdl.JpdlTestCase;
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionHandlerTest extends JpdlTestCase {
+
+ public static class GpsDecisionHandler implements DecisionHandler {
+ String theWayToGo;
+ public String decide(JpdlExecution execution) {
+ return theWayToGo;
+ }
+ }
+
+ public void testDecisionHandlerLeft() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b'>" +
+ " <handler class='"+GpsDecisionHandler.class.getName()+"'>" +
+ " <field name='theWayToGo'>" +
+ " <string value='left'/>" +
+ " </field>" +
+ " </handler>" +
+ " <transition name='left' to='c' />" +
+ " <transition name='right' to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "left");
+ execution.signal();
+ assertEquals("c", execution.getNode().getName());
+ }
+
+ /*
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "right");
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: null", e.getMessage());
+ }
+
+ execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", "up");
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: up", e.getMessage());
+ }
+ }
+
+ public void testDecisionOutgoingUnnamedTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseJpdl(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
+ execution.signal();
+ assertEquals("d", execution.getNode().getName());
+ }
+
+ */
+}
Deleted: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.jpdl.controlflow;
-
-import org.jbpm.jpdl.JpdlTestCase;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.client.ClientExecution;
-import org.jbpm.pvm.client.ClientProcessDefinition;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DecisionTest extends JpdlTestCase {
-
- public void testDecisionOutgoingTransitionExpression() {
- ClientProcessDefinition processDefinition = parseProcess(
- "<process initial='a' name='p'>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " </state>" +
- " <decision name='b' expr='#{theWayToGo}'>" +
- " <transition name='left' to='c' />" +
- " <transition name='right' to='d' />" +
- " </decision>" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- ClientExecution execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "left");
- execution.signal();
- assertEquals("c", execution.getNode().getName());
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "right");
- execution.signal();
- assertEquals("d", execution.getNode().getName());
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", null);
- try {
- execution.signal();
- fail("expected exception");
- } catch (PvmException e) {
- assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: null", e.getMessage());
- }
-
- execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", "up");
- try {
- execution.signal();
- fail("expected exception");
- } catch (PvmException e) {
- assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: up", e.getMessage());
- }
- }
-
- public void testDecisionOutgoingUnnamedTransitionExpression() {
- ClientProcessDefinition processDefinition = parseProcess(
- "<process initial='a' name='p'>" +
- " <state name='a'>" +
- " <transition to='b' />" +
- " </state>" +
- " <decision name='b' expr='#{theWayToGo}'>" +
- " <transition name='left' to='c' />" +
- " <transition to='d' />" +
- " </decision>" +
- " <state name='c' />" +
- " <state name='d' />" +
- "</process>"
- );
-
- ClientExecution execution = processDefinition.beginProcessInstance();
- execution.setVariable("theWayToGo", null);
- execution.signal();
- assertEquals("d", execution.getNode().getName());
- }
-}
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java 2008-08-08 16:04:28 UTC (rev 1856)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/StateTest.java 2008-08-09 14:08:19 UTC (rev 1857)
@@ -35,7 +35,7 @@
public class StateTest extends JpdlTestCase {
public void testWaitStatesSequence() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition to='b' />" +
@@ -61,7 +61,7 @@
}
public void testExternalDecision() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -88,7 +88,7 @@
}
public void testDefaultSignalWithNamedTransitions() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -110,7 +110,7 @@
}
public void testNamedSignalWithoutMatchingTransition() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a'>" +
" <transition name='left' to='b' />" +
@@ -132,7 +132,7 @@
}
public void testDefaultSignalWithoutTransitions() {
- ClientProcessDefinition processDefinition = parseProcess(
+ ClientProcessDefinition processDefinition = parseJpdl(
"<process initial='a' name='p'>" +
" <state name='a' />" +
"</process>"
17 years, 8 months
JBoss JBPM SVN: r1856 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/internal/tx and 9 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-08-08 12:04:28 -0400 (Fri, 08 Aug 2008)
New Revision: 1856
Added:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
Removed:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionInterceptor.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransaction.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransactionInterceptor.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionInterceptorBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionBinding.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionInterceptorBinding.java
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml
Log:
reintroduced standard transaction: JBPM-1458
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/ExecuteJobCmd.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -63,6 +63,7 @@
try {
log.debug("executing job "+job+"...");
job.execute(environment);
+ log.debug("executed job "+job);
// if this job is locked too long, it could be unlocked by the lockmonitor and
// executed by another thread.
@@ -79,8 +80,7 @@
log.error("exception while executing '"+job+"'", exception);
handleJobExecutionException(environment, job, exception);
}
-
- log.debug("executed job "+job);
+
} else {
log.debug("job " + jobDbid + " no longer exists");
}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionInterceptor.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionInterceptor.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionInterceptor.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.tx;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.internal.svc.Interceptor;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HibernateSessionInterceptor extends Interceptor {
-
- private static final Log log = Log.getLog(HibernateSessionInterceptor.class.getName());
-
- public <T> T execute(Command<T> command) {
- Environment environment = Environment.getCurrent();
- if (environment==null) {
- throw new PvmException("no environment for managing the hibernate session");
- }
-
- log.debug("getting session from environment");
- Session session = environment.get(Session.class);
- if (session==null) {
- throw new PvmException("no session in environment");
- }
-
- try {
- return next.execute(command);
-
- } finally {
- log.debug("closing hibernate session");
- session.close();
- }
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java (from rev 1850, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransaction.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.internal.log.Log;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HibernateSessionResource implements StandardResource {
+
+ private static final Log log = Log.getLog(HibernateSessionResource.class.getName());
+
+ protected Session session;
+ protected org.hibernate.Transaction transaction;
+
+ public HibernateSessionResource(Session session) {
+ this.session = session;
+ if (log.isTraceEnabled()) log.trace("beginning transaction on hibernate session "+System.identityHashCode(session));
+
+ try {
+ this.transaction = session.beginTransaction();
+ } catch (RuntimeException e) {
+ log.error("hibernate transaction begin failed. closing hibernate session", e);
+ session.close();
+ throw e;
+ }
+
+ log.debug("begun hibernate transaction "+System.identityHashCode(transaction)+" on hibernate session "+System.identityHashCode(session));
+ }
+
+ public void prepare() {
+ log.debug("flushing hibernate session "+System.identityHashCode(session));
+ session.flush();
+ }
+
+ public void commit() {
+ log.debug("committing hibernate transaction "+System.identityHashCode(transaction));
+ try {
+ transaction.commit();
+ } finally {
+ closeSession();
+ }
+ }
+
+ private void closeSession() {
+ log.debug("closing hibernate session "+System.identityHashCode(session));
+ session.close();
+ }
+
+ public void rollback() {
+ log.debug("rolling back hibernate transaction "+System.identityHashCode(transaction));
+ try {
+ transaction.rollback();
+ } finally {
+ closeSession();
+ }
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateSessionResource.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransaction.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransaction.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransaction.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.tx;
-
-import javax.transaction.Synchronization;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.env.Transaction;
-import org.jbpm.pvm.internal.log.Log;
-
-/**
- * @author Tom Baeyens
- */
-public class HibernateTransaction implements Transaction {
-
- private static final Log log = Log.getLog(HibernateTransaction.class.getName());
-
- /* injected */
- protected Session session;
-
- /* created */
- protected org.hibernate.Transaction transaction;
-
- protected boolean isRollbackOnly;
-
- public void begin() {
- log.debug("beginning "+this);
- transaction = session.beginTransaction();
- }
-
- public void complete() {
- log.trace("completing "+this);
-
- if (isRollbackOnly) {
- rollback();
- } else {
- commit();
- }
- }
-
- public void commit() {
- log.debug("committing "+this);
- transaction.commit();
- }
-
- public void rollback() {
- log.debug("rolling back "+this);
- transaction.rollback();
- }
-
- public void registerSynchronization(Synchronization synchronization) {
- log.debug("registering synchronization "+synchronization);
- transaction.registerSynchronization(synchronization);
- }
-
- public void setRollbackOnly() {
- isRollbackOnly = true;
- }
-
- public boolean isRollbackOnly() {
- return isRollbackOnly;
- }
-
- public String toString() {
- return "HibernateTransaction["+System.identityHashCode(this)+"]";
- }
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransactionInterceptor.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransactionInterceptor.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransactionInterceptor.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.tx;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.cmd.Command;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.internal.svc.Interceptor;
-
-
-/** calls setRollbackOnly on the transaction in the environment
- * in case an exception occurs during execution of the command.
- *
- * @author Tom Baeyens
- */
-public class HibernateTransactionInterceptor extends Interceptor {
-
- private static final Log log = Log.getLog(HibernateTransactionInterceptor.class.getName());
-
- public <T> T execute(Command<T> command) {
- Environment environment = Environment.getCurrent();
- if (environment==null) {
- throw new PvmException("no environment for managing hibernate transaction");
- }
-
- HibernateTransaction hibernateTransaction = environment.get(HibernateTransaction.class);
- if (hibernateTransaction==null) {
- throw new PvmException("no hibernate transaction in environment");
- }
-
- hibernateTransaction.begin();
-
- try {
- return next.execute(command);
-
- } catch (RuntimeException e) {
- hibernateTransaction.setRollbackOnly();
- throw e;
-
- } finally {
- hibernateTransaction.complete();
- }
- }
-}
Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardResource.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public interface StandardResource {
+
+ void prepare();
+
+ void commit();
+
+ void rollback();
+
+}
Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardSynchronization.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StandardSynchronization {
+
+ Synchronization synchronization;
+
+ public StandardSynchronization(Synchronization synchronization) {
+ this.synchronization = synchronization;
+ }
+
+ public void afterCompletion(StandardTransaction.State transactionState) {
+ if (transactionState==StandardTransaction.State.COMMITTED) {
+ synchronization.afterCompletion(Status.STATUS_COMMITTED);
+
+ } else if (transactionState==StandardTransaction.State.ROLLEDBACK) {
+ synchronization.afterCompletion(Status.STATUS_ROLLEDBACK);
+
+ } else {
+ throw new TransactionException("invalid transaction state: "+transactionState);
+ }
+ }
+
+ public void beforeCompletion() {
+ synchronization.beforeCompletion();
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransaction.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,243 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.Synchronization;
+
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.log.Log;
+
+
+/** simple 2 phase commit transaction.
+ * no logging or recovery.
+ * non thread safe (which is ok).
+ * @author Tom Baeyens
+ */
+public class StandardTransaction implements Transaction, Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private static Log log = Log.getLog(StandardTransaction.class.getName());
+
+ enum State {
+ CREATED,
+ ACTIVE,
+ ROLLBACKONLY,
+ COMMITTED,
+ ROLLEDBACK
+ }
+
+ protected List<StandardResource> resources;
+ protected List<StandardSynchronization> synchronizations;
+ protected State state = State.CREATED;
+
+ // methods for interceptor //////////////////////////////////////////////////
+
+ public void begin() {
+ log.debug("beginning "+this);
+ state = State.ACTIVE;
+ }
+
+ public void complete() {
+ if (state==State.ACTIVE) {
+ commit();
+ } else if (state==State.ROLLBACKONLY){
+ rollback();
+ } else {
+ throw new TransactionException("complete on transaction in state "+state);
+ }
+ }
+
+ // public tx methods ////////////////////////////////////////////////////////
+
+ public void setRollbackOnly() {
+ if (state!=State.ACTIVE) {
+ throw new TransactionException("transaction was not active: "+state);
+ }
+ state = State.ROLLBACKONLY;
+ }
+
+ public boolean isRollbackOnly() {
+ return ( (state==State.ROLLBACKONLY)
+ || (state==State.ROLLEDBACK)
+ );
+ }
+
+ // commit ///////////////////////////////////////////////////////////////////
+
+ /** implements simplest two phase commit. */
+ public void commit() {
+ if (state!=State.ACTIVE) {
+ throw new TransactionException("commit on transaction in state "+state);
+ }
+
+ log.trace("committing "+this);
+
+ try {
+ beforeCompletion();
+
+ if (resources!=null) {
+ // prepare //////////////////////////////////////////////////////////////
+ // the prepare loop will be skipped at the first exception
+ for (StandardResource standardResource: resources) {
+ log.trace("preparing resource "+standardResource);
+ standardResource.prepare();
+ }
+ }
+
+ // for any exception in the prepare phase, we'll rollback
+ } catch (Exception exception) {
+ try {
+ log.debug("resource threw exception in prepare. rolling back.");
+ rollbackResources();
+ } catch (Exception rollbackException) {
+ log.error("rollback failed as well", rollbackException);
+ }
+
+ // rethrow
+ if (exception instanceof RuntimeException) {
+ throw (RuntimeException) exception;
+ }
+ throw new TransactionException("prepare failed", exception);
+ }
+
+ // here is the point of no return :-)
+
+ // commit ///////////////////////////////////////////////////////////////
+ Throwable commitException = null;
+ if (resources!=null) {
+ // The commit loop will try to send the commit to every resource,
+ // No matter what it takes. If exceptions come out of resource.commit's
+ // they will be suppressed and the first exception will be rethrown after
+ // all the resources are commited
+ for (StandardResource standardResource: resources) {
+ try {
+ log.trace("committing resource "+standardResource);
+ standardResource.commit();
+
+ // Exceptions in the commit phase will not lead to rollback, since some resources
+ // might have committed and can't go back.
+ } catch (Throwable t) {
+ // TODO this should go to a special log for sys admin recovery
+ log.error("commit failed for resource "+standardResource, t);
+ if (commitException==null) {
+ commitException = t;
+ }
+ }
+ }
+ }
+
+ state = State.COMMITTED;
+ afterCompletion();
+ log.debug("committed "+this);
+
+ if (commitException!=null) {
+ if (commitException instanceof RuntimeException) {
+ throw (RuntimeException) commitException;
+ } else if (commitException instanceof Error) {
+ throw (Error) commitException;
+ }
+ throw new TransactionException("resource failed to commit", commitException);
+ }
+ }
+
+ // rollback /////////////////////////////////////////////////////////////////
+
+ public void rollback() {
+ if ( (state!=State.ACTIVE)
+ && (state!=State.ROLLBACKONLY)
+ ) {
+ throw new TransactionException("rollback on transaction in state "+state);
+ }
+
+ log.trace("rolling back "+this);
+
+ beforeCompletion();
+ rollbackResources();
+ }
+
+
+ void rollbackResources() {
+ if (resources!=null) {
+ for (StandardResource resource: resources) {
+ try {
+ log.trace("rolling back resource "+resource);
+ resource.rollback();
+ } catch (Exception e) {
+ log.error("rollback failed for resource "+resource);
+ }
+ }
+ }
+
+ state = State.ROLLEDBACK;
+
+ afterCompletion();
+
+ log.debug("rolled back");
+ }
+
+ // synchronizations /////////////////////////////////////////////////////////
+
+ public void registerSynchronization(Synchronization synchronization) {
+ if (synchronizations==null) {
+ synchronizations = new ArrayList<StandardSynchronization>();
+ }
+ synchronizations.add(new StandardSynchronization(synchronization));
+ }
+
+ public void afterCompletion() {
+ if (synchronizations!=null) {
+ for (StandardSynchronization synchronization: synchronizations) {
+ synchronization.afterCompletion(state);
+ }
+ }
+ }
+
+ public void beforeCompletion() {
+ if (synchronizations!=null) {
+ for (StandardSynchronization synchronization: synchronizations) {
+ synchronization.beforeCompletion();
+ }
+ }
+ }
+
+ // resource enlisting ///////////////////////////////////////////////////////
+
+ public void enlistResource(StandardResource standardResource) {
+ if (resources==null) {
+ resources = new ArrayList<StandardResource>();
+ }
+ log.trace("enlisting resource "+standardResource+" to standard transaction");
+ resources.add(standardResource);
+ }
+
+ List<StandardResource> getResources() {
+ return resources;
+ }
+
+ public String toString() {
+ return "StandardTransaction["+System.identityHashCode(this)+"]";
+ }
+}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java (from rev 1850, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/HibernateTransactionInterceptor.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/tx/StandardTransactionInterceptor.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.svc.Interceptor;
+
+
+/** calls setRollbackOnly on the transaction in the environment
+ * in case an exception occurs during execution of the command.
+ *
+ * @author Tom Baeyens
+ */
+public class StandardTransactionInterceptor extends Interceptor {
+
+ private static final Log log = Log.getLog(StandardTransactionInterceptor.class.getName());
+
+ public <T> T execute(Command<T> command) {
+ Environment environment = Environment.getCurrent();
+ if (environment==null) {
+ throw new PvmException("no environment for managing hibernate transaction");
+ }
+
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ if (standardTransaction==null) {
+ throw new PvmException("no standard-transaction in environment");
+ }
+
+ standardTransaction.begin();
+
+ try {
+ return next.execute(command);
+
+ } catch (RuntimeException e) {
+ standardTransaction.setRollbackOnly();
+ throw e;
+
+ } finally {
+ standardTransaction.complete();
+ }
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/EnlistBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.wire.operation.EnlistOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating an {@link EnlistOperation enlist operation}.
+ *
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnlistBinding extends WireOperationBinding {
+
+ public EnlistBinding() {
+ super("enlist");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ EnlistOperation enlistOperation = new EnlistOperation();
+ if (element.hasAttribute("transaction")) {
+ enlistOperation.setTransactionName(element.getAttribute("transaction"));
+ }
+ return enlistOperation;
+ }
+
+}
\ No newline at end of file
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionInterceptorBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionInterceptorBinding.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateSessionInterceptorBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.binding;
-
-import org.jbpm.pvm.internal.tx.HibernateSessionInterceptor;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HibernateSessionInterceptorBinding extends WireInterceptorBinding {
-
- public HibernateSessionInterceptorBinding() {
- super("hibernate-session-interceptor");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- HibernateSessionInterceptor hibernateSessionInterceptor = new HibernateSessionInterceptor();
- return new ProvidedObjectDescriptor(hibernateSessionInterceptor);
- }
-
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionBinding.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.binding;
-
-import org.hibernate.Session;
-import org.jbpm.pvm.env.Transaction;
-import org.jbpm.pvm.internal.tx.HibernateTransaction;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-/** parses a descriptor for creating a {@link Transaction}.
- *
- * See schema docs for more details.
- *
- * @author Tom Baeyens
- */
-public class HibernateTransactionBinding extends WireDescriptorBinding {
-
- public HibernateTransactionBinding() {
- super("hibernate-transaction");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- ObjectDescriptor descriptor = new ObjectDescriptor(HibernateTransaction.class);
- descriptor.addTypedInjection("session", Session.class);
- return descriptor;
- }
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionInterceptorBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionInterceptorBinding.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionInterceptorBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.binding;
-
-import org.jbpm.pvm.internal.tx.HibernateTransactionInterceptor;
-import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-/** parses a descriptor for creating a {@link HibernateTransactionInterceptor}.
- *
- * See schema docs for more details.
- *
- * @author Tom Baeyens
- */
-public class HibernateTransactionInterceptorBinding extends WireInterceptorBinding {
-
- public HibernateTransactionInterceptorBinding() {
- super("hibernate-transaction-interceptor");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- HibernateTransactionInterceptor hibernateTransactionInterceptor = new HibernateTransactionInterceptor();
- return new ProvidedObjectDescriptor(hibernateTransactionInterceptor);
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java (from rev 1850, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionInterceptorBinding.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/StandardTransactionInterceptorBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.internal.tx.StandardTransactionInterceptor;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link StandardTransactionInterceptor}.
+ *
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class StandardTransactionInterceptorBinding extends WireInterceptorBinding {
+
+ public StandardTransactionInterceptorBinding() {
+ super("standard-transaction-interceptor");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ StandardTransactionInterceptor standardTransactionInterceptor = new StandardTransactionInterceptor();
+ return new ProvidedObjectDescriptor(standardTransactionInterceptor);
+ }
+}
Copied: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java (from rev 1850, jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/HibernateTransactionBinding.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.binding;
+
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link Transaction}.
+ *
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class TransactionBinding extends WireDescriptorBinding {
+
+ public TransactionBinding() {
+ super("transaction");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ ObjectDescriptor transactionDescriptor = null;
+
+ String type = "standard";
+ if (element.hasAttribute("type")) {
+ type = element.getAttribute("type");
+ }
+
+ if ("standard".equals(type)) {
+ transactionDescriptor = new ObjectDescriptor(StandardTransaction.class);
+ } else {
+ parse.addProblem("unsupported transaction type: "+type);
+ }
+
+ return transactionDescriptor;
+ }
+}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HibernateSessionDescriptor.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -27,6 +27,8 @@
import org.hibernate.SessionFactory;
import org.jbpm.pvm.env.Environment;
import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.tx.HibernateSessionResource;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
import org.jbpm.pvm.internal.wire.WireException;
@@ -47,17 +49,17 @@
protected String connectionName;
public Object construct(WireContext wireContext) {
+ Environment environment = Environment.getCurrent();
+ if (environment==null) {
+ throw new WireException("no environment");
+ }
+
// get the hibernate-session-factory
SessionFactory sessionFactory = null;
if (factoryName!=null) {
sessionFactory = (SessionFactory) wireContext.get(factoryName);
} else {
- Environment environment = Environment.getCurrent();
- if (environment!=null) {
- sessionFactory = environment.get(SessionFactory.class);
- } else {
- sessionFactory = wireContext.get(SessionFactory.class);
- }
+ sessionFactory = environment.get(SessionFactory.class);
}
if (sessionFactory==null) {
throw new WireException("couldn't find hibernate-session-factory "+(factoryName!=null ? "'"+factoryName+"'" : "by type ")+"to open a hibernate-session");
@@ -78,6 +80,12 @@
log.debug("creating hibernate session");
session = sessionFactory.openSession();
}
+
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ if (standardTransaction!=null) {
+ HibernateSessionResource hibernateSessionResource = new HibernateSessionResource(session);
+ standardTransaction.enlistResource(hibernateSessionResource);
+ }
return session;
}
Added: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/wire/operation/EnlistOperation.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,74 @@
+package org.jbpm.pvm.internal.wire.operation;
+
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.tx.StandardResource;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+
+
+/**
+ * enlists this {@link StandardResource} with the current {@link Transaction}.
+ *
+ * <p>This {@link Operation} specifies that the object on which this operation is applied
+ * should be added as a {@link StandardResource} to the specified {@link Transaction}.
+ * </p>
+ *
+ * <p>property transactionName refers to the objectName of the {@link Transaction}
+ * and it may not be null.
+ * </p>
+ *
+ * @author Tom Baeyens
+ * @author Guillaume Porcher (documentation)
+ */
+public class EnlistOperation implements Operation {
+
+ private static final long serialVersionUID = 1L;
+ private static Log log = Log.getLog(EnlistOperation.class.getName());
+
+ String transactionName = null;
+
+ /**
+ * @throws WireException if this operation is applied on an object which is not a resource
+ * or if the specified transaction cannot be found.
+ */
+ public void apply(Object target, WireContext wireContext) {
+ if (! (target instanceof StandardResource)) {
+ throw new WireException("operation enlist can only be applied on objects that implement "+StandardResource.class.getName()+": "+target+(target!=null ? " ("+target.getClass().getName()+")" : ""));
+ }
+
+ Object object = null;
+ if (transactionName!=null) {
+ object = wireContext.get(transactionName);
+ } else {
+ object = wireContext.get(Transaction.class);
+ }
+
+ if ( (object==null)
+ || (! (object instanceof StandardTransaction))
+ ) {
+ throw new WireException("couldn't find "+StandardTransaction.class.getName()+" "+(transactionName!=null ? "'"+transactionName+"'" : "by type")+" to enlist resource "+target);
+ }
+
+ StandardTransaction standardTransaction = (StandardTransaction) object;
+
+ log.trace("enlisting resource "+target+" with transaction");
+ standardTransaction.enlistResource((StandardResource)target);
+ }
+
+ /**
+ * Gets the name of the transaction to which the object should be added.
+ */
+ public String getTransactionName() {
+ return transactionName;
+ }
+
+ /**
+ * Sets the name of the transaction to which the object should be added.
+ * @param transactionName
+ */
+ public void setTransactionName(String transactionName) {
+ this.transactionName = transactionName;
+ }
+}
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/pvm.wire.bindings.xml 2008-08-08 16:04:28 UTC (rev 1856)
@@ -31,7 +31,7 @@
<binding class="org.jbpm.pvm.internal.wire.binding.ContextRefBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.TransactionRefBinding" />
<!-- various specials -->
- <binding class="org.jbpm.pvm.internal.wire.binding.HibernateTransactionBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.TransactionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.JobExecutorBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.JobTestHelperBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.ScriptManagerBinding" />
@@ -67,8 +67,8 @@
<binding class="org.jbpm.pvm.internal.wire.binding.EnvironmentInterceptorBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.AuthorizationInterceptorBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.RetryInterceptorBinding" />
- <binding class="org.jbpm.pvm.internal.wire.binding.HibernateTransactionInterceptorBinding" />
- <binding class="org.jbpm.pvm.internal.wire.binding.HibernateSessionInterceptorBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.StandardTransactionInterceptorBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.EnlistBinding" />
<!-- ########################## -->
<!-- ### Operation bindings ### -->
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -56,7 +56,7 @@
static Map<String, Set<Long>> exclusiveThreadIds;
static List<Integer> failOnceMessageIds;
- static int nbrOfTestMessages = 10;
+ static int nbrOfTestMessages = 50;
static int timeoutMillis = 10000;
static int checkInterval = 400;
static int nbrOfTestMessagesPerExecution = 7;
@@ -162,8 +162,6 @@
for (Comment comment: comments) {
Integer messageId = new Integer(comment.getMessage());
assertTrue("message "+messageId+" committed twice", failOnceMessageIds.remove(messageId));
- // clean up for next tests
- session.delete(comment);
}
assertTrue("not all messages made a successful commit: "+failOnceMessageIds, failOnceMessageIds.isEmpty());
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/EnlistTest.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,241 @@
+package org.jbpm.pvm.internal.tx;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.wire.WireTestCase;
+
+/**
+ * @author Guillaume Porcher
+ */
+public class EnlistTest extends WireTestCase {
+
+ public void setUp() throws Exception {
+ super.setUp();
+ MyResource.events = new ArrayList<String>();
+ }
+
+ public void tearDown() throws Exception {
+ MyResource.events = null;
+ super.tearDown();
+ }
+
+ public static class MyResource implements StandardResource {
+ public static List<String> events = null;
+ public void commit() { events.add("commit"); }
+ public void flush() { events.add("flush"); }
+ public void prepare() { events.add("prepare"); }
+ public void rollback() { events.add("rollback"); }
+ }
+
+ public void testEnlist() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction name='tx' />" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ Object o = environment.get("o");
+ assertNotNull(o);
+
+ StandardTransaction t = (StandardTransaction) environment.get("tx");
+ t.begin();
+
+ assertNotNull(t);
+ assertTrue(t.getResources().contains(o));
+ assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+
+ t.complete();
+
+ assertEquals(MyResource.events.toString(), 2, MyResource.events.size());
+ assertEquals("prepare", MyResource.events.get(0));
+ assertEquals("commit", MyResource.events.get(1));
+ }
+
+ public void testEnlistRollback() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction name='tx' />" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ Object o = environment.get("o");
+ assertNotNull(o);
+
+ StandardTransaction t = (StandardTransaction) environment.get("tx");
+ t.begin();
+
+ assertNotNull(t);
+ assertTrue(t.getResources().contains(o));
+ assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+
+ t.setRollbackOnly();
+
+ t.complete();
+
+ assertEquals(MyResource.events.toString(), 1, MyResource.events.size());
+ assertEquals("rollback", MyResource.events.get(0));
+ }
+
+ public void testEnlistInOtherContext() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction name='tx' />" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ WireContext context = createWireContext(
+ "<objects>" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>"+
+ "</objects>"
+ );
+ environment.addContext(context);
+ Object o = environment.get("o");
+
+ assertNotNull(o);
+
+ StandardTransaction t = (StandardTransaction) environment.get("tx");
+ t.begin();
+
+ assertNotNull(t);
+ assertTrue(t.getResources().contains(o));
+ assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+
+ t.complete();
+
+ assertEquals(MyResource.events.toString(), 2, MyResource.events.size());
+ assertEquals("prepare", MyResource.events.get(0));
+ assertEquals("commit", MyResource.events.get(1));
+ }
+
+ public void testEnlistInOtherContextWithRollback() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction name='tx' />" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ WireContext context = createWireContext(
+ "<objects>" +
+ " <object name='o' class='"+ MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>"+
+ "</objects>"
+ );
+ environment.addContext(context);
+ Object o = environment.get("o");
+
+ assertNotNull(o);
+
+ StandardTransaction t = (StandardTransaction) environment.get("tx");
+ t.begin();
+
+ assertNotNull(t);
+ assertTrue(t.getResources().contains(o));
+ assertEquals(MyResource.events.toString(), 0, MyResource.events.size());
+
+ t.setRollbackOnly();
+
+ t.complete();
+
+ assertEquals(MyResource.events.toString(), 1, MyResource.events.size());
+ assertEquals("rollback", MyResource.events.get(0));
+ }
+
+ public void testEnlistNotAResource() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction name='transaction' />" +
+ " <object name='o' class='java.lang.Object'>" +
+ " <enlist transaction='transaction'/>" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ try{
+ environment.get("o");
+ fail("expected exeption");
+ } catch (WireException e) {
+ assertTextPresent("couldn't initialize object 'o':", e.getMessage());
+ assertTextPresent("operation enlist can only be applied on objects that implement org.jbpm.pvm.internal.tx.StandardResource", e.getMessage());
+ } finally {
+ environment.close();
+ }
+ }
+
+ public void testEnlistNotATransaction() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <object name='o' class='"+MyResource.class.getName()+"'>" +
+ " <enlist transaction='tx'/>" +
+ " </object>" +
+ " <object name='tx' class='java.lang.Object'/>" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ try{
+ environment.get("o");
+ fail("expected exeption");
+ } catch (WireException e) {
+ assertTextPresent("couldn't initialize object 'o':", e.getMessage());
+ assertTextPresent("couldn't find org.jbpm.pvm.internal.tx.StandardTransaction 'tx' to enlist resource ", e.getMessage());
+ } finally {
+ environment.close();
+ }
+ }
+
+ public void testMissingTransactionName() {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " </environment>" +
+ "</contexts>"
+ );
+
+ try{
+ assertNotNull(environment.get(Transaction.class));
+ assertNotNull(environment.get(StandardTransaction.class));
+ } finally {
+ environment.close();
+ }
+ }
+
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TestResource.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+
+public class TestResource implements StandardResource {
+
+ boolean isPrepared;
+ boolean isCommitted;
+ boolean isRolledBack;
+
+ public void prepare() {
+ isPrepared = true;
+ }
+ public void commit() {
+ isCommitted = true;
+ }
+ public void rollback() {
+ isRolledBack = true;
+ }
+}
\ No newline at end of file
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionFailingCommitTest.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,182 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.env.Environment;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionFailingCommitTest extends JbpmTestCase {
+
+ public static class CommitException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+ public CommitException(String msg) {
+ super(msg);
+ }
+ }
+
+ public static class FailingPrepareResource extends TestResource {
+ public void prepare() {
+ super.prepare();
+ throw new CommitException("resource couldn't prepare");
+ }
+ }
+
+ public void testMultipleResourcesFailingPrepare() {
+ TestResource resourceOne = null;
+ TestResource resourceTwo = null;
+ TestResource resourceThree = null;
+
+ try {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+FailingPrepareResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ resourceThree = (TestResource) environment.get("resourceThree");
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+ fail("expected exception");
+ } catch (CommitException e) {
+ // OK
+ }
+
+ assertTrue(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertTrue(resourceOne.isRolledBack);
+
+ assertTrue(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertTrue(resourceTwo.isRolledBack);
+
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertTrue(resourceThree.isRolledBack);
+ }
+
+ public static class FailingCommitResource extends TestResource {
+ public void commit() {
+ super.commit();
+ throw new CommitException("resource couldn't commit");
+ }
+ }
+
+ public void testMultipleResourcesFailingCommit() {
+ TestResource resourceOne = null;
+ TestResource resourceTwo = null;
+ TestResource resourceThree = null;
+
+ try {
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+FailingCommitResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ resourceThree = (TestResource) environment.get("resourceThree");
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+ fail("expected exception");
+ } catch (CommitException e) {
+ // OK
+ }
+
+ assertTrue(resourceOne.isPrepared);
+ assertTrue(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ assertTrue(resourceTwo.isPrepared);
+ assertTrue(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ assertTrue(resourceThree.isPrepared);
+ assertTrue(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesCommitTest.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionResourcesCommitTest extends JbpmTestCase {
+
+ public void testOneResourceCommit() {
+
+ TestResource resourceOne = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertTrue(resourceOne.isPrepared);
+ assertTrue(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+ }
+
+ public void testMultipleResourcesCommit() {
+ TestResource resourceOne = null;
+ TestResource resourceTwo = null;
+ TestResource resourceThree = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ resourceThree = (TestResource) environment.get("resourceThree");
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertTrue(resourceOne.isPrepared);
+ assertTrue(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ assertTrue(resourceTwo.isPrepared);
+ assertTrue(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ assertTrue(resourceThree.isPrepared);
+ assertTrue(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+ }
+
+ public void testFetchOneResourceOutOfManyCommit() {
+ TestResource resourceTwo = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+ assertTrue(resourceTwo.isPrepared);
+ assertTrue(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TransactionResourcesSetRollbackOnlyTest.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,180 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.tx.StandardTransaction;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TransactionResourcesSetRollbackOnlyTest extends JbpmTestCase {
+
+ public void testOneResourceSetRollbackOnly() {
+
+ TestResource resourceOne = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+
+ environment.get(Transaction.class).setRollbackOnly();
+
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertTrue(resourceOne.isRolledBack);
+ }
+
+ public void testMultipleResourcesSetRollbackOnly() {
+ TestResource resourceOne = null;
+ TestResource resourceTwo = null;
+ TestResource resourceThree = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceOne = (TestResource) environment.get("resourceOne");
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertFalse(resourceOne.isRolledBack);
+
+ environment.get(Transaction.class).setRollbackOnly();
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ resourceThree = (TestResource) environment.get("resourceThree");
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertFalse(resourceThree.isRolledBack);
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertFalse(resourceOne.isPrepared);
+ assertFalse(resourceOne.isCommitted);
+ assertTrue(resourceOne.isRolledBack);
+
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertTrue(resourceTwo.isRolledBack);
+
+ assertFalse(resourceThree.isPrepared);
+ assertFalse(resourceThree.isCommitted);
+ assertTrue(resourceThree.isRolledBack);
+ }
+
+ public void testFetchOneResourceOutOfManySetRollbackOnly() {
+ TestResource resourceTwo = null;
+
+ Environment environment = openEnvironment(
+ "<contexts>" +
+ " <environment-factory/>"+
+ " <environment>" +
+ " <transaction />" +
+ " <object name='resourceOne' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceTwo' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " <object name='resourceThree' class='"+TestResource.class.getName()+"'>" +
+ " <enlist />" +
+ " </object>" +
+ " </environment>" +
+ "</contexts>"
+ );
+ try {
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ standardTransaction.begin();
+
+ resourceTwo = (TestResource) environment.get("resourceTwo");
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertFalse(resourceTwo.isRolledBack);
+
+ environment.get(Transaction.class).setRollbackOnly();
+
+ assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+ standardTransaction.complete();
+
+ } finally {
+ environment.close();
+ }
+
+ assertEquals(1, environment.get(StandardTransaction.class).resources.size());
+
+ assertFalse(resourceTwo.isPrepared);
+ assertFalse(resourceTwo.isCommitted);
+ assertTrue(resourceTwo.isRolledBack);
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/internal/tx/TxTests.java 2008-08-08 16:04:28 UTC (rev 1856)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TxTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("org.jbpm.pvm.internal.tx");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TransactionResourcesCommitTest.class);
+ suite.addTestSuite(TransactionResourcesSetRollbackOnlyTest.class);
+ suite.addTestSuite(EnlistTest.class);
+ suite.addTestSuite(TransactionFailingCommitTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml 2008-08-08 16:04:28 UTC (rev 1856)
@@ -18,8 +18,7 @@
<command-service>
<retry-interceptor />
<environment-interceptor />
- <hibernate-session-interceptor />
- <hibernate-transaction-interceptor />
+ <standard-transaction-interceptor />
</command-service>
<job-executor threads="1" auto-start="false" />
@@ -38,7 +37,7 @@
<environment>
<hibernate-session />
- <hibernate-transaction />
+ <transaction />
<pvm-db-session />
<job-db-session />
<message-session />
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml 2008-08-08 15:21:20 UTC (rev 1855)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/internal/db/langext/environment.cfg.xml 2008-08-08 16:04:28 UTC (rev 1856)
@@ -18,8 +18,7 @@
<command-service>
<retry-interceptor />
<environment-interceptor />
- <hibernate-session-interceptor />
- <hibernate-transaction-interceptor />
+ <standard-transaction-interceptor />
</command-service>
<hibernate-configuration>
@@ -37,7 +36,7 @@
<environment>
<hibernate-session />
- <hibernate-transaction />
+ <transaction />
<pvm-db-session />
<object class="org.jbpm.pvm.internal.db.langext.AddressSession" />
</environment>
17 years, 8 months
JBoss JBPM SVN: r1853 - jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base.
by do-not-reply@jboss.org
Author: porcherg
Date: 2008-08-08 10:14:50 -0400 (Fri, 08 Aug 2008)
New Revision: 1853
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/DbTestCase.java
Log:
remove services references at tearDown (to reduce memory used by the test suite)
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/DbTestCase.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/DbTestCase.java 2008-08-08 13:24:27 UTC (rev 1852)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/DbTestCase.java 2008-08-08 14:14:50 UTC (rev 1853)
@@ -24,7 +24,6 @@
import org.jbpm.pvm.ExecutionService;
import org.jbpm.pvm.ManagementService;
import org.jbpm.pvm.ProcessService;
-import org.jbpm.pvm.env.EnvironmentFactory;
import org.jbpm.pvm.internal.cmd.CommandService;
@@ -61,4 +60,12 @@
executionService = getEnvironmentFactory().get(ExecutionService.class);
managementService = getEnvironmentFactory().get(ManagementService.class);
}
+
+ public void tearDown() throws Exception {
+ commandService = null;
+ processService = null;
+ executionService = null;
+ managementService = null;
+ super.tearDown();
+ }
}
17 years, 8 months
JBoss JBPM SVN: r1852 - in jbpm4/jpdl/trunk/modules/core: src/main/java/org/jbpm/jpdl/xml and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-08-08 09:24:27 -0400 (Fri, 08 Aug 2008)
New Revision: 1852
Added:
jbpm4/jpdl/trunk/modules/core/pom.xml
jbpm4/jpdl/trunk/modules/core/src/test/resources/logging.properties
Modified:
jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
Log:
jpdl decision completion
Added: jbpm4/jpdl/trunk/modules/core/pom.xml
===================================================================
--- jbpm4/jpdl/trunk/modules/core/pom.xml (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/pom.xml 2008-08-08 13:24:27 UTC (rev 1852)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id: pom.xml 1790 2008-07-31 12:13:06Z tom.baeyens(a)jboss.com $ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ### GENERAL PROJECT INFO ########################################### -->
+ <name>JBoss jBPM 4 - jPDL</name>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jpdl</artifactId>
+ <packaging>jar</packaging>
+
+ <!-- ### PARENT ######################################################### -->
+ <parent>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jpdl-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <!-- ### PROPERTIES ##################################################### -->
+ <properties>
+ <surefire.gc.args>-XX:MaxPermSize=128m</surefire.gc.args>
+ <surefire.jdwp.args>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</surefire.jdwp.args>
+ </properties>
+
+ <!-- ### DEPENDENCIES ################################################### -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jbpm</groupId>
+ <artifactId>pvm</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <!-- ### PLUGINS ###################################################### -->
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <showDeprecation>false</showDeprecation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>${surefire.jvm.args}</argLine>
+ <includes>
+ <include>org/jbpm/jpdl/CheckInTests.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- ### PROFILES ####################################################### -->
+ <profiles>
+ <profile>
+ <id>debug</id>
+ <activation>
+ <property>
+ <name>debug</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jvm.args>${surefire.jdwp.args} ${surefire.gc.args}</surefire.jvm.args>
+ </properties>
+ </profile>
+ <profile>
+ <id>no-debug</id>
+ <activation>
+ <property>
+ <name>!debug</name>
+ </property>
+ </activation>
+ <properties>
+ <surefire.jvm.args>${surefire.gc.args}</surefire.jvm.args>
+ </properties>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Modified: jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-08-08 13:23:00 UTC (rev 1851)
+++ jbpm4/jpdl/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlParser.java 2008-08-08 13:24:27 UTC (rev 1852)
@@ -31,6 +31,7 @@
import org.jbpm.pvm.internal.log.Log;
import org.jbpm.pvm.internal.model.NodeImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.UrlEntity;
import org.jbpm.pvm.internal.util.XmlUtil;
@@ -134,23 +135,25 @@
if (transitionElements!=null) {
UnresolvedTransitions unresolvedTransitions = parse.findObject(UnresolvedTransitions.class);
for (Element transitionElement: transitionElements) {
- unresolvedTransitions.add(node, transitionElement);
+ String transitionName = XmlUtil.attribute(transitionElement, "name", false, parse);
+ TransitionImpl transition = node.createOutgoingTransition(transitionName);
+ unresolvedTransitions.add(transition, transitionElement);
}
}
}
static class UnresolvedTransitions {
List<UnresolvedTransition> list = new ArrayList<UnresolvedTransition>();
- public void add(NodeImpl node, Element transitionElement) {
- list.add(new UnresolvedTransition(node, transitionElement));
+ public void add(TransitionImpl transition, Element transitionElement) {
+ list.add(new UnresolvedTransition(transition, transitionElement));
}
}
static class UnresolvedTransition {
- NodeImpl source;
+ TransitionImpl transition;
Element transitionElement;
- public UnresolvedTransition(NodeImpl source, Element transitionElement) {
- this.source = source;
+ public UnresolvedTransition(TransitionImpl transition, Element transitionElement) {
+ this.transition = transition;
this.transitionElement = transitionElement;
}
public void resolve(ProcessDefinitionImpl processDefinition, Parse parse) {
@@ -158,7 +161,7 @@
if (to!=null) {
NodeImpl destination = (NodeImpl) processDefinition.findNode(to);
if (destination!=null) {
- source.createOutgoingTransition(destination);
+ destination.addIncomingTransition(transition);
} else {
parse.addProblem(XmlUtil.errorMessageAttribute(transitionElement, "to", to, "doesn't reference an existing node name"));
}
Modified: jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-08 13:23:00 UTC (rev 1851)
+++ jbpm4/jpdl/trunk/modules/core/src/test/java/org/jbpm/jpdl/controlflow/DecisionTest.java 2008-08-08 13:24:27 UTC (rev 1852)
@@ -22,6 +22,7 @@
package org.jbpm.jpdl.controlflow;
import org.jbpm.jpdl.JpdlTestCase;
+import org.jbpm.pvm.PvmException;
import org.jbpm.pvm.client.ClientExecution;
import org.jbpm.pvm.client.ClientProcessDefinition;
@@ -38,8 +39,8 @@
" <transition to='b' />" +
" </state>" +
" <decision name='b' expr='#{theWayToGo}'>" +
- " <transition name='left' to='c' />" +
- " <transition name='right' to='d' />" +
+ " <transition name='left' to='c' />" +
+ " <transition name='right' to='d' />" +
" </decision>" +
" <state name='c' />" +
" <state name='d' />" +
@@ -58,11 +59,41 @@
execution = processDefinition.beginProcessInstance();
execution.setVariable("theWayToGo", null);
- execution.signal();
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: null", e.getMessage());
+ }
execution = processDefinition.beginProcessInstance();
execution.setVariable("theWayToGo", "up");
+ try {
+ execution.signal();
+ fail("expected exception");
+ } catch (PvmException e) {
+ assertTextPresent("decision expression '#{theWayToGo}' returned unexisting outgoing transition name: up", e.getMessage());
+ }
+ }
+
+ public void testDecisionOutgoingUnnamedTransitionExpression() {
+ ClientProcessDefinition processDefinition = parseProcess(
+ "<process initial='a' name='p'>" +
+ " <state name='a'>" +
+ " <transition to='b' />" +
+ " </state>" +
+ " <decision name='b' expr='#{theWayToGo}'>" +
+ " <transition name='left' to='c' />" +
+ " <transition to='d' />" +
+ " </decision>" +
+ " <state name='c' />" +
+ " <state name='d' />" +
+ "</process>"
+ );
+
+ ClientExecution execution = processDefinition.beginProcessInstance();
+ execution.setVariable("theWayToGo", null);
execution.signal();
+ assertEquals("d", execution.getNode().getName());
}
-
}
Added: jbpm4/jpdl/trunk/modules/core/src/test/resources/logging.properties
===================================================================
--- jbpm4/jpdl/trunk/modules/core/src/test/resources/logging.properties (rev 0)
+++ jbpm4/jpdl/trunk/modules/core/src/test/resources/logging.properties 2008-08-08 13:24:27 UTC (rev 1852)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.pvm.internal.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=FINEST
+org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE
+org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.level=FINE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
17 years, 8 months