Author: boisvert
Date: Fri Oct  2 00:51:25 2009
New Revision: 820856

URL: http://svn.apache.org/viewvc?rev=820856&view=rev
Log:
Scheduler.execTransaction() now checks if thread already enroled in 
transaction; ProcessManagement.listAllProcesses() now executes as single 
transaction

Modified:
    
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
    
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java

Modified: 
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java?rev=820856&r1=820855&r2=820856&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/engine/ProcessAndInstanceManagementImpl.java
 Fri Oct  2 00:51:25 2009
@@ -171,15 +171,23 @@
         ProcessInfoListDocument ret = 
ProcessInfoListDocument.Factory.newInstance();
         final TProcessInfoList procInfoList = ret.addNewProcessInfoList();
         final ProcessFilter processFilter = new ProcessFilter(filter, 
orderKeys);
-
-        for (ProcessConf pconf : processQuery(processFilter)) {
-            try {
-                fillProcessInfo(procInfoList.addNewProcessInfo(), pconf, 
custom);
-            } catch (Exception e) {
-                __log.error("Exception when querying process " + 
pconf.getProcessId(), e);
-            }
+        try {
+            _db.exec(new BpelDatabase.Callable<Object>() {
+                public Object run(BpelDAOConnection conn) {
+                    for (ProcessConf pconf : processQuery(processFilter)) {
+                        try {
+                            fillProcessInfo(procInfoList.addNewProcessInfo(), 
pconf, custom);
+                        } catch (Exception e) {
+                            __log.error("Exception when querying process " + 
pconf.getProcessId(), e);
+                        }
+                    }
+                    return null;
+                }
+            });
+        } catch (Exception e) {
+            __log.error("Exception while listing processes", e);
+            throw new ProcessingException("Exception while listing processes: 
" + e.toString());
         }
-
         return ret;
     }
 

Modified: 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
URL: 
http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java?rev=820856&r1=820855&r2=820856&view=diff
==============================================================================
--- 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
 (original)
+++ 
ode/branches/APACHE_ODE_1.X/scheduler-simple/src/main/java/org/apache/ode/scheduler/simple/SimpleScheduler.java
 Fri Oct  2 00:51:25 2009
@@ -216,6 +216,20 @@
     }
 
     public <T> T execTransaction(Callable<T> transaction) throws Exception, 
ContextException {
+        boolean existingTransaction = false;
+        try {
+            existingTransaction = _txm.getTransaction() != null;
+        } catch (Exception ex) {
+            String errmsg = "Internal Error, could not get current 
transaction.";
+            throw new ContextException(errmsg, ex);
+        }
+
+        // already in transaction, execute and return directly
+        if (existingTransaction) {
+            return transaction.call();
+        }
+
+        // run in new transaction
         try {
             if (__log.isDebugEnabled()) __log.debug("Beginning a new 
transaction");
             _txm.begin();


Reply via email to