ECA actions can now specify to run in a new transaction
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@508207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -212,6 +212,14 @@ under the License.
|
||||
</xs:attribute>
|
||||
<xs:attribute type="xs:string" name="runAsUser"/>
|
||||
<xs:attribute type="xs:string" name="result-map-name"/>
|
||||
<xs:attribute name="new-transaction" default="false">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:token">
|
||||
<xs:enumeration value="true"/>
|
||||
<xs:enumeration value="false"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="result-to-context" default="true">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:token">
|
||||
|
||||
@@ -121,7 +121,9 @@ public class GenericDispatcher extends GenericAbstractDispatcher {
|
||||
// clone the model service for updates
|
||||
ModelService cloned = new ModelService(service);
|
||||
cloned.requireNewTransaction = requireNewTransaction;
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
if (transactionTimeout != -1) {
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
}
|
||||
return dispatcher.runSync(this.name, cloned, context);
|
||||
}
|
||||
|
||||
@@ -141,7 +143,9 @@ public class GenericDispatcher extends GenericAbstractDispatcher {
|
||||
// clone the model service for updates
|
||||
ModelService cloned = new ModelService(service);
|
||||
cloned.requireNewTransaction = requireNewTransaction;
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
if (transactionTimeout != -1) {
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
}
|
||||
dispatcher.runSyncIgnore(this.name, cloned, context);
|
||||
}
|
||||
|
||||
@@ -153,7 +157,9 @@ public class GenericDispatcher extends GenericAbstractDispatcher {
|
||||
// clone the model service for updates
|
||||
ModelService cloned = new ModelService(service);
|
||||
cloned.requireNewTransaction = requireNewTransaction;
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
if (transactionTimeout != -1) {
|
||||
cloned.transactionTimeout = transactionTimeout;
|
||||
}
|
||||
dispatcher.runAsync(this.name, cloned, context, requester, persist);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,10 @@ public class ServiceEcaAction implements java.io.Serializable {
|
||||
protected String resultMapName = null;
|
||||
protected String runAsUser = null;
|
||||
|
||||
protected boolean newTransaction = false;
|
||||
protected boolean resultToContext = true;
|
||||
protected boolean ignoreFailure = false;
|
||||
protected boolean ignoreError = false;
|
||||
protected boolean ignoreError = false;
|
||||
protected boolean persist = false;
|
||||
|
||||
protected ServiceEcaAction() {}
|
||||
@@ -59,6 +60,7 @@ public class ServiceEcaAction implements java.io.Serializable {
|
||||
|
||||
// default is true, so anything but false is true
|
||||
this.resultToContext = !"false".equals(action.getAttribute("result-to-context"));
|
||||
this.newTransaction = !"false".equals(action.getAttribute("new-transaction"));
|
||||
this.ignoreFailure = !"false".equals(action.getAttribute("ignore-failure"));
|
||||
this.ignoreError = !"false".equals(action.getAttribute("ignore-error"));
|
||||
this.persist = "true".equals(action.getAttribute("persist"));
|
||||
@@ -94,7 +96,10 @@ public class ServiceEcaAction implements java.io.Serializable {
|
||||
} else {
|
||||
// standard ECA
|
||||
if (serviceMode.equals("sync")) {
|
||||
actionResult = dispatcher.runSync(serviceName, actionContext);
|
||||
if (newTransaction)
|
||||
actionResult = dispatcher.runSync(serviceName, actionContext, -1, true);
|
||||
else
|
||||
actionResult = dispatcher.runSync(serviceName, actionContext);
|
||||
} else if (serviceMode.equals("async")) {
|
||||
dispatcher.runAsync(serviceName, actionContext, persist);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user